*/
package jalview.datamodel;
-import jalview.analysis.Rna;
-import jalview.analysis.SecStrConsensus.SimpleBP;
-import jalview.analysis.WUSSParseException;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Map.Entry;
+import jalview.analysis.Rna;
+import jalview.analysis.SecStrConsensus.SimpleBP;
+import jalview.analysis.WUSSParseException;
+
/**
* DOCUMENT ME!
*
*/
public class AlignmentAnnotation
{
+ private static final String ANNOTATION_ID_PREFIX = "ann";
+
/*
* Identifers for different types of profile data
*/
public static final int CDNA_PROFILE = 2;
+ private static long counter = 0;
+
/**
* If true, this annotations is calculated every edit, eg consensus, quality
* or conservation graphs
public AlignmentAnnotation(String label, String description,
Annotation[] annotations)
{
+ setAnnotationId();
// always editable?
editable = true;
this.label = label;
_updateRnaSecStr(new AnnotCharSequence());
}
}
-
- annotationId = this.hashCode() + "";
}
/**
public AlignmentAnnotation(String label, String description,
Annotation[] annotations, float min, float max, int graphType)
{
+ setAnnotationId();
// graphs are not editable
editable = graphType == 0;
*/
public AlignmentAnnotation(AlignmentAnnotation annotation)
{
+ setAnnotationId();
this.label = new String(annotation.label);
if (annotation.description != null)
{
return sequenceMapping == null ? null : sequenceMapping.get(position);
}
+
+ /**
+ * Set the id to "ann" followed by a counter that increments so as to be
+ * unique for the lifetime of the JVM
+ */
+ protected final void setAnnotationId()
+ {
+ this.annotationId = ANNOTATION_ID_PREFIX + Long.toString(nextId());
+ }
+
+ protected static synchronized long nextId()
+ {
+ return counter++;
+ }
}
if (aa[i].sequenceRef != null)
{
- // TODO later annotation sequenceRef should be the XML ID of the
- // sequence rather than its display name
- an.setSequenceRef(aa[i].sequenceRef.getName());
+ // 2.9 JAL-1781 xref on sequence id rather than name
+ an.setSequenceRef(seqsToIds.get(aa[i].sequenceRef));
}
if (aa[i].groupRef != null)
{
jaa.annotationId = an[i].getId();
}
// recover sequence association
- if (an[i].getSequenceRef() != null)
+ String sequenceRef = an[i].getSequenceRef();
+ if (sequenceRef != null)
{
- if (al.findName(an[i].getSequenceRef()) != null)
+ // from 2.9 sequenceRef is to sequence id (JAL-1781)
+ SequenceI sequence = seqRefIds.get(sequenceRef);
+ if (sequence == null)
{
- jaa.createSequenceMapping(al.findName(an[i].getSequenceRef()),
- 1, true);
- al.findName(an[i].getSequenceRef()).addAlignmentAnnotation(jaa);
+ // in pre-2.9 projects sequence ref is to sequence name
+ sequence = al.findName(sequenceRef);
+ }
+ if (sequence != null)
+ {
+ jaa.createSequenceMapping(sequence, 1, true);
+ sequence.addAlignmentAnnotation(jaa);
}
}
// and make a note of any group association