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.AAFrequency;
24 import jalview.analysis.Conservation;
25 import jalview.renderer.ResidueShader;
26 import jalview.renderer.ResidueShaderI;
27 import jalview.schemes.ColourSchemeI;
29 import java.awt.Color;
30 import java.beans.PropertyChangeListener;
31 import java.beans.PropertyChangeSupport;
32 import java.util.ArrayList;
33 import java.util.Arrays;
34 import java.util.Hashtable;
35 import java.util.List;
39 * Collects a set contiguous ranges on a set of sequences
44 public class SequenceGroup implements AnnotatedCollectionI
46 // TODO ideally this event notification functionality should be separated into
48 // subclass of ViewportProperties similarly to ViewportRanges. Done here as
49 // quick fix for JAL-2665
50 public static final String SEQ_GROUP_CHANGED = "Sequence group changed";
52 protected PropertyChangeSupport changeSupport = new PropertyChangeSupport(
55 public void addPropertyChangeListener(PropertyChangeListener listener)
57 changeSupport.addPropertyChangeListener(listener);
60 public void removePropertyChangeListener(PropertyChangeListener listener)
62 changeSupport.removePropertyChangeListener(listener);
64 // end of event notification functionality initialisation
70 Conservation conserve;
72 boolean displayBoxes = true;
74 boolean displayText = true;
76 boolean colourText = false;
79 * True if the group is defined as a group on the alignment, false if it is
82 boolean isDefined = false;
85 * after Olivier's non-conserved only character display
87 boolean showNonconserved = false;
92 private List<SequenceI> sequences;
95 * representative sequence for this group (if any)
97 private SequenceI seqrep = null;
102 * Colourscheme applied to group if any
104 public ResidueShaderI cs;
107 * start column (base 0)
109 private int startRes = 0;
112 * end column (base 0)
114 private int endRes = 0;
116 public Color outlineColour = Color.black;
118 public Color idColour = null;
120 public int thresholdTextColour = 0;
122 public Color textColour = Color.black;
124 public Color textColour2 = Color.white;
127 * consensus calculation property
129 private boolean ignoreGapsInConsensus = true;
132 * consensus calculation property
134 private boolean showSequenceLogo = false;
137 * flag indicating if logo should be rendered normalised
139 private boolean normaliseSequenceLogo;
142 * visibility of rows or represented rows covered by group
144 private boolean hidereps = false;
147 * visibility of columns intersecting this group
149 private boolean hidecols = false;
151 AlignmentAnnotation consensus = null;
153 AlignmentAnnotation conservation = null;
155 private boolean showConsensusHistogram;
157 private AnnotatedCollectionI context;
160 * Creates a new SequenceGroup object.
162 public SequenceGroup()
164 groupName = "JGroup:" + this.hashCode();
165 cs = new ResidueShader();
166 sequences = new ArrayList<>();
170 * Creates a new SequenceGroup object.
175 * @param displayBoxes
179 * first column of group
181 * last column of group
183 public SequenceGroup(List<SequenceI> sequences, String groupName,
184 ColourSchemeI scheme, boolean displayBoxes, boolean displayText,
185 boolean colourText, int start, int end)
188 this.sequences = sequences;
189 this.groupName = groupName;
190 this.displayBoxes = displayBoxes;
191 this.displayText = displayText;
192 this.colourText = colourText;
193 this.cs = new ResidueShader(scheme);
196 recalcConservation();
204 public SequenceGroup(SequenceGroup seqsel)
209 sequences = new ArrayList<>();
210 sequences.addAll(seqsel.sequences);
211 if (seqsel.groupName != null)
213 groupName = new String(seqsel.groupName);
215 displayBoxes = seqsel.displayBoxes;
216 displayText = seqsel.displayText;
217 colourText = seqsel.colourText;
219 startRes = seqsel.startRes;
220 endRes = seqsel.endRes;
221 cs = new ResidueShader((ResidueShader) seqsel.cs);
222 if (seqsel.description != null)
224 description = new String(seqsel.description);
226 hidecols = seqsel.hidecols;
227 hidereps = seqsel.hidereps;
228 showNonconserved = seqsel.showNonconserved;
229 showSequenceLogo = seqsel.showSequenceLogo;
230 normaliseSequenceLogo = seqsel.normaliseSequenceLogo;
231 showConsensusHistogram = seqsel.showConsensusHistogram;
232 idColour = seqsel.idColour;
233 outlineColour = seqsel.outlineColour;
234 seqrep = seqsel.seqrep;
235 textColour = seqsel.textColour;
236 textColour2 = seqsel.textColour2;
237 thresholdTextColour = seqsel.thresholdTextColour;
238 width = seqsel.width;
239 ignoreGapsInConsensus = seqsel.ignoreGapsInConsensus;
240 if (seqsel.conserve != null)
242 recalcConservation(); // safer than
243 // aaFrequency = (Vector) seqsel.aaFrequency.clone(); // ??
249 * Constructor that copies the given list of sequences
253 public SequenceGroup(List<SequenceI> seqs)
256 this.sequences.addAll(seqs);
259 public boolean isShowSequenceLogo()
261 return showSequenceLogo;
264 public SequenceI[] getSelectionAsNewSequences(AlignmentI align)
266 int iSize = sequences.size();
267 SequenceI[] seqs = new SequenceI[iSize];
268 SequenceI[] inorder = getSequencesInOrder(align);
270 for (int i = 0, ipos = 0; i < inorder.length; i++)
272 SequenceI seq = inorder[i];
273 SequenceI seqipos = seqs[ipos] = seq.getSubSequence(startRes,
277 seqipos.setDescription(seq.getDescription());
278 seqipos.setDBRefs(seq.getDBRefs());
279 seqipos.setSequenceFeatures(seq.getSequenceFeatures());
280 if (seq.getDatasetSequence() != null)
282 seqipos.setDatasetSequence(seq.getDatasetSequence());
285 if (seq.getAnnotation() != null)
287 AlignmentAnnotation[] alann = align.getAlignmentAnnotation();
288 // Only copy annotation that is either a score or referenced by the
289 // alignment's annotation vector
290 for (int a = 0; a < seq.getAnnotation().length; a++)
292 AlignmentAnnotation tocopy = seq.getAnnotation()[a];
295 boolean found = false;
296 for (int pos = 0, np = alann.length; pos < np; pos++)
298 if (alann[pos] == tocopy)
309 AlignmentAnnotation newannot = new AlignmentAnnotation(
310 seq.getAnnotation()[a]);
311 newannot.restrict(startRes, endRes);
312 newannot.setSequenceRef(seqs[ipos]);
313 newannot.adjustForAlignment();
314 seqipos.addAlignmentAnnotation(newannot);
324 if (iSize != inorder.length)
326 SequenceI[] nseqs = new SequenceI[iSize];
327 System.arraycopy(seqs, 0, nseqs, 0, iSize);
335 * If sequence ends in gaps, the end residue can be correctly calculated here
341 public int findEndRes(SequenceI seq)
346 for (int j = 0; j < endRes + 1 && j < seq.getLength(); j++)
348 ch = seq.getCharAt(j);
349 if (!jalview.util.Comparison.isGap((ch)))
357 eres += seq.getStart() - 1;
364 public List<SequenceI> getSequences()
370 public List<SequenceI> getSequences(
371 Map<SequenceI, SequenceCollectionI> hiddenReps)
373 if (hiddenReps == null)
375 // TODO: need a synchronizedCollection here ?
380 List<SequenceI> allSequences = new ArrayList<>();
381 for (SequenceI seq : sequences)
383 allSequences.add(seq);
384 if (hiddenReps.containsKey(seq))
386 SequenceCollectionI hsg = hiddenReps.get(seq);
387 for (SequenceI seq2 : hsg.getSequences())
389 if (seq2 != seq && !allSequences.contains(seq2))
391 allSequences.add(seq2);
401 public SequenceI[] getSequencesAsArray(
402 Map<SequenceI, SequenceCollectionI> map)
404 List<SequenceI> tmp = getSequences(map);
409 return tmp.toArray(new SequenceI[tmp.size()]);
418 * @return DOCUMENT ME!
420 public boolean adjustForRemoveLeft(int col)
422 // return value is true if the group still exists
425 startRes = startRes - col;
430 endRes = endRes - col;
432 if (startRes > endRes)
439 // must delete this group!!
452 * @return DOCUMENT ME!
454 public boolean adjustForRemoveRight(int col)
473 * @return DOCUMENT ME!
475 public String getName()
480 public String getDescription()
491 public void setName(String name)
494 // TODO: URGENT: update dependent objects (annotation row)
497 public void setDescription(String desc)
505 * @return DOCUMENT ME!
508 public Conservation getConservation()
519 public void setConservation(Conservation c)
525 * Add s to this sequence group. If aligment sequence is already contained in
526 * group, it will not be added again, but recalculation may happen if the flag
530 * alignment sequence to be added
532 * true means Group's conservation should be recalculated
534 public void addSequence(SequenceI s, boolean recalc)
536 synchronized (sequences)
538 if (s != null && !sequences.contains(s))
541 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED,
542 sequences.size() - 1, sequences.size());
547 recalcConservation();
553 * Max Gaps Threshold (percent) for performing a conservation calculation
555 private int consPercGaps = 25;
558 * @return Max Gaps Threshold for performing a conservation calculation
560 public int getConsPercGaps()
566 * set Max Gaps Threshold (percent) for performing a conservation calculation
568 * @param consPercGaps
570 public void setConsPercGaps(int consPercGaps)
572 this.consPercGaps = consPercGaps;
576 * calculate residue conservation and colourschemes for group - but only if
577 * necessary. returns true if the calculation resulted in a visible change to
580 public boolean recalcConservation()
582 return recalcConservation(false);
586 * calculate residue conservation for group - but only if necessary. returns
587 * true if the calculation resulted in a visible change to group
590 * when set, colourschemes for this group are not refreshed after
593 public boolean recalcConservation(boolean defer)
595 if (cs == null && consensus == null && conservation == null)
599 // TODO: try harder to detect changes in state in order to minimise
600 // recalculation effort
604 ProfilesI cnsns = AAFrequency.calculate(sequences, startRes,
605 endRes + 1, showSequenceLogo);
606 if (consensus != null)
608 _updateConsensusRow(cnsns, sequences.size());
613 cs.setConsensus(cnsns);
617 if ((conservation != null)
618 || (cs != null && cs.conservationApplied()))
620 Conservation c = new Conservation(groupName, sequences, startRes,
623 c.verdict(false, consPercGaps);
624 if (conservation != null)
626 _updateConservationRow(c);
630 if (cs.conservationApplied())
632 cs.setConservation(c);
635 // eager update - will cause a refresh of overview regardless
638 if (cs != null && !defer)
640 // TODO: JAL-2034 should cs.alignmentChanged modify return state
641 cs.alignmentChanged(context != null ? context : this, null);
648 } catch (java.lang.OutOfMemoryError err)
651 System.out.println("Out of memory loading groups: " + err);
656 private void _updateConservationRow(Conservation c)
658 if (conservation == null)
663 conservation.label = "Conservation for " + getName();
664 conservation.description = "Conservation for group " + getName()
665 + " less than " + consPercGaps + "% gaps";
666 // preserve width if already set
667 int aWidth = (conservation.annotations != null)
668 ? (endRes < conservation.annotations.length
669 ? conservation.annotations.length
672 conservation.annotations = null;
673 conservation.annotations = new Annotation[aWidth]; // should be alignment
675 c.completeAnnotations(conservation, null, startRes, endRes + 1);
678 public ProfilesI consensusData = null;
681 public ProfilesI getSequenceConsensusHash()
683 return consensusData;
687 public Hashtable[] getComplementConsensusHash()
689 // TODO: Groupwise CDS Consensus
694 public Hashtable[] getRnaStructureConsensusHash()
696 // TODO Groupwise RNA Consensus
700 private void _updateConsensusRow(ProfilesI cnsns, long nseq)
702 if (consensus == null)
706 consensus.label = "Consensus for " + getName();
707 consensus.description = "Percent Identity";
708 consensusData = cnsns;
709 // preserve width if already set
710 int aWidth = (consensus.annotations != null)
711 ? (endRes < consensus.annotations.length
712 ? consensus.annotations.length
715 consensus.annotations = null;
716 consensus.annotations = new Annotation[aWidth]; // should be alignment width
718 AAFrequency.completeConsensus(consensus, cnsns, startRes, endRes + 1,
719 ignoreGapsInConsensus, showSequenceLogo, nseq); // TODO: setting
722 // ignoreGapsInConsensusCalculation);
727 * sequence to either add or remove from group
729 * flag passed to delete/addSequence to indicate if group properties
730 * should be recalculated
732 public void addOrRemove(SequenceI s, boolean recalc)
734 synchronized (sequences)
736 if (sequences.contains(s))
738 deleteSequence(s, recalc);
742 addSequence(s, recalc);
753 * true means recalculate conservation
755 public void deleteSequence(SequenceI s, boolean recalc)
757 synchronized (sequences)
760 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED,
761 sequences.size() + 1, sequences.size());
765 recalcConservation();
773 * @return the first column selected by this group. Runs from 0<=i<N_cols
776 public int getStartRes()
783 * @return the groups last selected column. Runs from 0<=i<N_cols
786 public int getEndRes()
792 * Set the first column selected by this group. Runs from 0<=i<N_cols
796 public void setStartRes(int newStart)
798 int before = startRes;
799 startRes = Math.max(0, newStart); // sanity check for negative start column
801 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, startRes);
806 * Set the groups last selected column. Runs from 0<=i<N_cols
810 public void setEndRes(int i)
814 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, endRes);
818 * @return number of sequences in group
822 return sequences.size();
827 * @return the ith sequence
829 public SequenceI getSequenceAt(int i)
831 return sequences.get(i);
838 public void setColourText(boolean state)
846 * @return DOCUMENT ME!
848 public boolean getColourText()
859 public void setDisplayText(boolean state)
867 * @return DOCUMENT ME!
869 public boolean getDisplayText()
880 public void setDisplayBoxes(boolean state)
882 displayBoxes = state;
888 * @return DOCUMENT ME!
890 public boolean getDisplayBoxes()
896 * computes the width of current set of sequences and returns it
898 * @return DOCUMENT ME!
901 public int getWidth()
903 synchronized (sequences)
905 // MC This needs to get reset when characters are inserted and deleted
906 boolean first = true;
907 for (SequenceI seq : sequences)
909 if (first || seq.getLength() > width)
911 width = seq.getLength();
925 public void setOutlineColour(Color c)
933 * @return DOCUMENT ME!
935 public Color getOutlineColour()
937 return outlineColour;
942 * returns the sequences in the group ordered by the ordering given by al.
943 * this used to return an array with null entries regardless, new behaviour is
944 * below. TODO: verify that this does not affect use in applet or application
948 * @return SequenceI[] intersection of sequences in group with al, ordered by
949 * al, or null if group does not intersect with al
951 public SequenceI[] getSequencesInOrder(AlignmentI al)
953 return getSequencesInOrder(al, true);
957 * return an array representing the intersection of the group with al,
958 * optionally returning an array the size of al.getHeight() where nulls mark
959 * the non-intersected sequences
963 * @return null or array
965 public SequenceI[] getSequencesInOrder(AlignmentI al, boolean trim)
967 synchronized (sequences)
969 int sSize = sequences.size();
970 int alHeight = al.getHeight();
972 SequenceI[] seqs = new SequenceI[(trim) ? sSize : alHeight];
975 for (int i = 0; i < alHeight && index < sSize; i++)
977 if (sequences.contains(al.getSequenceAt(i)))
979 seqs[(trim) ? index : i] = al.getSequenceAt(i);
991 if (index < seqs.length)
993 SequenceI[] dummy = seqs;
994 seqs = new SequenceI[index];
997 seqs[index] = dummy[index];
1006 * @return the idColour
1008 public Color getIdColour()
1015 * the idColour to set
1017 public void setIdColour(Color idColour)
1019 this.idColour = idColour;
1023 * @return the representative sequence for this group
1026 public SequenceI getSeqrep()
1032 * set the representative sequence for this group. Note - this affects the
1033 * interpretation of the Hidereps attribute.
1036 * the seqrep to set (null means no sequence representative)
1039 public void setSeqrep(SequenceI seqrep)
1041 this.seqrep = seqrep;
1046 * @return true if group has a sequence representative
1049 public boolean hasSeqrep()
1051 return seqrep != null;
1055 * set visibility of sequences covered by (if no sequence representative is
1056 * defined) or represented by this group.
1060 public void setHidereps(boolean visibility)
1062 hidereps = visibility;
1067 * @return true if sequences represented (or covered) by this group should be
1070 public boolean isHidereps()
1076 * set intended visibility of columns covered by this group
1080 public void setHideCols(boolean visibility)
1082 hidecols = visibility;
1087 * @return true if columns covered by group should be hidden
1089 public boolean isHideCols()
1095 * create a new sequence group from the intersection of this group with an
1096 * alignment Hashtable of hidden representatives
1102 * @return new group containing sequences common to this group and alignment
1104 public SequenceGroup intersect(AlignmentI alignment,
1105 Map<SequenceI, SequenceCollectionI> map)
1107 SequenceGroup sgroup = new SequenceGroup(this);
1108 SequenceI[] insect = getSequencesInOrder(alignment);
1109 sgroup.sequences = new ArrayList<>();
1110 for (int s = 0; insect != null && s < insect.length; s++)
1112 if (map == null || map.containsKey(insect[s]))
1114 sgroup.sequences.add(insect[s]);
1121 * @return the showUnconserved
1123 public boolean getShowNonconserved()
1125 return showNonconserved;
1129 * @param showNonconserved
1130 * the showUnconserved to set
1132 public void setShowNonconserved(boolean displayNonconserved)
1134 this.showNonconserved = displayNonconserved;
1138 * set this alignmentAnnotation object as the one used to render consensus
1143 public void setConsensus(AlignmentAnnotation aan)
1145 if (consensus == null)
1153 * @return automatically calculated consensus row note: the row is a stub if a
1154 * consensus calculation has not yet been performed on the group
1156 public AlignmentAnnotation getConsensus()
1158 // TODO get or calculate and get consensus annotation row for this group
1159 int aWidth = this.getWidth();
1167 if (consensus == null)
1169 consensus = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1170 100f, AlignmentAnnotation.BAR_GRAPH);
1171 consensus.hasText = true;
1172 consensus.autoCalculated = true;
1173 consensus.groupRef = this;
1174 consensus.label = "Consensus for " + getName();
1175 consensus.description = "Percent Identity";
1181 * set this alignmentAnnotation object as the one used to render consensus
1186 public void setConservationRow(AlignmentAnnotation aan)
1188 if (conservation == null)
1195 * get the conservation annotation row for this group
1197 * @return autoCalculated annotation row
1199 public AlignmentAnnotation getConservationRow()
1201 if (conservation == null)
1203 conservation = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1204 11f, AlignmentAnnotation.BAR_GRAPH);
1207 conservation.hasText = true;
1208 conservation.autoCalculated = true;
1209 conservation.groupRef = this;
1210 conservation.label = "Conservation for " + getName();
1211 conservation.description = "Conservation for group " + getName()
1212 + " less than " + consPercGaps + "% gaps";
1213 return conservation;
1218 * @return true if annotation rows have been instantiated for this group
1220 public boolean hasAnnotationRows()
1222 return consensus != null || conservation != null;
1225 public SequenceI getConsensusSeq()
1228 StringBuffer seqs = new StringBuffer();
1229 for (int i = 0; i < consensus.annotations.length; i++)
1231 if (consensus.annotations[i] != null)
1233 String desc = consensus.annotations[i].description;
1234 if (desc.length() > 1 && desc.charAt(0) == '[')
1236 seqs.append(desc.charAt(1));
1240 seqs.append(consensus.annotations[i].displayCharacter);
1245 SequenceI sq = new Sequence("Group" + getName() + " Consensus",
1247 sq.setDescription("Percentage Identity Consensus "
1248 + ((ignoreGapsInConsensus) ? " without gaps" : ""));
1252 public void setIgnoreGapsConsensus(boolean state)
1254 if (this.ignoreGapsInConsensus != state && consensus != null)
1256 ignoreGapsInConsensus = state;
1257 recalcConservation();
1259 ignoreGapsInConsensus = state;
1262 public boolean getIgnoreGapsConsensus()
1264 return ignoreGapsInConsensus;
1268 * @param showSequenceLogo
1269 * indicates if a sequence logo is shown for consensus annotation
1271 public void setshowSequenceLogo(boolean showSequenceLogo)
1273 // TODO: decouple calculation from settings update
1274 if (this.showSequenceLogo != showSequenceLogo && consensus != null)
1276 this.showSequenceLogo = showSequenceLogo;
1277 recalcConservation();
1279 this.showSequenceLogo = showSequenceLogo;
1284 * @param showConsHist
1285 * flag indicating if the consensus histogram for this group should
1288 public void setShowConsensusHistogram(boolean showConsHist)
1291 if (showConsensusHistogram != showConsHist && consensus != null)
1293 this.showConsensusHistogram = showConsHist;
1294 recalcConservation();
1296 this.showConsensusHistogram = showConsHist;
1300 * @return the showConsensusHistogram
1302 public boolean isShowConsensusHistogram()
1304 return showConsensusHistogram;
1308 * set flag indicating if logo should be normalised when rendered
1312 public void setNormaliseSequenceLogo(boolean norm)
1314 normaliseSequenceLogo = norm;
1317 public boolean isNormaliseSequenceLogo()
1319 return normaliseSequenceLogo;
1324 * returns a new array with all annotation involving this group
1326 public AlignmentAnnotation[] getAlignmentAnnotation()
1328 // TODO add in other methods like 'getAlignmentAnnotation(String label),
1330 ArrayList<AlignmentAnnotation> annot = new ArrayList<>();
1331 synchronized (sequences)
1333 for (SequenceI seq : sequences)
1335 AlignmentAnnotation[] aa = seq.getAnnotation();
1338 for (AlignmentAnnotation al : aa)
1340 if (al.groupRef == this)
1347 if (consensus != null)
1349 annot.add(consensus);
1351 if (conservation != null)
1353 annot.add(conservation);
1356 return annot.toArray(new AlignmentAnnotation[0]);
1360 public Iterable<AlignmentAnnotation> findAnnotation(String calcId)
1362 return AlignmentAnnotation.findAnnotation(
1363 Arrays.asList(getAlignmentAnnotation()), calcId);
1367 public Iterable<AlignmentAnnotation> findAnnotations(SequenceI seq,
1368 String calcId, String label)
1370 return AlignmentAnnotation.findAnnotations(
1371 Arrays.asList(getAlignmentAnnotation()), seq, calcId, label);
1375 * Answer true if any annotation matches the calcId passed in (if not null).
1380 public boolean hasAnnotation(String calcId)
1382 return AlignmentAnnotation
1383 .hasAnnotation(Arrays.asList(getAlignmentAnnotation()), calcId);
1387 * Remove all sequences from the group (leaving other properties unchanged).
1391 synchronized (sequences)
1393 int before = sequences.size();
1395 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before,
1401 * Sets the alignment or group context for this group, and whether it is
1402 * defined as a group
1405 * the context for the group
1407 * whether the group is defined on the alignment or is just a
1409 * @throws IllegalArgumentException
1410 * if setting the context would result in a circular reference chain
1412 public void setContext(AnnotatedCollectionI ctx, boolean defined)
1415 this.isDefined = defined;
1419 * Sets the alignment or group context for this group
1422 * the context for the group
1423 * @throws IllegalArgumentException
1424 * if setting the context would result in a circular reference chain
1426 public void setContext(AnnotatedCollectionI ctx)
1428 AnnotatedCollectionI ref = ctx;
1431 if (ref == this || ref.getContext() == ctx)
1433 throw new IllegalArgumentException(
1434 "Circular reference in SequenceGroup.context");
1436 ref = ref.getContext();
1444 * @see jalview.datamodel.AnnotatedCollectionI#getContext()
1447 public AnnotatedCollectionI getContext()
1452 public boolean isDefined()
1457 public void setColourScheme(ColourSchemeI scheme)
1461 cs = new ResidueShader();
1463 cs.setColourScheme(scheme);
1466 public void setGroupColourScheme(ResidueShaderI scheme)
1471 public ColourSchemeI getColourScheme()
1473 return cs == null ? null : cs.getColourScheme();
1476 public ResidueShaderI getGroupColourScheme()
1482 public boolean isNucleotide()
1484 if (context != null)
1486 return context.isNucleotide();
1493 * @return true if seq is a member of the group
1496 public boolean contains(SequenceI seq1)
1498 return sequences.contains(seq1);
1504 * @return true if startRes<=apos and endRes>=apos and seq is in the group
1506 public boolean contains(SequenceI seq, int apos)
1508 return (startRes <= apos && endRes >= apos) && sequences.contains(seq);