2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 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.util.MessageManager;
25 import java.util.ArrayList;
26 import java.util.Enumeration;
27 import java.util.Hashtable;
28 import java.util.List;
30 import java.util.Vector;
33 * Data structure to hold and manipulate a multiple sequence alignment
39 public class Alignment implements AlignmentI
41 protected Alignment dataset;
43 protected List<SequenceI> sequences;
45 protected List<SequenceGroup> groups = java.util.Collections
46 .synchronizedList(new ArrayList<SequenceGroup>());
48 protected char gapCharacter = '-';
50 protected int type = NUCLEOTIDE;
52 public static final int PROTEIN = 0;
54 public static final int NUCLEOTIDE = 1;
56 public boolean hasRNAStructure = false;
59 public AlignmentAnnotation[] annotations;
61 HiddenSequences hiddenSequences = new HiddenSequences(this);
63 public Hashtable alignmentProperties;
65 private void initAlignment(SequenceI[] seqs)
69 if (jalview.util.Comparison.isNucleotide(seqs))
78 sequences = java.util.Collections
79 .synchronizedList(new ArrayList<SequenceI>());
81 for (i = 0; i < seqs.length; i++)
83 sequences.add(seqs[i]);
89 * Make an alignment from an array of Sequences.
93 public Alignment(SequenceI[] seqs)
99 * Make a new alignment from an array of SeqCigars
104 public Alignment(SeqCigar[] alseqs)
106 SequenceI[] seqs = SeqCigar.createAlignmentSequences(alseqs,
107 gapCharacter, new ColumnSelection(), null);
112 * Make a new alignment from an CigarArray JBPNote - can only do this when
113 * compactAlignment does not contain hidden regions. JBPNote - must also check
114 * that compactAlignment resolves to a set of SeqCigars - or construct them
117 * @param compactAlignment
120 public static AlignmentI createAlignment(CigarArray compactAlignment)
122 throw new Error(MessageManager.getString("error.alignment_cigararray_not_implemented"));
123 // this(compactAlignment.refCigars);
129 * @return DOCUMENT ME!
132 public List<SequenceI> getSequences()
138 public List<SequenceI> getSequences(
139 Map<SequenceI, SequenceCollectionI> hiddenReps)
141 // TODO: in jalview 2.8 we don't do anything with hiddenreps - fix design to
147 public SequenceI[] getSequencesArray()
149 if (sequences == null)
153 synchronized (sequences)
155 return sequences.toArray(new SequenceI[sequences.size()]);
165 * @return DOCUMENT ME!
168 public SequenceI getSequenceAt(int i)
170 synchronized (sequences)
172 if (i > -1 && i < sequences.size())
174 return sequences.get(i);
181 * Adds a sequence to the alignment. Recalculates maxLength and size.
186 public void addSequence(SequenceI snew)
190 // maintain dataset integrity
191 if (snew.getDatasetSequence() != null)
193 getDataset().addSequence(snew.getDatasetSequence());
197 // derive new sequence
198 SequenceI adding = snew.deriveSequence();
199 getDataset().addSequence(adding.getDatasetSequence());
203 if (sequences == null)
205 initAlignment(new SequenceI[]
210 synchronized (sequences)
215 if (hiddenSequences != null)
217 hiddenSequences.adjustHeightSequenceAdded();
222 * Adds a sequence to the alignment. Recalculates maxLength and size.
227 public void setSequenceAt(int i, SequenceI snew)
229 SequenceI oldseq = getSequenceAt(i);
231 synchronized (sequences)
233 sequences.set(i, snew);
240 * @return DOCUMENT ME!
243 public List<SequenceGroup> getGroups()
249 public void finalize()
251 if (getDataset() != null)
253 getDataset().removeAlignmentRef();
260 hiddenSequences = null;
264 * decrement the alignmentRefs counter by one and call finalize if it goes to
267 private void removeAlignmentRef()
269 if (--alignmentRefs == 0)
282 public void deleteSequence(SequenceI s)
284 deleteSequence(findIndex(s));
294 public void deleteSequence(int i)
296 if (i > -1 && i < getHeight())
298 synchronized (sequences)
302 hiddenSequences.adjustHeightSequenceDeleted(i);
309 * @see jalview.datamodel.AlignmentI#findGroup(jalview.datamodel.SequenceI)
312 public SequenceGroup findGroup(SequenceI s)
314 synchronized (groups)
316 for (int i = 0; i < this.groups.size(); i++)
318 SequenceGroup sg = groups.get(i);
320 if (sg.getSequences(null).contains(s))
333 * jalview.datamodel.AlignmentI#findAllGroups(jalview.datamodel.SequenceI)
336 public SequenceGroup[] findAllGroups(SequenceI s)
338 ArrayList<SequenceGroup> temp = new ArrayList<SequenceGroup>();
340 synchronized (groups)
342 int gSize = groups.size();
343 for (int i = 0; i < gSize; i++)
345 SequenceGroup sg = groups.get(i);
346 if (sg == null || sg.getSequences(null) == null)
348 this.deleteGroup(sg);
353 if (sg.getSequences(null).contains(s))
359 SequenceGroup[] ret = new SequenceGroup[temp.size()];
360 return temp.toArray(ret);
365 public void addGroup(SequenceGroup sg)
367 synchronized (groups)
369 if (!groups.contains(sg))
371 if (hiddenSequences.getSize() > 0)
373 int i, iSize = sg.getSize();
374 for (i = 0; i < iSize; i++)
376 if (!sequences.contains(sg.getSequenceAt(i)))
378 sg.deleteSequence(sg.getSequenceAt(i), false);
384 if (sg.getSize() < 1)
396 * remove any annotation that references gp
399 * (if null, removes all group associated annotation)
401 private void removeAnnotationForGroup(SequenceGroup gp)
403 if (annotations == null || annotations.length == 0)
407 // remove annotation very quickly
408 AlignmentAnnotation[] t, todelete = new AlignmentAnnotation[annotations.length], tokeep = new AlignmentAnnotation[annotations.length];
412 for (i = 0, p = 0, k = 0; i < annotations.length; i++)
414 if (annotations[i].groupRef != null)
416 todelete[p++] = annotations[i];
420 tokeep[k++] = annotations[i];
426 for (i = 0, p = 0, k = 0; i < annotations.length; i++)
428 if (annotations[i].groupRef == gp)
430 todelete[p++] = annotations[i];
434 tokeep[k++] = annotations[i];
440 // clear out the group associated annotation.
441 for (i = 0; i < p; i++)
443 unhookAnnotation(todelete[i]);
446 t = new AlignmentAnnotation[k];
447 for (i = 0; i < k; i++)
456 public void deleteAllGroups()
458 synchronized (groups)
460 if (annotations != null)
462 removeAnnotationForGroup(null);
464 for (SequenceGroup sg : groups)
474 public void deleteGroup(SequenceGroup g)
476 synchronized (groups)
478 if (groups.contains(g))
480 removeAnnotationForGroup(g);
489 public SequenceI findName(String name)
491 return findName(name, false);
497 * @see jalview.datamodel.AlignmentI#findName(java.lang.String, boolean)
500 public SequenceI findName(String token, boolean b)
502 return findName(null, token, b);
508 * @see jalview.datamodel.AlignmentI#findName(SequenceI, java.lang.String,
512 public SequenceI findName(SequenceI startAfter, String token, boolean b)
517 String sqname = null;
518 if (startAfter != null)
520 // try to find the sequence in the alignment
521 boolean matched = false;
522 while (i < sequences.size())
524 if (getSequenceAt(i++) == startAfter)
535 while (i < sequences.size())
537 sq = getSequenceAt(i);
538 sqname = sq.getName();
539 if (sqname.equals(token) // exact match
540 || (b && // allow imperfect matches - case varies
541 (sqname.equalsIgnoreCase(token))))
543 return getSequenceAt(i);
553 public SequenceI[] findSequenceMatch(String name)
555 Vector matches = new Vector();
558 while (i < sequences.size())
560 if (getSequenceAt(i).getName().equals(name))
562 matches.addElement(getSequenceAt(i));
567 SequenceI[] result = new SequenceI[matches.size()];
568 for (i = 0; i < result.length; i++)
570 result[i] = (SequenceI) matches.elementAt(i);
580 * @see jalview.datamodel.AlignmentI#findIndex(jalview.datamodel.SequenceI)
583 public int findIndex(SequenceI s)
587 while (i < sequences.size())
589 if (s == getSequenceAt(i))
604 * jalview.datamodel.AlignmentI#findIndex(jalview.datamodel.SearchResults)
607 public int findIndex(SearchResults results)
611 while (i < sequences.size())
613 if (results.involvesSequence(getSequenceAt(i)))
625 * @return DOCUMENT ME!
628 public int getHeight()
630 return sequences.size();
636 * @return DOCUMENT ME!
639 public int getWidth()
643 for (int i = 0; i < sequences.size(); i++)
645 if (getSequenceAt(i).getLength() > maxLength)
647 maxLength = getSequenceAt(i).getLength();
661 public void setGapCharacter(char gc)
664 synchronized (sequences)
666 for (SequenceI seq : sequences)
668 seq.setSequence(seq.getSequenceAsString().replace('.', gc)
669 .replace('-', gc).replace(' ', gc));
677 * @return DOCUMENT ME!
680 public char getGapCharacter()
688 * @see jalview.datamodel.AlignmentI#isAligned()
691 public boolean isAligned()
693 return isAligned(false);
699 * @see jalview.datamodel.AlignmentI#isAligned(boolean)
702 public boolean isAligned(boolean includeHidden)
704 int width = getWidth();
705 if (hiddenSequences == null || hiddenSequences.getSize() == 0)
707 includeHidden = true; // no hidden sequences to check against.
709 for (int i = 0; i < sequences.size(); i++)
711 if (includeHidden || !hiddenSequences.isHidden(getSequenceAt(i)))
713 if (getSequenceAt(i).getLength() != width)
726 * @seejalview.datamodel.AlignmentI#deleteAnnotation(jalview.datamodel.
727 * AlignmentAnnotation)
730 public boolean deleteAnnotation(AlignmentAnnotation aa)
732 return deleteAnnotation(aa, true);
736 public boolean deleteAnnotation(AlignmentAnnotation aa, boolean unhook)
740 if (annotations != null)
742 aSize = annotations.length;
750 AlignmentAnnotation[] temp = new AlignmentAnnotation[aSize - 1];
752 boolean swap = false;
755 for (int i = 0; i < aSize; i++)
757 if (annotations[i] == aa)
762 if (tIndex < temp.length)
764 temp[tIndex++] = annotations[i];
773 unhookAnnotation(aa);
780 * remove any object references associated with this annotation
784 private void unhookAnnotation(AlignmentAnnotation aa)
786 if (aa.sequenceRef != null)
788 aa.sequenceRef.removeAlignmentAnnotation(aa);
790 if (aa.groupRef != null)
792 // probably need to do more here in the future (post 2.5.0)
800 * @seejalview.datamodel.AlignmentI#addAnnotation(jalview.datamodel.
801 * AlignmentAnnotation)
804 public void addAnnotation(AlignmentAnnotation aa)
806 addAnnotation(aa, -1);
812 * @seejalview.datamodel.AlignmentI#addAnnotation(jalview.datamodel.
813 * AlignmentAnnotation, int)
816 public void addAnnotation(AlignmentAnnotation aa, int pos)
818 if (aa.getRNAStruc() != null)
820 hasRNAStructure = true;
824 if (annotations != null)
826 aSize = annotations.length + 1;
829 AlignmentAnnotation[] temp = new AlignmentAnnotation[aSize];
831 if (pos == -1 || pos >= aSize)
833 temp[aSize - 1] = aa;
842 for (i = 0; i < (aSize - 1); i++, p++)
850 temp[p] = annotations[i];
859 public void setAnnotationIndex(AlignmentAnnotation aa, int index)
861 if (aa == null || annotations == null || annotations.length - 1 < index)
866 int aSize = annotations.length;
867 AlignmentAnnotation[] temp = new AlignmentAnnotation[aSize];
871 for (int i = 0; i < aSize; i++)
880 temp[i] = annotations[i];
884 temp[i] = annotations[i - 1];
893 * returns all annotation on the alignment
895 public AlignmentAnnotation[] getAlignmentAnnotation()
901 public void setNucleotide(boolean b)
914 public boolean isNucleotide()
916 if (type == NUCLEOTIDE)
927 public boolean hasRNAStructure()
929 // TODO can it happen that structure is removed from alignment?
930 return hasRNAStructure;
934 public void setDataset(Alignment data)
936 if (dataset == null && data == null)
938 // Create a new dataset for this alignment.
939 // Can only be done once, if dataset is not null
940 // This will not be performed
941 SequenceI[] seqs = new SequenceI[getHeight()];
942 SequenceI currentSeq;
943 for (int i = 0; i < getHeight(); i++)
945 currentSeq = getSequenceAt(i);
946 if (currentSeq.getDatasetSequence() != null)
948 seqs[i] = currentSeq.getDatasetSequence();
952 seqs[i] = currentSeq.createDatasetSequence();
956 dataset = new Alignment(seqs);
958 else if (dataset == null && data != null)
961 for (int i = 0; i < getHeight(); i++)
963 SequenceI currentSeq = getSequenceAt(i);
964 SequenceI dsq = currentSeq.getDatasetSequence();
967 dsq = currentSeq.createDatasetSequence();
968 dataset.addSequence(dsq);
972 while (dsq.getDatasetSequence() != null)
974 dsq = dsq.getDatasetSequence();
976 if (dataset.findIndex(dsq) == -1)
978 dataset.addSequence(dsq);
983 dataset.addAlignmentRef();
987 * reference count for number of alignments referencing this one.
989 int alignmentRefs = 0;
992 * increase reference count to this alignment.
994 private void addAlignmentRef()
1000 public Alignment getDataset()
1006 public boolean padGaps()
1008 boolean modified = false;
1010 // Remove excess gaps from the end of alignment
1014 for (int i = 0; i < sequences.size(); i++)
1016 current = getSequenceAt(i);
1017 for (int j = current.getLength(); j > maxLength; j--)
1020 && !jalview.util.Comparison.isGap(current.getCharAt(j)))
1031 for (int i = 0; i < sequences.size(); i++)
1033 current = getSequenceAt(i);
1034 cLength = current.getLength();
1036 if (cLength < maxLength)
1038 current.insertCharAt(cLength, maxLength - cLength, gapCharacter);
1041 else if (current.getLength() > maxLength)
1043 current.deleteChars(maxLength, current.getLength());
1050 * Justify the sequences to the left or right by deleting and inserting gaps
1051 * before the initial residue or after the terminal residue
1054 * true if alignment padded to right, false to justify to left
1055 * @return true if alignment was changed
1058 public boolean justify(boolean right)
1060 boolean modified = false;
1062 // Remove excess gaps from the end of alignment
1064 int ends[] = new int[sequences.size() * 2];
1066 for (int i = 0; i < sequences.size(); i++)
1068 current = getSequenceAt(i);
1069 // This should really be a sequence method
1070 ends[i * 2] = current.findIndex(current.getStart());
1071 ends[i * 2 + 1] = current.findIndex(current.getStart()
1072 + current.getLength());
1073 boolean hitres = false;
1074 for (int j = 0, rs = 0, ssiz = current.getLength(); j < ssiz; j++)
1076 if (!jalview.util.Comparison.isGap(current.getCharAt(j)))
1085 ends[i * 2 + 1] = j;
1086 if (j - ends[i * 2] > maxLength)
1088 maxLength = j - ends[i * 2];
1096 // now edit the flanking gaps to justify to either left or right
1097 int cLength, extent, diff;
1098 for (int i = 0; i < sequences.size(); i++)
1100 current = getSequenceAt(i);
1102 cLength = 1 + ends[i * 2 + 1] - ends[i * 2];
1103 diff = maxLength - cLength; // number of gaps to indent
1104 extent = current.getLength();
1108 if (extent > ends[i * 2 + 1])
1110 current.deleteChars(ends[i * 2 + 1] + 1, extent);
1113 if (ends[i * 2] > diff)
1115 current.deleteChars(0, ends[i * 2] - diff);
1120 if (ends[i * 2] < diff)
1122 current.insertCharAt(0, diff - ends[i * 2], gapCharacter);
1130 if (ends[i * 2] > 0)
1132 current.deleteChars(0, ends[i * 2]);
1134 ends[i * 2 + 1] -= ends[i * 2];
1135 extent -= ends[i * 2];
1137 if (extent > maxLength)
1139 current.deleteChars(maxLength + 1, extent);
1144 if (extent < maxLength)
1146 current.insertCharAt(extent, maxLength - extent, gapCharacter);
1156 public HiddenSequences getHiddenSequences()
1158 return hiddenSequences;
1162 public CigarArray getCompactAlignment()
1164 synchronized (sequences)
1166 SeqCigar alseqs[] = new SeqCigar[sequences.size()];
1168 for (SequenceI seq : sequences)
1170 alseqs[i++] = new SeqCigar(seq);
1172 CigarArray cal = new CigarArray(alseqs);
1173 cal.addOperation(CigarArray.M, getWidth());
1179 public void setProperty(Object key, Object value)
1181 if (alignmentProperties == null)
1183 alignmentProperties = new Hashtable();
1186 alignmentProperties.put(key, value);
1190 public Object getProperty(Object key)
1192 if (alignmentProperties != null)
1194 return alignmentProperties.get(key);
1203 public Hashtable getProperties()
1205 return alignmentProperties;
1208 AlignedCodonFrame[] codonFrameList = null;
1214 * jalview.datamodel.AlignmentI#addCodonFrame(jalview.datamodel.AlignedCodonFrame
1218 public void addCodonFrame(AlignedCodonFrame codons)
1224 if (codonFrameList == null)
1226 codonFrameList = new AlignedCodonFrame[]
1230 AlignedCodonFrame[] t = new AlignedCodonFrame[codonFrameList.length + 1];
1231 System.arraycopy(codonFrameList, 0, t, 0, codonFrameList.length);
1232 t[codonFrameList.length] = codons;
1239 * @see jalview.datamodel.AlignmentI#getCodonFrame(int)
1242 public AlignedCodonFrame getCodonFrame(int index)
1244 return codonFrameList[index];
1251 * jalview.datamodel.AlignmentI#getCodonFrame(jalview.datamodel.SequenceI)
1254 public AlignedCodonFrame[] getCodonFrame(SequenceI seq)
1256 if (seq == null || codonFrameList == null)
1260 Vector cframes = new Vector();
1261 for (int f = 0; f < codonFrameList.length; f++)
1263 if (codonFrameList[f].involvesSequence(seq))
1265 cframes.addElement(codonFrameList[f]);
1268 if (cframes.size() == 0)
1272 AlignedCodonFrame[] cfr = new AlignedCodonFrame[cframes.size()];
1273 cframes.copyInto(cfr);
1280 * @see jalview.datamodel.AlignmentI#getCodonFrames()
1283 public AlignedCodonFrame[] getCodonFrames()
1285 return codonFrameList;
1291 * @seejalview.datamodel.AlignmentI#removeCodonFrame(jalview.datamodel.
1292 * AlignedCodonFrame)
1295 public boolean removeCodonFrame(AlignedCodonFrame codons)
1297 if (codons == null || codonFrameList == null)
1301 boolean removed = false;
1302 int i = 0, iSize = codonFrameList.length;
1305 if (codonFrameList[i] == codons)
1310 System.arraycopy(codonFrameList, i + 1, codonFrameList, i, iSize
1324 public void append(AlignmentI toappend)
1326 if (toappend == this)
1328 System.err.println("Self append may cause a deadlock.");
1330 // TODO test this method for a future 2.5 release
1331 // currently tested for use in jalview.gui.SequenceFetcher
1332 boolean samegap = toappend.getGapCharacter() == getGapCharacter();
1333 char oldc = toappend.getGapCharacter();
1334 boolean hashidden = toappend.getHiddenSequences() != null
1335 && toappend.getHiddenSequences().hiddenSequences != null;
1336 // get all sequences including any hidden ones
1337 List<SequenceI> sqs = (hashidden) ? toappend.getHiddenSequences()
1338 .getFullAlignment().getSequences() : toappend.getSequences();
1343 for (SequenceI addedsq : sqs)
1347 char[] oldseq = addedsq.getSequence();
1348 for (int c = 0; c < oldseq.length; c++)
1350 if (oldseq[c] == oldc)
1352 oldseq[c] = gapCharacter;
1356 addSequence(addedsq);
1360 AlignmentAnnotation[] alan = toappend.getAlignmentAnnotation();
1361 for (int a = 0; alan != null && a < alan.length; a++)
1363 addAnnotation(alan[a]);
1365 AlignedCodonFrame[] acod = toappend.getCodonFrames();
1366 for (int a = 0; acod != null && a < acod.length; a++)
1368 this.addCodonFrame(acod[a]);
1370 List<SequenceGroup> sg = toappend.getGroups();
1373 for (SequenceGroup _sg : sg)
1378 if (toappend.getHiddenSequences() != null)
1380 HiddenSequences hs = toappend.getHiddenSequences();
1381 if (hiddenSequences == null)
1383 hiddenSequences = new HiddenSequences(this);
1385 if (hs.hiddenSequences != null)
1387 for (int s = 0; s < hs.hiddenSequences.length; s++)
1389 // hide the newly appended sequence in the alignment
1390 if (hs.hiddenSequences[s] != null)
1392 hiddenSequences.hideSequence(hs.hiddenSequences[s]);
1397 if (toappend.getProperties() != null)
1399 // we really can't do very much here - just try to concatenate strings
1400 // where property collisions occur.
1401 Enumeration key = toappend.getProperties().keys();
1402 while (key.hasMoreElements())
1404 Object k = key.nextElement();
1405 Object ourval = this.getProperty(k);
1406 Object toapprop = toappend.getProperty(k);
1409 if (ourval.getClass().equals(toapprop.getClass())
1410 && !ourval.equals(toapprop))
1412 if (ourval instanceof String)
1415 this.setProperty(k, ((String) ourval) + "; "
1416 + ((String) toapprop));
1420 if (ourval instanceof Vector)
1423 Enumeration theirv = ((Vector) toapprop).elements();
1424 while (theirv.hasMoreElements())
1426 ((Vector) ourval).addElement(theirv);
1434 // just add new property directly
1435 setProperty(k, toapprop);
1443 public AlignmentAnnotation findOrCreateAnnotation(String name,
1444 String calcId, boolean autoCalc, SequenceI seqRef,
1445 SequenceGroup groupRef)
1447 assert (name != null);
1448 if (annotations != null)
1450 for (AlignmentAnnotation annot : getAlignmentAnnotation())
1452 if (annot.autoCalculated == autoCalc && (name.equals(annot.label))
1453 && (calcId == null || annot.getCalcId().equals(calcId))
1454 && annot.sequenceRef == seqRef
1455 && annot.groupRef == groupRef)
1461 AlignmentAnnotation annot = new AlignmentAnnotation(name, name,
1462 new Annotation[1], 0f, 0f, AlignmentAnnotation.BAR_GRAPH);
1463 annot.hasText = false;
1464 annot.setCalcId(new String(calcId));
1465 annot.autoCalculated = autoCalc;
1468 annot.setSequenceRef(seqRef);
1470 annot.groupRef = groupRef;
1471 addAnnotation(annot);
1477 public Iterable<AlignmentAnnotation> findAnnotation(String calcId)
1479 ArrayList<AlignmentAnnotation> aa = new ArrayList<AlignmentAnnotation>();
1480 for (AlignmentAnnotation a : getAlignmentAnnotation())
1482 if (a.getCalcId() == calcId
1483 || (a.getCalcId() != null && calcId != null && a.getCalcId()
1493 public void moveSelectedSequencesByOne(SequenceGroup sg,
1494 Map<SequenceI, SequenceCollectionI> map, boolean up)
1496 synchronized (sequences)
1501 for (int i = 1, iSize = sequences.size(); i < iSize; i++)
1503 SequenceI seq = sequences.get(i);
1504 if (!sg.getSequences(map).contains(seq))
1509 SequenceI temp = sequences.get(i - 1);
1510 if (sg.getSequences(null).contains(temp))
1515 sequences.set(i, temp);
1516 sequences.set(i - 1, seq);
1521 for (int i = sequences.size() - 2; i > -1; i--)
1523 SequenceI seq = sequences.get(i);
1524 if (!sg.getSequences(map).contains(seq))
1529 SequenceI temp = sequences.get(i + 1);
1530 if (sg.getSequences(map).contains(temp))
1535 sequences.set(i, temp);
1536 sequences.set(i + 1, seq);
1544 public void validateAnnotation(AlignmentAnnotation alignmentAnnotation)
1546 alignmentAnnotation.validateRangeAndDisplay();
1547 if (isNucleotide() && alignmentAnnotation.isValidStruc())
1549 hasRNAStructure = true;
1554 public int getEndRes()
1556 return getWidth() - 1;
1560 public int getStartRes()
1566 * In the case of AlignmentI - returns the dataset for the alignment, if set
1569 * @see jalview.datamodel.AnnotatedCollectionI#getContext()
1572 public AnnotatedCollectionI getContext()