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.List;
37 * Collects a set contiguous ranges on a set of sequences
42 public class SequenceGroup implements AnnotatedCollectionI
44 // TODO ideally this event notification functionality should be separated into
46 // subclass of ViewportProperties similarly to ViewportRanges. Done here as
47 // quick fix for JAL-2665
48 public static final String SEQ_GROUP_CHANGED = "Sequence group changed";
50 protected PropertyChangeSupport changeSupport = new PropertyChangeSupport(
53 public void addPropertyChangeListener(PropertyChangeListener listener)
55 changeSupport.addPropertyChangeListener(listener);
58 public void removePropertyChangeListener(PropertyChangeListener listener)
60 changeSupport.removePropertyChangeListener(listener);
62 // end of event notification functionality initialisation
68 Conservation conserve;
70 boolean displayBoxes = true;
72 boolean displayText = true;
74 boolean colourText = false;
77 * True if the group is defined as a group on the alignment, false if it is
80 boolean isDefined = false;
83 * after Olivier's non-conserved only character display
85 boolean showNonconserved = false;
90 private List<SequenceI> sequences = new ArrayList<>();
93 * representative sequence for this group (if any)
95 private SequenceI seqrep = null;
100 * Colourscheme applied to group if any
102 public ResidueShaderI cs;
105 * start column (base 0)
107 private int startRes = 0;
110 * end column (base 0)
112 private int endRes = 0;
114 public Color outlineColour = Color.black;
116 public Color idColour = null;
118 public int thresholdTextColour = 0;
120 public Color textColour = Color.black;
122 public Color textColour2 = Color.white;
125 * consensus calculation property
127 private boolean ignoreGapsInConsensus = true;
130 * consensus calculation property
132 private boolean showSequenceLogo = false;
135 * flag indicating if logo should be rendered normalised
137 private boolean normaliseSequenceLogo;
140 * visibility of rows or represented rows covered by group
142 private boolean hidereps = false;
145 * visibility of columns intersecting this group
147 private boolean hidecols = false;
149 AlignmentAnnotation consensus = null;
151 AlignmentAnnotation conservation = null;
153 private boolean showConsensusHistogram;
155 private AnnotatedCollectionI context;
158 * Creates a new SequenceGroup object.
160 public SequenceGroup()
162 groupName = "JGroup:" + this.hashCode();
163 cs = new ResidueShader();
167 * Creates a new SequenceGroup object.
172 * @param displayBoxes
176 * first column of group
178 * last column of group
180 public SequenceGroup(List<SequenceI> sequences, String groupName,
181 ColourSchemeI scheme, boolean displayBoxes, boolean displayText,
182 boolean colourText, int start, int end)
185 this.sequences = sequences;
186 this.groupName = groupName;
187 this.displayBoxes = displayBoxes;
188 this.displayText = displayText;
189 this.colourText = colourText;
190 this.cs = new ResidueShader(scheme);
193 recalcConservation();
201 public SequenceGroup(SequenceGroup seqsel)
206 sequences = new ArrayList<>();
207 sequences.addAll(seqsel.sequences);
208 if (seqsel.groupName != null)
210 groupName = new String(seqsel.groupName);
212 displayBoxes = seqsel.displayBoxes;
213 displayText = seqsel.displayText;
214 colourText = seqsel.colourText;
216 startRes = seqsel.startRes;
217 endRes = seqsel.endRes;
218 cs = new ResidueShader((ResidueShader) seqsel.cs);
219 if (seqsel.description != null)
221 description = new String(seqsel.description);
223 hidecols = seqsel.hidecols;
224 hidereps = seqsel.hidereps;
225 showNonconserved = seqsel.showNonconserved;
226 showSequenceLogo = seqsel.showSequenceLogo;
227 normaliseSequenceLogo = seqsel.normaliseSequenceLogo;
228 showConsensusHistogram = seqsel.showConsensusHistogram;
229 idColour = seqsel.idColour;
230 outlineColour = seqsel.outlineColour;
231 seqrep = seqsel.seqrep;
232 textColour = seqsel.textColour;
233 textColour2 = seqsel.textColour2;
234 thresholdTextColour = seqsel.thresholdTextColour;
235 width = seqsel.width;
236 ignoreGapsInConsensus = seqsel.ignoreGapsInConsensus;
237 if (seqsel.conserve != null)
239 recalcConservation(); // safer than
240 // aaFrequency = (Vector) seqsel.aaFrequency.clone(); // ??
245 public boolean isShowSequenceLogo()
247 return showSequenceLogo;
250 public SequenceI[] getSelectionAsNewSequences(AlignmentI align)
252 int iSize = sequences.size();
253 SequenceI[] seqs = new SequenceI[iSize];
254 SequenceI[] inorder = getSequencesInOrder(align);
256 for (int i = 0, ipos = 0; i < inorder.length; i++)
258 SequenceI seq = inorder[i];
260 seqs[ipos] = seq.getSubSequence(startRes, endRes + 1);
261 if (seqs[ipos] != null)
263 seqs[ipos].setDescription(seq.getDescription());
264 seqs[ipos].setDBRefs(seq.getDBRefs());
265 seqs[ipos].setSequenceFeatures(seq.getSequenceFeatures());
266 if (seq.getDatasetSequence() != null)
268 seqs[ipos].setDatasetSequence(seq.getDatasetSequence());
271 if (seq.getAnnotation() != null)
273 AlignmentAnnotation[] alann = align.getAlignmentAnnotation();
274 // Only copy annotation that is either a score or referenced by the
275 // alignment's annotation vector
276 for (int a = 0; a < seq.getAnnotation().length; a++)
278 AlignmentAnnotation tocopy = seq.getAnnotation()[a];
281 boolean found = false;
282 for (int pos = 0; pos < alann.length; pos++)
284 if (alann[pos] == tocopy)
295 AlignmentAnnotation newannot = new AlignmentAnnotation(
296 seq.getAnnotation()[a]);
297 newannot.restrict(startRes, endRes);
298 newannot.setSequenceRef(seqs[ipos]);
299 newannot.adjustForAlignment();
300 seqs[ipos].addAlignmentAnnotation(newannot);
310 if (iSize != inorder.length)
312 SequenceI[] nseqs = new SequenceI[iSize];
313 System.arraycopy(seqs, 0, nseqs, 0, iSize);
321 * If sequence ends in gaps, the end residue can be correctly calculated here
327 public int findEndRes(SequenceI seq)
332 for (int j = 0; j < endRes + 1 && j < seq.getLength(); j++)
334 ch = seq.getCharAt(j);
335 if (!jalview.util.Comparison.isGap((ch)))
343 eres += seq.getStart() - 1;
350 public List<SequenceI> getSequences()
356 public List<SequenceI> getSequences(
357 Map<SequenceI, SequenceCollectionI> hiddenReps)
359 if (hiddenReps == null)
361 // TODO: need a synchronizedCollection here ?
366 List<SequenceI> allSequences = new ArrayList<>();
367 for (SequenceI seq : sequences)
369 allSequences.add(seq);
370 if (hiddenReps.containsKey(seq))
372 SequenceCollectionI hsg = hiddenReps.get(seq);
373 for (SequenceI seq2 : hsg.getSequences())
375 if (seq2 != seq && !allSequences.contains(seq2))
377 allSequences.add(seq2);
387 public SequenceI[] getSequencesAsArray(
388 Map<SequenceI, SequenceCollectionI> map)
390 List<SequenceI> tmp = getSequences(map);
395 return tmp.toArray(new SequenceI[tmp.size()]);
404 * @return DOCUMENT ME!
406 public boolean adjustForRemoveLeft(int col)
408 // return value is true if the group still exists
411 startRes = startRes - col;
416 endRes = endRes - col;
418 if (startRes > endRes)
425 // must delete this group!!
438 * @return DOCUMENT ME!
440 public boolean adjustForRemoveRight(int col)
459 * @return DOCUMENT ME!
461 public String getName()
466 public String getDescription()
477 public void setName(String name)
480 // TODO: URGENT: update dependent objects (annotation row)
483 public void setDescription(String desc)
491 * @return DOCUMENT ME!
493 public Conservation getConservation()
504 public void setConservation(Conservation c)
510 * Add s to this sequence group. If aligment sequence is already contained in
511 * group, it will not be added again, but recalculation may happen if the flag
515 * alignment sequence to be added
517 * true means Group's conservation should be recalculated
519 public void addSequence(SequenceI s, boolean recalc)
521 synchronized (sequences)
523 if (s != null && !sequences.contains(s))
526 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED,
527 sequences.size() - 1, sequences.size());
532 recalcConservation();
538 * Max Gaps Threshold (percent) for performing a conservation calculation
540 private int consPercGaps = 25;
543 * @return Max Gaps Threshold for performing a conservation calculation
545 public int getConsPercGaps()
551 * set Max Gaps Threshold (percent) for performing a conservation calculation
553 * @param consPercGaps
555 public void setConsPercGaps(int consPercGaps)
557 this.consPercGaps = consPercGaps;
561 * calculate residue conservation and colourschemes for group - but only if
562 * necessary. returns true if the calculation resulted in a visible change to
565 public boolean recalcConservation()
567 return recalcConservation(false);
571 * calculate residue conservation for group - but only if necessary. returns
572 * true if the calculation resulted in a visible change to group
575 * when set, colourschemes for this group are not refreshed after
578 public boolean recalcConservation(boolean defer)
580 if (cs == null && consensus == null && conservation == null)
584 // TODO: try harder to detect changes in state in order to minimise
585 // recalculation effort
589 ProfilesI cnsns = AAFrequency.calculate(sequences, startRes,
590 endRes + 1, showSequenceLogo);
591 if (consensus != null)
593 _updateConsensusRow(cnsns, sequences.size());
598 cs.setConsensus(cnsns);
602 if ((conservation != null)
603 || (cs != null && cs.conservationApplied()))
605 Conservation c = new Conservation(groupName, sequences, startRes,
608 c.verdict(false, consPercGaps);
609 if (conservation != null)
611 _updateConservationRow(c);
615 if (cs.conservationApplied())
617 cs.setConservation(c);
620 // eager update - will cause a refresh of overview regardless
623 if (cs != null && !defer)
625 // TODO: JAL-2034 should cs.alignmentChanged modify return state
626 cs.alignmentChanged(context != null ? context : this, null);
633 } catch (java.lang.OutOfMemoryError err)
636 System.out.println("Out of memory loading groups: " + err);
641 private void _updateConservationRow(Conservation c)
643 if (conservation == null)
648 conservation.label = "Conservation for " + getName();
649 conservation.description = "Conservation for group " + getName()
650 + " less than " + consPercGaps + "% gaps";
651 // preserve width if already set
652 int aWidth = (conservation.annotations != null)
653 ? (endRes < conservation.annotations.length
654 ? conservation.annotations.length
657 conservation.annotations = null;
658 conservation.annotations = new Annotation[aWidth]; // should be alignment
660 c.completeAnnotations(conservation, null, startRes, endRes + 1);
663 public ProfilesI consensusData = null;
665 private void _updateConsensusRow(ProfilesI cnsns, long nseq)
667 if (consensus == null)
671 consensus.label = "Consensus for " + getName();
672 consensus.description = "Percent Identity";
673 consensusData = cnsns;
674 // preserve width if already set
675 int aWidth = (consensus.annotations != null)
676 ? (endRes < consensus.annotations.length
677 ? consensus.annotations.length
680 consensus.annotations = null;
681 consensus.annotations = new Annotation[aWidth]; // should be alignment width
683 AAFrequency.completeConsensus(consensus, cnsns, startRes, endRes + 1,
684 ignoreGapsInConsensus, showSequenceLogo, nseq); // TODO: setting
687 // ignoreGapsInConsensusCalculation);
692 * sequence to either add or remove from group
694 * flag passed to delete/addSequence to indicate if group properties
695 * should be recalculated
697 public void addOrRemove(SequenceI s, boolean recalc)
699 synchronized (sequences)
701 if (sequences.contains(s))
703 deleteSequence(s, recalc);
707 addSequence(s, recalc);
718 * true means recalculate conservation
720 public void deleteSequence(SequenceI s, boolean recalc)
722 synchronized (sequences)
725 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED,
726 sequences.size() + 1, sequences.size());
730 recalcConservation();
738 * @return the first column selected by this group. Runs from 0<=i<N_cols
741 public int getStartRes()
748 * @return the groups last selected column. Runs from 0<=i<N_cols
751 public int getEndRes()
757 * Set the first column selected by this group. Runs from 0<=i<N_cols
761 public void setStartRes(int newStart)
763 int before = startRes;
764 startRes= Math.max(0,newStart); // sanity check for negative start column positions
765 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, startRes);
772 * Set the groups last selected column. Runs from 0<=i<N_cols
776 public void setEndRes(int i)
780 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, endRes);
784 * @return number of sequences in group
788 return sequences.size();
793 * @return the ith sequence
795 public SequenceI getSequenceAt(int i)
797 return sequences.get(i);
804 public void setColourText(boolean state)
812 * @return DOCUMENT ME!
814 public boolean getColourText()
825 public void setDisplayText(boolean state)
833 * @return DOCUMENT ME!
835 public boolean getDisplayText()
846 public void setDisplayBoxes(boolean state)
848 displayBoxes = state;
854 * @return DOCUMENT ME!
856 public boolean getDisplayBoxes()
862 * computes the width of current set of sequences and returns it
864 * @return DOCUMENT ME!
867 public int getWidth()
869 synchronized (sequences)
871 // MC This needs to get reset when characters are inserted and deleted
872 boolean first = true;
873 for (SequenceI seq : sequences)
875 if (first || seq.getLength() > width)
877 width = seq.getLength();
891 public void setOutlineColour(Color c)
899 * @return DOCUMENT ME!
901 public Color getOutlineColour()
903 return outlineColour;
908 * returns the sequences in the group ordered by the ordering given by al.
909 * this used to return an array with null entries regardless, new behaviour is
910 * below. TODO: verify that this does not affect use in applet or application
914 * @return SequenceI[] intersection of sequences in group with al, ordered by
915 * al, or null if group does not intersect with al
917 public SequenceI[] getSequencesInOrder(AlignmentI al)
919 return getSequencesInOrder(al, true);
923 * return an array representing the intersection of the group with al,
924 * optionally returning an array the size of al.getHeight() where nulls mark
925 * the non-intersected sequences
929 * @return null or array
931 public SequenceI[] getSequencesInOrder(AlignmentI al, boolean trim)
933 synchronized (sequences)
935 int sSize = sequences.size();
936 int alHeight = al.getHeight();
938 SequenceI[] seqs = new SequenceI[(trim) ? sSize : alHeight];
941 for (int i = 0; i < alHeight && index < sSize; i++)
943 if (sequences.contains(al.getSequenceAt(i)))
945 seqs[(trim) ? index : i] = al.getSequenceAt(i);
957 if (index < seqs.length)
959 SequenceI[] dummy = seqs;
960 seqs = new SequenceI[index];
963 seqs[index] = dummy[index];
972 * @return the idColour
974 public Color getIdColour()
981 * the idColour to set
983 public void setIdColour(Color idColour)
985 this.idColour = idColour;
989 * @return the representative sequence for this group
992 public SequenceI getSeqrep()
998 * set the representative sequence for this group. Note - this affects the
999 * interpretation of the Hidereps attribute.
1002 * the seqrep to set (null means no sequence representative)
1005 public void setSeqrep(SequenceI seqrep)
1007 this.seqrep = seqrep;
1012 * @return true if group has a sequence representative
1015 public boolean hasSeqrep()
1017 return seqrep != null;
1021 * set visibility of sequences covered by (if no sequence representative is
1022 * defined) or represented by this group.
1026 public void setHidereps(boolean visibility)
1028 hidereps = visibility;
1033 * @return true if sequences represented (or covered) by this group should be
1036 public boolean isHidereps()
1042 * set intended visibility of columns covered by this group
1046 public void setHideCols(boolean visibility)
1048 hidecols = visibility;
1053 * @return true if columns covered by group should be hidden
1055 public boolean isHideCols()
1061 * create a new sequence group from the intersection of this group with an
1062 * alignment Hashtable of hidden representatives
1068 * @return new group containing sequences common to this group and alignment
1070 public SequenceGroup intersect(AlignmentI alignment,
1071 Map<SequenceI, SequenceCollectionI> map)
1073 SequenceGroup sgroup = new SequenceGroup(this);
1074 SequenceI[] insect = getSequencesInOrder(alignment);
1075 sgroup.sequences = new ArrayList<>();
1076 for (int s = 0; insect != null && s < insect.length; s++)
1078 if (map == null || map.containsKey(insect[s]))
1080 sgroup.sequences.add(insect[s]);
1087 * @return the showUnconserved
1089 public boolean getShowNonconserved()
1091 return showNonconserved;
1095 * @param showNonconserved
1096 * the showUnconserved to set
1098 public void setShowNonconserved(boolean displayNonconserved)
1100 this.showNonconserved = displayNonconserved;
1104 * set this alignmentAnnotation object as the one used to render consensus
1109 public void setConsensus(AlignmentAnnotation aan)
1111 if (consensus == null)
1119 * @return automatically calculated consensus row note: the row is a stub if a
1120 * consensus calculation has not yet been performed on the group
1122 public AlignmentAnnotation getConsensus()
1124 // TODO get or calculate and get consensus annotation row for this group
1125 int aWidth = this.getWidth();
1133 if (consensus == null)
1135 consensus = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1136 100f, AlignmentAnnotation.BAR_GRAPH);
1137 consensus.hasText = true;
1138 consensus.autoCalculated = true;
1139 consensus.groupRef = this;
1140 consensus.label = "Consensus for " + getName();
1141 consensus.description = "Percent Identity";
1147 * set this alignmentAnnotation object as the one used to render consensus
1152 public void setConservationRow(AlignmentAnnotation aan)
1154 if (conservation == null)
1161 * get the conservation annotation row for this group
1163 * @return autoCalculated annotation row
1165 public AlignmentAnnotation getConservationRow()
1167 if (conservation == null)
1169 conservation = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1170 11f, AlignmentAnnotation.BAR_GRAPH);
1173 conservation.hasText = true;
1174 conservation.autoCalculated = true;
1175 conservation.groupRef = this;
1176 conservation.label = "Conservation for " + getName();
1177 conservation.description = "Conservation for group " + getName()
1178 + " less than " + consPercGaps + "% gaps";
1179 return conservation;
1184 * @return true if annotation rows have been instantiated for this group
1186 public boolean hasAnnotationRows()
1188 return consensus != null || conservation != null;
1191 public SequenceI getConsensusSeq()
1194 StringBuffer seqs = new StringBuffer();
1195 for (int i = 0; i < consensus.annotations.length; i++)
1197 if (consensus.annotations[i] != null)
1199 if (consensus.annotations[i].description.charAt(0) == '[')
1201 seqs.append(consensus.annotations[i].description.charAt(1));
1205 seqs.append(consensus.annotations[i].displayCharacter);
1210 SequenceI sq = new Sequence("Group" + getName() + " Consensus",
1212 sq.setDescription("Percentage Identity Consensus "
1213 + ((ignoreGapsInConsensus) ? " without gaps" : ""));
1217 public void setIgnoreGapsConsensus(boolean state)
1219 if (this.ignoreGapsInConsensus != state && consensus != null)
1221 ignoreGapsInConsensus = state;
1222 recalcConservation();
1224 ignoreGapsInConsensus = state;
1227 public boolean getIgnoreGapsConsensus()
1229 return ignoreGapsInConsensus;
1233 * @param showSequenceLogo
1234 * indicates if a sequence logo is shown for consensus annotation
1236 public void setshowSequenceLogo(boolean showSequenceLogo)
1238 // TODO: decouple calculation from settings update
1239 if (this.showSequenceLogo != showSequenceLogo && consensus != null)
1241 this.showSequenceLogo = showSequenceLogo;
1242 recalcConservation();
1244 this.showSequenceLogo = showSequenceLogo;
1249 * @param showConsHist
1250 * flag indicating if the consensus histogram for this group should
1253 public void setShowConsensusHistogram(boolean showConsHist)
1256 if (showConsensusHistogram != showConsHist && consensus != null)
1258 this.showConsensusHistogram = showConsHist;
1259 recalcConservation();
1261 this.showConsensusHistogram = showConsHist;
1265 * @return the showConsensusHistogram
1267 public boolean isShowConsensusHistogram()
1269 return showConsensusHistogram;
1273 * set flag indicating if logo should be normalised when rendered
1277 public void setNormaliseSequenceLogo(boolean norm)
1279 normaliseSequenceLogo = norm;
1282 public boolean isNormaliseSequenceLogo()
1284 return normaliseSequenceLogo;
1289 * returns a new array with all annotation involving this group
1291 public AlignmentAnnotation[] getAlignmentAnnotation()
1293 // TODO add in other methods like 'getAlignmentAnnotation(String label),
1295 ArrayList<AlignmentAnnotation> annot = new ArrayList<>();
1296 synchronized (sequences)
1298 for (SequenceI seq : sequences)
1300 AlignmentAnnotation[] aa = seq.getAnnotation();
1303 for (AlignmentAnnotation al : aa)
1305 if (al.groupRef == this)
1312 if (consensus != null)
1314 annot.add(consensus);
1316 if (conservation != null)
1318 annot.add(conservation);
1321 return annot.toArray(new AlignmentAnnotation[0]);
1325 public Iterable<AlignmentAnnotation> findAnnotation(String calcId)
1327 List<AlignmentAnnotation> aa = new ArrayList<>();
1332 for (AlignmentAnnotation a : getAlignmentAnnotation())
1334 if (calcId.equals(a.getCalcId()))
1343 public Iterable<AlignmentAnnotation> findAnnotations(SequenceI seq,
1344 String calcId, String label)
1346 ArrayList<AlignmentAnnotation> aa = new ArrayList<>();
1347 for (AlignmentAnnotation ann : getAlignmentAnnotation())
1349 if ((calcId == null || (ann.getCalcId() != null
1350 && ann.getCalcId().equals(calcId)))
1351 && (seq == null || (ann.sequenceRef != null
1352 && ann.sequenceRef == seq))
1354 || (ann.label != null && ann.label.equals(label))))
1363 * Answer true if any annotation matches the calcId passed in (if not null).
1368 public boolean hasAnnotation(String calcId)
1370 if (calcId != null && !"".equals(calcId))
1372 for (AlignmentAnnotation a : getAlignmentAnnotation())
1374 if (a.getCalcId() == calcId)
1384 * Remove all sequences from the group (leaving other properties unchanged).
1388 synchronized (sequences)
1390 int before = sequences.size();
1392 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before,
1398 * Sets the alignment or group context for this group, and whether it is
1399 * defined as a group
1402 * the context for the group
1404 * whether the group is defined on the alignment or is just a
1406 * @throws IllegalArgumentException
1407 * if setting the context would result in a circular reference chain
1409 public void setContext(AnnotatedCollectionI ctx, boolean defined)
1412 this.isDefined = defined;
1416 * Sets the alignment or group context for this group
1419 * the context for the group
1420 * @throws IllegalArgumentException
1421 * if setting the context would result in a circular reference chain
1423 public void setContext(AnnotatedCollectionI ctx)
1425 AnnotatedCollectionI ref = ctx;
1428 if (ref == this || ref.getContext() == ctx)
1430 throw new IllegalArgumentException(
1431 "Circular reference in SequenceGroup.context");
1433 ref = ref.getContext();
1441 * @see jalview.datamodel.AnnotatedCollectionI#getContext()
1444 public AnnotatedCollectionI getContext()
1449 public boolean isDefined()
1454 public void setColourScheme(ColourSchemeI scheme)
1458 cs = new ResidueShader();
1460 cs.setColourScheme(scheme);
1463 public void setGroupColourScheme(ResidueShaderI scheme)
1468 public ColourSchemeI getColourScheme()
1470 return cs == null ? null : cs.getColourScheme();
1473 public ResidueShaderI getGroupColourScheme()
1479 public boolean isNucleotide()
1481 if (context != null)
1483 return context.isNucleotide();
1490 * @return true if seq is a member of the group
1493 public boolean contains(SequenceI seq1)
1495 return sequences.contains(seq1);
1501 * @return true if startRes<=apos and endRes>=apos and seq is in the group
1503 public boolean contains(SequenceI seq, int apos)
1505 return (startRes <= apos && endRes >= apos) && sequences.contains(seq);