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;
55 * True if the group is defined as a group on the alignment, false if it is
58 boolean isDefined = false;
61 * after Olivier's non-conserved only character display
63 boolean showNonconserved = false;
68 private List<SequenceI> sequences = new ArrayList<>();
71 * representative sequence for this group (if any)
73 private SequenceI seqrep = null;
78 * Colourscheme applied to group if any
80 public ResidueShaderI cs;
82 // start column (base 0)
85 // end column (base 0)
88 public Color outlineColour = Color.black;
90 public Color idColour = null;
92 public int thresholdTextColour = 0;
94 public Color textColour = Color.black;
96 public Color textColour2 = Color.white;
99 * consensus calculation property
101 private boolean ignoreGapsInConsensus = true;
103 private boolean ignoreBelowBackground = true;
106 * consensus calculation property
108 private boolean showSequenceLogo = false;
111 * flag indicating if logo should be rendered normalised
113 private boolean normaliseSequenceLogo;
116 * visibility of rows or represented rows covered by group
118 private boolean hidereps = false;
121 * visibility of columns intersecting this group
123 private boolean hidecols = false;
125 AlignmentAnnotation consensus = null;
127 AlignmentAnnotation conservation = null;
129 AlignmentAnnotation information = null;
131 private boolean showConsensusHistogram;
133 private AnnotatedCollectionI context;
135 private boolean showHMMSequenceLogo;
137 private boolean normaliseHMMSequenceLogo;
139 private boolean showInformationHistogram;
142 * Creates a new SequenceGroup object.
144 public SequenceGroup()
146 groupName = "JGroup:" + this.hashCode();
147 cs = new ResidueShader();
151 * Creates a new SequenceGroup object.
156 * @param displayBoxes
160 * first column of group
162 * last column of group
164 public SequenceGroup(List<SequenceI> sequences, String groupName,
165 ColourSchemeI scheme, boolean displayBoxes, boolean displayText,
166 boolean colourText, int start, int end)
169 this.sequences = sequences;
170 this.groupName = groupName;
171 this.displayBoxes = displayBoxes;
172 this.displayText = displayText;
173 this.colourText = colourText;
174 this.cs = new ResidueShader(scheme);
177 recalcConservation();
185 public SequenceGroup(SequenceGroup seqsel)
190 sequences = new ArrayList<>();
191 sequences.addAll(seqsel.sequences);
192 if (seqsel.groupName != null)
194 groupName = new String(seqsel.groupName);
196 displayBoxes = seqsel.displayBoxes;
197 displayText = seqsel.displayText;
198 colourText = seqsel.colourText;
199 startRes = seqsel.startRes;
200 endRes = seqsel.endRes;
201 cs = new ResidueShader((ResidueShader) seqsel.cs);
202 if (seqsel.description != null)
204 description = new String(seqsel.description);
206 hidecols = seqsel.hidecols;
207 hidereps = seqsel.hidereps;
208 showNonconserved = seqsel.showNonconserved;
209 showSequenceLogo = seqsel.showSequenceLogo;
210 normaliseSequenceLogo = seqsel.normaliseSequenceLogo;
211 showConsensusHistogram = seqsel.showConsensusHistogram;
212 showHMMSequenceLogo = seqsel.showHMMSequenceLogo;
213 normaliseHMMSequenceLogo = seqsel.normaliseHMMSequenceLogo;
214 showInformationHistogram = seqsel.showInformationHistogram;
215 idColour = seqsel.idColour;
216 outlineColour = seqsel.outlineColour;
217 seqrep = seqsel.seqrep;
218 textColour = seqsel.textColour;
219 textColour2 = seqsel.textColour2;
220 thresholdTextColour = seqsel.thresholdTextColour;
221 width = seqsel.width;
222 ignoreGapsInConsensus = seqsel.ignoreGapsInConsensus;
223 ignoreBelowBackground = seqsel.ignoreBelowBackground;
224 if (seqsel.conserve != null)
226 recalcConservation(); // safer than
227 // aaFrequency = (Vector) seqsel.aaFrequency.clone(); // ??
232 public boolean isShowSequenceLogo()
234 return showSequenceLogo;
237 public SequenceI[] getSelectionAsNewSequences(AlignmentI align)
239 int iSize = sequences.size();
240 SequenceI[] seqs = new SequenceI[iSize];
241 SequenceI[] inorder = getSequencesInOrder(align);
243 for (int i = 0, ipos = 0; i < inorder.length; i++)
245 SequenceI seq = inorder[i];
247 seqs[ipos] = seq.getSubSequence(startRes, endRes + 1);
248 if (seqs[ipos] != null)
250 seqs[ipos].setDescription(seq.getDescription());
251 seqs[ipos].setDBRefs(seq.getDBRefs());
252 seqs[ipos].setSequenceFeatures(seq.getSequenceFeatures());
253 if (seq.getDatasetSequence() != null)
255 seqs[ipos].setDatasetSequence(seq.getDatasetSequence());
258 if (seq.getAnnotation() != null)
260 AlignmentAnnotation[] alann = align.getAlignmentAnnotation();
261 // Only copy annotation that is either a score or referenced by the
262 // alignment's annotation vector
263 for (int a = 0; a < seq.getAnnotation().length; a++)
265 AlignmentAnnotation tocopy = seq.getAnnotation()[a];
268 boolean found = false;
269 for (int pos = 0; pos < alann.length; pos++)
271 if (alann[pos] == tocopy)
282 AlignmentAnnotation newannot = new AlignmentAnnotation(
283 seq.getAnnotation()[a]);
284 newannot.restrict(startRes, endRes);
285 newannot.setSequenceRef(seqs[ipos]);
286 newannot.adjustForAlignment();
287 seqs[ipos].addAlignmentAnnotation(newannot);
297 if (iSize != inorder.length)
299 SequenceI[] nseqs = new SequenceI[iSize];
300 System.arraycopy(seqs, 0, nseqs, 0, iSize);
308 * If sequence ends in gaps, the end residue can be correctly calculated here
314 public int findEndRes(SequenceI seq)
319 for (int j = 0; j < endRes + 1 && j < seq.getLength(); j++)
321 ch = seq.getCharAt(j);
322 if (!jalview.util.Comparison.isGap((ch)))
330 eres += seq.getStart() - 1;
337 public List<SequenceI> getSequences()
343 public List<SequenceI> getSequences(
344 Map<SequenceI, SequenceCollectionI> hiddenReps)
346 if (hiddenReps == null)
348 // TODO: need a synchronizedCollection here ?
353 List<SequenceI> allSequences = new ArrayList<>();
354 for (SequenceI seq : sequences)
356 allSequences.add(seq);
357 if (hiddenReps.containsKey(seq))
359 SequenceCollectionI hsg = hiddenReps.get(seq);
360 for (SequenceI seq2 : hsg.getSequences())
362 if (seq2 != seq && !allSequences.contains(seq2))
364 allSequences.add(seq2);
374 public SequenceI[] getSequencesAsArray(
375 Map<SequenceI, SequenceCollectionI> map)
377 List<SequenceI> tmp = getSequences(map);
382 return tmp.toArray(new SequenceI[tmp.size()]);
391 * @return DOCUMENT ME!
393 public boolean adjustForRemoveLeft(int col)
395 // return value is true if the group still exists
398 startRes = startRes - col;
403 endRes = endRes - col;
405 if (startRes > endRes)
412 // must delete this group!!
425 * @return DOCUMENT ME!
427 public boolean adjustForRemoveRight(int col)
446 * @return DOCUMENT ME!
448 public String getName()
453 public String getDescription()
464 public void setName(String name)
467 // TODO: URGENT: update dependent objects (annotation row)
470 public void setDescription(String desc)
478 * @return DOCUMENT ME!
480 public Conservation getConservation()
491 public void setConservation(Conservation c)
497 * Add s to this sequence group. If aligment sequence is already contained in
498 * group, it will not be added again, but recalculation may happen if the flag
502 * alignment sequence to be added
504 * true means Group's conservation should be recalculated
506 public void addSequence(SequenceI s, boolean recalc)
508 synchronized (sequences)
510 if (s != null && !sequences.contains(s))
517 recalcConservation();
523 * Max Gaps Threshold (percent) for performing a conservation calculation
525 private int consPercGaps = 25;
528 * @return Max Gaps Threshold for performing a conservation calculation
530 public int getConsPercGaps()
536 * set Max Gaps Threshold (percent) for performing a conservation calculation
538 * @param consPercGaps
540 public void setConsPercGaps(int consPercGaps)
542 this.consPercGaps = consPercGaps;
546 * calculate residue conservation and colourschemes for group - but only if
547 * necessary. returns true if the calculation resulted in a visible change to
550 public boolean recalcConservation()
552 return recalcConservation(false);
556 * calculate residue conservation for group - but only if necessary. returns
557 * true if the calculation resulted in a visible change to group
560 * when set, colourschemes for this group are not refreshed after
563 public boolean recalcConservation(boolean defer)
565 if (cs == null && consensus == null && conservation == null
566 && information == null)
570 // TODO: try harder to detect changes in state in order to minimise
571 // recalculation effort
575 ProfilesI cnsns = AAFrequency.calculate(sequences, startRes,
576 endRes + 1, showSequenceLogo);
577 if (information != null)
579 HiddenMarkovModel hmm = information.sequenceRef.getHMM();
581 ProfilesI info = AAFrequency.calculateHMMProfiles(hmm,
582 (endRes + 1) - startRes, startRes, endRes + 1,
583 showHMMSequenceLogo, ignoreBelowBackground);
584 _updateInformationRow(info, sequences.size());
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 public ProfilesI informationData = null;
663 private void _updateConsensusRow(ProfilesI cnsns, long nseq)
665 if (consensus == null)
669 consensus.label = "Consensus for " + getName();
670 consensus.description = "Percent Identity";
671 consensusData = cnsns;
672 // preserve width if already set
673 int aWidth = (consensus.annotations != null)
674 ? (endRes < consensus.annotations.length
675 ? consensus.annotations.length
678 consensus.annotations = null;
679 consensus.annotations = new Annotation[aWidth]; // should be alignment width
681 AAFrequency.completeConsensus(consensus, cnsns, startRes, endRes + 1,
682 ignoreGapsInConsensus, showSequenceLogo, nseq); // TODO: setting
685 // ignoreGapsInConsensusCalculation);
689 * Recalculates the information content on the HMM annotation.
694 private void _updateInformationRow(ProfilesI cnsns, long nseq)
696 if (information == null)
700 information.label = "Information for " + getName();
701 information.description = "Percent Identity";
702 informationData = cnsns;
703 // preserve width if already set
704 int aWidth = (information.annotations != null)
705 ? (endRes < information.annotations.length
706 ? information.annotations.length : endRes + 1)
708 information.annotations = null;
709 information.annotations = new Annotation[aWidth]; // should be alignment
712 AAFrequency.completeInformation(information, cnsns, startRes,
713 endRes + 1, ignoreBelowBackground, showSequenceLogo, nseq); // TODO:
717 // ignoreGapsInInformationCalculation);
722 * sequence to either add or remove from group
724 * flag passed to delete/addSequence to indicate if group properties
725 * should be recalculated
727 public void addOrRemove(SequenceI s, boolean recalc)
729 synchronized (sequences)
731 if (sequences.contains(s))
733 deleteSequence(s, recalc);
737 addSequence(s, recalc);
748 * true means recalculate conservation
750 public void deleteSequence(SequenceI s, boolean recalc)
752 synchronized (sequences)
758 recalcConservation();
766 * @return the first column selected by this group. Runs from 0<=i<N_cols
769 public int getStartRes()
776 * @return the groups last selected column. Runs from 0<=i<N_cols
779 public int getEndRes()
785 * Set the first column selected by this group. Runs from 0<=i<N_cols
789 public void setStartRes(int i)
795 * Set the groups last selected column. Runs from 0<=i<N_cols
799 public void setEndRes(int i)
805 * @return number of sequences in group
809 return sequences.size();
814 * @return the ith sequence
816 public SequenceI getSequenceAt(int i)
818 return sequences.get(i);
825 public void setColourText(boolean state)
833 * @return DOCUMENT ME!
835 public boolean getColourText()
846 public void setDisplayText(boolean state)
854 * @return DOCUMENT ME!
856 public boolean getDisplayText()
867 public void setDisplayBoxes(boolean state)
869 displayBoxes = state;
875 * @return DOCUMENT ME!
877 public boolean getDisplayBoxes()
883 * computes the width of current set of sequences and returns it
885 * @return DOCUMENT ME!
888 public int getWidth()
890 synchronized (sequences)
892 // MC This needs to get reset when characters are inserted and deleted
893 boolean first = true;
894 for (SequenceI seq : sequences)
896 if (first || seq.getLength() > width)
898 width = seq.getLength();
912 public void setOutlineColour(Color c)
920 * @return DOCUMENT ME!
922 public Color getOutlineColour()
924 return outlineColour;
929 * returns the sequences in the group ordered by the ordering given by al.
930 * this used to return an array with null entries regardless, new behaviour is
931 * below. TODO: verify that this does not affect use in applet or application
935 * @return SequenceI[] intersection of sequences in group with al, ordered by
936 * al, or null if group does not intersect with al
938 public SequenceI[] getSequencesInOrder(AlignmentI al)
940 return getSequencesInOrder(al, true);
944 * return an array representing the intersection of the group with al,
945 * optionally returning an array the size of al.getHeight() where nulls mark
946 * the non-intersected sequences
950 * @return null or array
952 public SequenceI[] getSequencesInOrder(AlignmentI al, boolean trim)
954 synchronized (sequences)
956 int sSize = sequences.size();
957 int alHeight = al.getHeight();
959 SequenceI[] seqs = new SequenceI[(trim) ? sSize : alHeight];
962 for (int i = 0; i < alHeight && index < sSize; i++)
964 if (sequences.contains(al.getSequenceAt(i)))
966 seqs[(trim) ? index : i] = al.getSequenceAt(i);
978 if (index < seqs.length)
980 SequenceI[] dummy = seqs;
981 seqs = new SequenceI[index];
984 seqs[index] = dummy[index];
993 * @return the idColour
995 public Color getIdColour()
1002 * the idColour to set
1004 public void setIdColour(Color idColour)
1006 this.idColour = idColour;
1010 * @return the representative sequence for this group
1013 public SequenceI getSeqrep()
1019 * set the representative sequence for this group. Note - this affects the
1020 * interpretation of the Hidereps attribute.
1023 * the seqrep to set (null means no sequence representative)
1026 public void setSeqrep(SequenceI seqrep)
1028 this.seqrep = seqrep;
1033 * @return true if group has a sequence representative
1036 public boolean hasSeqrep()
1038 return seqrep != null;
1042 * set visibility of sequences covered by (if no sequence representative is
1043 * defined) or represented by this group.
1047 public void setHidereps(boolean visibility)
1049 hidereps = visibility;
1054 * @return true if sequences represented (or covered) by this group should be
1057 public boolean isHidereps()
1063 * set intended visibility of columns covered by this group
1067 public void setHideCols(boolean visibility)
1069 hidecols = visibility;
1074 * @return true if columns covered by group should be hidden
1076 public boolean isHideCols()
1082 * create a new sequence group from the intersection of this group with an
1083 * alignment Hashtable of hidden representatives
1089 * @return new group containing sequences common to this group and alignment
1091 public SequenceGroup intersect(AlignmentI alignment,
1092 Map<SequenceI, SequenceCollectionI> map)
1094 SequenceGroup sgroup = new SequenceGroup(this);
1095 SequenceI[] insect = getSequencesInOrder(alignment);
1096 sgroup.sequences = new ArrayList<>();
1097 for (int s = 0; insect != null && s < insect.length; s++)
1099 if (map == null || map.containsKey(insect[s]))
1101 sgroup.sequences.add(insect[s]);
1108 * @return the showUnconserved
1110 public boolean getShowNonconserved()
1112 return showNonconserved;
1116 * @param showNonconserved
1117 * the showUnconserved to set
1119 public void setShowNonconserved(boolean displayNonconserved)
1121 this.showNonconserved = displayNonconserved;
1125 * set this alignmentAnnotation object as the one used to render consensus
1130 public void setConsensus(AlignmentAnnotation aan)
1132 if (consensus == null)
1140 * @return automatically calculated consensus row note: the row is a stub if a
1141 * consensus calculation has not yet been performed on the group
1143 public AlignmentAnnotation getConsensus()
1145 // TODO get or calculate and get consensus annotation row for this group
1146 int aWidth = this.getWidth();
1154 if (consensus == null)
1156 consensus = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1157 100f, AlignmentAnnotation.BAR_GRAPH);
1158 consensus.hasText = true;
1159 consensus.autoCalculated = true;
1160 consensus.groupRef = this;
1161 consensus.label = "Consensus for " + getName();
1162 consensus.description = "Percent Identity";
1169 * @return information content annotation.
1171 public AlignmentAnnotation getInformation()
1173 // TODO get or calculate and get information annotation row for this group
1174 int aWidth = this.getWidth();
1182 if (information == null)
1184 information = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1185 6.25f, AlignmentAnnotation.BAR_GRAPH);
1186 information.hasText = true;
1187 information.autoCalculated = false;
1188 information.groupRef = this;
1189 information.label = getName() + "_HMM";
1190 information.description = "Information content, measured in bits";
1196 * set this alignmentAnnotation object as the one used to render consensus
1201 public void setConservationRow(AlignmentAnnotation aan)
1203 if (conservation == null)
1210 * get the conservation annotation row for this group
1212 * @return autoCalculated annotation row
1214 public AlignmentAnnotation getConservationRow()
1216 if (conservation == null)
1218 conservation = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1219 11f, AlignmentAnnotation.BAR_GRAPH);
1222 conservation.hasText = true;
1223 conservation.autoCalculated = true;
1224 conservation.groupRef = this;
1225 conservation.label = "Conservation for " + getName();
1226 conservation.description = "Conservation for group " + getName()
1227 + " less than " + consPercGaps + "% gaps";
1228 return conservation;
1233 * @return true if annotation rows have been instantiated for this group
1235 public boolean hasAnnotationRows()
1237 return consensus != null || conservation != null;
1240 public SequenceI getConsensusSeq()
1243 StringBuffer seqs = new StringBuffer();
1244 for (int i = 0; i < consensus.annotations.length; i++)
1246 if (consensus.annotations[i] != null)
1248 if (consensus.annotations[i].description.charAt(0) == '[')
1250 seqs.append(consensus.annotations[i].description.charAt(1));
1254 seqs.append(consensus.annotations[i].displayCharacter);
1259 SequenceI sq = new Sequence("Group" + getName() + " Consensus",
1261 sq.setDescription("Percentage Identity Consensus "
1262 + ((ignoreGapsInConsensus) ? " without gaps" : ""));
1266 public void setIgnoreGapsConsensus(boolean state)
1268 if (this.ignoreGapsInConsensus != state && consensus != null)
1270 ignoreGapsInConsensus = state;
1271 recalcConservation();
1273 ignoreGapsInConsensus = state;
1276 public boolean getIgnoreGapsConsensus()
1278 return ignoreGapsInConsensus;
1281 public void setIgnoreBelowBackground(boolean state)
1283 if (this.ignoreBelowBackground != state)
1285 ignoreBelowBackground = state;
1287 ignoreBelowBackground = state;
1290 public boolean getIgnoreBelowBackground()
1296 * @param showSequenceLogo
1297 * indicates if a sequence logo is shown for consensus annotation
1299 public void setshowSequenceLogo(boolean showSequenceLogo)
1301 // TODO: decouple calculation from settings update
1302 if (this.showSequenceLogo != showSequenceLogo && consensus != null)
1304 this.showSequenceLogo = showSequenceLogo;
1305 recalcConservation();
1307 this.showSequenceLogo = showSequenceLogo;
1312 * @param showConsHist
1313 * flag indicating if the consensus histogram for this group should
1316 public void setShowConsensusHistogram(boolean showConsHist)
1319 if (showConsensusHistogram != showConsHist && consensus != null)
1321 this.showConsensusHistogram = showConsHist;
1322 recalcConservation();
1324 this.showConsensusHistogram = showConsHist;
1328 * @return the showConsensusHistogram
1330 public boolean isShowConsensusHistogram()
1332 return showConsensusHistogram;
1336 * set flag indicating if logo should be normalised when rendered
1340 public void setNormaliseSequenceLogo(boolean norm)
1342 normaliseSequenceLogo = norm;
1345 public boolean isNormaliseSequenceLogo()
1347 return normaliseSequenceLogo;
1352 * returns a new array with all annotation involving this group
1354 public AlignmentAnnotation[] getAlignmentAnnotation()
1356 // TODO add in other methods like 'getAlignmentAnnotation(String label),
1358 ArrayList<AlignmentAnnotation> annot = new ArrayList<>();
1359 synchronized (sequences)
1361 for (SequenceI seq : sequences)
1363 AlignmentAnnotation[] aa = seq.getAnnotation();
1366 for (AlignmentAnnotation al : aa)
1368 if (al.groupRef == this)
1375 if (consensus != null)
1377 annot.add(consensus);
1379 if (conservation != null)
1381 annot.add(conservation);
1384 return annot.toArray(new AlignmentAnnotation[0]);
1388 public Iterable<AlignmentAnnotation> findAnnotation(String calcId)
1390 List<AlignmentAnnotation> aa = new ArrayList<>();
1395 for (AlignmentAnnotation a : getAlignmentAnnotation())
1397 if (calcId.equals(a.getCalcId()))
1406 public Iterable<AlignmentAnnotation> findAnnotations(SequenceI seq,
1407 String calcId, String label)
1409 ArrayList<AlignmentAnnotation> aa = new ArrayList<>();
1410 for (AlignmentAnnotation ann : getAlignmentAnnotation())
1412 if ((calcId == null || (ann.getCalcId() != null
1413 && ann.getCalcId().equals(calcId)))
1414 && (seq == null || (ann.sequenceRef != null
1415 && ann.sequenceRef == seq))
1417 || (ann.label != null && ann.label.equals(label))))
1426 * Answer true if any annotation matches the calcId passed in (if not null).
1431 public boolean hasAnnotation(String calcId)
1433 if (calcId != null && !"".equals(calcId))
1435 for (AlignmentAnnotation a : getAlignmentAnnotation())
1437 if (a.getCalcId() == calcId)
1447 * Remove all sequences from the group (leaving other properties unchanged).
1451 synchronized (sequences)
1458 * Sets the alignment or group context for this group, and whether it is
1459 * defined as a group
1462 * the context for the group
1464 * whether the group is defined on the alignment or is just a
1466 * @throws IllegalArgumentException
1467 * if setting the context would result in a circular reference chain
1469 public void setContext(AnnotatedCollectionI ctx, boolean defined)
1472 this.isDefined = defined;
1476 * Sets the alignment or group context for this group
1479 * the context for the group
1480 * @throws IllegalArgumentException
1481 * if setting the context would result in a circular reference chain
1483 public void setContext(AnnotatedCollectionI ctx)
1485 AnnotatedCollectionI ref = ctx;
1488 if (ref == this || ref.getContext() == ctx)
1490 throw new IllegalArgumentException(
1491 "Circular reference in SequenceGroup.context");
1493 ref = ref.getContext();
1501 * @see jalview.datamodel.AnnotatedCollectionI#getContext()
1504 public AnnotatedCollectionI getContext()
1509 public boolean isDefined()
1514 public void setColourScheme(ColourSchemeI scheme)
1518 cs = new ResidueShader();
1520 cs.setColourScheme(scheme);
1523 public void setGroupColourScheme(ResidueShaderI scheme)
1528 public ColourSchemeI getColourScheme()
1530 return cs == null ? null : cs.getColourScheme();
1533 public ResidueShaderI getGroupColourScheme()
1539 public boolean isNucleotide()
1541 if (context != null)
1543 return context.isNucleotide();
1550 * @return true if seq is a member of the group
1553 public boolean contains(SequenceI seq1)
1555 return sequences.contains(seq1);
1561 * @return true if startRes<=apos and endRes>=apos and seq is in the group
1563 public boolean contains(SequenceI seq, int apos)
1565 return (startRes <= apos && endRes >= apos) && sequences.contains(seq);
1568 public boolean isShowInformationHistogram()
1570 return showInformationHistogram;
1573 public void setShowInformationHistogram(boolean state)
1575 if (showInformationHistogram != state && information != null)
1577 this.showInformationHistogram = state;
1578 // recalcConservation(); TODO don't know what to do here next
1580 this.showInformationHistogram = state;
1584 public boolean isShowHMMSequenceLogo()
1586 // TODO Auto-generated method stub
1587 return showHMMSequenceLogo;
1590 public void setshowHMMSequenceLogo(boolean state)
1592 showHMMSequenceLogo = state;
1596 public boolean isNormaliseHMMSequenceLogo()
1598 // TODO Auto-generated method stub
1599 return normaliseHMMSequenceLogo;
1602 public void setNormaliseHMMSequenceLogo(boolean state)
1604 normaliseSequenceLogo = state;