import jalview.analysis.Rna;
import jalview.analysis.SecStrConsensus.SimpleBP;
-
import jalview.analysis.WUSSParseException;
import java.util.ArrayList;
import java.util.Enumeration;
+import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import java.util.Map.Entry;
-import fr.orsay.lri.varna.models.rna.RNA;
-
/**
* DOCUMENT ME!
*
// 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 ?
+ // 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 == '<'
{
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
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);
+ }
}
}
}
protected String calcId = "";
/**
+ * properties associated with the calcId
+ */
+ protected Map<String, String> properties = new HashMap<String, String>();
+
+ /**
* base colour for line graphs. If null, will be set automatically by
* searching the alignment annotation
*/
// trim positions
}
}
+ }
+ /**
+ * like liftOver but more general.
+ *
+ * Takes an array of int pairs that will be used to update the internal
+ * sequenceMapping and so shuffle the annotated positions
+ *
+ * @param newref
+ * - new sequence reference for the annotation row - if null,
+ * sequenceRef is left unchanged
+ * @param mapping
+ * array of ints containing corresponding positions
+ * @param from
+ * - column for current coordinate system (-1 for index+1)
+ * @param to
+ * - column for destination coordinate system (-1 for index+1)
+ * @param idxoffset
+ * - offset added to index when referencing either coordinate system
+ * @note no checks are made as to whether from and/or to are sensible
+ * @note caller should add the remapped annotation to newref if they have not
+ * already
+ */
+ public void remap(SequenceI newref, int[][] mapping, int from, int to,
+ int idxoffset)
+ {
+ if (mapping != null)
+ {
+ Hashtable<Integer, Annotation> old = sequenceMapping, remap = new Hashtable<Integer, Annotation>();
+ int index = -1;
+ for (int mp[] : mapping)
+ {
+ if (index++ < 0)
+ {
+ continue;
+ }
+ Annotation ann = null;
+ if (from == -1)
+ {
+ ann = sequenceMapping.get(Integer.valueOf(idxoffset + index));
+ }
+ else
+ {
+ if (mp != null && mp.length > from)
+ {
+ ann = sequenceMapping.get(Integer.valueOf(mp[from]));
+ }
+ }
+ if (ann != null)
+ {
+ if (to == -1)
+ {
+ remap.put(Integer.valueOf(idxoffset + index), ann);
+ }
+ else
+ {
+ if (to > -1 && to < mp.length)
+ {
+ remap.put(Integer.valueOf(mp[to]), ann);
+ }
+ }
+ }
+ }
+ sequenceMapping = remap;
+ old.clear();
+ if (newref != null)
+ {
+ sequenceRef = newref;
+ }
+ adjustForAlignment();
+ }
+ }
+
+ public Object getProperty(String property)
+ {
+ if (properties == null)
+ {
+ return null;
+ }
+ return properties.get(property);
+ }
+
+ public void setProperty(String property, String value)
+ {
+ if (properties==null)
+ {
+ properties = new HashMap<String,String>();
+ }
+ properties.put(property, value);
}
}