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)
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);
188 if (start > 0) // sanity check for negative start column positions
194 jalview.bin.Cache.log.warn(
195 "Negative start column index detected, resetting to default index: "
201 recalcConservation();
209 public SequenceGroup(SequenceGroup seqsel)
214 sequences = new ArrayList<>();
215 sequences.addAll(seqsel.sequences);
216 if (seqsel.groupName != null)
218 groupName = new String(seqsel.groupName);
220 displayBoxes = seqsel.displayBoxes;
221 displayText = seqsel.displayText;
222 colourText = seqsel.colourText;
224 if (seqsel.startRes > 0) // sanity check for negative start column
227 startRes = seqsel.startRes;
231 jalview.bin.Cache.log.warn(
232 "Negative start column index detected, resetting to default index: "
234 // seqsel.startRes = startRes;
237 endRes = seqsel.endRes;
238 cs = new ResidueShader((ResidueShader) seqsel.cs);
239 if (seqsel.description != null)
241 description = new String(seqsel.description);
243 hidecols = seqsel.hidecols;
244 hidereps = seqsel.hidereps;
245 showNonconserved = seqsel.showNonconserved;
246 showSequenceLogo = seqsel.showSequenceLogo;
247 normaliseSequenceLogo = seqsel.normaliseSequenceLogo;
248 showConsensusHistogram = seqsel.showConsensusHistogram;
249 idColour = seqsel.idColour;
250 outlineColour = seqsel.outlineColour;
251 seqrep = seqsel.seqrep;
252 textColour = seqsel.textColour;
253 textColour2 = seqsel.textColour2;
254 thresholdTextColour = seqsel.thresholdTextColour;
255 width = seqsel.width;
256 ignoreGapsInConsensus = seqsel.ignoreGapsInConsensus;
257 if (seqsel.conserve != null)
259 recalcConservation(); // safer than
260 // aaFrequency = (Vector) seqsel.aaFrequency.clone(); // ??
265 public boolean isShowSequenceLogo()
267 return showSequenceLogo;
270 public SequenceI[] getSelectionAsNewSequences(AlignmentI align)
272 int iSize = sequences.size();
273 SequenceI[] seqs = new SequenceI[iSize];
274 SequenceI[] inorder = getSequencesInOrder(align);
276 for (int i = 0, ipos = 0; i < inorder.length; i++)
278 SequenceI seq = inorder[i];
280 seqs[ipos] = seq.getSubSequence(startRes, endRes + 1);
281 if (seqs[ipos] != null)
283 seqs[ipos].setDescription(seq.getDescription());
284 seqs[ipos].setDBRefs(seq.getDBRefs());
285 seqs[ipos].setSequenceFeatures(seq.getSequenceFeatures());
286 if (seq.getDatasetSequence() != null)
288 seqs[ipos].setDatasetSequence(seq.getDatasetSequence());
291 if (seq.getAnnotation() != null)
293 AlignmentAnnotation[] alann = align.getAlignmentAnnotation();
294 // Only copy annotation that is either a score or referenced by the
295 // alignment's annotation vector
296 for (int a = 0; a < seq.getAnnotation().length; a++)
298 AlignmentAnnotation tocopy = seq.getAnnotation()[a];
301 boolean found = false;
302 for (int pos = 0; pos < alann.length; pos++)
304 if (alann[pos] == tocopy)
315 AlignmentAnnotation newannot = new AlignmentAnnotation(
316 seq.getAnnotation()[a]);
317 newannot.restrict(startRes, endRes);
318 newannot.setSequenceRef(seqs[ipos]);
319 newannot.adjustForAlignment();
320 seqs[ipos].addAlignmentAnnotation(newannot);
330 if (iSize != inorder.length)
332 SequenceI[] nseqs = new SequenceI[iSize];
333 System.arraycopy(seqs, 0, nseqs, 0, iSize);
341 * If sequence ends in gaps, the end residue can be correctly calculated here
347 public int findEndRes(SequenceI seq)
352 for (int j = 0; j < endRes + 1 && j < seq.getLength(); j++)
354 ch = seq.getCharAt(j);
355 if (!jalview.util.Comparison.isGap((ch)))
363 eres += seq.getStart() - 1;
370 public List<SequenceI> getSequences()
376 public List<SequenceI> getSequences(
377 Map<SequenceI, SequenceCollectionI> hiddenReps)
379 if (hiddenReps == null)
381 // TODO: need a synchronizedCollection here ?
386 List<SequenceI> allSequences = new ArrayList<>();
387 for (SequenceI seq : sequences)
389 allSequences.add(seq);
390 if (hiddenReps.containsKey(seq))
392 SequenceCollectionI hsg = hiddenReps.get(seq);
393 for (SequenceI seq2 : hsg.getSequences())
395 if (seq2 != seq && !allSequences.contains(seq2))
397 allSequences.add(seq2);
407 public SequenceI[] getSequencesAsArray(
408 Map<SequenceI, SequenceCollectionI> map)
410 List<SequenceI> tmp = getSequences(map);
415 return tmp.toArray(new SequenceI[tmp.size()]);
424 * @return DOCUMENT ME!
426 public boolean adjustForRemoveLeft(int col)
428 // return value is true if the group still exists
431 startRes = startRes - col;
436 endRes = endRes - col;
438 if (startRes > endRes)
445 // must delete this group!!
458 * @return DOCUMENT ME!
460 public boolean adjustForRemoveRight(int col)
479 * @return DOCUMENT ME!
481 public String getName()
486 public String getDescription()
497 public void setName(String name)
500 // TODO: URGENT: update dependent objects (annotation row)
503 public void setDescription(String desc)
511 * @return DOCUMENT ME!
513 public Conservation getConservation()
524 public void setConservation(Conservation c)
530 * Add s to this sequence group. If aligment sequence is already contained in
531 * group, it will not be added again, but recalculation may happen if the flag
535 * alignment sequence to be added
537 * true means Group's conservation should be recalculated
539 public void addSequence(SequenceI s, boolean recalc)
541 synchronized (sequences)
543 if (s != null && !sequences.contains(s))
546 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED,
547 sequences.size() - 1, sequences.size());
552 recalcConservation();
558 * Max Gaps Threshold (percent) for performing a conservation calculation
560 private int consPercGaps = 25;
563 * @return Max Gaps Threshold for performing a conservation calculation
565 public int getConsPercGaps()
571 * set Max Gaps Threshold (percent) for performing a conservation calculation
573 * @param consPercGaps
575 public void setConsPercGaps(int consPercGaps)
577 this.consPercGaps = consPercGaps;
581 * calculate residue conservation and colourschemes for group - but only if
582 * necessary. returns true if the calculation resulted in a visible change to
585 public boolean recalcConservation()
587 return recalcConservation(false);
591 * calculate residue conservation for group - but only if necessary. returns
592 * true if the calculation resulted in a visible change to group
595 * when set, colourschemes for this group are not refreshed after
598 public boolean recalcConservation(boolean defer)
600 if (cs == null && consensus == null && conservation == null)
604 // TODO: try harder to detect changes in state in order to minimise
605 // recalculation effort
609 ProfilesI cnsns = AAFrequency.calculate(sequences, startRes,
610 endRes + 1, showSequenceLogo);
611 if (consensus != null)
613 _updateConsensusRow(cnsns, sequences.size());
618 cs.setConsensus(cnsns);
622 if ((conservation != null)
623 || (cs != null && cs.conservationApplied()))
625 Conservation c = new Conservation(groupName, sequences, startRes,
628 c.verdict(false, consPercGaps);
629 if (conservation != null)
631 _updateConservationRow(c);
635 if (cs.conservationApplied())
637 cs.setConservation(c);
640 // eager update - will cause a refresh of overview regardless
643 if (cs != null && !defer)
645 // TODO: JAL-2034 should cs.alignmentChanged modify return state
646 cs.alignmentChanged(context != null ? context : this, null);
653 } catch (java.lang.OutOfMemoryError err)
656 System.out.println("Out of memory loading groups: " + err);
661 private void _updateConservationRow(Conservation c)
663 if (conservation == null)
668 conservation.label = "Conservation for " + getName();
669 conservation.description = "Conservation for group " + getName()
670 + " less than " + consPercGaps + "% gaps";
671 // preserve width if already set
672 int aWidth = (conservation.annotations != null)
673 ? (endRes < conservation.annotations.length
674 ? conservation.annotations.length
677 conservation.annotations = null;
678 conservation.annotations = new Annotation[aWidth]; // should be alignment
680 c.completeAnnotations(conservation, null, startRes, endRes + 1);
683 public ProfilesI consensusData = null;
685 private void _updateConsensusRow(ProfilesI cnsns, long nseq)
687 if (consensus == null)
691 consensus.label = "Consensus for " + getName();
692 consensus.description = "Percent Identity";
693 consensusData = cnsns;
694 // preserve width if already set
695 int aWidth = (consensus.annotations != null)
696 ? (endRes < consensus.annotations.length
697 ? consensus.annotations.length
700 consensus.annotations = null;
701 consensus.annotations = new Annotation[aWidth]; // should be alignment width
703 AAFrequency.completeConsensus(consensus, cnsns, startRes, endRes + 1,
704 ignoreGapsInConsensus, showSequenceLogo, nseq); // TODO: setting
707 // ignoreGapsInConsensusCalculation);
712 * sequence to either add or remove from group
714 * flag passed to delete/addSequence to indicate if group properties
715 * should be recalculated
717 public void addOrRemove(SequenceI s, boolean recalc)
719 synchronized (sequences)
721 if (sequences.contains(s))
723 deleteSequence(s, recalc);
727 addSequence(s, recalc);
738 * true means recalculate conservation
740 public void deleteSequence(SequenceI s, boolean recalc)
742 synchronized (sequences)
745 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED,
746 sequences.size() + 1, sequences.size());
750 recalcConservation();
758 * @return the first column selected by this group. Runs from 0<=i<N_cols
761 public int getStartRes()
768 * @return the groups last selected column. Runs from 0<=i<N_cols
771 public int getEndRes()
777 * Set the first column selected by this group. Runs from 0<=i<N_cols
781 public void setStartRes(int i)
783 int before = startRes;
785 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, startRes);
789 * Set the groups last selected column. Runs from 0<=i<N_cols
793 public void setEndRes(int i)
797 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, endRes);
801 * @return number of sequences in group
805 return sequences.size();
810 * @return the ith sequence
812 public SequenceI getSequenceAt(int i)
814 return sequences.get(i);
821 public void setColourText(boolean state)
829 * @return DOCUMENT ME!
831 public boolean getColourText()
842 public void setDisplayText(boolean state)
850 * @return DOCUMENT ME!
852 public boolean getDisplayText()
863 public void setDisplayBoxes(boolean state)
865 displayBoxes = state;
871 * @return DOCUMENT ME!
873 public boolean getDisplayBoxes()
879 * computes the width of current set of sequences and returns it
881 * @return DOCUMENT ME!
884 public int getWidth()
886 synchronized (sequences)
888 // MC This needs to get reset when characters are inserted and deleted
889 boolean first = true;
890 for (SequenceI seq : sequences)
892 if (first || seq.getLength() > width)
894 width = seq.getLength();
908 public void setOutlineColour(Color c)
916 * @return DOCUMENT ME!
918 public Color getOutlineColour()
920 return outlineColour;
925 * returns the sequences in the group ordered by the ordering given by al.
926 * this used to return an array with null entries regardless, new behaviour is
927 * below. TODO: verify that this does not affect use in applet or application
931 * @return SequenceI[] intersection of sequences in group with al, ordered by
932 * al, or null if group does not intersect with al
934 public SequenceI[] getSequencesInOrder(AlignmentI al)
936 return getSequencesInOrder(al, true);
940 * return an array representing the intersection of the group with al,
941 * optionally returning an array the size of al.getHeight() where nulls mark
942 * the non-intersected sequences
946 * @return null or array
948 public SequenceI[] getSequencesInOrder(AlignmentI al, boolean trim)
950 synchronized (sequences)
952 int sSize = sequences.size();
953 int alHeight = al.getHeight();
955 SequenceI[] seqs = new SequenceI[(trim) ? sSize : alHeight];
958 for (int i = 0; i < alHeight && index < sSize; i++)
960 if (sequences.contains(al.getSequenceAt(i)))
962 seqs[(trim) ? index : i] = al.getSequenceAt(i);
974 if (index < seqs.length)
976 SequenceI[] dummy = seqs;
977 seqs = new SequenceI[index];
980 seqs[index] = dummy[index];
989 * @return the idColour
991 public Color getIdColour()
998 * the idColour to set
1000 public void setIdColour(Color idColour)
1002 this.idColour = idColour;
1006 * @return the representative sequence for this group
1009 public SequenceI getSeqrep()
1015 * set the representative sequence for this group. Note - this affects the
1016 * interpretation of the Hidereps attribute.
1019 * the seqrep to set (null means no sequence representative)
1022 public void setSeqrep(SequenceI seqrep)
1024 this.seqrep = seqrep;
1029 * @return true if group has a sequence representative
1032 public boolean hasSeqrep()
1034 return seqrep != null;
1038 * set visibility of sequences covered by (if no sequence representative is
1039 * defined) or represented by this group.
1043 public void setHidereps(boolean visibility)
1045 hidereps = visibility;
1050 * @return true if sequences represented (or covered) by this group should be
1053 public boolean isHidereps()
1059 * set intended visibility of columns covered by this group
1063 public void setHideCols(boolean visibility)
1065 hidecols = visibility;
1070 * @return true if columns covered by group should be hidden
1072 public boolean isHideCols()
1078 * create a new sequence group from the intersection of this group with an
1079 * alignment Hashtable of hidden representatives
1085 * @return new group containing sequences common to this group and alignment
1087 public SequenceGroup intersect(AlignmentI alignment,
1088 Map<SequenceI, SequenceCollectionI> map)
1090 SequenceGroup sgroup = new SequenceGroup(this);
1091 SequenceI[] insect = getSequencesInOrder(alignment);
1092 sgroup.sequences = new ArrayList<>();
1093 for (int s = 0; insect != null && s < insect.length; s++)
1095 if (map == null || map.containsKey(insect[s]))
1097 sgroup.sequences.add(insect[s]);
1104 * @return the showUnconserved
1106 public boolean getShowNonconserved()
1108 return showNonconserved;
1112 * @param showNonconserved
1113 * the showUnconserved to set
1115 public void setShowNonconserved(boolean displayNonconserved)
1117 this.showNonconserved = displayNonconserved;
1121 * set this alignmentAnnotation object as the one used to render consensus
1126 public void setConsensus(AlignmentAnnotation aan)
1128 if (consensus == null)
1136 * @return automatically calculated consensus row note: the row is a stub if a
1137 * consensus calculation has not yet been performed on the group
1139 public AlignmentAnnotation getConsensus()
1141 // TODO get or calculate and get consensus annotation row for this group
1142 int aWidth = this.getWidth();
1150 if (consensus == null)
1152 consensus = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1153 100f, AlignmentAnnotation.BAR_GRAPH);
1154 consensus.hasText = true;
1155 consensus.autoCalculated = true;
1156 consensus.groupRef = this;
1157 consensus.label = "Consensus for " + getName();
1158 consensus.description = "Percent Identity";
1164 * set this alignmentAnnotation object as the one used to render consensus
1169 public void setConservationRow(AlignmentAnnotation aan)
1171 if (conservation == null)
1178 * get the conservation annotation row for this group
1180 * @return autoCalculated annotation row
1182 public AlignmentAnnotation getConservationRow()
1184 if (conservation == null)
1186 conservation = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1187 11f, AlignmentAnnotation.BAR_GRAPH);
1190 conservation.hasText = true;
1191 conservation.autoCalculated = true;
1192 conservation.groupRef = this;
1193 conservation.label = "Conservation for " + getName();
1194 conservation.description = "Conservation for group " + getName()
1195 + " less than " + consPercGaps + "% gaps";
1196 return conservation;
1201 * @return true if annotation rows have been instantiated for this group
1203 public boolean hasAnnotationRows()
1205 return consensus != null || conservation != null;
1208 public SequenceI getConsensusSeq()
1211 StringBuffer seqs = new StringBuffer();
1212 for (int i = 0; i < consensus.annotations.length; i++)
1214 if (consensus.annotations[i] != null)
1216 if (consensus.annotations[i].description.charAt(0) == '[')
1218 seqs.append(consensus.annotations[i].description.charAt(1));
1222 seqs.append(consensus.annotations[i].displayCharacter);
1227 SequenceI sq = new Sequence("Group" + getName() + " Consensus",
1229 sq.setDescription("Percentage Identity Consensus "
1230 + ((ignoreGapsInConsensus) ? " without gaps" : ""));
1234 public void setIgnoreGapsConsensus(boolean state)
1236 if (this.ignoreGapsInConsensus != state && consensus != null)
1238 ignoreGapsInConsensus = state;
1239 recalcConservation();
1241 ignoreGapsInConsensus = state;
1244 public boolean getIgnoreGapsConsensus()
1246 return ignoreGapsInConsensus;
1250 * @param showSequenceLogo
1251 * indicates if a sequence logo is shown for consensus annotation
1253 public void setshowSequenceLogo(boolean showSequenceLogo)
1255 // TODO: decouple calculation from settings update
1256 if (this.showSequenceLogo != showSequenceLogo && consensus != null)
1258 this.showSequenceLogo = showSequenceLogo;
1259 recalcConservation();
1261 this.showSequenceLogo = showSequenceLogo;
1266 * @param showConsHist
1267 * flag indicating if the consensus histogram for this group should
1270 public void setShowConsensusHistogram(boolean showConsHist)
1273 if (showConsensusHistogram != showConsHist && consensus != null)
1275 this.showConsensusHistogram = showConsHist;
1276 recalcConservation();
1278 this.showConsensusHistogram = showConsHist;
1282 * @return the showConsensusHistogram
1284 public boolean isShowConsensusHistogram()
1286 return showConsensusHistogram;
1290 * set flag indicating if logo should be normalised when rendered
1294 public void setNormaliseSequenceLogo(boolean norm)
1296 normaliseSequenceLogo = norm;
1299 public boolean isNormaliseSequenceLogo()
1301 return normaliseSequenceLogo;
1306 * returns a new array with all annotation involving this group
1308 public AlignmentAnnotation[] getAlignmentAnnotation()
1310 // TODO add in other methods like 'getAlignmentAnnotation(String label),
1312 ArrayList<AlignmentAnnotation> annot = new ArrayList<>();
1313 synchronized (sequences)
1315 for (SequenceI seq : sequences)
1317 AlignmentAnnotation[] aa = seq.getAnnotation();
1320 for (AlignmentAnnotation al : aa)
1322 if (al.groupRef == this)
1329 if (consensus != null)
1331 annot.add(consensus);
1333 if (conservation != null)
1335 annot.add(conservation);
1338 return annot.toArray(new AlignmentAnnotation[0]);
1342 public Iterable<AlignmentAnnotation> findAnnotation(String calcId)
1344 List<AlignmentAnnotation> aa = new ArrayList<>();
1349 for (AlignmentAnnotation a : getAlignmentAnnotation())
1351 if (calcId.equals(a.getCalcId()))
1360 public Iterable<AlignmentAnnotation> findAnnotations(SequenceI seq,
1361 String calcId, String label)
1363 ArrayList<AlignmentAnnotation> aa = new ArrayList<>();
1364 for (AlignmentAnnotation ann : getAlignmentAnnotation())
1366 if ((calcId == null || (ann.getCalcId() != null
1367 && ann.getCalcId().equals(calcId)))
1368 && (seq == null || (ann.sequenceRef != null
1369 && ann.sequenceRef == seq))
1371 || (ann.label != null && ann.label.equals(label))))
1380 * Answer true if any annotation matches the calcId passed in (if not null).
1385 public boolean hasAnnotation(String calcId)
1387 if (calcId != null && !"".equals(calcId))
1389 for (AlignmentAnnotation a : getAlignmentAnnotation())
1391 if (a.getCalcId() == calcId)
1401 * Remove all sequences from the group (leaving other properties unchanged).
1405 synchronized (sequences)
1407 int before = sequences.size();
1409 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before,
1415 * Sets the alignment or group context for this group, and whether it is
1416 * defined as a group
1419 * the context for the group
1421 * whether the group is defined on the alignment or is just a
1423 * @throws IllegalArgumentException
1424 * if setting the context would result in a circular reference chain
1426 public void setContext(AnnotatedCollectionI ctx, boolean defined)
1429 this.isDefined = defined;
1433 * Sets the alignment or group context for this group
1436 * the context for the group
1437 * @throws IllegalArgumentException
1438 * if setting the context would result in a circular reference chain
1440 public void setContext(AnnotatedCollectionI ctx)
1442 AnnotatedCollectionI ref = ctx;
1445 if (ref == this || ref.getContext() == ctx)
1447 throw new IllegalArgumentException(
1448 "Circular reference in SequenceGroup.context");
1450 ref = ref.getContext();
1458 * @see jalview.datamodel.AnnotatedCollectionI#getContext()
1461 public AnnotatedCollectionI getContext()
1466 public boolean isDefined()
1471 public void setColourScheme(ColourSchemeI scheme)
1475 cs = new ResidueShader();
1477 cs.setColourScheme(scheme);
1480 public void setGroupColourScheme(ResidueShaderI scheme)
1485 public ColourSchemeI getColourScheme()
1487 return cs == null ? null : cs.getColourScheme();
1490 public ResidueShaderI getGroupColourScheme()
1496 public boolean isNucleotide()
1498 if (context != null)
1500 return context.isNucleotide();
1507 * @return true if seq is a member of the group
1510 public boolean contains(SequenceI seq1)
1512 return sequences.contains(seq1);
1518 * @return true if startRes<=apos and endRes>=apos and seq is in the group
1520 public boolean contains(SequenceI seq, int apos)
1522 return (startRes <= apos && endRes >= apos) && sequences.contains(seq);