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)
151 synchronized (sequences)
153 return sequences.toArray(new SequenceI[sequences.size()]);
163 * @return DOCUMENT ME!
166 public SequenceI getSequenceAt(int i)
168 synchronized (sequences)
170 if (i > -1 && i < sequences.size())
172 return sequences.get(i);
179 * Adds a sequence to the alignment. Recalculates maxLength and size.
184 public void addSequence(SequenceI snew)
188 // maintain dataset integrity
189 if (snew.getDatasetSequence() != null)
191 getDataset().addSequence(snew.getDatasetSequence());
195 // derive new sequence
196 SequenceI adding = snew.deriveSequence();
197 getDataset().addSequence(adding.getDatasetSequence());
201 if (sequences == null)
203 initAlignment(new SequenceI[]
208 synchronized (sequences)
213 if (hiddenSequences != null)
214 hiddenSequences.adjustHeightSequenceAdded();
218 * Adds a sequence to the alignment. Recalculates maxLength and size.
223 public void setSequenceAt(int i, SequenceI snew)
225 SequenceI oldseq = getSequenceAt(i);
227 synchronized (sequences)
229 sequences.set(i, snew);
236 * @return DOCUMENT ME!
239 public List<SequenceGroup> getGroups()
245 public void finalize()
247 if (getDataset() != null)
248 getDataset().removeAlignmentRef();
254 hiddenSequences = null;
258 * decrement the alignmentRefs counter by one and call finalize if it goes to
261 private void removeAlignmentRef()
263 if (--alignmentRefs == 0)
276 public void deleteSequence(SequenceI s)
278 deleteSequence(findIndex(s));
288 public void deleteSequence(int i)
290 if (i > -1 && i < getHeight())
292 synchronized (sequences)
296 hiddenSequences.adjustHeightSequenceDeleted(i);
303 * @see jalview.datamodel.AlignmentI#findGroup(jalview.datamodel.SequenceI)
306 public SequenceGroup findGroup(SequenceI s)
308 synchronized (groups)
310 for (int i = 0; i < this.groups.size(); i++)
312 SequenceGroup sg = groups.get(i);
314 if (sg.getSequences(null).contains(s))
327 * jalview.datamodel.AlignmentI#findAllGroups(jalview.datamodel.SequenceI)
330 public SequenceGroup[] findAllGroups(SequenceI s)
332 ArrayList<SequenceGroup> temp = new ArrayList<SequenceGroup>();
334 synchronized (groups)
336 int gSize = groups.size();
337 for (int i = 0; i < gSize; i++)
339 SequenceGroup sg = groups.get(i);
340 if (sg == null || sg.getSequences(null) == null)
342 this.deleteGroup(sg);
347 if (sg.getSequences(null).contains(s))
353 SequenceGroup[] ret = new SequenceGroup[temp.size()];
354 return temp.toArray(ret);
359 public void addGroup(SequenceGroup sg)
361 synchronized (groups)
363 if (!groups.contains(sg))
365 if (hiddenSequences.getSize() > 0)
367 int i, iSize = sg.getSize();
368 for (i = 0; i < iSize; i++)
370 if (!sequences.contains(sg.getSequenceAt(i)))
372 sg.deleteSequence(sg.getSequenceAt(i), false);
378 if (sg.getSize() < 1)
390 * remove any annotation that references gp
393 * (if null, removes all group associated annotation)
395 private void removeAnnotationForGroup(SequenceGroup gp)
397 if (annotations == null || annotations.length == 0)
401 // remove annotation very quickly
402 AlignmentAnnotation[] t, todelete = new AlignmentAnnotation[annotations.length], tokeep = new AlignmentAnnotation[annotations.length];
406 for (i = 0, p = 0, k = 0; i < annotations.length; i++)
408 if (annotations[i].groupRef != null)
410 todelete[p++] = annotations[i];
414 tokeep[k++] = annotations[i];
420 for (i = 0, p = 0, k = 0; i < annotations.length; i++)
422 if (annotations[i].groupRef == gp)
424 todelete[p++] = annotations[i];
428 tokeep[k++] = annotations[i];
434 // clear out the group associated annotation.
435 for (i = 0; i < p; i++)
437 unhookAnnotation(todelete[i]);
440 t = new AlignmentAnnotation[k];
441 for (i = 0; i < k; i++)
450 public void deleteAllGroups()
452 synchronized (groups)
454 if (annotations != null)
456 removeAnnotationForGroup(null);
458 for (SequenceGroup sg : groups)
468 public void deleteGroup(SequenceGroup g)
470 synchronized (groups)
472 if (groups.contains(g))
474 removeAnnotationForGroup(g);
483 public SequenceI findName(String name)
485 return findName(name, false);
491 * @see jalview.datamodel.AlignmentI#findName(java.lang.String, boolean)
494 public SequenceI findName(String token, boolean b)
496 return findName(null, token, b);
502 * @see jalview.datamodel.AlignmentI#findName(SequenceI, java.lang.String,
506 public SequenceI findName(SequenceI startAfter, String token, boolean b)
511 String sqname = null;
512 if (startAfter != null)
514 // try to find the sequence in the alignment
515 boolean matched = false;
516 while (i < sequences.size())
518 if (getSequenceAt(i++) == startAfter)
529 while (i < sequences.size())
531 sq = getSequenceAt(i);
532 sqname = sq.getName();
533 if (sqname.equals(token) // exact match
534 || (b && // allow imperfect matches - case varies
535 (sqname.equalsIgnoreCase(token))))
537 return getSequenceAt(i);
547 public SequenceI[] findSequenceMatch(String name)
549 Vector matches = new Vector();
552 while (i < sequences.size())
554 if (getSequenceAt(i).getName().equals(name))
556 matches.addElement(getSequenceAt(i));
561 SequenceI[] result = new SequenceI[matches.size()];
562 for (i = 0; i < result.length; i++)
564 result[i] = (SequenceI) matches.elementAt(i);
574 * @see jalview.datamodel.AlignmentI#findIndex(jalview.datamodel.SequenceI)
577 public int findIndex(SequenceI s)
581 while (i < sequences.size())
583 if (s == getSequenceAt(i))
598 * jalview.datamodel.AlignmentI#findIndex(jalview.datamodel.SearchResults)
601 public int findIndex(SearchResults results)
605 while (i < sequences.size())
607 if (results.involvesSequence(getSequenceAt(i)))
619 * @return DOCUMENT ME!
622 public int getHeight()
624 return sequences.size();
630 * @return DOCUMENT ME!
633 public int getWidth()
637 for (int i = 0; i < sequences.size(); i++)
639 if (getSequenceAt(i).getLength() > maxLength)
641 maxLength = getSequenceAt(i).getLength();
655 public void setGapCharacter(char gc)
658 synchronized (sequences)
660 for (SequenceI seq : sequences)
662 seq.setSequence(seq.getSequenceAsString().replace('.', gc)
663 .replace('-', gc).replace(' ', gc));
671 * @return DOCUMENT ME!
674 public char getGapCharacter()
682 * @see jalview.datamodel.AlignmentI#isAligned()
685 public boolean isAligned()
687 return isAligned(false);
693 * @see jalview.datamodel.AlignmentI#isAligned(boolean)
696 public boolean isAligned(boolean includeHidden)
698 int width = getWidth();
699 if (hiddenSequences == null || hiddenSequences.getSize() == 0)
701 includeHidden = true; // no hidden sequences to check against.
703 for (int i = 0; i < sequences.size(); i++)
705 if (includeHidden || !hiddenSequences.isHidden(getSequenceAt(i)))
707 if (getSequenceAt(i).getLength() != width)
720 * @seejalview.datamodel.AlignmentI#deleteAnnotation(jalview.datamodel.
721 * AlignmentAnnotation)
724 public boolean deleteAnnotation(AlignmentAnnotation aa)
726 return deleteAnnotation(aa, true);
730 public boolean deleteAnnotation(AlignmentAnnotation aa, boolean unhook)
734 if (annotations != null)
736 aSize = annotations.length;
744 AlignmentAnnotation[] temp = new AlignmentAnnotation[aSize - 1];
746 boolean swap = false;
749 for (int i = 0; i < aSize; i++)
751 if (annotations[i] == aa)
756 if (tIndex < temp.length)
757 temp[tIndex++] = annotations[i];
765 unhookAnnotation(aa);
772 * remove any object references associated with this annotation
776 private void unhookAnnotation(AlignmentAnnotation aa)
778 if (aa.sequenceRef != null)
780 aa.sequenceRef.removeAlignmentAnnotation(aa);
782 if (aa.groupRef != null)
784 // probably need to do more here in the future (post 2.5.0)
792 * @seejalview.datamodel.AlignmentI#addAnnotation(jalview.datamodel.
793 * AlignmentAnnotation)
796 public void addAnnotation(AlignmentAnnotation aa)
798 addAnnotation(aa, -1);
804 * @seejalview.datamodel.AlignmentI#addAnnotation(jalview.datamodel.
805 * AlignmentAnnotation, int)
808 public void addAnnotation(AlignmentAnnotation aa, int pos)
810 if (aa.getRNAStruc() != null)
812 hasRNAStructure = true;
816 if (annotations != null)
818 aSize = annotations.length + 1;
821 AlignmentAnnotation[] temp = new AlignmentAnnotation[aSize];
823 if (pos == -1 || pos >= aSize)
825 temp[aSize - 1] = aa;
834 for (i = 0; i < (aSize - 1); i++, p++)
842 temp[p] = annotations[i];
851 public void setAnnotationIndex(AlignmentAnnotation aa, int index)
853 if (aa == null || annotations == null || annotations.length - 1 < index)
858 int aSize = annotations.length;
859 AlignmentAnnotation[] temp = new AlignmentAnnotation[aSize];
863 for (int i = 0; i < aSize; i++)
872 temp[i] = annotations[i];
876 temp[i] = annotations[i - 1];
885 * returns all annotation on the alignment
887 public AlignmentAnnotation[] getAlignmentAnnotation()
893 public void setNucleotide(boolean b)
906 public boolean isNucleotide()
908 if (type == NUCLEOTIDE)
919 public boolean hasRNAStructure()
921 // TODO can it happen that structure is removed from alignment?
922 return hasRNAStructure;
926 public void setDataset(Alignment data)
928 if (dataset == null && data == null)
930 // Create a new dataset for this alignment.
931 // Can only be done once, if dataset is not null
932 // This will not be performed
933 SequenceI[] seqs = new SequenceI[getHeight()];
934 SequenceI currentSeq;
935 for (int i = 0; i < getHeight(); i++)
937 currentSeq = getSequenceAt(i);
938 if (currentSeq.getDatasetSequence() != null)
940 seqs[i] = currentSeq.getDatasetSequence();
944 seqs[i] = currentSeq.createDatasetSequence();
948 dataset = new Alignment(seqs);
950 else if (dataset == null && data != null)
953 for (int i = 0; i < getHeight(); i++)
955 SequenceI currentSeq = getSequenceAt(i);
956 SequenceI dsq = currentSeq.getDatasetSequence();
959 dsq = currentSeq.createDatasetSequence();
960 dataset.addSequence(dsq);
964 while (dsq.getDatasetSequence() != null)
966 dsq = dsq.getDatasetSequence();
968 if (dataset.findIndex(dsq) == -1)
970 dataset.addSequence(dsq);
975 dataset.addAlignmentRef();
979 * reference count for number of alignments referencing this one.
981 int alignmentRefs = 0;
984 * increase reference count to this alignment.
986 private void addAlignmentRef()
992 public Alignment getDataset()
998 public boolean padGaps()
1000 boolean modified = false;
1002 // Remove excess gaps from the end of alignment
1006 for (int i = 0; i < sequences.size(); i++)
1008 current = getSequenceAt(i);
1009 for (int j = current.getLength(); j > maxLength; j--)
1012 && !jalview.util.Comparison.isGap(current.getCharAt(j)))
1023 for (int i = 0; i < sequences.size(); i++)
1025 current = getSequenceAt(i);
1026 cLength = current.getLength();
1028 if (cLength < maxLength)
1030 current.insertCharAt(cLength, maxLength - cLength, gapCharacter);
1033 else if (current.getLength() > maxLength)
1035 current.deleteChars(maxLength, current.getLength());
1042 * Justify the sequences to the left or right by deleting and inserting gaps
1043 * before the initial residue or after the terminal residue
1046 * true if alignment padded to right, false to justify to left
1047 * @return true if alignment was changed
1050 public boolean justify(boolean right)
1052 boolean modified = false;
1054 // Remove excess gaps from the end of alignment
1056 int ends[] = new int[sequences.size() * 2];
1058 for (int i = 0; i < sequences.size(); i++)
1060 current = getSequenceAt(i);
1061 // This should really be a sequence method
1062 ends[i * 2] = current.findIndex(current.getStart());
1063 ends[i * 2 + 1] = current.findIndex(current.getStart()
1064 + current.getLength());
1065 boolean hitres = false;
1066 for (int j = 0, rs = 0, ssiz = current.getLength(); j < ssiz; j++)
1068 if (!jalview.util.Comparison.isGap(current.getCharAt(j)))
1077 ends[i * 2 + 1] = j;
1078 if (j - ends[i * 2] > maxLength)
1080 maxLength = j - ends[i * 2];
1088 // now edit the flanking gaps to justify to either left or right
1089 int cLength, extent, diff;
1090 for (int i = 0; i < sequences.size(); i++)
1092 current = getSequenceAt(i);
1094 cLength = 1 + ends[i * 2 + 1] - ends[i * 2];
1095 diff = maxLength - cLength; // number of gaps to indent
1096 extent = current.getLength();
1100 if (extent > ends[i * 2 + 1])
1102 current.deleteChars(ends[i * 2 + 1] + 1, extent);
1105 if (ends[i * 2] > diff)
1107 current.deleteChars(0, ends[i * 2] - diff);
1112 if (ends[i * 2] < diff)
1114 current.insertCharAt(0, diff - ends[i * 2], gapCharacter);
1122 if (ends[i * 2] > 0)
1124 current.deleteChars(0, ends[i * 2]);
1126 ends[i * 2 + 1] -= ends[i * 2];
1127 extent -= ends[i * 2];
1129 if (extent > maxLength)
1131 current.deleteChars(maxLength + 1, extent);
1136 if (extent < maxLength)
1138 current.insertCharAt(extent, maxLength - extent, gapCharacter);
1148 public HiddenSequences getHiddenSequences()
1150 return hiddenSequences;
1154 public CigarArray getCompactAlignment()
1156 synchronized (sequences)
1158 SeqCigar alseqs[] = new SeqCigar[sequences.size()];
1160 for (SequenceI seq : sequences)
1162 alseqs[i++] = new SeqCigar(seq);
1164 CigarArray cal = new CigarArray(alseqs);
1165 cal.addOperation(CigarArray.M, getWidth());
1171 public void setProperty(Object key, Object value)
1173 if (alignmentProperties == null)
1174 alignmentProperties = new Hashtable();
1176 alignmentProperties.put(key, value);
1180 public Object getProperty(Object key)
1182 if (alignmentProperties != null)
1183 return alignmentProperties.get(key);
1189 public Hashtable getProperties()
1191 return alignmentProperties;
1194 AlignedCodonFrame[] codonFrameList = null;
1200 * jalview.datamodel.AlignmentI#addCodonFrame(jalview.datamodel.AlignedCodonFrame
1204 public void addCodonFrame(AlignedCodonFrame codons)
1208 if (codonFrameList == null)
1210 codonFrameList = new AlignedCodonFrame[]
1214 AlignedCodonFrame[] t = new AlignedCodonFrame[codonFrameList.length + 1];
1215 System.arraycopy(codonFrameList, 0, t, 0, codonFrameList.length);
1216 t[codonFrameList.length] = codons;
1223 * @see jalview.datamodel.AlignmentI#getCodonFrame(int)
1226 public AlignedCodonFrame getCodonFrame(int index)
1228 return codonFrameList[index];
1235 * jalview.datamodel.AlignmentI#getCodonFrame(jalview.datamodel.SequenceI)
1238 public AlignedCodonFrame[] getCodonFrame(SequenceI seq)
1240 if (seq == null || codonFrameList == null)
1242 Vector cframes = new Vector();
1243 for (int f = 0; f < codonFrameList.length; f++)
1245 if (codonFrameList[f].involvesSequence(seq))
1246 cframes.addElement(codonFrameList[f]);
1248 if (cframes.size() == 0)
1250 AlignedCodonFrame[] cfr = new AlignedCodonFrame[cframes.size()];
1251 cframes.copyInto(cfr);
1258 * @see jalview.datamodel.AlignmentI#getCodonFrames()
1261 public AlignedCodonFrame[] getCodonFrames()
1263 return codonFrameList;
1269 * @seejalview.datamodel.AlignmentI#removeCodonFrame(jalview.datamodel.
1270 * AlignedCodonFrame)
1273 public boolean removeCodonFrame(AlignedCodonFrame codons)
1275 if (codons == null || codonFrameList == null)
1277 boolean removed = false;
1278 int i = 0, iSize = codonFrameList.length;
1281 if (codonFrameList[i] == codons)
1286 System.arraycopy(codonFrameList, i + 1, codonFrameList, i, iSize
1300 public void append(AlignmentI toappend)
1302 if (toappend == this)
1304 System.err.println("Self append may cause a deadlock.");
1306 // TODO test this method for a future 2.5 release
1307 // currently tested for use in jalview.gui.SequenceFetcher
1308 boolean samegap = toappend.getGapCharacter() == getGapCharacter();
1309 char oldc = toappend.getGapCharacter();
1310 boolean hashidden = toappend.getHiddenSequences() != null
1311 && toappend.getHiddenSequences().hiddenSequences != null;
1312 // get all sequences including any hidden ones
1313 List<SequenceI> sqs = (hashidden) ? toappend.getHiddenSequences()
1314 .getFullAlignment().getSequences() : toappend.getSequences();
1319 for (SequenceI addedsq : sqs)
1323 char[] oldseq = addedsq.getSequence();
1324 for (int c = 0; c < oldseq.length; c++)
1326 if (oldseq[c] == oldc)
1328 oldseq[c] = gapCharacter;
1332 addSequence(addedsq);
1336 AlignmentAnnotation[] alan = toappend.getAlignmentAnnotation();
1337 for (int a = 0; alan != null && a < alan.length; a++)
1339 addAnnotation(alan[a]);
1341 AlignedCodonFrame[] acod = toappend.getCodonFrames();
1342 for (int a = 0; acod != null && a < acod.length; a++)
1344 this.addCodonFrame(acod[a]);
1346 List<SequenceGroup> sg = toappend.getGroups();
1349 for (SequenceGroup _sg : sg)
1354 if (toappend.getHiddenSequences() != null)
1356 HiddenSequences hs = toappend.getHiddenSequences();
1357 if (hiddenSequences == null)
1359 hiddenSequences = new HiddenSequences(this);
1361 if (hs.hiddenSequences != null)
1363 for (int s = 0; s < hs.hiddenSequences.length; s++)
1365 // hide the newly appended sequence in the alignment
1366 if (hs.hiddenSequences[s] != null)
1368 hiddenSequences.hideSequence(hs.hiddenSequences[s]);
1373 if (toappend.getProperties() != null)
1375 // we really can't do very much here - just try to concatenate strings
1376 // where property collisions occur.
1377 Enumeration key = toappend.getProperties().keys();
1378 while (key.hasMoreElements())
1380 Object k = key.nextElement();
1381 Object ourval = this.getProperty(k);
1382 Object toapprop = toappend.getProperty(k);
1385 if (ourval.getClass().equals(toapprop.getClass())
1386 && !ourval.equals(toapprop))
1388 if (ourval instanceof String)
1391 this.setProperty(k, ((String) ourval) + "; "
1392 + ((String) toapprop));
1396 if (ourval instanceof Vector)
1399 Enumeration theirv = ((Vector) toapprop).elements();
1400 while (theirv.hasMoreElements())
1402 ((Vector) ourval).addElement(theirv);
1410 // just add new property directly
1411 setProperty(k, toapprop);
1419 public AlignmentAnnotation findOrCreateAnnotation(String name,
1420 String calcId, boolean autoCalc, SequenceI seqRef,
1421 SequenceGroup groupRef)
1423 assert (name != null);
1424 if (annotations != null)
1426 for (AlignmentAnnotation annot : getAlignmentAnnotation())
1428 if (annot.autoCalculated == autoCalc && (name.equals(annot.label))
1429 && (calcId == null || annot.getCalcId().equals(calcId))
1430 && annot.sequenceRef == seqRef
1431 && annot.groupRef == groupRef)
1437 AlignmentAnnotation annot = new AlignmentAnnotation(name, name,
1438 new Annotation[1], 0f, 0f, AlignmentAnnotation.BAR_GRAPH);
1439 annot.hasText = false;
1440 annot.setCalcId(new String(calcId));
1441 annot.autoCalculated = autoCalc;
1444 annot.setSequenceRef(seqRef);
1446 annot.groupRef = groupRef;
1447 addAnnotation(annot);
1453 public Iterable<AlignmentAnnotation> findAnnotation(String calcId)
1455 ArrayList<AlignmentAnnotation> aa = new ArrayList<AlignmentAnnotation>();
1456 for (AlignmentAnnotation a : getAlignmentAnnotation())
1458 if (a.getCalcId() == calcId
1459 || (a.getCalcId() != null && calcId != null && a.getCalcId()
1469 public void moveSelectedSequencesByOne(SequenceGroup sg,
1470 Map<SequenceI, SequenceCollectionI> map, boolean up)
1472 synchronized (sequences)
1477 for (int i = 1, iSize = sequences.size(); i < iSize; i++)
1479 SequenceI seq = sequences.get(i);
1480 if (!sg.getSequences(map).contains(seq))
1485 SequenceI temp = sequences.get(i - 1);
1486 if (sg.getSequences(null).contains(temp))
1491 sequences.set(i, temp);
1492 sequences.set(i - 1, seq);
1497 for (int i = sequences.size() - 2; i > -1; i--)
1499 SequenceI seq = sequences.get(i);
1500 if (!sg.getSequences(map).contains(seq))
1505 SequenceI temp = sequences.get(i + 1);
1506 if (sg.getSequences(map).contains(temp))
1511 sequences.set(i, temp);
1512 sequences.set(i + 1, seq);
1520 public void validateAnnotation(AlignmentAnnotation alignmentAnnotation)
1522 alignmentAnnotation.validateRangeAndDisplay();
1523 if (isNucleotide() && alignmentAnnotation.isValidStruc())
1525 hasRNAStructure = true;
1530 public int getEndRes()
1532 return getWidth() - 1;
1536 public int getStartRes()
1542 * In the case of AlignmentI - returns the dataset for the alignment, if set
1545 * @see jalview.datamodel.AnnotatedCollectionI#getContext()
1548 public AnnotatedCollectionI getContext()