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.util.ArrayList;
31 import java.util.List;
35 * Collects a set contiguous ranges on a set of sequences
40 public class SequenceGroup implements AnnotatedCollectionI
46 Conservation conserve;
48 boolean displayBoxes = true;
50 boolean displayText = true;
52 boolean colourText = false;
54 HiddenMarkovModel hmm;
57 * True if the group is defined as a group on the alignment, false if it is
60 boolean isDefined = false;
63 * after Olivier's non-conserved only character display
65 boolean showNonconserved = false;
70 private List<SequenceI> sequences = new ArrayList<>();
73 * representative sequence for this group (if any)
75 private SequenceI seqrep = null;
80 * Colourscheme applied to group if any
82 public ResidueShaderI cs;
84 // start column (base 0)
87 // end column (base 0)
90 public Color outlineColour = Color.black;
92 public Color idColour = null;
94 public int thresholdTextColour = 0;
96 public Color textColour = Color.black;
98 public Color textColour2 = Color.white;
101 * consensus calculation property
103 private boolean ignoreGapsInConsensus = true;
105 private boolean ignoreBelowBackground = true;
108 * consensus calculation property
110 private boolean showSequenceLogo = false;
113 * flag indicating if logo should be rendered normalised
115 private boolean normaliseSequenceLogo;
118 * visibility of rows or represented rows covered by group
120 private boolean hidereps = false;
123 * visibility of columns intersecting this group
125 private boolean hidecols = false;
127 AlignmentAnnotation consensus = null;
129 AlignmentAnnotation conservation = null;
131 AlignmentAnnotation informationContent = null;
133 private boolean showConsensusHistogram;
135 private AnnotatedCollectionI context;
137 private boolean showHMMSequenceLogo;
139 private boolean normaliseHMMSequenceLogo;
141 private boolean showInformationHistogram;
144 * Creates a new SequenceGroup object.
146 public SequenceGroup()
148 groupName = "JGroup:" + this.hashCode();
149 cs = new ResidueShader();
153 * Creates a new SequenceGroup object.
158 * @param displayBoxes
162 * first column of group
164 * last column of group
166 public SequenceGroup(List<SequenceI> sequences, String groupName,
167 ColourSchemeI scheme, boolean displayBoxes, boolean displayText,
168 boolean colourText, int start, int end)
171 this.sequences = sequences;
172 this.groupName = groupName;
173 this.displayBoxes = displayBoxes;
174 this.displayText = displayText;
175 this.colourText = colourText;
176 this.cs = new ResidueShader(scheme);
179 recalcConservation();
187 public SequenceGroup(SequenceGroup seqsel)
192 sequences = new ArrayList<>();
193 sequences.addAll(seqsel.sequences);
194 if (seqsel.groupName != null)
196 groupName = new String(seqsel.groupName);
198 displayBoxes = seqsel.displayBoxes;
199 displayText = seqsel.displayText;
200 colourText = seqsel.colourText;
201 startRes = seqsel.startRes;
202 endRes = seqsel.endRes;
203 cs = new ResidueShader(seqsel.getColourScheme());
204 if (seqsel.description != null)
206 description = new String(seqsel.description);
208 hidecols = seqsel.hidecols;
209 hidereps = seqsel.hidereps;
210 showNonconserved = seqsel.showNonconserved;
211 showSequenceLogo = seqsel.showSequenceLogo;
212 normaliseSequenceLogo = seqsel.normaliseSequenceLogo;
213 showConsensusHistogram = seqsel.showConsensusHistogram;
214 showHMMSequenceLogo = seqsel.showHMMSequenceLogo;
215 normaliseHMMSequenceLogo = seqsel.normaliseHMMSequenceLogo;
216 showInformationHistogram = seqsel.showInformationHistogram;
217 idColour = seqsel.idColour;
218 outlineColour = seqsel.outlineColour;
219 seqrep = seqsel.seqrep;
220 textColour = seqsel.textColour;
221 textColour2 = seqsel.textColour2;
222 thresholdTextColour = seqsel.thresholdTextColour;
223 width = seqsel.width;
224 ignoreGapsInConsensus = seqsel.ignoreGapsInConsensus;
225 ignoreBelowBackground = seqsel.ignoreBelowBackground;
226 if (seqsel.conserve != null)
228 recalcConservation(); // safer than
229 // aaFrequency = (Vector) seqsel.aaFrequency.clone(); // ??
234 public boolean isShowSequenceLogo()
236 return showSequenceLogo;
239 public SequenceI[] getSelectionAsNewSequences(AlignmentI align)
241 int iSize = sequences.size();
242 SequenceI[] seqs = new SequenceI[iSize];
243 SequenceI[] inorder = getSequencesInOrder(align);
245 for (int i = 0, ipos = 0; i < inorder.length; i++)
247 SequenceI seq = inorder[i];
249 seqs[ipos] = seq.getSubSequence(startRes, endRes + 1);
250 if (seqs[ipos] != null)
252 seqs[ipos].setDescription(seq.getDescription());
253 seqs[ipos].setDBRefs(seq.getDBRefs());
254 seqs[ipos].setSequenceFeatures(seq.getSequenceFeatures());
255 if (seq.getDatasetSequence() != null)
257 seqs[ipos].setDatasetSequence(seq.getDatasetSequence());
260 if (seq.getAnnotation() != null)
262 AlignmentAnnotation[] alann = align.getAlignmentAnnotation();
263 // Only copy annotation that is either a score or referenced by the
264 // alignment's annotation vector
265 for (int a = 0; a < seq.getAnnotation().length; a++)
267 AlignmentAnnotation tocopy = seq.getAnnotation()[a];
270 boolean found = false;
271 for (int pos = 0; pos < alann.length; pos++)
273 if (alann[pos] == tocopy)
284 AlignmentAnnotation newannot = new AlignmentAnnotation(
285 seq.getAnnotation()[a]);
286 newannot.restrict(startRes, endRes);
287 newannot.setSequenceRef(seqs[ipos]);
288 newannot.adjustForAlignment();
289 seqs[ipos].addAlignmentAnnotation(newannot);
299 if (iSize != inorder.length)
301 SequenceI[] nseqs = new SequenceI[iSize];
302 System.arraycopy(seqs, 0, nseqs, 0, iSize);
310 * If sequence ends in gaps, the end residue can be correctly calculated here
316 public int findEndRes(SequenceI seq)
321 for (int j = 0; j < endRes + 1 && j < seq.getLength(); j++)
323 ch = seq.getCharAt(j);
324 if (!jalview.util.Comparison.isGap((ch)))
332 eres += seq.getStart() - 1;
339 public List<SequenceI> getSequences()
345 public List<SequenceI> getSequences(
346 Map<SequenceI, SequenceCollectionI> hiddenReps)
348 if (hiddenReps == null)
350 // TODO: need a synchronizedCollection here ?
355 List<SequenceI> allSequences = new ArrayList<>();
356 for (SequenceI seq : sequences)
358 allSequences.add(seq);
359 if (hiddenReps.containsKey(seq))
361 SequenceCollectionI hsg = hiddenReps.get(seq);
362 for (SequenceI seq2 : hsg.getSequences())
364 if (seq2 != seq && !allSequences.contains(seq2))
366 allSequences.add(seq2);
376 public SequenceI[] getSequencesAsArray(
377 Map<SequenceI, SequenceCollectionI> map)
379 List<SequenceI> tmp = getSequences(map);
384 return tmp.toArray(new SequenceI[tmp.size()]);
393 * @return DOCUMENT ME!
395 public boolean adjustForRemoveLeft(int col)
397 // return value is true if the group still exists
400 startRes = startRes - col;
405 endRes = endRes - col;
407 if (startRes > endRes)
414 // must delete this group!!
427 * @return DOCUMENT ME!
429 public boolean adjustForRemoveRight(int col)
448 * @return DOCUMENT ME!
450 public String getName()
455 public String getDescription()
466 public void setName(String name)
469 // TODO: URGENT: update dependent objects (annotation row)
472 public void setDescription(String desc)
480 * @return DOCUMENT ME!
482 public Conservation getConservation()
493 public void setConservation(Conservation c)
499 * Add s to this sequence group. If aligment sequence is already contained in
500 * group, it will not be added again, but recalculation may happen if the flag
504 * alignment sequence to be added
506 * true means Group's conservation should be recalculated
508 public void addSequence(SequenceI s, boolean recalc)
510 synchronized (sequences)
512 if (s != null && !sequences.contains(s))
519 recalcConservation();
525 * Max Gaps Threshold (percent) for performing a conservation calculation
527 private int consPercGaps = 25;
530 * @return Max Gaps Threshold for performing a conservation calculation
532 public int getConsPercGaps()
538 * set Max Gaps Threshold (percent) for performing a conservation calculation
540 * @param consPercGaps
542 public void setConsPercGaps(int consPercGaps)
544 this.consPercGaps = consPercGaps;
548 * calculate residue conservation and colourschemes for group - but only if
549 * necessary. returns true if the calculation resulted in a visible change to
552 public boolean recalcConservation()
554 return recalcConservation(false);
558 * calculate residue conservation for group - but only if necessary. returns
559 * true if the calculation resulted in a visible change to group
562 * when set, colourschemes for this group are not refreshed after
565 public boolean recalcConservation(boolean defer)
567 if (cs == null && consensus == null && conservation == null
568 && informationContent == null)
572 // TODO: try harder to detect changes in state in order to minimise
573 // recalculation effort
577 ProfilesI cnsns = AAFrequency.calculate(sequences, startRes,
578 endRes + 1, showSequenceLogo);
579 if (informationContent != null)
581 // _updateInformationRow(cnsns, sequences.size()); TODO don't know what
585 if (consensus != null)
587 _updateConsensusRow(cnsns, sequences.size());
592 cs.setConsensus(cnsns);
596 if ((conservation != null)
597 || (cs != null && cs.conservationApplied()))
599 Conservation c = new Conservation(groupName, sequences, startRes,
602 c.verdict(false, consPercGaps);
603 if (conservation != null)
605 _updateConservationRow(c);
609 if (cs.conservationApplied())
611 cs.setConservation(c);
614 // eager update - will cause a refresh of overview regardless
617 if (cs != null && !defer)
619 // TODO: JAL-2034 should cs.alignmentChanged modify return state
620 cs.alignmentChanged(context != null ? context : this, null);
627 } catch (java.lang.OutOfMemoryError err)
630 System.out.println("Out of memory loading groups: " + err);
635 private void _updateConservationRow(Conservation c)
637 if (conservation == null)
642 conservation.label = "Conservation for " + getName();
643 conservation.description = "Conservation for group " + getName()
644 + " less than " + consPercGaps + "% gaps";
645 // preserve width if already set
646 int aWidth = (conservation.annotations != null) ? (endRes < conservation.annotations.length ? conservation.annotations.length
649 conservation.annotations = null;
650 conservation.annotations = new Annotation[aWidth]; // should be alignment
652 c.completeAnnotations(conservation, null, startRes, endRes + 1);
655 public ProfilesI consensusData = null;
657 private void _updateConsensusRow(ProfilesI cnsns, long nseq)
659 if (consensus == null)
663 consensus.label = "Consensus for " + getName();
664 consensus.description = "Percent Identity";
665 consensusData = cnsns;
666 // preserve width if already set
667 int aWidth = (consensus.annotations != null) ? (endRes < consensus.annotations.length ? consensus.annotations.length
670 consensus.annotations = null;
671 consensus.annotations = new Annotation[aWidth]; // should be alignment width
673 AAFrequency.completeConsensus(consensus, cnsns, startRes, endRes + 1,
674 ignoreGapsInConsensus, showSequenceLogo, nseq); // TODO: setting
677 // ignoreGapsInConsensusCalculation);
680 private void _updateInformationRow(ProfilesI cnsns, long nseq)
682 if (consensus == null)
686 consensus.label = "Consensus for " + getName();
687 consensus.description = "Percent Identity";
688 consensusData = cnsns;
689 // preserve width if already set
690 int aWidth = (consensus.annotations != null)
691 ? (endRes < consensus.annotations.length
692 ? consensus.annotations.length : endRes + 1)
694 consensus.annotations = null;
695 consensus.annotations = new Annotation[aWidth]; // should be alignment width
697 AAFrequency.completeConsensus(consensus, cnsns, startRes, endRes + 1,
698 ignoreGapsInConsensus, showSequenceLogo, nseq); // TODO: setting
701 // ignoreGapsInConsensusCalculation);
706 * sequence to either add or remove from group
708 * flag passed to delete/addSequence to indicate if group properties
709 * should be recalculated
711 public void addOrRemove(SequenceI s, boolean recalc)
713 synchronized (sequences)
715 if (sequences.contains(s))
717 deleteSequence(s, recalc);
721 addSequence(s, recalc);
732 * true means recalculate conservation
734 public void deleteSequence(SequenceI s, boolean recalc)
736 synchronized (sequences)
742 recalcConservation();
750 * @return the first column selected by this group. Runs from 0<=i<N_cols
753 public int getStartRes()
760 * @return the groups last selected column. Runs from 0<=i<N_cols
763 public int getEndRes()
769 * Set the first column selected by this group. Runs from 0<=i<N_cols
773 public void setStartRes(int i)
779 * Set the groups last selected column. Runs from 0<=i<N_cols
783 public void setEndRes(int i)
789 * @return number of sequences in group
793 return sequences.size();
798 * @return the ith sequence
800 public SequenceI getSequenceAt(int i)
802 return sequences.get(i);
809 public void setColourText(boolean state)
817 * @return DOCUMENT ME!
819 public boolean getColourText()
830 public void setDisplayText(boolean state)
838 * @return DOCUMENT ME!
840 public boolean getDisplayText()
851 public void setDisplayBoxes(boolean state)
853 displayBoxes = state;
859 * @return DOCUMENT ME!
861 public boolean getDisplayBoxes()
867 * computes the width of current set of sequences and returns it
869 * @return DOCUMENT ME!
872 public int getWidth()
874 synchronized (sequences)
876 // MC This needs to get reset when characters are inserted and deleted
877 boolean first = true;
878 for (SequenceI seq : sequences)
880 if (first || seq.getLength() > width)
882 width = seq.getLength();
896 public void setOutlineColour(Color c)
904 * @return DOCUMENT ME!
906 public Color getOutlineColour()
908 return outlineColour;
913 * returns the sequences in the group ordered by the ordering given by al.
914 * this used to return an array with null entries regardless, new behaviour is
915 * below. TODO: verify that this does not affect use in applet or application
919 * @return SequenceI[] intersection of sequences in group with al, ordered by
920 * al, or null if group does not intersect with al
922 public SequenceI[] getSequencesInOrder(AlignmentI al)
924 return getSequencesInOrder(al, true);
928 * return an array representing the intersection of the group with al,
929 * optionally returning an array the size of al.getHeight() where nulls mark
930 * the non-intersected sequences
934 * @return null or array
936 public SequenceI[] getSequencesInOrder(AlignmentI al, boolean trim)
938 synchronized (sequences)
940 int sSize = sequences.size();
941 int alHeight = al.getHeight();
943 SequenceI[] seqs = new SequenceI[(trim) ? sSize : alHeight];
946 for (int i = 0; i < alHeight && index < sSize; i++)
948 if (sequences.contains(al.getSequenceAt(i)))
950 seqs[(trim) ? index : i] = al.getSequenceAt(i);
962 if (index < seqs.length)
964 SequenceI[] dummy = seqs;
965 seqs = new SequenceI[index];
968 seqs[index] = dummy[index];
977 * @return the idColour
979 public Color getIdColour()
986 * the idColour to set
988 public void setIdColour(Color idColour)
990 this.idColour = idColour;
994 * @return the representative sequence for this group
997 public SequenceI getSeqrep()
1003 * set the representative sequence for this group. Note - this affects the
1004 * interpretation of the Hidereps attribute.
1007 * the seqrep to set (null means no sequence representative)
1010 public void setSeqrep(SequenceI seqrep)
1012 this.seqrep = seqrep;
1017 * @return true if group has a sequence representative
1020 public boolean hasSeqrep()
1022 return seqrep != null;
1026 * set visibility of sequences covered by (if no sequence representative is
1027 * defined) or represented by this group.
1031 public void setHidereps(boolean visibility)
1033 hidereps = visibility;
1038 * @return true if sequences represented (or covered) by this group should be
1041 public boolean isHidereps()
1047 * set intended visibility of columns covered by this group
1051 public void setHideCols(boolean visibility)
1053 hidecols = visibility;
1058 * @return true if columns covered by group should be hidden
1060 public boolean isHideCols()
1066 * create a new sequence group from the intersection of this group with an
1067 * alignment Hashtable of hidden representatives
1073 * @return new group containing sequences common to this group and alignment
1075 public SequenceGroup intersect(AlignmentI alignment,
1076 Map<SequenceI, SequenceCollectionI> map)
1078 SequenceGroup sgroup = new SequenceGroup(this);
1079 SequenceI[] insect = getSequencesInOrder(alignment);
1080 sgroup.sequences = new ArrayList<>();
1081 for (int s = 0; insect != null && s < insect.length; s++)
1083 if (map == null || map.containsKey(insect[s]))
1085 sgroup.sequences.add(insect[s]);
1092 * @return the showUnconserved
1094 public boolean getShowNonconserved()
1096 return showNonconserved;
1100 * @param showNonconserved
1101 * the showUnconserved to set
1103 public void setShowNonconserved(boolean displayNonconserved)
1105 this.showNonconserved = displayNonconserved;
1109 * set this alignmentAnnotation object as the one used to render consensus
1114 public void setConsensus(AlignmentAnnotation aan)
1116 if (consensus == null)
1124 * @return automatically calculated consensus row note: the row is a stub if a
1125 * consensus calculation has not yet been performed on the group
1127 public AlignmentAnnotation getConsensus()
1129 // TODO get or calculate and get consensus annotation row for this group
1130 int aWidth = this.getWidth();
1138 if (consensus == null)
1140 consensus = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1141 100f, AlignmentAnnotation.BAR_GRAPH);
1142 consensus.hasText = true;
1143 consensus.autoCalculated = true;
1144 consensus.groupRef = this;
1145 consensus.label = "Consensus for " + getName();
1146 consensus.description = "Percent Identity";
1152 * set this alignmentAnnotation object as the one used to render consensus
1157 public void setConservationRow(AlignmentAnnotation aan)
1159 if (conservation == null)
1166 * get the conservation annotation row for this group
1168 * @return autoCalculated annotation row
1170 public AlignmentAnnotation getConservationRow()
1172 if (conservation == null)
1174 conservation = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1175 11f, AlignmentAnnotation.BAR_GRAPH);
1178 conservation.hasText = true;
1179 conservation.autoCalculated = true;
1180 conservation.groupRef = this;
1181 conservation.label = "Conservation for " + getName();
1182 conservation.description = "Conservation for group " + getName()
1183 + " less than " + consPercGaps + "% gaps";
1184 return conservation;
1189 * @return true if annotation rows have been instantiated for this group
1191 public boolean hasAnnotationRows()
1193 return consensus != null || conservation != null;
1196 public SequenceI getConsensusSeq()
1199 StringBuffer seqs = new StringBuffer();
1200 for (int i = 0; i < consensus.annotations.length; i++)
1202 if (consensus.annotations[i] != null)
1204 if (consensus.annotations[i].description.charAt(0) == '[')
1206 seqs.append(consensus.annotations[i].description.charAt(1));
1210 seqs.append(consensus.annotations[i].displayCharacter);
1215 SequenceI sq = new Sequence("Group" + getName() + " Consensus",
1217 sq.setDescription("Percentage Identity Consensus "
1218 + ((ignoreGapsInConsensus) ? " without gaps" : ""));
1222 public void setIgnoreGapsConsensus(boolean state)
1224 if (this.ignoreGapsInConsensus != state && consensus != null)
1226 ignoreGapsInConsensus = state;
1227 recalcConservation();
1229 ignoreGapsInConsensus = state;
1232 public boolean getIgnoreGapsConsensus()
1234 return ignoreGapsInConsensus;
1237 public void setIgnoreBelowBackground(boolean state)
1239 if (this.ignoreBelowBackground != state)
1241 ignoreBelowBackground = state;
1243 ignoreBelowBackground = state;
1246 public boolean getIgnoreBelowBackground()
1252 * @param showSequenceLogo
1253 * indicates if a sequence logo is shown for consensus annotation
1255 public void setshowSequenceLogo(boolean showSequenceLogo)
1257 // TODO: decouple calculation from settings update
1258 if (this.showSequenceLogo != showSequenceLogo && consensus != null)
1260 this.showSequenceLogo = showSequenceLogo;
1261 recalcConservation();
1263 this.showSequenceLogo = showSequenceLogo;
1268 * @param showConsHist
1269 * flag indicating if the consensus histogram for this group should
1272 public void setShowConsensusHistogram(boolean showConsHist)
1275 if (showConsensusHistogram != showConsHist && consensus != null)
1277 this.showConsensusHistogram = showConsHist;
1278 recalcConservation();
1280 this.showConsensusHistogram = showConsHist;
1284 * @return the showConsensusHistogram
1286 public boolean isShowConsensusHistogram()
1288 return showConsensusHistogram;
1292 * set flag indicating if logo should be normalised when rendered
1296 public void setNormaliseSequenceLogo(boolean norm)
1298 normaliseSequenceLogo = norm;
1301 public boolean isNormaliseSequenceLogo()
1303 return normaliseSequenceLogo;
1308 * returns a new array with all annotation involving this group
1310 public AlignmentAnnotation[] getAlignmentAnnotation()
1312 // TODO add in other methods like 'getAlignmentAnnotation(String label),
1314 ArrayList<AlignmentAnnotation> annot = new ArrayList<>();
1315 synchronized (sequences)
1317 for (SequenceI seq : sequences)
1319 AlignmentAnnotation[] aa = seq.getAnnotation();
1322 for (AlignmentAnnotation al : aa)
1324 if (al.groupRef == this)
1331 if (consensus != null)
1333 annot.add(consensus);
1335 if (conservation != null)
1337 annot.add(conservation);
1340 return annot.toArray(new AlignmentAnnotation[0]);
1344 public Iterable<AlignmentAnnotation> findAnnotation(String calcId)
1346 List<AlignmentAnnotation> aa = new ArrayList<>();
1351 for (AlignmentAnnotation a : getAlignmentAnnotation())
1353 if (calcId.equals(a.getCalcId()))
1362 public Iterable<AlignmentAnnotation> findAnnotations(SequenceI seq,
1363 String calcId, String label)
1365 ArrayList<AlignmentAnnotation> aa = new ArrayList<>();
1366 for (AlignmentAnnotation ann : getAlignmentAnnotation())
1368 if ((calcId == null || (ann.getCalcId() != null && ann.getCalcId()
1370 && (seq == null || (ann.sequenceRef != null && ann.sequenceRef == seq))
1371 && (label == null || (ann.label != null && ann.label
1381 * Answer true if any annotation matches the calcId passed in (if not null).
1386 public boolean hasAnnotation(String calcId)
1388 if (calcId != null && !"".equals(calcId))
1390 for (AlignmentAnnotation a : getAlignmentAnnotation())
1392 if (a.getCalcId() == calcId)
1402 * Remove all sequences from the group (leaving other properties unchanged).
1406 synchronized (sequences)
1413 * Sets the alignment or group context for this group, and whether it is
1414 * defined as a group
1417 * the context for the group
1419 * whether the group is defined on the alignment or is just a
1421 * @throws IllegalArgumentException
1422 * if setting the context would result in a circular reference chain
1424 public void setContext(AnnotatedCollectionI ctx, boolean defined)
1427 this.isDefined = defined;
1431 * Sets the alignment or group context for this group
1434 * the context for the group
1435 * @throws IllegalArgumentException
1436 * if setting the context would result in a circular reference chain
1438 public void setContext(AnnotatedCollectionI ctx)
1440 AnnotatedCollectionI ref = ctx;
1443 if (ref == this || ref.getContext() == ctx)
1445 throw new IllegalArgumentException(
1446 "Circular reference in SequenceGroup.context");
1448 ref = ref.getContext();
1456 * @see jalview.datamodel.AnnotatedCollectionI#getContext()
1459 public AnnotatedCollectionI getContext()
1464 public boolean isDefined()
1469 public void setColourScheme(ColourSchemeI scheme)
1473 cs = new ResidueShader();
1475 cs.setColourScheme(scheme);
1478 public void setGroupColourScheme(ResidueShaderI scheme)
1483 public ColourSchemeI getColourScheme()
1485 return cs == null ? null : cs.getColourScheme();
1488 public ResidueShaderI getGroupColourScheme()
1494 public boolean isNucleotide()
1496 if (context != null) {
1497 return context.isNucleotide();
1504 * @return true if seq is a member of the group
1507 public boolean contains(SequenceI seq1)
1509 return sequences.contains(seq1);
1515 * @return true if startRes<=apos and endRes>=apos and seq is in the group
1517 public boolean contains(SequenceI seq, int apos)
1519 return (startRes <= apos && endRes >= apos) && sequences.contains(seq);
1522 public boolean isShowInformationHistogram()
1524 return showInformationHistogram;
1527 public void setShowInformationHistogram(boolean state)
1529 if (showInformationHistogram != state && informationContent != null)
1531 this.showInformationHistogram = state;
1532 // recalcConservation(); TODO don't know what to do here next
1534 this.showInformationHistogram = state;
1538 public boolean isShowHMMSequenceLogo()
1540 // TODO Auto-generated method stub
1541 return showHMMSequenceLogo;
1544 public void setshowHMMSequenceLogo(boolean state)
1546 showHMMSequenceLogo = state;
1550 public boolean isNormaliseHMMSequenceLogo()
1552 // TODO Auto-generated method stub
1553 return normaliseHMMSequenceLogo;
1556 public void setNormaliseHMMSequenceLogo(boolean state)
1558 normaliseSequenceLogo = state;