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;
28 import jalview.util.MessageManager;
30 import java.awt.Color;
31 import java.util.ArrayList;
32 import java.util.List;
36 * Collects a set contiguous ranges on a set of sequences
41 public class SequenceGroup implements AnnotatedCollectionI
47 Conservation conserve;
49 boolean displayBoxes = true;
51 boolean displayText = true;
53 boolean colourText = false;
56 * True if the group is defined as a group on the alignment, false if it is
59 boolean isDefined = false;
62 * after Olivier's non-conserved only character display
64 boolean showNonconserved = false;
69 private List<SequenceI> sequences = new ArrayList<>();
72 * representative sequence for this group (if any)
74 private SequenceI seqrep = null;
79 * Colourscheme applied to group if any
81 public ResidueShaderI cs;
83 // start column (base 0)
86 // end column (base 0)
89 public Color outlineColour = Color.black;
91 public Color idColour = null;
93 public int thresholdTextColour = 0;
95 public Color textColour = Color.black;
97 public Color textColour2 = Color.white;
100 * consensus calculation property
102 private boolean ignoreGapsInConsensus = true;
104 private boolean ignoreBelowBackground = true;
107 * consensus calculation property
109 private boolean showSequenceLogo = false;
112 * flag indicating if logo should be rendered normalised
114 private boolean normaliseSequenceLogo;
117 * visibility of rows or represented rows covered by group
119 private boolean hidereps = false;
122 * visibility of columns intersecting this group
124 private boolean hidecols = false;
126 AlignmentAnnotation consensus = null;
128 AlignmentAnnotation conservation = null;
130 AlignmentAnnotation information = null;
132 private boolean showConsensusHistogram;
134 private AnnotatedCollectionI context;
136 private boolean showHMMSequenceLogo;
138 private boolean normaliseHMMSequenceLogo;
140 private boolean showInformationHistogram;
143 * Creates a new SequenceGroup object.
145 public SequenceGroup()
147 groupName = "JGroup:" + this.hashCode();
148 cs = new ResidueShader();
152 * Creates a new SequenceGroup object.
157 * @param displayBoxes
161 * first column of group
163 * last column of group
165 public SequenceGroup(List<SequenceI> sequences, String groupName,
166 ColourSchemeI scheme, boolean displayBoxes, boolean displayText,
167 boolean colourText, int start, int end)
170 this.sequences = sequences;
171 this.groupName = groupName;
172 this.displayBoxes = displayBoxes;
173 this.displayText = displayText;
174 this.colourText = colourText;
175 this.cs = new ResidueShader(scheme);
178 recalcConservation();
186 public SequenceGroup(SequenceGroup seqsel)
191 sequences = new ArrayList<>();
192 sequences.addAll(seqsel.sequences);
193 if (seqsel.groupName != null)
195 groupName = new String(seqsel.groupName);
197 displayBoxes = seqsel.displayBoxes;
198 displayText = seqsel.displayText;
199 colourText = seqsel.colourText;
200 startRes = seqsel.startRes;
201 endRes = seqsel.endRes;
202 cs = new ResidueShader((ResidueShader) seqsel.cs);
203 if (seqsel.description != null)
205 description = new String(seqsel.description);
207 hidecols = seqsel.hidecols;
208 hidereps = seqsel.hidereps;
209 showNonconserved = seqsel.showNonconserved;
210 showSequenceLogo = seqsel.showSequenceLogo;
211 normaliseSequenceLogo = seqsel.normaliseSequenceLogo;
212 showConsensusHistogram = seqsel.showConsensusHistogram;
213 showHMMSequenceLogo = seqsel.showHMMSequenceLogo;
214 normaliseHMMSequenceLogo = seqsel.normaliseHMMSequenceLogo;
215 showInformationHistogram = seqsel.showInformationHistogram;
216 idColour = seqsel.idColour;
217 outlineColour = seqsel.outlineColour;
218 seqrep = seqsel.seqrep;
219 textColour = seqsel.textColour;
220 textColour2 = seqsel.textColour2;
221 thresholdTextColour = seqsel.thresholdTextColour;
222 width = seqsel.width;
223 ignoreGapsInConsensus = seqsel.ignoreGapsInConsensus;
224 ignoreBelowBackground = seqsel.ignoreBelowBackground;
225 if (seqsel.conserve != null)
227 recalcConservation(); // safer than
228 // aaFrequency = (Vector) seqsel.aaFrequency.clone(); // ??
233 public boolean isShowSequenceLogo()
235 return showSequenceLogo;
238 public SequenceI[] getSelectionAsNewSequences(AlignmentI align)
240 int iSize = sequences.size();
241 SequenceI[] seqs = new SequenceI[iSize];
242 SequenceI[] inorder = getSequencesInOrder(align);
244 for (int i = 0, ipos = 0; i < inorder.length; i++)
246 SequenceI seq = inorder[i];
248 seqs[ipos] = seq.getSubSequence(startRes, endRes + 1);
249 if (seqs[ipos] != null)
251 seqs[ipos].setDescription(seq.getDescription());
252 seqs[ipos].setDBRefs(seq.getDBRefs());
253 seqs[ipos].setSequenceFeatures(seq.getSequenceFeatures());
254 if (seq.getDatasetSequence() != null)
256 seqs[ipos].setDatasetSequence(seq.getDatasetSequence());
259 if (seq.getAnnotation() != null)
261 AlignmentAnnotation[] alann = align.getAlignmentAnnotation();
262 // Only copy annotation that is either a score or referenced by the
263 // alignment's annotation vector
264 for (int a = 0; a < seq.getAnnotation().length; a++)
266 AlignmentAnnotation tocopy = seq.getAnnotation()[a];
269 boolean found = false;
270 for (int pos = 0; pos < alann.length; pos++)
272 if (alann[pos] == tocopy)
283 AlignmentAnnotation newannot = new AlignmentAnnotation(
284 seq.getAnnotation()[a]);
285 newannot.restrict(startRes, endRes);
286 newannot.setSequenceRef(seqs[ipos]);
287 newannot.adjustForAlignment();
288 seqs[ipos].addAlignmentAnnotation(newannot);
298 if (iSize != inorder.length)
300 SequenceI[] nseqs = new SequenceI[iSize];
301 System.arraycopy(seqs, 0, nseqs, 0, iSize);
309 * If sequence ends in gaps, the end residue can be correctly calculated here
315 public int findEndRes(SequenceI seq)
320 for (int j = 0; j < endRes + 1 && j < seq.getLength(); j++)
322 ch = seq.getCharAt(j);
323 if (!jalview.util.Comparison.isGap((ch)))
331 eres += seq.getStart() - 1;
338 public List<SequenceI> getSequences()
344 public List<SequenceI> getSequences(
345 Map<SequenceI, SequenceCollectionI> hiddenReps)
347 if (hiddenReps == null)
349 // TODO: need a synchronizedCollection here ?
354 List<SequenceI> allSequences = new ArrayList<>();
355 for (SequenceI seq : sequences)
357 allSequences.add(seq);
358 if (hiddenReps.containsKey(seq))
360 SequenceCollectionI hsg = hiddenReps.get(seq);
361 for (SequenceI seq2 : hsg.getSequences())
363 if (seq2 != seq && !allSequences.contains(seq2))
365 allSequences.add(seq2);
375 public SequenceI[] getSequencesAsArray(
376 Map<SequenceI, SequenceCollectionI> map)
378 List<SequenceI> tmp = getSequences(map);
383 return tmp.toArray(new SequenceI[tmp.size()]);
392 * @return DOCUMENT ME!
394 public boolean adjustForRemoveLeft(int col)
396 // return value is true if the group still exists
399 startRes = startRes - col;
404 endRes = endRes - col;
406 if (startRes > endRes)
413 // must delete this group!!
426 * @return DOCUMENT ME!
428 public boolean adjustForRemoveRight(int col)
447 * @return DOCUMENT ME!
449 public String getName()
454 public String getDescription()
465 public void setName(String name)
468 // TODO: URGENT: update dependent objects (annotation row)
471 public void setDescription(String desc)
479 * @return DOCUMENT ME!
481 public Conservation getConservation()
492 public void setConservation(Conservation c)
498 * Add s to this sequence group. If aligment sequence is already contained in
499 * group, it will not be added again, but recalculation may happen if the flag
503 * alignment sequence to be added
505 * true means Group's conservation should be recalculated
507 public void addSequence(SequenceI s, boolean recalc)
509 synchronized (sequences)
511 if (s != null && !sequences.contains(s))
518 recalcConservation();
524 * Max Gaps Threshold (percent) for performing a conservation calculation
526 private int consPercGaps = 25;
529 * @return Max Gaps Threshold for performing a conservation calculation
531 public int getConsPercGaps()
537 * set Max Gaps Threshold (percent) for performing a conservation calculation
539 * @param consPercGaps
541 public void setConsPercGaps(int consPercGaps)
543 this.consPercGaps = consPercGaps;
547 * calculate residue conservation and colourschemes for group - but only if
548 * necessary. returns true if the calculation resulted in a visible change to
551 public boolean recalcConservation()
553 return recalcConservation(false);
557 * calculate residue conservation for group - but only if necessary. returns
558 * true if the calculation resulted in a visible change to group
561 * when set, colourschemes for this group are not refreshed after
564 public boolean recalcConservation(boolean defer)
566 if (cs == null && consensus == null && conservation == null
567 && information == null)
571 // TODO: try harder to detect changes in state in order to minimise
572 // recalculation effort
576 ProfilesI cnsns = AAFrequency.calculate(sequences, startRes,
577 endRes + 1, showSequenceLogo);
578 if (information != null)
580 HiddenMarkovModel hmm = information.sequenceRef.getHMM();
582 ProfilesI info = AAFrequency.calculateHMMProfiles(hmm,
583 (endRes + 1) - startRes, startRes, endRes + 1,
584 showHMMSequenceLogo, ignoreBelowBackground);
585 _updateInformationRow(info, sequences.size());
588 if (consensus != null)
590 _updateConsensusRow(cnsns, sequences.size());
595 cs.setConsensus(cnsns);
599 if ((conservation != null)
600 || (cs != null && cs.conservationApplied()))
602 Conservation c = new Conservation(groupName, sequences, startRes,
605 c.verdict(false, consPercGaps);
606 if (conservation != null)
608 _updateConservationRow(c);
612 if (cs.conservationApplied())
614 cs.setConservation(c);
617 // eager update - will cause a refresh of overview regardless
620 if (cs != null && !defer)
622 // TODO: JAL-2034 should cs.alignmentChanged modify return state
623 cs.alignmentChanged(context != null ? context : this, null);
630 } catch (java.lang.OutOfMemoryError err)
633 System.out.println("Out of memory loading groups: " + err);
638 private void _updateConservationRow(Conservation c)
640 if (conservation == null)
645 conservation.label = "Conservation for " + getName();
646 conservation.description = "Conservation for group " + getName()
647 + " less than " + consPercGaps + "% gaps";
648 // preserve width if already set
649 int aWidth = (conservation.annotations != null)
650 ? (endRes < conservation.annotations.length
651 ? conservation.annotations.length
654 conservation.annotations = null;
655 conservation.annotations = new Annotation[aWidth]; // should be alignment
657 c.completeAnnotations(conservation, null, startRes, endRes + 1);
660 public ProfilesI consensusData = null;
662 public ProfilesI informationData = null;
664 private void _updateConsensusRow(ProfilesI cnsns, long nseq)
666 if (consensus == null)
670 consensus.label = "Consensus for " + getName();
671 consensus.description = "Percent Identity";
672 consensusData = cnsns;
673 // preserve width if already set
674 int aWidth = (consensus.annotations != null)
675 ? (endRes < consensus.annotations.length
676 ? consensus.annotations.length
679 consensus.annotations = null;
680 consensus.annotations = new Annotation[aWidth]; // should be alignment width
682 AAFrequency.completeConsensus(consensus, cnsns, startRes, endRes + 1,
683 ignoreGapsInConsensus, showSequenceLogo, nseq); // TODO: setting
686 // ignoreGapsInConsensusCalculation);
690 * Recalculates the information content on the HMM annotation.
695 private void _updateInformationRow(ProfilesI cnsns, long nseq)
697 if (information == null)
701 information.description = MessageManager
702 .getString("label.information_description");
703 informationData = cnsns;
704 // preserve width if already set
705 int aWidth = (information.annotations != null)
706 ? (endRes < information.annotations.length
707 ? information.annotations.length : endRes + 1)
709 information.annotations = null;
710 information.annotations = new Annotation[aWidth]; // should be alignment
712 information.calcId = "HMM";
713 AAFrequency.completeInformation(information, cnsns, startRes,
714 endRes + 1, ignoreBelowBackground, showSequenceLogo, nseq); // TODO:
718 // ignoreGapsInInformationCalculation);
723 * sequence to either add or remove from group
725 * flag passed to delete/addSequence to indicate if group properties
726 * should be recalculated
728 public void addOrRemove(SequenceI s, boolean recalc)
730 synchronized (sequences)
732 if (sequences.contains(s))
734 deleteSequence(s, recalc);
738 addSequence(s, recalc);
749 * true means recalculate conservation
751 public void deleteSequence(SequenceI s, boolean recalc)
753 synchronized (sequences)
759 recalcConservation();
767 * @return the first column selected by this group. Runs from 0<=i<N_cols
770 public int getStartRes()
777 * @return the groups last selected column. Runs from 0<=i<N_cols
780 public int getEndRes()
786 * Set the first column selected by this group. Runs from 0<=i<N_cols
790 public void setStartRes(int i)
796 * Set the groups last selected column. Runs from 0<=i<N_cols
800 public void setEndRes(int i)
806 * @return number of sequences in group
810 return sequences.size();
815 * @return the ith sequence
817 public SequenceI getSequenceAt(int i)
819 return sequences.get(i);
826 public void setColourText(boolean state)
834 * @return DOCUMENT ME!
836 public boolean getColourText()
847 public void setDisplayText(boolean state)
855 * @return DOCUMENT ME!
857 public boolean getDisplayText()
868 public void setDisplayBoxes(boolean state)
870 displayBoxes = state;
876 * @return DOCUMENT ME!
878 public boolean getDisplayBoxes()
884 * computes the width of current set of sequences and returns it
886 * @return DOCUMENT ME!
889 public int getWidth()
891 synchronized (sequences)
893 // MC This needs to get reset when characters are inserted and deleted
894 boolean first = true;
895 for (SequenceI seq : sequences)
897 if (first || seq.getLength() > width)
899 width = seq.getLength();
913 public void setOutlineColour(Color c)
921 * @return DOCUMENT ME!
923 public Color getOutlineColour()
925 return outlineColour;
930 * returns the sequences in the group ordered by the ordering given by al.
931 * this used to return an array with null entries regardless, new behaviour is
932 * below. TODO: verify that this does not affect use in applet or application
936 * @return SequenceI[] intersection of sequences in group with al, ordered by
937 * al, or null if group does not intersect with al
939 public SequenceI[] getSequencesInOrder(AlignmentI al)
941 return getSequencesInOrder(al, true);
945 * return an array representing the intersection of the group with al,
946 * optionally returning an array the size of al.getHeight() where nulls mark
947 * the non-intersected sequences
951 * @return null or array
953 public SequenceI[] getSequencesInOrder(AlignmentI al, boolean trim)
955 synchronized (sequences)
957 int sSize = sequences.size();
958 int alHeight = al.getHeight();
960 SequenceI[] seqs = new SequenceI[(trim) ? sSize : alHeight];
963 for (int i = 0; i < alHeight && index < sSize; i++)
965 if (sequences.contains(al.getSequenceAt(i)))
967 seqs[(trim) ? index : i] = al.getSequenceAt(i);
979 if (index < seqs.length)
981 SequenceI[] dummy = seqs;
982 seqs = new SequenceI[index];
985 seqs[index] = dummy[index];
994 * @return the idColour
996 public Color getIdColour()
1003 * the idColour to set
1005 public void setIdColour(Color idColour)
1007 this.idColour = idColour;
1011 * @return the representative sequence for this group
1014 public SequenceI getSeqrep()
1020 * set the representative sequence for this group. Note - this affects the
1021 * interpretation of the Hidereps attribute.
1024 * the seqrep to set (null means no sequence representative)
1027 public void setSeqrep(SequenceI seqrep)
1029 this.seqrep = seqrep;
1034 * @return true if group has a sequence representative
1037 public boolean hasSeqrep()
1039 return seqrep != null;
1043 * set visibility of sequences covered by (if no sequence representative is
1044 * defined) or represented by this group.
1048 public void setHidereps(boolean visibility)
1050 hidereps = visibility;
1055 * @return true if sequences represented (or covered) by this group should be
1058 public boolean isHidereps()
1064 * set intended visibility of columns covered by this group
1068 public void setHideCols(boolean visibility)
1070 hidecols = visibility;
1075 * @return true if columns covered by group should be hidden
1077 public boolean isHideCols()
1083 * create a new sequence group from the intersection of this group with an
1084 * alignment Hashtable of hidden representatives
1090 * @return new group containing sequences common to this group and alignment
1092 public SequenceGroup intersect(AlignmentI alignment,
1093 Map<SequenceI, SequenceCollectionI> map)
1095 SequenceGroup sgroup = new SequenceGroup(this);
1096 SequenceI[] insect = getSequencesInOrder(alignment);
1097 sgroup.sequences = new ArrayList<>();
1098 for (int s = 0; insect != null && s < insect.length; s++)
1100 if (map == null || map.containsKey(insect[s]))
1102 sgroup.sequences.add(insect[s]);
1109 * @return the showUnconserved
1111 public boolean getShowNonconserved()
1113 return showNonconserved;
1117 * @param showNonconserved
1118 * the showUnconserved to set
1120 public void setShowNonconserved(boolean displayNonconserved)
1122 this.showNonconserved = displayNonconserved;
1126 * set this alignmentAnnotation object as the one used to render consensus
1131 public void setConsensus(AlignmentAnnotation aan)
1133 if (consensus == null)
1141 * @return automatically calculated consensus row note: the row is a stub if a
1142 * consensus calculation has not yet been performed on the group
1144 public AlignmentAnnotation getConsensus()
1146 // TODO get or calculate and get consensus annotation row for this group
1147 int aWidth = this.getWidth();
1155 if (consensus == null)
1157 consensus = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1158 100f, AlignmentAnnotation.BAR_GRAPH);
1159 consensus.hasText = true;
1160 consensus.autoCalculated = true;
1161 consensus.groupRef = this;
1162 consensus.label = "Consensus for " + getName();
1163 consensus.description = "Percent Identity";
1170 * @return information content annotation.
1172 public AlignmentAnnotation getInformation()
1174 // TODO get or calculate and get information annotation row for this group
1175 int aWidth = this.getWidth();
1183 if (information == null)
1185 information = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1186 6.25f, AlignmentAnnotation.BAR_GRAPH);
1187 information.hasText = true;
1188 information.autoCalculated = false;
1189 information.groupRef = this;
1190 information.label = getName();
1191 information.description = "Information content, measured in bits";
1192 information.calcId = "HMM";
1198 * set this alignmentAnnotation object as the one used to render consensus
1203 public void setConservationRow(AlignmentAnnotation aan)
1205 if (conservation == null)
1212 * get the conservation annotation row for this group
1214 * @return autoCalculated annotation row
1216 public AlignmentAnnotation getConservationRow()
1218 if (conservation == null)
1220 conservation = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1221 11f, AlignmentAnnotation.BAR_GRAPH);
1224 conservation.hasText = true;
1225 conservation.autoCalculated = true;
1226 conservation.groupRef = this;
1227 conservation.label = "Conservation for " + getName();
1228 conservation.description = "Conservation for group " + getName()
1229 + " less than " + consPercGaps + "% gaps";
1230 return conservation;
1235 * @return true if annotation rows have been instantiated for this group
1237 public boolean hasAnnotationRows()
1239 return consensus != null || conservation != null;
1242 public SequenceI getConsensusSeq()
1245 StringBuffer seqs = new StringBuffer();
1246 for (int i = 0; i < consensus.annotations.length; i++)
1248 if (consensus.annotations[i] != null)
1250 if (consensus.annotations[i].description.charAt(0) == '[')
1252 seqs.append(consensus.annotations[i].description.charAt(1));
1256 seqs.append(consensus.annotations[i].displayCharacter);
1261 SequenceI sq = new Sequence("Group" + getName() + " Consensus",
1263 sq.setDescription("Percentage Identity Consensus "
1264 + ((ignoreGapsInConsensus) ? " without gaps" : ""));
1268 public void setIgnoreGapsConsensus(boolean state)
1270 if (this.ignoreGapsInConsensus != state && consensus != null)
1272 ignoreGapsInConsensus = state;
1273 recalcConservation();
1275 ignoreGapsInConsensus = state;
1278 public boolean getIgnoreGapsConsensus()
1280 return ignoreGapsInConsensus;
1283 public void setIgnoreBelowBackground(boolean state)
1285 if (this.ignoreBelowBackground != state)
1287 ignoreBelowBackground = state;
1289 ignoreBelowBackground = state;
1292 public boolean getIgnoreBelowBackground()
1298 * @param showSequenceLogo
1299 * indicates if a sequence logo is shown for consensus annotation
1301 public void setshowSequenceLogo(boolean showSequenceLogo)
1303 // TODO: decouple calculation from settings update
1304 if (this.showSequenceLogo != showSequenceLogo && consensus != null)
1306 this.showSequenceLogo = showSequenceLogo;
1307 recalcConservation();
1309 this.showSequenceLogo = showSequenceLogo;
1314 * @param showConsHist
1315 * flag indicating if the consensus histogram for this group should
1318 public void setShowConsensusHistogram(boolean showConsHist)
1321 if (showConsensusHistogram != showConsHist && consensus != null)
1323 this.showConsensusHistogram = showConsHist;
1324 recalcConservation();
1326 this.showConsensusHistogram = showConsHist;
1330 * @return the showConsensusHistogram
1332 public boolean isShowConsensusHistogram()
1334 return showConsensusHistogram;
1338 * set flag indicating if logo should be normalised when rendered
1342 public void setNormaliseSequenceLogo(boolean norm)
1344 normaliseSequenceLogo = norm;
1347 public boolean isNormaliseSequenceLogo()
1349 return normaliseSequenceLogo;
1354 * returns a new array with all annotation involving this group
1356 public AlignmentAnnotation[] getAlignmentAnnotation()
1358 // TODO add in other methods like 'getAlignmentAnnotation(String label),
1360 ArrayList<AlignmentAnnotation> annot = new ArrayList<>();
1361 synchronized (sequences)
1363 for (SequenceI seq : sequences)
1365 AlignmentAnnotation[] aa = seq.getAnnotation();
1368 for (AlignmentAnnotation al : aa)
1370 if (al.groupRef == this)
1377 if (consensus != null)
1379 annot.add(consensus);
1381 if (conservation != null)
1383 annot.add(conservation);
1386 return annot.toArray(new AlignmentAnnotation[0]);
1390 public Iterable<AlignmentAnnotation> findAnnotation(String calcId)
1392 List<AlignmentAnnotation> aa = new ArrayList<>();
1397 for (AlignmentAnnotation a : getAlignmentAnnotation())
1399 if (calcId.equals(a.getCalcId()))
1408 public Iterable<AlignmentAnnotation> findAnnotations(SequenceI seq,
1409 String calcId, String label)
1411 ArrayList<AlignmentAnnotation> aa = new ArrayList<>();
1412 for (AlignmentAnnotation ann : getAlignmentAnnotation())
1414 if ((calcId == null || (ann.getCalcId() != null
1415 && ann.getCalcId().equals(calcId)))
1416 && (seq == null || (ann.sequenceRef != null
1417 && ann.sequenceRef == seq))
1419 || (ann.label != null && ann.label.equals(label))))
1428 * Answer true if any annotation matches the calcId passed in (if not null).
1433 public boolean hasAnnotation(String calcId)
1435 if (calcId != null && !"".equals(calcId))
1437 for (AlignmentAnnotation a : getAlignmentAnnotation())
1439 if (a.getCalcId() == calcId)
1449 * Remove all sequences from the group (leaving other properties unchanged).
1453 synchronized (sequences)
1460 * Sets the alignment or group context for this group, and whether it is
1461 * defined as a group
1464 * the context for the group
1466 * whether the group is defined on the alignment or is just a
1468 * @throws IllegalArgumentException
1469 * if setting the context would result in a circular reference chain
1471 public void setContext(AnnotatedCollectionI ctx, boolean defined)
1474 this.isDefined = defined;
1478 * Sets the alignment or group context for this group
1481 * the context for the group
1482 * @throws IllegalArgumentException
1483 * if setting the context would result in a circular reference chain
1485 public void setContext(AnnotatedCollectionI ctx)
1487 AnnotatedCollectionI ref = ctx;
1490 if (ref == this || ref.getContext() == ctx)
1492 throw new IllegalArgumentException(
1493 "Circular reference in SequenceGroup.context");
1495 ref = ref.getContext();
1503 * @see jalview.datamodel.AnnotatedCollectionI#getContext()
1506 public AnnotatedCollectionI getContext()
1511 public boolean isDefined()
1516 public void setColourScheme(ColourSchemeI scheme)
1520 cs = new ResidueShader();
1522 cs.setColourScheme(scheme);
1525 public void setGroupColourScheme(ResidueShaderI scheme)
1530 public ColourSchemeI getColourScheme()
1532 return cs == null ? null : cs.getColourScheme();
1535 public ResidueShaderI getGroupColourScheme()
1541 public boolean isNucleotide()
1543 if (context != null)
1545 return context.isNucleotide();
1552 * @return true if seq is a member of the group
1555 public boolean contains(SequenceI seq1)
1557 return sequences.contains(seq1);
1563 * @return true if startRes<=apos and endRes>=apos and seq is in the group
1565 public boolean contains(SequenceI seq, int apos)
1567 return (startRes <= apos && endRes >= apos) && sequences.contains(seq);
1570 public boolean isShowInformationHistogram()
1572 return showInformationHistogram;
1575 public void setShowInformationHistogram(boolean state)
1577 if (showInformationHistogram != state && information != null)
1579 this.showInformationHistogram = state;
1580 // recalcConservation(); TODO don't know what to do here next
1582 this.showInformationHistogram = state;
1586 public boolean isShowHMMSequenceLogo()
1588 // TODO Auto-generated method stub
1589 return showHMMSequenceLogo;
1592 public void setshowHMMSequenceLogo(boolean state)
1594 showHMMSequenceLogo = state;
1598 public boolean isNormaliseHMMSequenceLogo()
1600 // TODO Auto-generated method stub
1601 return normaliseHMMSequenceLogo;
1604 public void setNormaliseHMMSequenceLogo(boolean state)
1606 normaliseSequenceLogo = state;
1610 * Returns all HMM consensus sequences. This will not return real sequences
1611 * with HMMs. If remove is set to true, the consensus sequences will be
1612 * removed from the alignment.
1614 @Override // TODO make this more efficient.
1615 public List<SequenceI> getHMMConsensusSequences(boolean remove)
1617 List<SequenceI> seqs = new ArrayList<>();
1619 int seqsRemoved = 0;
1620 boolean endReached = false;
1624 SequenceI seq = sequences.get(position);
1625 if (seq.isHMMConsensusSequence())
1629 sequences.remove(position);
1631 seq.setPreviousPosition(seqsRemoved + position - 1);
1644 if (position >= sequences.size())