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 information = 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 && information == 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 (information != 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 public ProfilesI informationData = null;
659 private void _updateConsensusRow(ProfilesI cnsns, long nseq)
661 if (consensus == null)
665 consensus.label = "Consensus for " + getName();
666 consensus.description = "Percent Identity";
667 consensusData = cnsns;
668 // preserve width if already set
669 int aWidth = (consensus.annotations != null) ? (endRes < consensus.annotations.length ? consensus.annotations.length
672 consensus.annotations = null;
673 consensus.annotations = new Annotation[aWidth]; // should be alignment width
675 AAFrequency.completeConsensus(consensus, cnsns, startRes, endRes + 1,
676 ignoreGapsInConsensus, showSequenceLogo, nseq); // TODO: setting
679 // ignoreGapsInConsensusCalculation);
682 private void _updateInformationRow(ProfilesI cnsns, long nseq)
684 if (information == null)
688 information.label = "Information for " + getName();
689 information.description = "Percent Identity";
690 informationData = cnsns;
691 // preserve width if already set
692 int aWidth = (information.annotations != null)
693 ? (endRes < information.annotations.length
694 ? information.annotations.length : endRes + 1)
696 information.annotations = null;
697 information.annotations = new Annotation[aWidth]; // should be alignment
700 AAFrequency.completeInformation(information, cnsns, startRes,
701 endRes + 1, ignoreBelowBackground, showSequenceLogo, nseq); // TODO:
705 // ignoreGapsInInformationCalculation);
710 * sequence to either add or remove from group
712 * flag passed to delete/addSequence to indicate if group properties
713 * should be recalculated
715 public void addOrRemove(SequenceI s, boolean recalc)
717 synchronized (sequences)
719 if (sequences.contains(s))
721 deleteSequence(s, recalc);
725 addSequence(s, recalc);
736 * true means recalculate conservation
738 public void deleteSequence(SequenceI s, boolean recalc)
740 synchronized (sequences)
746 recalcConservation();
754 * @return the first column selected by this group. Runs from 0<=i<N_cols
757 public int getStartRes()
764 * @return the groups last selected column. Runs from 0<=i<N_cols
767 public int getEndRes()
773 * Set the first column selected by this group. Runs from 0<=i<N_cols
777 public void setStartRes(int i)
783 * Set the groups last selected column. Runs from 0<=i<N_cols
787 public void setEndRes(int i)
793 * @return number of sequences in group
797 return sequences.size();
802 * @return the ith sequence
804 public SequenceI getSequenceAt(int i)
806 return sequences.get(i);
813 public void setColourText(boolean state)
821 * @return DOCUMENT ME!
823 public boolean getColourText()
834 public void setDisplayText(boolean state)
842 * @return DOCUMENT ME!
844 public boolean getDisplayText()
855 public void setDisplayBoxes(boolean state)
857 displayBoxes = state;
863 * @return DOCUMENT ME!
865 public boolean getDisplayBoxes()
871 * computes the width of current set of sequences and returns it
873 * @return DOCUMENT ME!
876 public int getWidth()
878 synchronized (sequences)
880 // MC This needs to get reset when characters are inserted and deleted
881 boolean first = true;
882 for (SequenceI seq : sequences)
884 if (first || seq.getLength() > width)
886 width = seq.getLength();
900 public void setOutlineColour(Color c)
908 * @return DOCUMENT ME!
910 public Color getOutlineColour()
912 return outlineColour;
917 * returns the sequences in the group ordered by the ordering given by al.
918 * this used to return an array with null entries regardless, new behaviour is
919 * below. TODO: verify that this does not affect use in applet or application
923 * @return SequenceI[] intersection of sequences in group with al, ordered by
924 * al, or null if group does not intersect with al
926 public SequenceI[] getSequencesInOrder(AlignmentI al)
928 return getSequencesInOrder(al, true);
932 * return an array representing the intersection of the group with al,
933 * optionally returning an array the size of al.getHeight() where nulls mark
934 * the non-intersected sequences
938 * @return null or array
940 public SequenceI[] getSequencesInOrder(AlignmentI al, boolean trim)
942 synchronized (sequences)
944 int sSize = sequences.size();
945 int alHeight = al.getHeight();
947 SequenceI[] seqs = new SequenceI[(trim) ? sSize : alHeight];
950 for (int i = 0; i < alHeight && index < sSize; i++)
952 if (sequences.contains(al.getSequenceAt(i)))
954 seqs[(trim) ? index : i] = al.getSequenceAt(i);
966 if (index < seqs.length)
968 SequenceI[] dummy = seqs;
969 seqs = new SequenceI[index];
972 seqs[index] = dummy[index];
981 * @return the idColour
983 public Color getIdColour()
990 * the idColour to set
992 public void setIdColour(Color idColour)
994 this.idColour = idColour;
998 * @return the representative sequence for this group
1001 public SequenceI getSeqrep()
1007 * set the representative sequence for this group. Note - this affects the
1008 * interpretation of the Hidereps attribute.
1011 * the seqrep to set (null means no sequence representative)
1014 public void setSeqrep(SequenceI seqrep)
1016 this.seqrep = seqrep;
1021 * @return true if group has a sequence representative
1024 public boolean hasSeqrep()
1026 return seqrep != null;
1030 * set visibility of sequences covered by (if no sequence representative is
1031 * defined) or represented by this group.
1035 public void setHidereps(boolean visibility)
1037 hidereps = visibility;
1042 * @return true if sequences represented (or covered) by this group should be
1045 public boolean isHidereps()
1051 * set intended visibility of columns covered by this group
1055 public void setHideCols(boolean visibility)
1057 hidecols = visibility;
1062 * @return true if columns covered by group should be hidden
1064 public boolean isHideCols()
1070 * create a new sequence group from the intersection of this group with an
1071 * alignment Hashtable of hidden representatives
1077 * @return new group containing sequences common to this group and alignment
1079 public SequenceGroup intersect(AlignmentI alignment,
1080 Map<SequenceI, SequenceCollectionI> map)
1082 SequenceGroup sgroup = new SequenceGroup(this);
1083 SequenceI[] insect = getSequencesInOrder(alignment);
1084 sgroup.sequences = new ArrayList<>();
1085 for (int s = 0; insect != null && s < insect.length; s++)
1087 if (map == null || map.containsKey(insect[s]))
1089 sgroup.sequences.add(insect[s]);
1096 * @return the showUnconserved
1098 public boolean getShowNonconserved()
1100 return showNonconserved;
1104 * @param showNonconserved
1105 * the showUnconserved to set
1107 public void setShowNonconserved(boolean displayNonconserved)
1109 this.showNonconserved = displayNonconserved;
1113 * set this alignmentAnnotation object as the one used to render consensus
1118 public void setConsensus(AlignmentAnnotation aan)
1120 if (consensus == null)
1128 * @return automatically calculated consensus row note: the row is a stub if a
1129 * consensus calculation has not yet been performed on the group
1131 public AlignmentAnnotation getConsensus()
1133 // TODO get or calculate and get consensus annotation row for this group
1134 int aWidth = this.getWidth();
1142 if (consensus == null)
1144 consensus = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1145 100f, AlignmentAnnotation.BAR_GRAPH);
1146 consensus.hasText = true;
1147 consensus.autoCalculated = true;
1148 consensus.groupRef = this;
1149 consensus.label = "Consensus for " + getName();
1150 consensus.description = "Percent Identity";
1157 * @return information content annotation.
1159 public AlignmentAnnotation getInformation()
1161 // TODO get or calculate and get information annotation row for this group
1162 int aWidth = this.getWidth();
1170 if (information == null)
1172 information = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1173 100f, AlignmentAnnotation.BAR_GRAPH);
1174 information.hasText = true;
1175 information.autoCalculated = true;
1176 information.groupRef = this;
1177 information.label = "Consensus for " + getName();
1178 information.description = "Percent Identity";
1184 * set this alignmentAnnotation object as the one used to render consensus
1189 public void setConservationRow(AlignmentAnnotation aan)
1191 if (conservation == null)
1198 * get the conservation annotation row for this group
1200 * @return autoCalculated annotation row
1202 public AlignmentAnnotation getConservationRow()
1204 if (conservation == null)
1206 conservation = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1207 11f, AlignmentAnnotation.BAR_GRAPH);
1210 conservation.hasText = true;
1211 conservation.autoCalculated = true;
1212 conservation.groupRef = this;
1213 conservation.label = "Conservation for " + getName();
1214 conservation.description = "Conservation for group " + getName()
1215 + " less than " + consPercGaps + "% gaps";
1216 return conservation;
1221 * @return true if annotation rows have been instantiated for this group
1223 public boolean hasAnnotationRows()
1225 return consensus != null || conservation != null;
1228 public SequenceI getConsensusSeq()
1231 StringBuffer seqs = new StringBuffer();
1232 for (int i = 0; i < consensus.annotations.length; i++)
1234 if (consensus.annotations[i] != null)
1236 if (consensus.annotations[i].description.charAt(0) == '[')
1238 seqs.append(consensus.annotations[i].description.charAt(1));
1242 seqs.append(consensus.annotations[i].displayCharacter);
1247 SequenceI sq = new Sequence("Group" + getName() + " Consensus",
1249 sq.setDescription("Percentage Identity Consensus "
1250 + ((ignoreGapsInConsensus) ? " without gaps" : ""));
1254 public void setIgnoreGapsConsensus(boolean state)
1256 if (this.ignoreGapsInConsensus != state && consensus != null)
1258 ignoreGapsInConsensus = state;
1259 recalcConservation();
1261 ignoreGapsInConsensus = state;
1264 public boolean getIgnoreGapsConsensus()
1266 return ignoreGapsInConsensus;
1269 public void setIgnoreBelowBackground(boolean state)
1271 if (this.ignoreBelowBackground != state)
1273 ignoreBelowBackground = state;
1275 ignoreBelowBackground = state;
1278 public boolean getIgnoreBelowBackground()
1284 * @param showSequenceLogo
1285 * indicates if a sequence logo is shown for consensus annotation
1287 public void setshowSequenceLogo(boolean showSequenceLogo)
1289 // TODO: decouple calculation from settings update
1290 if (this.showSequenceLogo != showSequenceLogo && consensus != null)
1292 this.showSequenceLogo = showSequenceLogo;
1293 recalcConservation();
1295 this.showSequenceLogo = showSequenceLogo;
1300 * @param showConsHist
1301 * flag indicating if the consensus histogram for this group should
1304 public void setShowConsensusHistogram(boolean showConsHist)
1307 if (showConsensusHistogram != showConsHist && consensus != null)
1309 this.showConsensusHistogram = showConsHist;
1310 recalcConservation();
1312 this.showConsensusHistogram = showConsHist;
1316 * @return the showConsensusHistogram
1318 public boolean isShowConsensusHistogram()
1320 return showConsensusHistogram;
1324 * set flag indicating if logo should be normalised when rendered
1328 public void setNormaliseSequenceLogo(boolean norm)
1330 normaliseSequenceLogo = norm;
1333 public boolean isNormaliseSequenceLogo()
1335 return normaliseSequenceLogo;
1340 * returns a new array with all annotation involving this group
1342 public AlignmentAnnotation[] getAlignmentAnnotation()
1344 // TODO add in other methods like 'getAlignmentAnnotation(String label),
1346 ArrayList<AlignmentAnnotation> annot = new ArrayList<>();
1347 synchronized (sequences)
1349 for (SequenceI seq : sequences)
1351 AlignmentAnnotation[] aa = seq.getAnnotation();
1354 for (AlignmentAnnotation al : aa)
1356 if (al.groupRef == this)
1363 if (consensus != null)
1365 annot.add(consensus);
1367 if (conservation != null)
1369 annot.add(conservation);
1372 return annot.toArray(new AlignmentAnnotation[0]);
1376 public Iterable<AlignmentAnnotation> findAnnotation(String calcId)
1378 List<AlignmentAnnotation> aa = new ArrayList<>();
1383 for (AlignmentAnnotation a : getAlignmentAnnotation())
1385 if (calcId.equals(a.getCalcId()))
1394 public Iterable<AlignmentAnnotation> findAnnotations(SequenceI seq,
1395 String calcId, String label)
1397 ArrayList<AlignmentAnnotation> aa = new ArrayList<>();
1398 for (AlignmentAnnotation ann : getAlignmentAnnotation())
1400 if ((calcId == null || (ann.getCalcId() != null && ann.getCalcId()
1402 && (seq == null || (ann.sequenceRef != null && ann.sequenceRef == seq))
1403 && (label == null || (ann.label != null && ann.label
1413 * Answer true if any annotation matches the calcId passed in (if not null).
1418 public boolean hasAnnotation(String calcId)
1420 if (calcId != null && !"".equals(calcId))
1422 for (AlignmentAnnotation a : getAlignmentAnnotation())
1424 if (a.getCalcId() == calcId)
1434 * Remove all sequences from the group (leaving other properties unchanged).
1438 synchronized (sequences)
1445 * Sets the alignment or group context for this group, and whether it is
1446 * defined as a group
1449 * the context for the group
1451 * whether the group is defined on the alignment or is just a
1453 * @throws IllegalArgumentException
1454 * if setting the context would result in a circular reference chain
1456 public void setContext(AnnotatedCollectionI ctx, boolean defined)
1459 this.isDefined = defined;
1463 * Sets the alignment or group context for this group
1466 * the context for the group
1467 * @throws IllegalArgumentException
1468 * if setting the context would result in a circular reference chain
1470 public void setContext(AnnotatedCollectionI ctx)
1472 AnnotatedCollectionI ref = ctx;
1475 if (ref == this || ref.getContext() == ctx)
1477 throw new IllegalArgumentException(
1478 "Circular reference in SequenceGroup.context");
1480 ref = ref.getContext();
1488 * @see jalview.datamodel.AnnotatedCollectionI#getContext()
1491 public AnnotatedCollectionI getContext()
1496 public boolean isDefined()
1501 public void setColourScheme(ColourSchemeI scheme)
1505 cs = new ResidueShader();
1507 cs.setColourScheme(scheme);
1510 public void setGroupColourScheme(ResidueShaderI scheme)
1515 public ColourSchemeI getColourScheme()
1517 return cs == null ? null : cs.getColourScheme();
1520 public ResidueShaderI getGroupColourScheme()
1526 public boolean isNucleotide()
1528 if (context != null) {
1529 return context.isNucleotide();
1536 * @return true if seq is a member of the group
1539 public boolean contains(SequenceI seq1)
1541 return sequences.contains(seq1);
1547 * @return true if startRes<=apos and endRes>=apos and seq is in the group
1549 public boolean contains(SequenceI seq, int apos)
1551 return (startRes <= apos && endRes >= apos) && sequences.contains(seq);
1554 public boolean isShowInformationHistogram()
1556 return showInformationHistogram;
1559 public void setShowInformationHistogram(boolean state)
1561 if (showInformationHistogram != state && information != null)
1563 this.showInformationHistogram = state;
1564 // recalcConservation(); TODO don't know what to do here next
1566 this.showInformationHistogram = state;
1570 public boolean isShowHMMSequenceLogo()
1572 // TODO Auto-generated method stub
1573 return showHMMSequenceLogo;
1576 public void setshowHMMSequenceLogo(boolean state)
1578 showHMMSequenceLogo = state;
1582 public boolean isNormaliseHMMSequenceLogo()
1584 // TODO Auto-generated method stub
1585 return normaliseHMMSequenceLogo;
1588 public void setNormaliseHMMSequenceLogo(boolean state)
1590 normaliseSequenceLogo = state;