2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.datamodel;
23 import jalview.analysis.Rna;
24 import jalview.analysis.SecStrConsensus.SimpleBP;
25 import jalview.analysis.WUSSParseException;
27 import java.util.ArrayList;
28 import java.util.Collection;
29 import java.util.Collections;
30 import java.util.HashMap;
31 import java.util.Iterator;
33 import java.util.Map.Entry;
41 public class AlignmentAnnotation
44 * Identifers for different types of profile data
46 public static final int SEQUENCE_PROFILE = 0;
48 public static final int STRUCTURE_PROFILE = 1;
50 public static final int CDNA_PROFILE = 2;
53 * If true, this annotations is calculated every edit, eg consensus, quality
54 * or conservation graphs
56 public boolean autoCalculated = false;
59 * unique ID for this annotation, used to match up the same annotation row
60 * shown in multiple views and alignments
62 public String annotationId;
65 * the sequence this annotation is associated with (or null)
67 public SequenceI sequenceRef;
69 /** label shown in dropdown menus and in the annotation label area */
72 /** longer description text shown as a tooltip */
73 public String description;
75 /** Array of annotations placed in the current coordinate system */
76 public Annotation[] annotations;
78 public ArrayList<SimpleBP> bps = null;
81 * RNA secondary structure contact positions
83 public SequenceFeature[] _rnasecstr = null;
86 * position of annotation resulting in invalid WUSS parsing or -1. -2 means
87 * there was no RNA structure in this annotation
89 private long invalidrnastruc = -2;
92 * Updates the _rnasecstr field Determines the positions that base pair and
93 * the positions of helices based on secondary structure from a Stockholm file
97 private void _updateRnaSecStr(CharSequence RNAannot)
101 _rnasecstr = Rna.GetBasePairs(RNAannot);
102 bps = Rna.GetModeleBP(RNAannot);
103 invalidrnastruc = -1;
104 } catch (WUSSParseException px)
106 // DEBUG System.out.println(px);
107 invalidrnastruc = px.getProblemPos();
109 if (invalidrnastruc > -1)
113 Rna.HelixMap(_rnasecstr);
114 // setRNAStruc(RNAannot);
116 if (_rnasecstr != null && _rnasecstr.length > 0)
118 // show all the RNA secondary structure annotation symbols.
120 showAllColLabels = true;
121 scaleColLabel = true;
124 // System.out.println("featuregroup " + _rnasecstr[0].getFeatureGroup());
128 private void _markRnaHelices()
131 // Figure out number of helices
132 // Length of rnasecstr is the number of pairs of positions that base pair
133 // with each other in the secondary structure
134 for (int x = 0; x < _rnasecstr.length; x++)
138 * System.out.println(this.annotation._rnasecstr[x] + " Begin" +
139 * this.annotation._rnasecstr[x].getBegin());
141 // System.out.println(this.annotation._rnasecstr[x].getFeatureGroup());
145 val = Integer.valueOf(_rnasecstr[x].getFeatureGroup());
150 } catch (NumberFormatException q)
155 annotations[_rnasecstr[x].getBegin()].value = val;
156 annotations[_rnasecstr[x].getEnd()].value = val;
158 // annotations[_rnasecstr[x].getBegin()].displayCharacter = "" + val;
159 // annotations[_rnasecstr[x].getEnd()].displayCharacter = "" + val;
164 * map of positions in the associated annotation
166 private Map<Integer, Annotation> sequenceMapping;
169 public float graphMin;
172 public float graphMax;
175 * Score associated with label and description.
177 public double score = Double.NaN;
180 * flag indicating if annotation has a score.
182 public boolean hasScore = false;
184 public GraphLine threshold;
186 // Graphical hints and tips
188 /** Can this row be edited by the user ? */
189 public boolean editable = false;
191 /** Indicates if annotation has a graphical symbol track */
192 public boolean hasIcons; //
194 /** Indicates if annotation has a text character label */
195 public boolean hasText;
197 /** is the row visible */
198 public boolean visible = true;
200 public int graphGroup = -1;
202 /** Displayed height of row in pixels */
203 public int height = 0;
205 public int graph = 0;
207 public int graphHeight = 40;
209 public boolean padGaps = false;
211 public static final int NO_GRAPH = 0;
213 public static final int BAR_GRAPH = 1;
215 public static final int LINE_GRAPH = 2;
217 public boolean belowAlignment = true;
219 public SequenceGroup groupRef = null;
222 * display every column label, even if there is a row of identical labels
224 public boolean showAllColLabels = false;
227 * scale the column label to fit within the alignment column.
229 public boolean scaleColLabel = false;
232 * centre the column labels relative to the alignment column
234 public boolean centreColLabels = false;
236 private boolean isrna;
241 * @see java.lang.Object#finalize()
243 protected void finalize() throws Throwable
250 public static int getGraphValueFromString(String string)
252 if (string.equalsIgnoreCase("BAR_GRAPH"))
256 else if (string.equalsIgnoreCase("LINE_GRAPH"))
266 // JBPNote: what does this do ?
267 public void ConcenStru(CharSequence RNAannot) throws WUSSParseException
269 bps = Rna.GetModeleBP(RNAannot);
273 * Creates a new AlignmentAnnotation object.
276 * short label shown under sequence labels
278 * text displayed on mouseover
280 * set of positional annotation elements
282 public AlignmentAnnotation(String label, String description,
283 Annotation[] annotations)
288 this.description = description;
289 this.annotations = annotations;
291 validateRangeAndDisplay();
295 * Checks if annotation labels represent secondary structures
298 void areLabelsSecondaryStructure()
300 boolean nonSSLabel = false;
302 StringBuffer rnastring = new StringBuffer();
305 for (int i = 0; i < annotations.length; i++)
307 if (annotations[i] == null)
311 if (annotations[i].secondaryStructure == 'H'
312 || annotations[i].secondaryStructure == 'E')
317 // Check for RNA secondary structure
319 // System.out.println(annotations[i].secondaryStructure);
320 // TODO: 2.8.2 should this ss symbol validation check be a function in
321 // RNA/ResidueProperties ?
322 if (annotations[i].secondaryStructure == '('
323 || annotations[i].secondaryStructure == '['
324 || annotations[i].secondaryStructure == '<'
325 || annotations[i].secondaryStructure == '{'
326 || annotations[i].secondaryStructure == 'A'
327 || annotations[i].secondaryStructure == 'B'
328 || annotations[i].secondaryStructure == 'C'
329 || annotations[i].secondaryStructure == 'D'
330 || annotations[i].secondaryStructure == 'E'
331 || annotations[i].secondaryStructure == 'F'
332 || annotations[i].secondaryStructure == 'G'
333 || annotations[i].secondaryStructure == 'H'
334 || annotations[i].secondaryStructure == 'I'
335 || annotations[i].secondaryStructure == 'J'
336 || annotations[i].secondaryStructure == 'K'
337 || annotations[i].secondaryStructure == 'L'
338 || annotations[i].secondaryStructure == 'M'
339 || annotations[i].secondaryStructure == 'N'
340 || annotations[i].secondaryStructure == 'O'
341 || annotations[i].secondaryStructure == 'P'
342 || annotations[i].secondaryStructure == 'Q'
343 || annotations[i].secondaryStructure == 'R'
344 || annotations[i].secondaryStructure == 'S'
345 || annotations[i].secondaryStructure == 'T'
346 || annotations[i].secondaryStructure == 'U'
347 || annotations[i].secondaryStructure == 'V'
348 || annotations[i].secondaryStructure == 'W'
349 || annotations[i].secondaryStructure == 'X'
350 || annotations[i].secondaryStructure == 'Y'
351 || annotations[i].secondaryStructure == 'Z')
358 // System.out.println("displaychar " + annotations[i].displayCharacter);
360 if (annotations[i].displayCharacter == null
361 || annotations[i].displayCharacter.length() == 0)
363 rnastring.append('.');
366 if (annotations[i].displayCharacter.length() == 1)
368 firstChar = annotations[i].displayCharacter.charAt(0);
369 // check to see if it looks like a sequence or is secondary structure
371 if (annotations[i].secondaryStructure != ' '
374 // Uncomment to only catch case where
375 // displayCharacter==secondary
377 // to correctly redisplay SS annotation imported from Stockholm,
378 // exported to JalviewXML and read back in again.
380 // annotations[i].displayCharacter.charAt(0)==annotations[i].secondaryStructure
415 && firstChar < jalview.schemes.ResidueProperties.aaIndex.length)
417 if (jalview.schemes.ResidueProperties.aaIndex[firstChar] < 23) // TODO:
430 rnastring.append(annotations[i].displayCharacter.charAt(1));
433 if (annotations[i].displayCharacter.length() > 0)
442 for (int j = 0; j < annotations.length; j++)
444 if (annotations[j] != null
445 && annotations[j].secondaryStructure != ' ')
447 annotations[j].displayCharacter = String
448 .valueOf(annotations[j].secondaryStructure);
449 annotations[j].secondaryStructure = ' ';
458 _updateRnaSecStr(new AnnotCharSequence());
462 annotationId = this.hashCode() + "";
466 * flyweight access to positions in the alignment annotation row for RNA
472 private class AnnotCharSequence implements CharSequence
478 public AnnotCharSequence()
480 this(0, annotations.length);
483 public AnnotCharSequence(int start, int end)
490 public CharSequence subSequence(int start, int end)
492 return new AnnotCharSequence(offset + start, offset + end);
502 public char charAt(int index)
504 return ((index + offset < 0) || (index + offset) >= max
505 || annotations[index + offset] == null || (annotations[index
506 + offset].secondaryStructure <= ' ') ? ' '
507 : annotations[index + offset].displayCharacter.charAt(0));
511 public String toString()
513 char[] string = new char[max - offset];
514 int mx = annotations.length;
516 for (int i = offset; i < mx; i++)
518 string[i] = (annotations[i] == null || (annotations[i].secondaryStructure <= 32)) ? ' '
519 : annotations[i].displayCharacter.charAt(0);
521 return new String(string);
525 private long _lastrnaannot = -1;
527 public String getRNAStruc()
531 String rnastruc = new AnnotCharSequence().toString();
532 if (_lastrnaannot != rnastruc.hashCode())
534 // ensure rna structure contacts are up to date
535 _lastrnaannot = rnastruc.hashCode();
536 _updateRnaSecStr(rnastruc);
544 * Creates a new AlignmentAnnotation object.
559 public AlignmentAnnotation(String label, String description,
560 Annotation[] annotations, float min, float max, int graphType)
562 // graphs are not editable
563 editable = graphType == 0;
566 this.description = description;
567 this.annotations = annotations;
571 validateRangeAndDisplay();
575 * checks graphMin and graphMax, secondary structure symbols, sets graphType
576 * appropriately, sets null labels to the empty string if appropriate.
578 public void validateRangeAndDisplay()
581 if (annotations == null)
583 visible = false; // try to prevent renderer from displaying.
584 return; // this is a non-annotation row annotation - ie a sequence score.
587 int graphType = graph;
588 float min = graphMin;
589 float max = graphMax;
590 boolean drawValues = true;
595 for (int i = 0; i < annotations.length; i++)
597 if (annotations[i] == null)
602 if (drawValues && annotations[i].displayCharacter != null
603 && annotations[i].displayCharacter.length() > 1)
608 if (annotations[i].value > max)
610 max = annotations[i].value;
613 if (annotations[i].value < min)
615 min = annotations[i].value;
617 if (_linecolour == null && annotations[i].colour != null)
619 _linecolour = annotations[i].colour;
622 // ensure zero is origin for min/max ranges on only one side of zero
639 areLabelsSecondaryStructure();
641 if (!drawValues && graphType != NO_GRAPH)
643 for (int i = 0; i < annotations.length; i++)
645 if (annotations[i] != null)
647 annotations[i].displayCharacter = "X";
654 * Copy constructor creates a new independent annotation row with the same
655 * associated sequenceRef
659 public AlignmentAnnotation(AlignmentAnnotation annotation)
661 this.label = new String(annotation.label);
662 if (annotation.description != null)
664 this.description = new String(annotation.description);
666 this.graphMin = annotation.graphMin;
667 this.graphMax = annotation.graphMax;
668 this.graph = annotation.graph;
669 this.graphHeight = annotation.graphHeight;
670 this.graphGroup = annotation.graphGroup;
671 this.groupRef = annotation.groupRef;
672 this.editable = annotation.editable;
673 this.autoCalculated = annotation.autoCalculated;
674 this.hasIcons = annotation.hasIcons;
675 this.hasText = annotation.hasText;
676 this.height = annotation.height;
677 this.label = annotation.label;
678 this.padGaps = annotation.padGaps;
679 this.visible = annotation.visible;
680 this.centreColLabels = annotation.centreColLabels;
681 this.scaleColLabel = annotation.scaleColLabel;
682 this.showAllColLabels = annotation.showAllColLabels;
683 this.calcId = annotation.calcId;
684 if (annotation.properties!=null)
686 properties = new HashMap<String,String>();
687 for (Map.Entry<String, String> val:annotation.properties.entrySet())
689 properties.put(val.getKey(), val.getValue());
692 if (this.hasScore = annotation.hasScore)
694 this.score = annotation.score;
696 if (annotation.threshold != null)
698 threshold = new GraphLine(annotation.threshold);
700 Annotation[] ann = annotation.annotations;
701 if (annotation.annotations != null)
703 this.annotations = new Annotation[ann.length];
704 for (int i = 0; i < ann.length; i++)
708 annotations[i] = new Annotation(ann[i]);
709 if (_linecolour != null)
711 _linecolour = annotations[i].colour;
716 if (annotation.sequenceRef != null)
718 this.sequenceRef = annotation.sequenceRef;
719 if (annotation.sequenceMapping != null)
722 sequenceMapping = new HashMap<Integer, Annotation>();
723 Iterator<Integer> pos = annotation.sequenceMapping.keySet()
725 while (pos.hasNext())
727 // could optimise this!
729 Annotation a = annotation.sequenceMapping.get(p);
736 for (int i = 0; i < ann.length; i++)
740 sequenceMapping.put(p, annotations[i]);
748 this.sequenceMapping = null;
751 // TODO: check if we need to do this: JAL-952
752 // if (this.isrna=annotation.isrna)
754 // _rnasecstr=new SequenceFeature[annotation._rnasecstr];
756 validateRangeAndDisplay(); // construct hashcodes, etc.
760 * clip the annotation to the columns given by startRes and endRes (inclusive)
761 * and prune any existing sequenceMapping to just those columns.
766 public void restrict(int startRes, int endRes)
768 if (annotations == null)
777 if (startRes >= annotations.length)
779 startRes = annotations.length - 1;
781 if (endRes >= annotations.length)
783 endRes = annotations.length - 1;
785 if (annotations == null)
789 Annotation[] temp = new Annotation[endRes - startRes + 1];
790 if (startRes < annotations.length)
792 System.arraycopy(annotations, startRes, temp, 0, endRes - startRes
795 if (sequenceRef != null)
797 // Clip the mapping, if it exists.
798 int spos = sequenceRef.findPosition(startRes);
799 int epos = sequenceRef.findPosition(endRes);
800 if (sequenceMapping != null)
802 Map<Integer, Annotation> newmapping = new HashMap<Integer, Annotation>();
803 Iterator<Integer> e = sequenceMapping.keySet().iterator();
806 Integer pos = e.next();
807 if (pos.intValue() >= spos && pos.intValue() <= epos)
809 newmapping.put(pos, sequenceMapping.get(pos));
812 sequenceMapping.clear();
813 sequenceMapping = newmapping;
820 * set the annotation row to be at least length Annotations
823 * minimum number of columns required in the annotation row
824 * @return false if the annotation row is greater than length
826 public boolean padAnnotation(int length)
828 if (annotations == null)
830 return true; // annotation row is correct - null == not visible and
833 if (annotations.length < length)
835 Annotation[] na = new Annotation[length];
836 System.arraycopy(annotations, 0, na, 0, annotations.length);
840 return annotations.length > length;
847 * @return DOCUMENT ME!
850 public String toString()
852 StringBuilder buffer = new StringBuilder(256);
854 for (int i = 0; i < annotations.length; i++)
856 if (annotations[i] != null)
860 buffer.append(annotations[i].value);
864 buffer.append(annotations[i].secondaryStructure);
868 buffer.append(annotations[i].displayCharacter);
874 // TODO: remove disgusting hack for 'special' treatment of consensus line.
875 if (label.indexOf("Consensus") == 0)
879 for (int i = 0; i < annotations.length; i++)
881 if (annotations[i] != null)
883 buffer.append(annotations[i].description);
890 return buffer.toString();
893 public void setThreshold(GraphLine line)
898 public GraphLine getThreshold()
904 * Attach the annotation to seqRef, starting from startRes position. If
905 * alreadyMapped is true then the indices of the annotation[] array are
906 * sequence positions rather than alignment column positions.
910 * @param alreadyMapped
912 public void createSequenceMapping(SequenceI seqRef, int startRes,
913 boolean alreadyMapped)
920 sequenceRef = seqRef;
921 if (annotations == null)
925 sequenceMapping = new HashMap<Integer, Annotation>();
929 for (int i = 0; i < annotations.length; i++)
931 if (annotations[i] != null)
935 seqPos = seqRef.findPosition(i);
939 seqPos = i + startRes;
942 sequenceMapping.put(new Integer(seqPos), annotations[i]);
948 public void adjustForAlignment()
950 if (sequenceRef == null)
955 if (annotations == null)
960 int a = 0, aSize = sequenceRef.getLength();
969 Annotation[] temp = new Annotation[aSize];
972 for (a = sequenceRef.getStart(); a <= sequenceRef.getEnd(); a++)
974 index = new Integer(a);
975 if (sequenceMapping.containsKey(index))
977 position = sequenceRef.findIndex(a) - 1;
979 temp[position] = sequenceMapping.get(index);
987 * remove any null entries in annotation row and return the number of non-null
988 * annotation elements.
992 public int compactAnnotationArray()
994 int i = 0, iSize = annotations.length;
997 if (annotations[i] == null)
1001 System.arraycopy(annotations, i + 1, annotations, i, iSize - i
1011 Annotation[] ann = annotations;
1012 annotations = new Annotation[i];
1013 System.arraycopy(ann, 0, annotations, 0, i);
1019 * Associate this annotion with the aligned residues of a particular sequence.
1020 * sequenceMapping will be updated in the following way: null sequenceI -
1021 * existing mapping will be discarded but annotations left in mapped
1022 * positions. valid sequenceI not equal to current sequenceRef: mapping is
1023 * discarded and rebuilt assuming 1:1 correspondence TODO: overload with
1024 * parameter to specify correspondence between current and new sequenceRef
1028 public void setSequenceRef(SequenceI sequenceI)
1030 if (sequenceI != null)
1032 if (sequenceRef != null)
1034 boolean rIsDs=sequenceRef.getDatasetSequence()==null,tIsDs=sequenceI.getDatasetSequence()==null;
1035 if (sequenceRef != sequenceI
1036 && (rIsDs && !tIsDs && sequenceRef != sequenceI
1037 .getDatasetSequence())
1038 && (!rIsDs && tIsDs && sequenceRef.getDatasetSequence() != sequenceI)
1039 && (!rIsDs && !tIsDs && sequenceRef.getDatasetSequence() != sequenceI
1040 .getDatasetSequence())
1041 && !sequenceRef.equals(sequenceI))
1043 // if sequenceRef isn't intersecting with sequenceI
1044 // throw away old mapping and reconstruct.
1046 if (sequenceMapping != null)
1048 sequenceMapping = null;
1049 // compactAnnotationArray();
1051 createSequenceMapping(sequenceI, 1, true);
1052 adjustForAlignment();
1056 // Mapping carried over
1057 sequenceRef = sequenceI;
1062 // No mapping exists
1063 createSequenceMapping(sequenceI, 1, true);
1064 adjustForAlignment();
1069 // throw away the mapping without compacting.
1070 sequenceMapping = null;
1078 public double getScore()
1087 public void setScore(double score)
1095 * @return true if annotation has an associated score
1097 public boolean hasScore()
1099 return hasScore || !Double.isNaN(score);
1103 * Score only annotation
1106 * @param description
1109 public AlignmentAnnotation(String label, String description, double score)
1111 this(label, description, null);
1116 * copy constructor with edit based on the hidden columns marked in colSel
1118 * @param alignmentAnnotation
1121 public AlignmentAnnotation(AlignmentAnnotation alignmentAnnotation,
1122 ColumnSelection colSel)
1124 this(alignmentAnnotation);
1125 if (annotations == null)
1129 colSel.makeVisibleAnnotation(this);
1132 public void setPadGaps(boolean padgaps, char gapchar)
1134 this.padGaps = padgaps;
1138 for (int i = 0; i < annotations.length; i++)
1140 if (annotations[i] == null)
1142 annotations[i] = new Annotation(String.valueOf(gapchar), null,
1145 else if (annotations[i].displayCharacter == null
1146 || annotations[i].displayCharacter.equals(" "))
1148 annotations[i].displayCharacter = String.valueOf(gapchar);
1155 * format description string for display
1158 * @return Get the annotation description string optionally prefixed by
1159 * associated sequence name (if any)
1161 public String getDescription(boolean seqname)
1163 if (seqname && this.sequenceRef != null)
1165 int i = description.toLowerCase().indexOf("<html>");
1168 // move the html tag to before the sequence reference.
1169 return "<html>" + sequenceRef.getName() + " : "
1170 + description.substring(i + 6);
1172 return sequenceRef.getName() + " : " + description;
1177 public boolean isValidStruc()
1179 return invalidrnastruc == -1;
1182 public long getInvalidStrucPos()
1184 return invalidrnastruc;
1188 * machine readable ID string indicating what generated this annotation
1190 protected String calcId = "";
1193 * properties associated with the calcId
1195 protected Map<String, String> properties = new HashMap<String, String>();
1198 * base colour for line graphs. If null, will be set automatically by
1199 * searching the alignment annotation
1201 public java.awt.Color _linecolour;
1203 public String getCalcId()
1208 public void setCalcId(String calcId)
1210 this.calcId = calcId;
1213 public boolean isRNA()
1219 * transfer annotation to the given sequence using the given mapping from the
1220 * current positions or an existing sequence mapping
1224 * map involving sq as To or From
1226 public void liftOver(SequenceI sq, Mapping sp2sq)
1228 if (sp2sq.getMappedWidth() != sp2sq.getWidth())
1230 // TODO: employ getWord/MappedWord to transfer annotation between cDNA and Protein reference frames
1231 throw new Error("liftOver currently not implemented for transfer of annotation between different types of seqeunce");
1233 boolean mapIsTo = (sp2sq != null) ? (sp2sq.getTo() == sq || sp2sq
1234 .getTo() == sq.getDatasetSequence()) : false;
1236 // TODO build a better annotation element map and get rid of annotations[]
1237 Map<Integer, Annotation> mapForsq = new HashMap<Integer, Annotation>();
1238 if (sequenceMapping != null)
1242 for (Entry<Integer, Annotation> ie : sequenceMapping.entrySet())
1244 Integer mpos = Integer.valueOf(mapIsTo ? sp2sq
1245 .getMappedPosition(ie.getKey()) : sp2sq.getPosition(ie
1247 if (mpos >= sq.getStart() && mpos <= sq.getEnd())
1249 mapForsq.put(mpos, ie.getValue());
1252 sequenceMapping = mapForsq;
1254 adjustForAlignment();
1264 * like liftOver but more general.
1266 * Takes an array of int pairs that will be used to update the internal
1267 * sequenceMapping and so shuffle the annotated positions
1270 * - new sequence reference for the annotation row - if null,
1271 * sequenceRef is left unchanged
1273 * array of ints containing corresponding positions
1275 * - column for current coordinate system (-1 for index+1)
1277 * - column for destination coordinate system (-1 for index+1)
1279 * - offset added to index when referencing either coordinate system
1280 * @note no checks are made as to whether from and/or to are sensible
1281 * @note caller should add the remapped annotation to newref if they have not
1284 public void remap(SequenceI newref, int[][] mapping, int from, int to,
1287 if (mapping != null)
1289 Map<Integer, Annotation> old = sequenceMapping;
1290 Map<Integer, Annotation> remap = new HashMap<Integer, Annotation>();
1292 for (int mp[] : mapping)
1298 Annotation ann = null;
1301 ann = sequenceMapping.get(Integer.valueOf(idxoffset + index));
1305 if (mp != null && mp.length > from)
1307 ann = sequenceMapping.get(Integer.valueOf(mp[from]));
1314 remap.put(Integer.valueOf(idxoffset + index), ann);
1318 if (to > -1 && to < mp.length)
1320 remap.put(Integer.valueOf(mp[to]), ann);
1325 sequenceMapping = remap;
1329 sequenceRef = newref;
1331 adjustForAlignment();
1335 public String getProperty(String property)
1337 if (properties == null)
1341 return properties.get(property);
1344 public void setProperty(String property, String value)
1346 if (properties==null)
1348 properties = new HashMap<String,String>();
1350 properties.put(property, value);
1353 public boolean hasProperties()
1355 return properties != null && properties.size() > 0;
1358 public Collection<String> getProperties()
1360 if (properties == null)
1362 return Collections.EMPTY_LIST;
1364 return properties.keySet();