import jalview.analysis.Rna;
import jalview.analysis.SecStrConsensus.SimpleBP;
-
import jalview.analysis.WUSSParseException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
-
-import fr.orsay.lri.varna.models.rna.RNA;
+import java.util.Map.Entry;
/**
* DOCUMENT ME!
// System.out.println("featuregroup " + _rnasecstr[0].getFeatureGroup());
}
- public java.util.Hashtable sequenceMapping;
+ public java.util.Hashtable<Integer, Annotation> sequenceMapping;
/** DOCUMENT ME!! */
public float graphMin;
// Check for RNA secondary structure
{
// System.out.println(annotations[i].secondaryStructure);
+ // TODO: 2.8.2 should this ss symbol validation check be a function in
+ // RNA/ResidueProperties ?
if (annotations[i].secondaryStructure == '('
|| annotations[i].secondaryStructure == '['
|| annotations[i].secondaryStructure == '<'
// annotations[i].displayCharacter.charAt(0)==annotations[i].secondaryStructure
firstChar != ' '
&& firstChar != '$'
- && firstChar != '�' // JBPNote should explicitly express as
- // unicode number to avoid source code
- // translation problems
+ && firstChar != 0xCE
&& firstChar != '('
&& firstChar != '['
&& firstChar != '>'
{
this.label = new String(annotation.label);
if (annotation.description != null)
+ {
this.description = new String(annotation.description);
+ }
this.graphMin = annotation.graphMin;
this.graphMax = annotation.graphMax;
this.graph = annotation.graph;
{
// could optimise this!
p = (Integer) pos.nextElement();
- Annotation a = (Annotation) annotation.sequenceMapping.get(p);
+ Annotation a = annotation.sequenceMapping.get(p);
if (a == null)
{
continue;
return;
}
if (startRes < 0)
+ {
startRes = 0;
+ }
if (startRes >= annotations.length)
+ {
startRes = annotations.length - 1;
+ }
if (endRes >= annotations.length)
+ {
endRes = annotations.length - 1;
+ }
if (annotations == null)
+ {
return;
+ }
Annotation[] temp = new Annotation[endRes - startRes + 1];
if (startRes < annotations.length)
{
public void adjustForAlignment()
{
if (sequenceRef == null)
+ {
return;
+ }
if (annotations == null)
{
{
position = sequenceRef.findIndex(a) - 1;
- temp[position] = (Annotation) sequenceMapping.get(index);
+ temp[position] = sequenceMapping.get(index);
}
}
if (annotations[i] == null)
{
if (i + 1 < iSize)
+ {
System.arraycopy(annotations, i + 1, annotations, i, iSize - i
- 1);
+ }
iSize--;
}
else
{
if (sequenceRef != null)
{
+ boolean rIsDs=sequenceRef.getDatasetSequence()==null,tIsDs=sequenceI.getDatasetSequence()==null;
if (sequenceRef != sequenceI
- && !sequenceRef.equals(sequenceI)
- && sequenceRef.getDatasetSequence() != sequenceI
+ && (rIsDs && !tIsDs && sequenceRef != sequenceI
+ .getDatasetSequence())
+ && (!rIsDs && tIsDs && sequenceRef.getDatasetSequence() != sequenceI)
+ && (!rIsDs && !tIsDs && sequenceRef.getDatasetSequence() != sequenceI
.getDatasetSequence())
+ && !sequenceRef.equals(sequenceI))
{
// if sequenceRef isn't intersecting with sequenceI
// throw away old mapping and reconstruct.
for (int i = 0; i < annotations.length; i++)
{
if (annotations[i] == null)
+ {
annotations[i] = new Annotation(String.valueOf(gapchar), null,
' ', 0f, null);
+ }
else if (annotations[i].displayCharacter == null
|| annotations[i].displayCharacter.equals(" "))
+ {
annotations[i].displayCharacter = String.valueOf(gapchar);
+ }
}
}
}
{
this.calcId = calcId;
}
+
+ public boolean isRNA()
+ {
+ return isrna;
+ }
+
+ /**
+ * transfer annotation to the given sequence using the given mapping from the
+ * current positions or an existing sequence mapping
+ *
+ * @param sq
+ * @param sp2sq
+ * map involving sq as To or From
+ */
+ public void liftOver(SequenceI sq, Mapping sp2sq)
+ {
+ if (sp2sq.getMappedWidth() != sp2sq.getWidth())
+ {
+ // TODO: employ getWord/MappedWord to transfer annotation between cDNA and Protein reference frames
+ throw new Error("liftOver currently not implemented for transfer of annotation between different types of seqeunce");
+ }
+ boolean mapIsTo = (sp2sq != null) ? (sp2sq.getTo() == sq || sp2sq
+ .getTo() == sq.getDatasetSequence()) : false;
+
+ // TODO build a better annotation element map and get rid of annotations[]
+ Hashtable<Integer, Annotation> mapForsq = new Hashtable();
+ if (sequenceMapping != null)
+ {
+ if (sp2sq != null)
+ {
+ for (Entry<Integer, Annotation> ie : sequenceMapping.entrySet())
+ {
+ Integer mpos = Integer.valueOf(mapIsTo ? sp2sq
+ .getMappedPosition(ie.getKey()) : sp2sq.getPosition(ie
+ .getKey()));
+ if (mpos >= sq.getStart() && mpos <= sq.getEnd())
+ {
+ mapForsq.put(mpos, ie.getValue());
+ }
+ }
+ sequenceMapping = mapForsq;
+ sequenceRef = sq;
+ adjustForAlignment();
+ }
+ else
+ {
+ // trim positions
+ }
+ }
+
+ }
}