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

fix for naming duplicate features

parent e1705276
No related branches found
No related tags found
No related merge requests found
...@@ -69,10 +69,10 @@ public class GFFStreamFeature extends SimpleDocumentFeature ...@@ -69,10 +69,10 @@ public class GFFStreamFeature extends SimpleDocumentFeature
StringVector gff_lines = null; StringVector gff_lines = null;
/** store for spliced features containing id and range of each segment */ /** store for spliced features containing id and range of each segment */
private Hashtable id_range_store; private Hashtable<String, Range> id_range_store;
/** store a record of the new and old uniquenames that have been changed */ /** store a record of the new and old uniquenames that have been changed */
private Hashtable newIdMapToOldId; private Hashtable<String, String> newIdMapToOldId;
/** store the Timestamp for the feature */ /** store the Timestamp for the feature */
private Timestamp timelastmodified; private Timestamp timelastmodified;
...@@ -82,7 +82,7 @@ public class GFFStreamFeature extends SimpleDocumentFeature ...@@ -82,7 +82,7 @@ public class GFFStreamFeature extends SimpleDocumentFeature
private boolean visible = true; private boolean visible = true;
/** combined feature_relationship.rank store for exons */ /** combined feature_relationship.rank store for exons */
private Hashtable feature_relationship_rank_store; private Hashtable<String, Integer> feature_relationship_rank_store;
/** first tabbed parameter */ /** first tabbed parameter */
private String gffSeqName; private String gffSeqName;
...@@ -231,18 +231,22 @@ public class GFFStreamFeature extends SimpleDocumentFeature ...@@ -231,18 +231,22 @@ public class GFFStreamFeature extends SimpleDocumentFeature
duplicatePrefix = "DUP"; duplicatePrefix = "DUP";
if(id_range_store != null) if(id_range_store != null)
{ {
final Hashtable new_id_range_store = new Hashtable(id_range_store.size()); final Hashtable<String, Range> new_id_range_store = new Hashtable<String, Range>(id_range_store.size());
final Enumeration enumIdRangeStore = id_range_store.keys(); final Enumeration<String> enumIdRangeStore = id_range_store.keys();
while(enumIdRangeStore.hasMoreElements()) while(enumIdRangeStore.hasMoreElements())
{ {
final String keyId = (String)enumIdRangeStore.nextElement(); final String keyId = enumIdRangeStore.nextElement();
final Range range = (Range)id_range_store.get(keyId); final Range range = id_range_store.get(keyId);
new_id_range_store.put(duplicatePrefix+keyId, range); new_id_range_store.put(duplicatePrefix+keyId, range);
} }
id_range_store.clear(); id_range_store.clear();
this.id_range_store = (Hashtable) new_id_range_store.clone(); this.id_range_store = (Hashtable) new_id_range_store.clone();
uniquename = getSegmentID(getLocation().getRanges());
if(getLocation().getRanges().size() > 1)
uniquename = getSegmentID(getLocation().getRanges());
else
uniquename = duplicatePrefix+ (String)getQualifierByName("ID").getValues().get(0);
} }
else else
uniquename = duplicatePrefix+ (String)getQualifierByName("ID").getValues().get(0); uniquename = duplicatePrefix+ (String)getQualifierByName("ID").getValues().get(0);
...@@ -347,24 +351,20 @@ public class GFFStreamFeature extends SimpleDocumentFeature ...@@ -347,24 +351,20 @@ public class GFFStreamFeature extends SimpleDocumentFeature
final String rest_of_line = (String)line_bits.elementAt(8); final String rest_of_line = (String)line_bits.elementAt(8);
// parse the rest of the line as ACeDB format attributes // parse the rest of the line as ACeDB format attributes
final Hashtable attributes = parseAttributes(rest_of_line); final Hashtable<String, StringVector> attributes = parseAttributes(rest_of_line);
// final String type = (String)line_bits.elementAt(2); for(final Enumeration<String> attribute_enum = attributes.keys();
for(final java.util.Enumeration attribute_enum = attributes.keys();
attribute_enum.hasMoreElements();) attribute_enum.hasMoreElements();)
{ {
String name = (String)attribute_enum.nextElement(); String name = attribute_enum.nextElement();
final StringVector values = attributes.get(name);
final StringVector values = (StringVector)attributes.get(name);
if(MatchPanel.isClusterTag(name)) if(MatchPanel.isClusterTag(name))
{ {
List lazyValues = new Vector(); List<ClusterLazyQualifierValue> lazyValues = new Vector<ClusterLazyQualifierValue>();
for(int i=0; i<values.size(); i++) for(int i=0; i<values.size(); i++)
lazyValues.add( lazyValues.add(
new ClusterLazyQualifierValue( (String)values.get(i), name, new ClusterLazyQualifierValue( (String)values.get(i), name,
this )); this ));
setQualifier(new QualifierLazyLoading(name, lazyValues)); setQualifier(new QualifierLazyLoading(name, lazyValues));
} }
else else
...@@ -455,23 +455,23 @@ public class GFFStreamFeature extends SimpleDocumentFeature ...@@ -455,23 +455,23 @@ public class GFFStreamFeature extends SimpleDocumentFeature
* Store for spliced regions of segments ID's and ranges. * Store for spliced regions of segments ID's and ranges.
* *
*/ */
public void setSegmentRangeStore(Hashtable id_range_store) public void setSegmentRangeStore(Hashtable<String, Range> id_range_store)
{ {
this.id_range_store = id_range_store; this.id_range_store = id_range_store;
} }
public Hashtable getSegmentRangeStore() public Hashtable<String, Range> getSegmentRangeStore()
{ {
if(id_range_store == null) if(id_range_store == null)
{ {
id_range_store = new Hashtable(); id_range_store = new Hashtable<String, Range>();
id_range_store.put((String)this.getQualifierByName("ID").getValues().get(0), id_range_store.put((String)this.getQualifierByName("ID").getValues().get(0),
this.getLocation().getTotalRange()); this.getLocation().getTotalRange());
} }
return id_range_store; return id_range_store;
} }
public Hashtable getNewIdMapToOldId() public Hashtable<String, String> getNewIdMapToOldId()
{ {
return newIdMapToOldId; return newIdMapToOldId;
} }
...@@ -480,7 +480,7 @@ public class GFFStreamFeature extends SimpleDocumentFeature ...@@ -480,7 +480,7 @@ public class GFFStreamFeature extends SimpleDocumentFeature
* Used when changing spliced feature uniquenames * Used when changing spliced feature uniquenames
* @param newIdMapToOldId * @param newIdMapToOldId
*/ */
public void setNewIdMapToOldId(Hashtable newIdMapToOldId) public void setNewIdMapToOldId(Hashtable<String, String> newIdMapToOldId)
{ {
this.newIdMapToOldId = newIdMapToOldId; this.newIdMapToOldId = newIdMapToOldId;
} }
...@@ -490,7 +490,7 @@ public class GFFStreamFeature extends SimpleDocumentFeature ...@@ -490,7 +490,7 @@ public class GFFStreamFeature extends SimpleDocumentFeature
* @param feature_relationship_rank_store * @param feature_relationship_rank_store
*/ */
public void setFeature_relationship_rank_store( public void setFeature_relationship_rank_store(
Hashtable feature_relationship_rank_store) Hashtable<String, Integer> feature_relationship_rank_store)
{ {
this.feature_relationship_rank_store = feature_relationship_rank_store; this.feature_relationship_rank_store = feature_relationship_rank_store;
} }
...@@ -499,7 +499,7 @@ public class GFFStreamFeature extends SimpleDocumentFeature ...@@ -499,7 +499,7 @@ public class GFFStreamFeature extends SimpleDocumentFeature
* Store for ID's and CHADO feature_relationship.rank * Store for ID's and CHADO feature_relationship.rank
* @return * @return
*/ */
public Hashtable getFeature_relationship_rank_store() public Hashtable<String, Integer> getFeature_relationship_rank_store()
{ {
return feature_relationship_rank_store; return feature_relationship_rank_store;
} }
...@@ -514,13 +514,13 @@ public class GFFStreamFeature extends SimpleDocumentFeature ...@@ -514,13 +514,13 @@ public class GFFStreamFeature extends SimpleDocumentFeature
{ {
if(id_range_store != null) if(id_range_store != null)
{ {
Enumeration enum_ranges = id_range_store.keys(); Enumeration<String> enum_ranges = id_range_store.keys();
//Iterator it = id_range_store.values().iterator(); //Iterator it = id_range_store.values().iterator();
while(enum_ranges.hasMoreElements()) while(enum_ranges.hasMoreElements())
//while(it.hasNext()) //while(it.hasNext())
{ {
String key = (String)enum_ranges.nextElement(); String key = enum_ranges.nextElement();
Range range = (Range)id_range_store.get(key); Range range = id_range_store.get(key);
if(range.getStart() == r.getStart() && if(range.getStart() == r.getStart() &&
range.getEnd() == r.getEnd()) range.getEnd() == r.getEnd())
return key; return key;
...@@ -963,9 +963,7 @@ public class GFFStreamFeature extends SimpleDocumentFeature ...@@ -963,9 +963,7 @@ public class GFFStreamFeature extends SimpleDocumentFeature
if (chadoGene != null) if (chadoGene != null)
{ {
if(getUserData() == null) if(getUserData() == null)
{ new uk.ac.sanger.artemis.Feature(this);
uk.ac.sanger.artemis.Feature f = new uk.ac.sanger.artemis.Feature(this);
}
// the above line constructs the appropriate userData within this current GFFStreamFeature object, // the above line constructs the appropriate userData within this current GFFStreamFeature object,
// which is required by the following GeneUtils.deriveResidues() // which is required by the following GeneUtils.deriveResidues()
String residues = GeneUtils.deriveResidues(this); String residues = GeneUtils.deriveResidues(this);
...@@ -1072,9 +1070,9 @@ public class GFFStreamFeature extends SimpleDocumentFeature ...@@ -1072,9 +1070,9 @@ public class GFFStreamFeature extends SimpleDocumentFeature
* If the attribute has no value then the Hashtable value will be a zero * If the attribute has no value then the Hashtable value will be a zero
* length vector. * length vector.
**/ **/
private Hashtable parseAttributes(final String att_val_list) private Hashtable<String, StringVector> parseAttributes(final String att_val_list)
{ {
Hashtable attributes = new Hashtable(); Hashtable<String, StringVector> attributes = new Hashtable<String, StringVector>();
// StringTokenizer tokeniser = new StringTokenizer(att_val_list, ";", false); // StringTokenizer tokeniser = new StringTokenizer(att_val_list, ";", false);
// while(tokeniser.hasMoreTokens()) // while(tokeniser.hasMoreTokens())
...@@ -1136,7 +1134,8 @@ public class GFFStreamFeature extends SimpleDocumentFeature ...@@ -1136,7 +1134,8 @@ public class GFFStreamFeature extends SimpleDocumentFeature
if(quote_index < 0) if(quote_index < 0)
{ {
// no closing quote - panic // no closing quote - panic
final Hashtable panic_attributes = new Hashtable(); final Hashtable<String, StringVector> panic_attributes =
new Hashtable<String, StringVector>();
final StringVector notes = new StringVector(); final StringVector notes = new StringVector();
notes.add(att_val_list); notes.add(att_val_list);
panic_attributes.put("note", notes); panic_attributes.put("note", notes);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment