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;
104 // start column (base 0)
105 private int startRes = 0;
107 // end column (base 0)
110 public Color outlineColour = Color.black;
112 public Color idColour = null;
114 public int thresholdTextColour = 0;
116 public Color textColour = Color.black;
118 public Color textColour2 = Color.white;
121 * consensus calculation property
123 private boolean ignoreGapsInConsensus = true;
126 * consensus calculation property
128 private boolean showSequenceLogo = false;
131 * flag indicating if logo should be rendered normalised
133 private boolean normaliseSequenceLogo;
136 * visibility of rows or represented rows covered by group
138 private boolean hidereps = false;
141 * visibility of columns intersecting this group
143 private boolean hidecols = false;
145 AlignmentAnnotation consensus = null;
147 AlignmentAnnotation conservation = null;
149 private boolean showConsensusHistogram;
151 private AnnotatedCollectionI context;
154 * Creates a new SequenceGroup object.
156 public SequenceGroup()
158 groupName = "JGroup:" + this.hashCode();
159 cs = new ResidueShader();
163 * Creates a new SequenceGroup object.
168 * @param displayBoxes
172 * first column of group
174 * last column of group
176 public SequenceGroup(List<SequenceI> sequences, String groupName,
177 ColourSchemeI scheme, boolean displayBoxes, boolean displayText,
178 boolean colourText, int start, int end)
181 this.sequences = sequences;
182 this.groupName = groupName;
183 this.displayBoxes = displayBoxes;
184 this.displayText = displayText;
185 this.colourText = colourText;
186 this.cs = new ResidueShader(scheme);
189 recalcConservation();
197 public SequenceGroup(SequenceGroup seqsel)
202 sequences = new ArrayList<>();
203 sequences.addAll(seqsel.sequences);
204 if (seqsel.groupName != null)
206 groupName = new String(seqsel.groupName);
208 displayBoxes = seqsel.displayBoxes;
209 displayText = seqsel.displayText;
210 colourText = seqsel.colourText;
212 startRes = seqsel.startRes;
213 endRes = seqsel.endRes;
214 cs = new ResidueShader((ResidueShader) seqsel.cs);
215 if (seqsel.description != null)
217 description = new String(seqsel.description);
219 hidecols = seqsel.hidecols;
220 hidereps = seqsel.hidereps;
221 showNonconserved = seqsel.showNonconserved;
222 showSequenceLogo = seqsel.showSequenceLogo;
223 normaliseSequenceLogo = seqsel.normaliseSequenceLogo;
224 showConsensusHistogram = seqsel.showConsensusHistogram;
225 idColour = seqsel.idColour;
226 outlineColour = seqsel.outlineColour;
227 seqrep = seqsel.seqrep;
228 textColour = seqsel.textColour;
229 textColour2 = seqsel.textColour2;
230 thresholdTextColour = seqsel.thresholdTextColour;
231 width = seqsel.width;
232 ignoreGapsInConsensus = seqsel.ignoreGapsInConsensus;
233 if (seqsel.conserve != null)
235 recalcConservation(); // safer than
236 // aaFrequency = (Vector) seqsel.aaFrequency.clone(); // ??
241 public boolean isShowSequenceLogo()
243 return showSequenceLogo;
246 public SequenceI[] getSelectionAsNewSequences(AlignmentI align)
248 int iSize = sequences.size();
249 SequenceI[] seqs = new SequenceI[iSize];
250 SequenceI[] inorder = getSequencesInOrder(align);
252 for (int i = 0, ipos = 0; i < inorder.length; i++)
254 SequenceI seq = inorder[i];
256 seqs[ipos] = seq.getSubSequence(startRes, endRes + 1);
257 if (seqs[ipos] != null)
259 seqs[ipos].setDescription(seq.getDescription());
260 seqs[ipos].setDBRefs(seq.getDBRefs());
261 seqs[ipos].setSequenceFeatures(seq.getSequenceFeatures());
262 if (seq.getDatasetSequence() != null)
264 seqs[ipos].setDatasetSequence(seq.getDatasetSequence());
267 if (seq.getAnnotation() != null)
269 AlignmentAnnotation[] alann = align.getAlignmentAnnotation();
270 // Only copy annotation that is either a score or referenced by the
271 // alignment's annotation vector
272 for (int a = 0; a < seq.getAnnotation().length; a++)
274 AlignmentAnnotation tocopy = seq.getAnnotation()[a];
277 boolean found = false;
278 for (int pos = 0; pos < alann.length; pos++)
280 if (alann[pos] == tocopy)
291 AlignmentAnnotation newannot = new AlignmentAnnotation(
292 seq.getAnnotation()[a]);
293 newannot.restrict(startRes, endRes);
294 newannot.setSequenceRef(seqs[ipos]);
295 newannot.adjustForAlignment();
296 seqs[ipos].addAlignmentAnnotation(newannot);
306 if (iSize != inorder.length)
308 SequenceI[] nseqs = new SequenceI[iSize];
309 System.arraycopy(seqs, 0, nseqs, 0, iSize);
317 * If sequence ends in gaps, the end residue can be correctly calculated here
323 public int findEndRes(SequenceI seq)
328 for (int j = 0; j < endRes + 1 && j < seq.getLength(); j++)
330 ch = seq.getCharAt(j);
331 if (!jalview.util.Comparison.isGap((ch)))
339 eres += seq.getStart() - 1;
346 public List<SequenceI> getSequences()
352 public List<SequenceI> getSequences(
353 Map<SequenceI, SequenceCollectionI> hiddenReps)
355 if (hiddenReps == null)
357 // TODO: need a synchronizedCollection here ?
362 List<SequenceI> allSequences = new ArrayList<>();
363 for (SequenceI seq : sequences)
365 allSequences.add(seq);
366 if (hiddenReps.containsKey(seq))
368 SequenceCollectionI hsg = hiddenReps.get(seq);
369 for (SequenceI seq2 : hsg.getSequences())
371 if (seq2 != seq && !allSequences.contains(seq2))
373 allSequences.add(seq2);
383 public SequenceI[] getSequencesAsArray(
384 Map<SequenceI, SequenceCollectionI> map)
386 List<SequenceI> tmp = getSequences(map);
391 return tmp.toArray(new SequenceI[tmp.size()]);
400 * @return DOCUMENT ME!
402 public boolean adjustForRemoveLeft(int col)
404 // return value is true if the group still exists
407 startRes = startRes - col;
412 endRes = endRes - col;
414 if (startRes > endRes)
421 // must delete this group!!
434 * @return DOCUMENT ME!
436 public boolean adjustForRemoveRight(int col)
455 * @return DOCUMENT ME!
457 public String getName()
462 public String getDescription()
473 public void setName(String name)
476 // TODO: URGENT: update dependent objects (annotation row)
479 public void setDescription(String desc)
487 * @return DOCUMENT ME!
489 public Conservation getConservation()
500 public void setConservation(Conservation c)
506 * Add s to this sequence group. If aligment sequence is already contained in
507 * group, it will not be added again, but recalculation may happen if the flag
511 * alignment sequence to be added
513 * true means Group's conservation should be recalculated
515 public void addSequence(SequenceI s, boolean recalc)
517 synchronized (sequences)
519 if (s != null && !sequences.contains(s))
522 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED,
523 sequences.size() - 1, sequences.size());
528 recalcConservation();
534 * Max Gaps Threshold (percent) for performing a conservation calculation
536 private int consPercGaps = 25;
539 * @return Max Gaps Threshold for performing a conservation calculation
541 public int getConsPercGaps()
547 * set Max Gaps Threshold (percent) for performing a conservation calculation
549 * @param consPercGaps
551 public void setConsPercGaps(int consPercGaps)
553 this.consPercGaps = consPercGaps;
557 * calculate residue conservation and colourschemes for group - but only if
558 * necessary. returns true if the calculation resulted in a visible change to
561 public boolean recalcConservation()
563 return recalcConservation(false);
567 * calculate residue conservation for group - but only if necessary. returns
568 * true if the calculation resulted in a visible change to group
571 * when set, colourschemes for this group are not refreshed after
574 public boolean recalcConservation(boolean defer)
576 if (cs == null && consensus == null && conservation == null)
580 // TODO: try harder to detect changes in state in order to minimise
581 // recalculation effort
585 ProfilesI cnsns = AAFrequency.calculate(sequences, startRes,
586 endRes + 1, showSequenceLogo);
587 if (consensus != null)
589 _updateConsensusRow(cnsns, sequences.size());
594 cs.setConsensus(cnsns);
598 if ((conservation != null)
599 || (cs != null && cs.conservationApplied()))
601 Conservation c = new Conservation(groupName, sequences, startRes,
604 c.verdict(false, consPercGaps);
605 if (conservation != null)
607 _updateConservationRow(c);
611 if (cs.conservationApplied())
613 cs.setConservation(c);
616 // eager update - will cause a refresh of overview regardless
619 if (cs != null && !defer)
621 // TODO: JAL-2034 should cs.alignmentChanged modify return state
622 cs.alignmentChanged(context != null ? context : this, null);
629 } catch (java.lang.OutOfMemoryError err)
632 System.out.println("Out of memory loading groups: " + err);
637 private void _updateConservationRow(Conservation c)
639 if (conservation == null)
644 conservation.label = "Conservation for " + getName();
645 conservation.description = "Conservation for group " + getName()
646 + " less than " + consPercGaps + "% gaps";
647 // preserve width if already set
648 int aWidth = (conservation.annotations != null)
649 ? (endRes < conservation.annotations.length
650 ? conservation.annotations.length
653 conservation.annotations = null;
654 conservation.annotations = new Annotation[aWidth]; // should be alignment
656 c.completeAnnotations(conservation, null, startRes, endRes + 1);
659 public ProfilesI consensusData = null;
661 private void _updateConsensusRow(ProfilesI cnsns, long nseq)
663 if (consensus == null)
667 consensus.label = "Consensus for " + getName();
668 consensus.description = "Percent Identity";
669 consensusData = cnsns;
670 // preserve width if already set
671 int aWidth = (consensus.annotations != null)
672 ? (endRes < consensus.annotations.length
673 ? consensus.annotations.length
676 consensus.annotations = null;
677 consensus.annotations = new Annotation[aWidth]; // should be alignment width
679 AAFrequency.completeConsensus(consensus, cnsns, startRes, endRes + 1,
680 ignoreGapsInConsensus, showSequenceLogo, nseq); // TODO: setting
683 // ignoreGapsInConsensusCalculation);
688 * sequence to either add or remove from group
690 * flag passed to delete/addSequence to indicate if group properties
691 * should be recalculated
693 public void addOrRemove(SequenceI s, boolean recalc)
695 synchronized (sequences)
697 if (sequences.contains(s))
699 deleteSequence(s, recalc);
703 addSequence(s, recalc);
714 * true means recalculate conservation
716 public void deleteSequence(SequenceI s, boolean recalc)
718 synchronized (sequences)
721 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED,
722 sequences.size() + 1, sequences.size());
726 recalcConservation();
734 * @return the first column selected by this group. Runs from 0<=i<N_cols
737 public int getStartRes()
744 * @return the groups last selected column. Runs from 0<=i<N_cols
747 public int getEndRes()
753 * Set the first column selected by this group. Runs from 0<=i<N_cols
757 public void setStartRes(int newStart)
759 newStart= Math.max(0,newStart); // sanity check for negative start column positions
760 int before = startRes;
763 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, startRes);
770 * Set the groups last selected column. Runs from 0<=i<N_cols
774 public void setEndRes(int i)
778 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, endRes);
782 * @return number of sequences in group
786 return sequences.size();
791 * @return the ith sequence
793 public SequenceI getSequenceAt(int i)
795 return sequences.get(i);
802 public void setColourText(boolean state)
810 * @return DOCUMENT ME!
812 public boolean getColourText()
823 public void setDisplayText(boolean state)
831 * @return DOCUMENT ME!
833 public boolean getDisplayText()
844 public void setDisplayBoxes(boolean state)
846 displayBoxes = state;
852 * @return DOCUMENT ME!
854 public boolean getDisplayBoxes()
860 * computes the width of current set of sequences and returns it
862 * @return DOCUMENT ME!
865 public int getWidth()
867 synchronized (sequences)
869 // MC This needs to get reset when characters are inserted and deleted
870 boolean first = true;
871 for (SequenceI seq : sequences)
873 if (first || seq.getLength() > width)
875 width = seq.getLength();
889 public void setOutlineColour(Color c)
897 * @return DOCUMENT ME!
899 public Color getOutlineColour()
901 return outlineColour;
906 * returns the sequences in the group ordered by the ordering given by al.
907 * this used to return an array with null entries regardless, new behaviour is
908 * below. TODO: verify that this does not affect use in applet or application
912 * @return SequenceI[] intersection of sequences in group with al, ordered by
913 * al, or null if group does not intersect with al
915 public SequenceI[] getSequencesInOrder(AlignmentI al)
917 return getSequencesInOrder(al, true);
921 * return an array representing the intersection of the group with al,
922 * optionally returning an array the size of al.getHeight() where nulls mark
923 * the non-intersected sequences
927 * @return null or array
929 public SequenceI[] getSequencesInOrder(AlignmentI al, boolean trim)
931 synchronized (sequences)
933 int sSize = sequences.size();
934 int alHeight = al.getHeight();
936 SequenceI[] seqs = new SequenceI[(trim) ? sSize : alHeight];
939 for (int i = 0; i < alHeight && index < sSize; i++)
941 if (sequences.contains(al.getSequenceAt(i)))
943 seqs[(trim) ? index : i] = al.getSequenceAt(i);
955 if (index < seqs.length)
957 SequenceI[] dummy = seqs;
958 seqs = new SequenceI[index];
961 seqs[index] = dummy[index];
970 * @return the idColour
972 public Color getIdColour()
979 * the idColour to set
981 public void setIdColour(Color idColour)
983 this.idColour = idColour;
987 * @return the representative sequence for this group
990 public SequenceI getSeqrep()
996 * set the representative sequence for this group. Note - this affects the
997 * interpretation of the Hidereps attribute.
1000 * the seqrep to set (null means no sequence representative)
1003 public void setSeqrep(SequenceI seqrep)
1005 this.seqrep = seqrep;
1010 * @return true if group has a sequence representative
1013 public boolean hasSeqrep()
1015 return seqrep != null;
1019 * set visibility of sequences covered by (if no sequence representative is
1020 * defined) or represented by this group.
1024 public void setHidereps(boolean visibility)
1026 hidereps = visibility;
1031 * @return true if sequences represented (or covered) by this group should be
1034 public boolean isHidereps()
1040 * set intended visibility of columns covered by this group
1044 public void setHideCols(boolean visibility)
1046 hidecols = visibility;
1051 * @return true if columns covered by group should be hidden
1053 public boolean isHideCols()
1059 * create a new sequence group from the intersection of this group with an
1060 * alignment Hashtable of hidden representatives
1066 * @return new group containing sequences common to this group and alignment
1068 public SequenceGroup intersect(AlignmentI alignment,
1069 Map<SequenceI, SequenceCollectionI> map)
1071 SequenceGroup sgroup = new SequenceGroup(this);
1072 SequenceI[] insect = getSequencesInOrder(alignment);
1073 sgroup.sequences = new ArrayList<>();
1074 for (int s = 0; insect != null && s < insect.length; s++)
1076 if (map == null || map.containsKey(insect[s]))
1078 sgroup.sequences.add(insect[s]);
1085 * @return the showUnconserved
1087 public boolean getShowNonconserved()
1089 return showNonconserved;
1093 * @param showNonconserved
1094 * the showUnconserved to set
1096 public void setShowNonconserved(boolean displayNonconserved)
1098 this.showNonconserved = displayNonconserved;
1102 * set this alignmentAnnotation object as the one used to render consensus
1107 public void setConsensus(AlignmentAnnotation aan)
1109 if (consensus == null)
1117 * @return automatically calculated consensus row note: the row is a stub if a
1118 * consensus calculation has not yet been performed on the group
1120 public AlignmentAnnotation getConsensus()
1122 // TODO get or calculate and get consensus annotation row for this group
1123 int aWidth = this.getWidth();
1131 if (consensus == null)
1133 consensus = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1134 100f, AlignmentAnnotation.BAR_GRAPH);
1135 consensus.hasText = true;
1136 consensus.autoCalculated = true;
1137 consensus.groupRef = this;
1138 consensus.label = "Consensus for " + getName();
1139 consensus.description = "Percent Identity";
1145 * set this alignmentAnnotation object as the one used to render consensus
1150 public void setConservationRow(AlignmentAnnotation aan)
1152 if (conservation == null)
1159 * get the conservation annotation row for this group
1161 * @return autoCalculated annotation row
1163 public AlignmentAnnotation getConservationRow()
1165 if (conservation == null)
1167 conservation = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1168 11f, AlignmentAnnotation.BAR_GRAPH);
1171 conservation.hasText = true;
1172 conservation.autoCalculated = true;
1173 conservation.groupRef = this;
1174 conservation.label = "Conservation for " + getName();
1175 conservation.description = "Conservation for group " + getName()
1176 + " less than " + consPercGaps + "% gaps";
1177 return conservation;
1182 * @return true if annotation rows have been instantiated for this group
1184 public boolean hasAnnotationRows()
1186 return consensus != null || conservation != null;
1189 public SequenceI getConsensusSeq()
1192 StringBuffer seqs = new StringBuffer();
1193 for (int i = 0; i < consensus.annotations.length; i++)
1195 if (consensus.annotations[i] != null)
1197 if (consensus.annotations[i].description.charAt(0) == '[')
1199 seqs.append(consensus.annotations[i].description.charAt(1));
1203 seqs.append(consensus.annotations[i].displayCharacter);
1208 SequenceI sq = new Sequence("Group" + getName() + " Consensus",
1210 sq.setDescription("Percentage Identity Consensus "
1211 + ((ignoreGapsInConsensus) ? " without gaps" : ""));
1215 public void setIgnoreGapsConsensus(boolean state)
1217 if (this.ignoreGapsInConsensus != state && consensus != null)
1219 ignoreGapsInConsensus = state;
1220 recalcConservation();
1222 ignoreGapsInConsensus = state;
1225 public boolean getIgnoreGapsConsensus()
1227 return ignoreGapsInConsensus;
1231 * @param showSequenceLogo
1232 * indicates if a sequence logo is shown for consensus annotation
1234 public void setshowSequenceLogo(boolean showSequenceLogo)
1236 // TODO: decouple calculation from settings update
1237 if (this.showSequenceLogo != showSequenceLogo && consensus != null)
1239 this.showSequenceLogo = showSequenceLogo;
1240 recalcConservation();
1242 this.showSequenceLogo = showSequenceLogo;
1247 * @param showConsHist
1248 * flag indicating if the consensus histogram for this group should
1251 public void setShowConsensusHistogram(boolean showConsHist)
1254 if (showConsensusHistogram != showConsHist && consensus != null)
1256 this.showConsensusHistogram = showConsHist;
1257 recalcConservation();
1259 this.showConsensusHistogram = showConsHist;
1263 * @return the showConsensusHistogram
1265 public boolean isShowConsensusHistogram()
1267 return showConsensusHistogram;
1271 * set flag indicating if logo should be normalised when rendered
1275 public void setNormaliseSequenceLogo(boolean norm)
1277 normaliseSequenceLogo = norm;
1280 public boolean isNormaliseSequenceLogo()
1282 return normaliseSequenceLogo;
1287 * returns a new array with all annotation involving this group
1289 public AlignmentAnnotation[] getAlignmentAnnotation()
1291 // TODO add in other methods like 'getAlignmentAnnotation(String label),
1293 ArrayList<AlignmentAnnotation> annot = new ArrayList<>();
1294 synchronized (sequences)
1296 for (SequenceI seq : sequences)
1298 AlignmentAnnotation[] aa = seq.getAnnotation();
1301 for (AlignmentAnnotation al : aa)
1303 if (al.groupRef == this)
1310 if (consensus != null)
1312 annot.add(consensus);
1314 if (conservation != null)
1316 annot.add(conservation);
1319 return annot.toArray(new AlignmentAnnotation[0]);
1323 public Iterable<AlignmentAnnotation> findAnnotation(String calcId)
1325 List<AlignmentAnnotation> aa = new ArrayList<>();
1330 for (AlignmentAnnotation a : getAlignmentAnnotation())
1332 if (calcId.equals(a.getCalcId()))
1341 public Iterable<AlignmentAnnotation> findAnnotations(SequenceI seq,
1342 String calcId, String label)
1344 ArrayList<AlignmentAnnotation> aa = new ArrayList<>();
1345 for (AlignmentAnnotation ann : getAlignmentAnnotation())
1347 if ((calcId == null || (ann.getCalcId() != null
1348 && ann.getCalcId().equals(calcId)))
1349 && (seq == null || (ann.sequenceRef != null
1350 && ann.sequenceRef == seq))
1352 || (ann.label != null && ann.label.equals(label))))
1361 * Answer true if any annotation matches the calcId passed in (if not null).
1366 public boolean hasAnnotation(String calcId)
1368 if (calcId != null && !"".equals(calcId))
1370 for (AlignmentAnnotation a : getAlignmentAnnotation())
1372 if (a.getCalcId() == calcId)
1382 * Remove all sequences from the group (leaving other properties unchanged).
1386 synchronized (sequences)
1388 int before = sequences.size();
1390 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before,
1396 * Sets the alignment or group context for this group, and whether it is
1397 * defined as a group
1400 * the context for the group
1402 * whether the group is defined on the alignment or is just a
1404 * @throws IllegalArgumentException
1405 * if setting the context would result in a circular reference chain
1407 public void setContext(AnnotatedCollectionI ctx, boolean defined)
1410 this.isDefined = defined;
1414 * Sets the alignment or group context for this group
1417 * the context for the group
1418 * @throws IllegalArgumentException
1419 * if setting the context would result in a circular reference chain
1421 public void setContext(AnnotatedCollectionI ctx)
1423 AnnotatedCollectionI ref = ctx;
1426 if (ref == this || ref.getContext() == ctx)
1428 throw new IllegalArgumentException(
1429 "Circular reference in SequenceGroup.context");
1431 ref = ref.getContext();
1439 * @see jalview.datamodel.AnnotatedCollectionI#getContext()
1442 public AnnotatedCollectionI getContext()
1447 public boolean isDefined()
1452 public void setColourScheme(ColourSchemeI scheme)
1456 cs = new ResidueShader();
1458 cs.setColourScheme(scheme);
1461 public void setGroupColourScheme(ResidueShaderI scheme)
1466 public ColourSchemeI getColourScheme()
1468 return cs == null ? null : cs.getColourScheme();
1471 public ResidueShaderI getGroupColourScheme()
1477 public boolean isNucleotide()
1479 if (context != null)
1481 return context.isNucleotide();
1488 * @return true if seq is a member of the group
1491 public boolean contains(SequenceI seq1)
1493 return sequences.contains(seq1);
1499 * @return true if startRes<=apos and endRes>=apos and seq is in the group
1501 public boolean contains(SequenceI seq, int apos)
1503 return (startRes <= apos && endRes >= apos) && sequences.contains(seq);