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(seqsel.getColourScheme());
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) ? (endRes < conservation.annotations.length ? conservation.annotations.length
651 conservation.annotations = null;
652 conservation.annotations = new Annotation[aWidth]; // should be alignment
654 c.completeAnnotations(conservation, null, startRes, endRes + 1);
657 public ProfilesI consensusData = null;
659 public ProfilesI informationData = null;
661 private void _updateConsensusRow(ProfilesI cnsns, long nseq)
663 if (consensus == null)
667 consensus.label = "Consensus for " + getName();
668 consensus.description = "Percent Identity";
669 consensusData = cnsns;
670 // preserve width if already set
671 int aWidth = (consensus.annotations != null) ? (endRes < consensus.annotations.length ? consensus.annotations.length
674 consensus.annotations = null;
675 consensus.annotations = new Annotation[aWidth]; // should be alignment width
677 AAFrequency.completeConsensus(consensus, cnsns, startRes, endRes + 1,
678 ignoreGapsInConsensus, showSequenceLogo, nseq); // TODO: setting
681 // ignoreGapsInConsensusCalculation);
685 * Recalculates the information content on the HMM annotation.
690 private void _updateInformationRow(ProfilesI cnsns, long nseq)
692 if (information == null)
696 information.label = "Information for " + getName();
697 information.description = "Percent Identity";
698 informationData = cnsns;
699 // preserve width if already set
700 int aWidth = (information.annotations != null)
701 ? (endRes < information.annotations.length
702 ? information.annotations.length : endRes + 1)
704 information.annotations = null;
705 information.annotations = new Annotation[aWidth]; // should be alignment
708 AAFrequency.completeInformation(information, cnsns, startRes,
709 endRes + 1, ignoreBelowBackground, showSequenceLogo, nseq); // TODO:
713 // ignoreGapsInInformationCalculation);
718 * sequence to either add or remove from group
720 * flag passed to delete/addSequence to indicate if group properties
721 * should be recalculated
723 public void addOrRemove(SequenceI s, boolean recalc)
725 synchronized (sequences)
727 if (sequences.contains(s))
729 deleteSequence(s, recalc);
733 addSequence(s, recalc);
744 * true means recalculate conservation
746 public void deleteSequence(SequenceI s, boolean recalc)
748 synchronized (sequences)
754 recalcConservation();
762 * @return the first column selected by this group. Runs from 0<=i<N_cols
765 public int getStartRes()
772 * @return the groups last selected column. Runs from 0<=i<N_cols
775 public int getEndRes()
781 * Set the first column selected by this group. Runs from 0<=i<N_cols
785 public void setStartRes(int i)
791 * Set the groups last selected column. Runs from 0<=i<N_cols
795 public void setEndRes(int i)
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";
1165 * @return information content annotation.
1167 public AlignmentAnnotation getInformation()
1169 // TODO get or calculate and get information annotation row for this group
1170 int aWidth = this.getWidth();
1178 if (information == null)
1180 information = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1181 6.25f, AlignmentAnnotation.BAR_GRAPH);
1182 information.hasText = true;
1183 information.autoCalculated = false;
1184 information.groupRef = this;
1185 information.label = getName() + "_HMM";
1186 information.description = "Information content, measured in bits";
1192 * set this alignmentAnnotation object as the one used to render consensus
1197 public void setConservationRow(AlignmentAnnotation aan)
1199 if (conservation == null)
1206 * get the conservation annotation row for this group
1208 * @return autoCalculated annotation row
1210 public AlignmentAnnotation getConservationRow()
1212 if (conservation == null)
1214 conservation = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1215 11f, AlignmentAnnotation.BAR_GRAPH);
1218 conservation.hasText = true;
1219 conservation.autoCalculated = true;
1220 conservation.groupRef = this;
1221 conservation.label = "Conservation for " + getName();
1222 conservation.description = "Conservation for group " + getName()
1223 + " less than " + consPercGaps + "% gaps";
1224 return conservation;
1229 * @return true if annotation rows have been instantiated for this group
1231 public boolean hasAnnotationRows()
1233 return consensus != null || conservation != null;
1236 public SequenceI getConsensusSeq()
1239 StringBuffer seqs = new StringBuffer();
1240 for (int i = 0; i < consensus.annotations.length; i++)
1242 if (consensus.annotations[i] != null)
1244 if (consensus.annotations[i].description.charAt(0) == '[')
1246 seqs.append(consensus.annotations[i].description.charAt(1));
1250 seqs.append(consensus.annotations[i].displayCharacter);
1255 SequenceI sq = new Sequence("Group" + getName() + " Consensus",
1257 sq.setDescription("Percentage Identity Consensus "
1258 + ((ignoreGapsInConsensus) ? " without gaps" : ""));
1262 public void setIgnoreGapsConsensus(boolean state)
1264 if (this.ignoreGapsInConsensus != state && consensus != null)
1266 ignoreGapsInConsensus = state;
1267 recalcConservation();
1269 ignoreGapsInConsensus = state;
1272 public boolean getIgnoreGapsConsensus()
1274 return ignoreGapsInConsensus;
1277 public void setIgnoreBelowBackground(boolean state)
1279 if (this.ignoreBelowBackground != state)
1281 ignoreBelowBackground = state;
1283 ignoreBelowBackground = state;
1286 public boolean getIgnoreBelowBackground()
1292 * @param showSequenceLogo
1293 * indicates if a sequence logo is shown for consensus annotation
1295 public void setshowSequenceLogo(boolean showSequenceLogo)
1297 // TODO: decouple calculation from settings update
1298 if (this.showSequenceLogo != showSequenceLogo && consensus != null)
1300 this.showSequenceLogo = showSequenceLogo;
1301 recalcConservation();
1303 this.showSequenceLogo = showSequenceLogo;
1308 * @param showConsHist
1309 * flag indicating if the consensus histogram for this group should
1312 public void setShowConsensusHistogram(boolean showConsHist)
1315 if (showConsensusHistogram != showConsHist && consensus != null)
1317 this.showConsensusHistogram = showConsHist;
1318 recalcConservation();
1320 this.showConsensusHistogram = showConsHist;
1324 * @return the showConsensusHistogram
1326 public boolean isShowConsensusHistogram()
1328 return showConsensusHistogram;
1332 * set flag indicating if logo should be normalised when rendered
1336 public void setNormaliseSequenceLogo(boolean norm)
1338 normaliseSequenceLogo = norm;
1341 public boolean isNormaliseSequenceLogo()
1343 return normaliseSequenceLogo;
1348 * returns a new array with all annotation involving this group
1350 public AlignmentAnnotation[] getAlignmentAnnotation()
1352 // TODO add in other methods like 'getAlignmentAnnotation(String label),
1354 ArrayList<AlignmentAnnotation> annot = new ArrayList<>();
1355 synchronized (sequences)
1357 for (SequenceI seq : sequences)
1359 AlignmentAnnotation[] aa = seq.getAnnotation();
1362 for (AlignmentAnnotation al : aa)
1364 if (al.groupRef == this)
1371 if (consensus != null)
1373 annot.add(consensus);
1375 if (conservation != null)
1377 annot.add(conservation);
1380 return annot.toArray(new AlignmentAnnotation[0]);
1384 public Iterable<AlignmentAnnotation> findAnnotation(String calcId)
1386 List<AlignmentAnnotation> aa = new ArrayList<>();
1391 for (AlignmentAnnotation a : getAlignmentAnnotation())
1393 if (calcId.equals(a.getCalcId()))
1402 public Iterable<AlignmentAnnotation> findAnnotations(SequenceI seq,
1403 String calcId, String label)
1405 ArrayList<AlignmentAnnotation> aa = new ArrayList<>();
1406 for (AlignmentAnnotation ann : getAlignmentAnnotation())
1408 if ((calcId == null || (ann.getCalcId() != null && ann.getCalcId()
1410 && (seq == null || (ann.sequenceRef != null && ann.sequenceRef == seq))
1411 && (label == null || (ann.label != null && ann.label
1421 * Answer true if any annotation matches the calcId passed in (if not null).
1426 public boolean hasAnnotation(String calcId)
1428 if (calcId != null && !"".equals(calcId))
1430 for (AlignmentAnnotation a : getAlignmentAnnotation())
1432 if (a.getCalcId() == calcId)
1442 * Remove all sequences from the group (leaving other properties unchanged).
1446 synchronized (sequences)
1453 * Sets the alignment or group context for this group, and whether it is
1454 * defined as a group
1457 * the context for the group
1459 * whether the group is defined on the alignment or is just a
1461 * @throws IllegalArgumentException
1462 * if setting the context would result in a circular reference chain
1464 public void setContext(AnnotatedCollectionI ctx, boolean defined)
1467 this.isDefined = defined;
1471 * Sets the alignment or group context for this group
1474 * the context for the group
1475 * @throws IllegalArgumentException
1476 * if setting the context would result in a circular reference chain
1478 public void setContext(AnnotatedCollectionI ctx)
1480 AnnotatedCollectionI ref = ctx;
1483 if (ref == this || ref.getContext() == ctx)
1485 throw new IllegalArgumentException(
1486 "Circular reference in SequenceGroup.context");
1488 ref = ref.getContext();
1496 * @see jalview.datamodel.AnnotatedCollectionI#getContext()
1499 public AnnotatedCollectionI getContext()
1504 public boolean isDefined()
1509 public void setColourScheme(ColourSchemeI scheme)
1513 cs = new ResidueShader();
1515 cs.setColourScheme(scheme);
1518 public void setGroupColourScheme(ResidueShaderI scheme)
1523 public ColourSchemeI getColourScheme()
1525 return cs == null ? null : cs.getColourScheme();
1528 public ResidueShaderI getGroupColourScheme()
1534 public boolean isNucleotide()
1536 if (context != null) {
1537 return context.isNucleotide();
1544 * @return true if seq is a member of the group
1547 public boolean contains(SequenceI seq1)
1549 return sequences.contains(seq1);
1555 * @return true if startRes<=apos and endRes>=apos and seq is in the group
1557 public boolean contains(SequenceI seq, int apos)
1559 return (startRes <= apos && endRes >= apos) && sequences.contains(seq);
1562 public boolean isShowInformationHistogram()
1564 return showInformationHistogram;
1567 public void setShowInformationHistogram(boolean state)
1569 if (showInformationHistogram != state && information != null)
1571 this.showInformationHistogram = state;
1572 // recalcConservation(); TODO don't know what to do here next
1574 this.showInformationHistogram = state;
1578 public boolean isShowHMMSequenceLogo()
1580 // TODO Auto-generated method stub
1581 return showHMMSequenceLogo;
1584 public void setshowHMMSequenceLogo(boolean state)
1586 showHMMSequenceLogo = state;
1590 public boolean isNormaliseHMMSequenceLogo()
1592 // TODO Auto-generated method stub
1593 return normaliseHMMSequenceLogo;
1596 public void setNormaliseHMMSequenceLogo(boolean state)
1598 normaliseSequenceLogo = state;