Skip to content
Snippets Groups Projects
Commit c89c19db authored by tcarver's avatar tcarver
Browse files

implement deriveSeqName()

parent fcb19ce6
No related branches found
No related tags found
No related merge requests found
...@@ -731,7 +731,7 @@ public class GFFStreamFeature extends SimpleDocumentFeature ...@@ -731,7 +731,7 @@ public class GFFStreamFeature extends SimpleDocumentFeature
throw new ReadOnlyException(); throw new ReadOnlyException();
} }
protected static Hashtable contig_ranges; protected static Hashtable<String, Range> contig_ranges;
/** /**
* Write this Feature to the given stream. * Write this Feature to the given stream.
...@@ -762,18 +762,13 @@ public class GFFStreamFeature extends SimpleDocumentFeature ...@@ -762,18 +762,13 @@ public class GFFStreamFeature extends SimpleDocumentFeature
source_str = getDbxrefGFFSource(getQualifierByName("Dbxref")); source_str = getDbxrefGFFSource(getQualifierByName("Dbxref"));
} }
int start = this_range.getStart();
int end = this_range.getEnd();
if(seqname == null && ((GFFDocumentEntry)getEntry()).getDocument() != null) if(seqname == null && ((GFFDocumentEntry)getEntry()).getDocument() != null)
seqname = ((GFFDocumentEntry)getEntry()).getDocument().getName(); seqname = ((GFFDocumentEntry)getEntry()).getDocument().getName();
if(seqname == null) if(seqname == null)
{ seqname = deriveSeqName(start);
try
{
seqname = ((GFFStreamFeature)(getEntry().getAllFeatures().elementAt(0))).getGffSeqName();
}
catch(Exception e) {}
if(seqname == null)
seqname = "gff_seqname";
}
if(source == null) if(source == null)
source = "artemis"; source = "artemis";
...@@ -781,8 +776,6 @@ public class GFFStreamFeature extends SimpleDocumentFeature ...@@ -781,8 +776,6 @@ public class GFFStreamFeature extends SimpleDocumentFeature
if(score == null) if(score == null)
score = new Qualifier("score", "."); score = new Qualifier("score", ".");
int start = this_range.getStart();
int end = this_range.getEnd();
if(seqname != null && contig_ranges != null && if(seqname != null && contig_ranges != null &&
contig_ranges.containsKey(seqname)) contig_ranges.containsKey(seqname))
{ {
...@@ -845,32 +838,40 @@ public class GFFStreamFeature extends SimpleDocumentFeature ...@@ -845,32 +838,40 @@ public class GFFStreamFeature extends SimpleDocumentFeature
} }
/** /**
* Get the GFF_source value of a Dbxref qualifier. * If the seqname is not set for this feature try to derive the contig/chromosome
* @param qualifier * it is located on
* @return the gff_source value or NULL * @param start
* @return
*/ */
/* private String deriveSeqName(int start)
private String getDbxrefGFFSource(final Qualifier qualifier)
{ {
StringVector qualifier_strings = String seqname = null;
StreamQualifier.toStringVector(null, qualifier); if(contig_ranges != null)
for(int i=0; i<qualifier_strings.size(); i++)
{ {
String qualifier_string = (String)qualifier_strings.elementAt(i); final Enumeration<String> contigEnum = contig_ranges.keys();
while(contigEnum.hasMoreElements())
if(qualifier_string.indexOf("GFF_source:") >-1)
{ {
int index = qualifier_string.indexOf(":")+1; final String key = contigEnum.nextElement();
int len = qualifier_string.length(); final Range r = contig_ranges.get(key);
if(qualifier_string.endsWith("\"")) if(r.getStart() > start)
len--; continue;
return qualifier_string.substring(index, len); if(r.getEnd() > start)
return key;
} }
} }
return null; else
{
try
{
seqname = ((GFFStreamFeature)(getEntry().getAllFeatures().elementAt(0))).getGffSeqName();
}
catch(Exception e) {}
}
if(seqname == null)
seqname = "gff_seqname";
return seqname;
} }
*/
/** /**
* Return a String containing the qualifiers of this feature in a form * Return a String containing the qualifiers of this feature in a form
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment