Skip to content
Snippets Groups Projects
Commit 532b9b0e authored by tjc's avatar tjc
Browse files

use lazy loading for feature locations

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@4517 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent 69846f2c
No related branches found
No related tags found
No related merge requests found
......@@ -132,17 +132,13 @@ public class GeneEdit
final JComboBox schema_list = new JComboBox(v_schemas);
schema_list.setSelectedItem(schema);
JScrollPane jsp = new JScrollPane(schema_list);
panel.add(jsp, BorderLayout.EAST);
Box xbox = Box.createHorizontalBox();
final JTextField gene_text = new JTextField(20);
gene_text.setText("AfA24A6.005"); //"SPAC212.04c");
xbox.add(gene_text);
xbox.add(schema_list);
gene_text.selectAll();
JButton findButt = new JButton("RETRIEVE");
findButt.addActionListener(new ActionListener()
{
......@@ -162,7 +158,11 @@ public class GeneEdit
try
{
search(search_gene, schema_search, dao);
GFFStreamFeature gff_gene_feature = getGFFStreamFeature(search_gene,
schema_search, dao);
new GeneBuilderFrame(new uk.ac.sanger.artemis.Feature(gff_gene_feature),
null, null, null);
}
catch(SQLException sqlExp)
{
......@@ -179,6 +179,7 @@ public class GeneEdit
});
xbox.add(findButt);
xbox.add(Box.createHorizontalGlue());
panel.add(xbox, BorderLayout.NORTH);
JFrame frame = new JFrame("Feature Search");
......@@ -226,8 +227,11 @@ public class GeneEdit
* @throws SQLException
* @throws ReadFormatException
*/
public void search(final String search_gene, final List schema_search,
final ChadoDAO dao) throws SQLException, ReadFormatException
private GFFStreamFeature getGFFStreamFeature(
final String search_gene,
final List schema_search,
final ChadoDAO dao)
throws SQLException, ReadFormatException
{
Hashtable id_store = new Hashtable();
......@@ -244,17 +248,31 @@ public class GeneEdit
feature = (ChadoFeature)featureList.get(0);
id_store.put(Integer.toString(feature.getId()), feature.getUniquename());
int src = feature.getFeatureloc().getSrcfeature_id();
/*
List dbxrefs = feature.getFeatureDbxrefs();
for(int i=0; i<dbxrefs.size(); i++)
{
ChadoFeatureDbxref dbx = (ChadoFeatureDbxref)dbxrefs.get(i);
System.out.println( dbx.getDbxref().getDb().getName()+"="+
dbx.getDbxref().getAccession() );
}
*/
List featurelocs = feature.getFeaturelocsForFeatureId();
ChadoFeatureLoc featureloc = (ChadoFeatureLoc)featurelocs.get(0);
int src = featureloc.getSrcfeature_id();
ChadoFeature parent = new ChadoFeature();
parent.setId(src);
List parentList = dao.getLazyFeature(parent, schema_search);
parent = (ChadoFeature)parentList.get(0);
chado_gene.setSeqlen( parent.getLength() );
chado_gene.setSrcfeature_id(src);
ByteBuffer buff = new ByteBuffer();
DatabaseDocument.chadoToGFF(feature, null, null, null, null, dao, buff);
DatabaseDocument.chadoToGFF(feature, null, null, null, null,
dao, featureloc, buff);
//System.out.println(new String(buff.getBytes()));
......@@ -274,8 +292,11 @@ public class GeneEdit
transcript = (ChadoFeature)featureList.get(0);
id_store.put(Integer.toString(transcript.getId()), transcript.getUniquename());
buff = new ByteBuffer();
ChadoFeatureLoc loc = ChadoFeature.getFeatureLoc(
transcript.getFeaturelocsForFeatureId(), src);
DatabaseDocument.chadoToGFF(transcript, feature.getUniquename(),
null, null, id_store, dao, buff);
null, null, id_store, dao, loc, buff);
GFFStreamFeature gff_feature = new GFFStreamFeature(new String(buff.getBytes()));
new uk.ac.sanger.artemis.Feature(gff_feature);
......@@ -295,8 +316,10 @@ public class GeneEdit
child = (ChadoFeature)featureList.get(0);
id_store.put(Integer.toString(child.getId()), child.getUniquename());
buff = new ByteBuffer();
loc = ChadoFeature.getFeatureLoc(child.getFeaturelocsForFeatureId(), src);
DatabaseDocument.chadoToGFF(child, transcript.getUniquename(),
null, null, id_store, dao, buff);
null, null, id_store, dao, loc, buff);
gff_feature = new GFFStreamFeature(new String(buff.getBytes()));
new uk.ac.sanger.artemis.Feature(gff_feature);
......@@ -318,11 +341,7 @@ public class GeneEdit
}
gff_gene_feature.setChadoGene(chado_gene);
GeneBuilderFrame frame =
new GeneBuilderFrame(new uk.ac.sanger.artemis.Feature(gff_gene_feature),
null, null, null);
return gff_gene_feature;
}
......
......@@ -20,7 +20,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/genebuilder/GeneViewerPanel.java,v 1.3 2006-07-04 15:57:57 tjc Exp $
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/genebuilder/GeneViewerPanel.java,v 1.4 2006-07-05 12:30:53 tjc Exp $
*/
package uk.ac.sanger.artemis.components.genebuilder;
......@@ -124,26 +124,34 @@ public class GeneViewerPanel extends JPanel
int last_ypos = 0;
ChadoFeature start_exon = (ChadoFeature)exons.get(0);
if(start_exon.getFeatureloc().getStrand() == -1)
ChadoFeatureLoc loc = ChadoFeature.getFeatureLoc(
start_exon.getFeaturelocsForFeatureId(), chado_gene.getSrcfeature_id());
if(loc.getStrand() == -1)
{
if( start_exon.getFeatureloc().getFmin() <
((ChadoFeature)exons.get(exons.size()-1)).getFeatureloc().getFmin())
ChadoFeatureLoc loc_last = ChadoFeature.getFeatureLoc(
((ChadoFeature)exons.get(exons.size()-1)).getFeaturelocsForFeatureId(),
chado_gene.getSrcfeature_id());
if( loc.getFmin() < loc_last.getFmin())
Collections.reverse(exons);
}
for(int j=0; j<exons.size(); j++)
{
ChadoFeature exon = (ChadoFeature)exons.get(j);
loc = ChadoFeature.getFeatureLoc(
exon.getFeaturelocsForFeatureId(), chado_gene.getSrcfeature_id());
int ex_start = border+(int)((exon.getFeatureloc().getFmin()+1-start)*fraction);
int ex_end = border+(int)((exon.getFeatureloc().getFmax()-start)*fraction);
int ex_start = border+(int)((loc.getFmin()+1-start)*fraction);
int ex_end = border+(int)((loc.getFmax()-start)*fraction);
Color exon_col = Color.CYAN;
offset = getFrameID(chado_gene, exon, j, exons) * getFontHeight() * 2;
offset = getFrameID(chado_gene, loc, j, exons) * getFontHeight() * 2;
boolean isForward = false;
if(exon.getFeatureloc().getStrand() == 1)
if(loc.getStrand() == 1)
isForward = true;
drawExons(g2d, ex_start, ex_end,
......@@ -251,21 +259,30 @@ public class GeneViewerPanel extends JPanel
}
private int getFrameID(ChadoCanonicalGene chado_gene, ChadoFeature feature,
/**
* Get the frame id for a feature segment
* @param chado_gene the chado representation of the gene model
* @param loc feature location of the feature
* @param nexon number of the exon
* @param exons List of exons
* @return frame id
*/
private int getFrameID(ChadoCanonicalGene chado_gene,
ChadoFeatureLoc loc,
int nexon, List exons)
{
final int position_on_strand;
if(feature.getFeatureloc().getStrand() == -1)
position_on_strand = chado_gene.getSeqlen()-feature.getFeatureloc().getFmax();
if(loc.getStrand() == -1)
position_on_strand = chado_gene.getSeqlen()-loc.getFmax();
else
position_on_strand = feature.getFeatureloc().getFmin();
position_on_strand = loc.getFmin();
// this will be 0, 1 or 2 depending on which frame the segment is in
final int start_base_modulo =
(position_on_strand + getFrameShift(nexon, exons)) % 3;
(position_on_strand + getFrameShift(nexon, exons, chado_gene, loc)) % 3;
if(feature.getFeatureloc().getStrand() == 1)
if(loc.getStrand() == 1)
{
switch (start_base_modulo)
{
......@@ -301,7 +318,9 @@ public class GeneViewerPanel extends JPanel
* translating one base ahead of the start position and 2 means start
* translating two bases ahead of the start position.
**/
private int getFrameShift(int nexon, List exons)
private int getFrameShift(int nexon, List exons,
ChadoCanonicalGene chado_gene,
ChadoFeatureLoc loc)
{
// find the number of bases in the segments before this one
int base_count = 0;
......@@ -310,7 +329,8 @@ public class GeneViewerPanel extends JPanel
for(int i = 0; i < exons.size(); ++i)
{
ChadoFeature this_feature = (ChadoFeature)exons.get(i);
ChadoFeatureLoc featureLoc = this_feature.getFeatureloc();
ChadoFeatureLoc featureLoc = ChadoFeature.getFeatureLoc(
this_feature.getFeaturelocsForFeatureId(), chado_gene.getSrcfeature_id());
int this_direction;
if(featureLoc.getStrand() == 1)
......@@ -336,10 +356,9 @@ public class GeneViewerPanel extends JPanel
}
}
int codon_start = ((ChadoFeature)exons.get(nexon)).getFeatureloc().getPhase();
int codon_start = loc.getPhase();
int mod_value = (base_count + 3 - codon_start) % 3;
//System.out.println("GVP mod_value="+mod_value+" base_count="+base_count + " codon_start="+codon_start);
if(mod_value == 1)
return 2;
else if(mod_value == 2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment