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 java.awt.Color;
24 import java.beans.PropertyChangeListener;
25 import java.beans.PropertyChangeSupport;
26 import java.util.ArrayList;
27 import java.util.Arrays;
28 import java.util.Collection;
29 import java.util.List;
32 import jalview.analysis.AAFrequency;
33 import jalview.analysis.Conservation;
34 import jalview.renderer.ResidueShader;
35 import jalview.renderer.ResidueShaderI;
36 import jalview.schemes.ColourSchemeI;
39 * Collects a set contiguous ranges on a set of sequences
44 public class SequenceGroup implements AnnotatedCollectionI
46 // TODO ideally this event notification functionality should be separated into
48 // subclass of ViewportProperties similarly to ViewportRanges. Done here as
49 // quick fix for JAL-2665
50 public static final String SEQ_GROUP_CHANGED = "Sequence group changed";
52 protected PropertyChangeSupport changeSupport = new PropertyChangeSupport(
55 public void addPropertyChangeListener(PropertyChangeListener listener)
57 changeSupport.addPropertyChangeListener(listener);
60 public void removePropertyChangeListener(PropertyChangeListener listener)
62 changeSupport.removePropertyChangeListener(listener);
64 // end of event notification functionality initialisation
70 Conservation conserve;
72 boolean displayBoxes = true;
74 boolean displayText = true;
76 boolean colourText = false;
79 * True if the group is defined as a group on the alignment, false if it is
82 boolean isDefined = false;
85 * after Olivier's non-conserved only character display
87 boolean showNonconserved = false;
92 private List<SequenceI> sequences;
95 * representative sequence for this group (if any)
97 private SequenceI seqrep = null;
102 * Colourscheme applied to group if any
104 public ResidueShaderI cs;
107 * start column (base 0)
109 private int startRes = 0;
112 * end column (base 0)
114 private int endRes = 0;
116 public Color outlineColour = Color.black;
118 public Color idColour = null;
120 public int thresholdTextColour = 0;
122 public Color textColour = Color.black;
124 public Color textColour2 = Color.white;
127 * consensus calculation property
129 private boolean ignoreGapsInConsensus = true;
132 * consensus calculation property
134 private boolean showSequenceLogo = false;
137 * flag indicating if logo should be rendered normalised
139 private boolean normaliseSequenceLogo;
142 * visibility of rows or represented rows covered by group
144 private boolean hidereps = false;
147 * visibility of columns intersecting this group
149 private boolean hidecols = false;
151 AlignmentAnnotation consensus = null;
153 AlignmentAnnotation conservation = null;
155 private boolean showConsensusHistogram;
157 private AnnotatedCollectionI context;
160 * Creates a new SequenceGroup object.
162 public SequenceGroup()
164 groupName = "JGroup:" + this.hashCode();
165 cs = new ResidueShader();
166 sequences = new ArrayList<>();
170 * Creates a new SequenceGroup object.
175 * @param displayBoxes
179 * first column of group
181 * last column of group
183 public SequenceGroup(List<SequenceI> sequences, String groupName,
184 ColourSchemeI scheme, boolean displayBoxes, boolean displayText,
185 boolean colourText, int start, int end)
188 this.sequences = sequences;
189 this.groupName = groupName;
190 this.displayBoxes = displayBoxes;
191 this.displayText = displayText;
192 this.colourText = colourText;
193 this.cs = new ResidueShader(scheme);
196 recalcConservation();
204 public SequenceGroup(SequenceGroup seqsel)
209 sequences = new ArrayList<>();
210 sequences.addAll(seqsel.sequences);
211 if (seqsel.groupName != null)
213 groupName = new String(seqsel.groupName);
215 displayBoxes = seqsel.displayBoxes;
216 displayText = seqsel.displayText;
217 colourText = seqsel.colourText;
219 startRes = seqsel.startRes;
220 endRes = seqsel.endRes;
221 cs = new ResidueShader((ResidueShader) seqsel.cs);
222 if (seqsel.description != null)
224 description = new String(seqsel.description);
226 hidecols = seqsel.hidecols;
227 hidereps = seqsel.hidereps;
228 showNonconserved = seqsel.showNonconserved;
229 showSequenceLogo = seqsel.showSequenceLogo;
230 normaliseSequenceLogo = seqsel.normaliseSequenceLogo;
231 showConsensusHistogram = seqsel.showConsensusHistogram;
232 idColour = seqsel.idColour;
233 outlineColour = seqsel.outlineColour;
234 seqrep = seqsel.seqrep;
235 textColour = seqsel.textColour;
236 textColour2 = seqsel.textColour2;
237 thresholdTextColour = seqsel.thresholdTextColour;
238 width = seqsel.width;
239 ignoreGapsInConsensus = seqsel.ignoreGapsInConsensus;
240 if (seqsel.conserve != null)
242 recalcConservation(); // safer than
243 // aaFrequency = (Vector) seqsel.aaFrequency.clone(); // ??
249 * Constructor that copies the given list of sequences
253 public SequenceGroup(List<SequenceI> seqs)
256 this.sequences.addAll(seqs);
259 public boolean isShowSequenceLogo()
261 return showSequenceLogo;
264 public SequenceI[] getSelectionAsNewSequences(AlignmentI align)
266 int iSize = sequences.size();
267 SequenceI[] seqs = new SequenceI[iSize];
268 SequenceI[] inorder = getSequencesInOrder(align);
270 for (int i = 0, ipos = 0; i < inorder.length; i++)
272 SequenceI seq = inorder[i];
273 SequenceI seqipos = seqs[ipos] = seq.getSubSequence(startRes,
277 if (seq.getAnnotation() != null)
279 AlignmentAnnotation[] alann = align.getAlignmentAnnotation();
280 // Only copy annotation that is either a score or referenced by the
281 // alignment's annotation vector
282 for (int a = 0; a < seq.getAnnotation().length; a++)
284 AlignmentAnnotation tocopy = seq.getAnnotation()[a];
287 boolean found = false;
288 for (int pos = 0, np = alann.length; pos < np; pos++)
290 if (alann[pos] == tocopy)
301 AlignmentAnnotation newannot = new AlignmentAnnotation(
302 seq.getAnnotation()[a]);
303 newannot.restrict(startRes, endRes);
304 newannot.setSequenceRef(seqs[ipos]);
305 newannot.adjustForAlignment();
306 ContactMatrixI cm = seq
307 .getContactMatrixFor(seq.getAnnotation()[a]);
310 seqs[ipos].addContactListFor(newannot, cm);
312 seqipos.addAlignmentAnnotation(newannot);
322 if (iSize != inorder.length)
324 SequenceI[] nseqs = new SequenceI[iSize];
325 System.arraycopy(seqs, 0, nseqs, 0, iSize);
333 * If sequence ends in gaps, the end residue can be correctly calculated here
339 public int findEndRes(SequenceI seq)
344 for (int j = 0; j < endRes + 1 && j < seq.getLength(); j++)
346 ch = seq.getCharAt(j);
347 if (!jalview.util.Comparison.isGap((ch)))
355 eres += seq.getStart() - 1;
362 public List<SequenceI> getSequences()
368 public List<SequenceI> getSequences(
369 Map<SequenceI, SequenceCollectionI> hiddenReps)
371 if (hiddenReps == null)
373 // TODO: need a synchronizedCollection here ?
378 List<SequenceI> allSequences = new ArrayList<>();
379 for (SequenceI seq : sequences)
381 allSequences.add(seq);
382 if (hiddenReps.containsKey(seq))
384 SequenceCollectionI hsg = hiddenReps.get(seq);
385 for (SequenceI seq2 : hsg.getSequences())
387 if (seq2 != seq && !allSequences.contains(seq2))
389 allSequences.add(seq2);
399 public SequenceI[] getSequencesAsArray(
400 Map<SequenceI, SequenceCollectionI> map)
402 List<SequenceI> tmp = getSequences(map);
407 return tmp.toArray(new SequenceI[tmp.size()]);
416 * @return DOCUMENT ME!
418 public boolean adjustForRemoveLeft(int col)
420 // return value is true if the group still exists
423 startRes = startRes - col;
428 endRes = endRes - col;
430 if (startRes > endRes)
437 // must delete this group!!
450 * @return DOCUMENT ME!
452 public boolean adjustForRemoveRight(int col)
471 * @return DOCUMENT ME!
473 public String getName()
478 public String getDescription()
489 public void setName(String name)
492 // TODO: URGENT: update dependent objects (annotation row)
495 public void setDescription(String desc)
503 * @return DOCUMENT ME!
505 public Conservation getConservation()
516 public void setConservation(Conservation c)
522 * Add s to this sequence group. If aligment sequence is already contained in
523 * group, it will not be added again, but recalculation may happen if the flag
527 * alignment sequence to be added
529 * true means Group's conservation should be recalculated
531 public void addSequence(SequenceI s, boolean recalc)
533 synchronized (sequences)
535 if (s != null && !sequences.contains(s))
538 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED,
539 sequences.size() - 1, sequences.size());
544 recalcConservation();
550 * Max Gaps Threshold (percent) for performing a conservation calculation
552 private int consPercGaps = 25;
555 * @return Max Gaps Threshold for performing a conservation calculation
557 public int getConsPercGaps()
563 * set Max Gaps Threshold (percent) for performing a conservation calculation
565 * @param consPercGaps
567 public void setConsPercGaps(int consPercGaps)
569 this.consPercGaps = consPercGaps;
573 * calculate residue conservation and colourschemes for group - but only if
574 * necessary. returns true if the calculation resulted in a visible change to
577 public boolean recalcConservation()
579 return recalcConservation(false);
583 * calculate residue conservation for group - but only if necessary. returns
584 * true if the calculation resulted in a visible change to group
587 * when set, colourschemes for this group are not refreshed after
590 public boolean recalcConservation(boolean defer)
592 if (cs == null && consensus == null && conservation == null)
596 // TODO: try harder to detect changes in state in order to minimise
597 // recalculation effort
601 ProfilesI cnsns = AAFrequency.calculate(sequences, startRes,
602 endRes + 1, showSequenceLogo);
603 if (consensus != null)
605 _updateConsensusRow(cnsns, sequences.size());
610 cs.setConsensus(cnsns);
614 if ((conservation != null)
615 || (cs != null && cs.conservationApplied()))
617 Conservation c = new Conservation(groupName, sequences, startRes,
620 c.verdict(false, consPercGaps);
621 if (conservation != null)
623 _updateConservationRow(c);
627 if (cs.conservationApplied())
629 cs.setConservation(c);
632 // eager update - will cause a refresh of overview regardless
635 if (cs != null && !defer)
637 // TODO: JAL-2034 should cs.alignmentChanged modify return state
638 cs.alignmentChanged(context != null ? context : this, null);
645 } catch (java.lang.OutOfMemoryError err)
649 .outPrintln("Out of memory loading groups: " + err);
654 private void _updateConservationRow(Conservation c)
656 if (conservation == null)
661 conservation.label = "Conservation for " + getName();
662 conservation.description = "Conservation for group " + getName()
663 + " less than " + consPercGaps + "% gaps";
664 // preserve width if already set
665 int aWidth = (conservation.annotations != null)
666 ? (endRes < conservation.annotations.length
667 ? conservation.annotations.length
670 conservation.annotations = null;
671 conservation.annotations = new Annotation[aWidth]; // should be alignment
673 c.completeAnnotations(conservation, null, startRes, endRes + 1);
676 public ProfilesI consensusData = null;
678 private void _updateConsensusRow(ProfilesI cnsns, long nseq)
680 if (consensus == null)
684 consensus.label = "Consensus for " + getName();
685 consensus.description = "Percent Identity";
686 consensusData = cnsns;
687 // preserve width if already set
688 int aWidth = (consensus.annotations != null)
689 ? (endRes < consensus.annotations.length
690 ? consensus.annotations.length
693 consensus.annotations = null;
694 consensus.annotations = new Annotation[aWidth]; // should be alignment width
696 AAFrequency.completeConsensus(consensus, cnsns, startRes, endRes + 1,
697 ignoreGapsInConsensus, showSequenceLogo, nseq); // TODO: setting
700 // ignoreGapsInConsensusCalculation);
705 * sequence to either add or remove from group
707 * flag passed to delete/addSequence to indicate if group properties
708 * should be recalculated
710 public void addOrRemove(SequenceI s, boolean recalc)
712 synchronized (sequences)
714 if (sequences.contains(s))
716 deleteSequence(s, recalc);
720 addSequence(s, recalc);
731 * true means recalculate conservation
733 public void deleteSequence(SequenceI s, boolean recalc)
735 synchronized (sequences)
738 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED,
739 sequences.size() + 1, sequences.size());
743 recalcConservation();
751 * @return the first column selected by this group. Runs from 0<=i<N_cols
754 public int getStartRes()
761 * @return the groups last selected column. Runs from 0<=i<N_cols
764 public int getEndRes()
770 * Set the first column selected by this group. Runs from 0<=i<N_cols
774 public void setStartRes(int newStart)
776 int before = startRes;
777 startRes = Math.max(0, newStart); // sanity check for negative start column
779 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, startRes);
784 * Set the groups last selected column. Runs from 0<=i<N_cols
788 public void setEndRes(int i)
792 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, endRes);
796 * @return number of sequences in group
800 return sequences.size();
805 * @return the ith sequence
807 public SequenceI getSequenceAt(int i)
809 return sequences.get(i);
816 public void setColourText(boolean state)
824 * @return DOCUMENT ME!
826 public boolean getColourText()
837 public void setDisplayText(boolean state)
845 * @return DOCUMENT ME!
847 public boolean getDisplayText()
858 public void setDisplayBoxes(boolean state)
860 displayBoxes = state;
866 * @return DOCUMENT ME!
868 public boolean getDisplayBoxes()
874 * computes the width of current set of sequences and returns it
876 * @return DOCUMENT ME!
879 public int getWidth()
881 synchronized (sequences)
883 // MC This needs to get reset when characters are inserted and deleted
884 boolean first = true;
885 for (SequenceI seq : sequences)
887 if (first || seq.getLength() > width)
889 width = seq.getLength();
903 public void setOutlineColour(Color c)
911 * @return DOCUMENT ME!
913 public Color getOutlineColour()
915 return outlineColour;
920 * returns the sequences in the group ordered by the ordering given by al.
921 * this used to return an array with null entries regardless, new behaviour is
922 * below. TODO: verify that this does not affect use in applet or application
926 * @return SequenceI[] intersection of sequences in group with al, ordered by
927 * al, or null if group does not intersect with al
929 public SequenceI[] getSequencesInOrder(AlignmentI al)
931 return getSequencesInOrder(al, true);
935 * return an array representing the intersection of the group with al,
936 * optionally returning an array the size of al.getHeight() where nulls mark
937 * the non-intersected sequences
941 * @return null or array
943 public SequenceI[] getSequencesInOrder(AlignmentI al, boolean trim)
945 synchronized (sequences)
947 int sSize = sequences.size();
948 int alHeight = al.getHeight();
950 SequenceI[] seqs = new SequenceI[(trim) ? sSize : alHeight];
953 for (int i = 0; i < alHeight && index < sSize; i++)
955 if (sequences.contains(al.getSequenceAt(i)))
957 seqs[(trim) ? index : i] = al.getSequenceAt(i);
969 if (index < seqs.length)
971 SequenceI[] dummy = seqs;
972 seqs = new SequenceI[index];
975 seqs[index] = dummy[index];
984 * @return the idColour
986 public Color getIdColour()
993 * the idColour to set
995 public void setIdColour(Color idColour)
997 this.idColour = idColour;
1001 * @return the representative sequence for this group
1004 public SequenceI getSeqrep()
1010 * set the representative sequence for this group. Note - this affects the
1011 * interpretation of the Hidereps attribute.
1014 * the seqrep to set (null means no sequence representative)
1017 public void setSeqrep(SequenceI seqrep)
1019 this.seqrep = seqrep;
1024 * @return true if group has a sequence representative
1027 public boolean hasSeqrep()
1029 return seqrep != null;
1033 * set visibility of sequences covered by (if no sequence representative is
1034 * defined) or represented by this group.
1038 public void setHidereps(boolean visibility)
1040 hidereps = visibility;
1045 * @return true if sequences represented (or covered) by this group should be
1048 public boolean isHidereps()
1054 * set intended visibility of columns covered by this group
1058 public void setHideCols(boolean visibility)
1060 hidecols = visibility;
1065 * @return true if columns covered by group should be hidden
1067 public boolean isHideCols()
1073 * create a new sequence group from the intersection of this group with an
1074 * alignment Hashtable of hidden representatives
1080 * @return new group containing sequences common to this group and alignment
1082 public SequenceGroup intersect(AlignmentI alignment,
1083 Map<SequenceI, SequenceCollectionI> map)
1085 SequenceGroup sgroup = new SequenceGroup(this);
1086 SequenceI[] insect = getSequencesInOrder(alignment);
1087 sgroup.sequences = new ArrayList<>();
1088 for (int s = 0; insect != null && s < insect.length; s++)
1090 if (map == null || map.containsKey(insect[s]))
1092 sgroup.sequences.add(insect[s]);
1099 * @return the showUnconserved
1101 public boolean getShowNonconserved()
1103 return showNonconserved;
1107 * @param showNonconserved
1108 * the showUnconserved to set
1110 public void setShowNonconserved(boolean displayNonconserved)
1112 this.showNonconserved = displayNonconserved;
1116 * set this alignmentAnnotation object as the one used to render consensus
1121 public void setConsensus(AlignmentAnnotation aan)
1123 if (consensus == null)
1131 * @return automatically calculated consensus row note: the row is a stub if a
1132 * consensus calculation has not yet been performed on the group
1134 public AlignmentAnnotation getConsensus()
1136 // TODO get or calculate and get consensus annotation row for this group
1137 int aWidth = this.getWidth();
1145 if (consensus == null)
1147 consensus = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1148 100f, AlignmentAnnotation.BAR_GRAPH);
1149 consensus.hasText = true;
1150 consensus.autoCalculated = true;
1151 consensus.groupRef = this;
1152 consensus.label = "Consensus for " + getName();
1153 consensus.description = "Percent Identity";
1159 * set this alignmentAnnotation object as the one used to render consensus
1164 public void setConservationRow(AlignmentAnnotation aan)
1166 if (conservation == null)
1173 * get the conservation annotation row for this group
1175 * @return autoCalculated annotation row
1177 public AlignmentAnnotation getConservationRow()
1179 if (conservation == null)
1181 conservation = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1182 11f, AlignmentAnnotation.BAR_GRAPH);
1185 conservation.hasText = true;
1186 conservation.autoCalculated = true;
1187 conservation.groupRef = this;
1188 conservation.label = "Conservation for " + getName();
1189 conservation.description = "Conservation for group " + getName()
1190 + " less than " + consPercGaps + "% gaps";
1191 return conservation;
1196 * @return true if annotation rows have been instantiated for this group
1198 public boolean hasAnnotationRows()
1200 return consensus != null || conservation != null;
1203 public SequenceI getConsensusSeq()
1206 StringBuffer seqs = new StringBuffer();
1207 for (int i = 0; i < consensus.annotations.length; i++)
1209 if (consensus.annotations[i] != null)
1211 String desc = consensus.annotations[i].description;
1212 if (desc.length() > 1 && desc.charAt(0) == '[')
1214 seqs.append(desc.charAt(1));
1218 seqs.append(consensus.annotations[i].displayCharacter);
1223 SequenceI sq = new Sequence("Group" + getName() + " Consensus",
1225 sq.setDescription("Percentage Identity Consensus "
1226 + ((ignoreGapsInConsensus) ? " without gaps" : ""));
1230 public void setIgnoreGapsConsensus(boolean state)
1232 if (this.ignoreGapsInConsensus != state && consensus != null)
1234 ignoreGapsInConsensus = state;
1235 recalcConservation();
1237 ignoreGapsInConsensus = state;
1240 public boolean getIgnoreGapsConsensus()
1242 return ignoreGapsInConsensus;
1246 * @param showSequenceLogo
1247 * indicates if a sequence logo is shown for consensus annotation
1249 public void setshowSequenceLogo(boolean showSequenceLogo)
1251 // TODO: decouple calculation from settings update
1252 if (this.showSequenceLogo != showSequenceLogo && consensus != null)
1254 this.showSequenceLogo = showSequenceLogo;
1255 recalcConservation();
1257 this.showSequenceLogo = showSequenceLogo;
1262 * @param showConsHist
1263 * flag indicating if the consensus histogram for this group should
1266 public void setShowConsensusHistogram(boolean showConsHist)
1269 if (showConsensusHistogram != showConsHist && consensus != null)
1271 this.showConsensusHistogram = showConsHist;
1272 recalcConservation();
1274 this.showConsensusHistogram = showConsHist;
1278 * @return the showConsensusHistogram
1280 public boolean isShowConsensusHistogram()
1282 return showConsensusHistogram;
1286 * set flag indicating if logo should be normalised when rendered
1290 public void setNormaliseSequenceLogo(boolean norm)
1292 normaliseSequenceLogo = norm;
1295 public boolean isNormaliseSequenceLogo()
1297 return normaliseSequenceLogo;
1302 * returns a new array with all annotation involving this group
1304 public AlignmentAnnotation[] getAlignmentAnnotation()
1306 // TODO add in other methods like 'getAlignmentAnnotation(String label),
1308 ArrayList<AlignmentAnnotation> annot = new ArrayList<>();
1309 synchronized (sequences)
1311 for (SequenceI seq : sequences)
1313 AlignmentAnnotation[] aa = seq.getAnnotation();
1316 for (AlignmentAnnotation al : aa)
1318 if (al.groupRef == this)
1325 if (consensus != null)
1327 annot.add(consensus);
1329 if (conservation != null)
1331 annot.add(conservation);
1334 return annot.toArray(new AlignmentAnnotation[0]);
1338 public Iterable<AlignmentAnnotation> findAnnotation(String calcId)
1340 return AlignmentAnnotation.findAnnotation(
1341 Arrays.asList(getAlignmentAnnotation()), calcId);
1345 public Iterable<AlignmentAnnotation> findAnnotations(SequenceI seq,
1346 String calcId, String label)
1348 return AlignmentAnnotation.findAnnotations(
1349 Arrays.asList(getAlignmentAnnotation()), seq, calcId, label);
1353 * Answer true if any annotation matches the calcId passed in (if not null).
1358 public boolean hasAnnotation(String calcId)
1360 return AlignmentAnnotation
1361 .hasAnnotation(Arrays.asList(getAlignmentAnnotation()), calcId);
1365 * Remove all sequences from the group (leaving other properties unchanged).
1369 synchronized (sequences)
1371 int before = sequences.size();
1373 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before,
1379 * Sets the alignment or group context for this group, and whether it is
1380 * defined as a group
1383 * the context for the group
1385 * whether the group is defined on the alignment or is just a
1387 * @throws IllegalArgumentException
1388 * if setting the context would result in a circular reference chain
1390 public void setContext(AnnotatedCollectionI ctx, boolean defined)
1393 this.isDefined = defined;
1397 * Sets the alignment or group context for this group
1400 * the context for the group
1401 * @throws IllegalArgumentException
1402 * if setting the context would result in a circular reference chain
1404 public void setContext(AnnotatedCollectionI ctx)
1406 AnnotatedCollectionI ref = ctx;
1409 if (ref == this || ref.getContext() == ctx)
1411 throw new IllegalArgumentException(
1412 "Circular reference in SequenceGroup.context");
1414 ref = ref.getContext();
1422 * @see jalview.datamodel.AnnotatedCollectionI#getContext()
1425 public AnnotatedCollectionI getContext()
1430 public boolean isDefined()
1435 public void setColourScheme(ColourSchemeI scheme)
1439 cs = new ResidueShader();
1441 cs.setColourScheme(scheme);
1444 public void setGroupColourScheme(ResidueShaderI scheme)
1449 public ColourSchemeI getColourScheme()
1451 return cs == null ? null : cs.getColourScheme();
1454 public ResidueShaderI getGroupColourScheme()
1460 public boolean isNucleotide()
1462 if (context != null)
1464 return context.isNucleotide();
1471 * @return true if seq is a member of the group
1474 public boolean contains(SequenceI seq1)
1476 return sequences.contains(seq1);
1482 * @return true if startRes<=apos and endRes>=apos and seq is in the group
1484 public boolean contains(SequenceI seq, int apos)
1486 return (startRes <= apos && endRes >= apos) && sequences.contains(seq);
1490 //// Contact Matrix Holder Boilerplate
1492 ContactMapHolder cmholder = new ContactMapHolder();
1495 public Collection<ContactMatrixI> getContactMaps()
1497 return cmholder.getContactMaps();
1501 public ContactMatrixI getContactMatrixFor(AlignmentAnnotation ann)
1503 return cmholder.getContactMatrixFor(ann);
1507 public ContactListI getContactListFor(AlignmentAnnotation _aa, int column)
1509 return cmholder.getContactListFor(_aa, column);
1513 public AlignmentAnnotation addContactList(ContactMatrixI cm)
1515 AlignmentAnnotation aa = cmholder.addContactList(cm);
1517 Annotation _aa[] = new Annotation[getWidth()];
1518 Annotation dummy = new Annotation(0.0f);
1519 for (int i = 0; i < _aa.length; _aa[i++] = dummy)
1523 aa.annotations = _aa;
1524 // TODO passing annotations back to context to be added
1529 public void addContactListFor(AlignmentAnnotation annotation,
1532 cmholder.addContactListFor(annotation, cm);