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.getContactMatrixFor(seq.getAnnotation()[a]);
309 seqs[ipos].addContactListFor(newannot, cm);
311 seqipos.addAlignmentAnnotation(newannot);
321 if (iSize != inorder.length)
323 SequenceI[] nseqs = new SequenceI[iSize];
324 System.arraycopy(seqs, 0, nseqs, 0, iSize);
332 * If sequence ends in gaps, the end residue can be correctly calculated here
338 public int findEndRes(SequenceI seq)
343 for (int j = 0; j < endRes + 1 && j < seq.getLength(); j++)
345 ch = seq.getCharAt(j);
346 if (!jalview.util.Comparison.isGap((ch)))
354 eres += seq.getStart() - 1;
361 public List<SequenceI> getSequences()
367 public List<SequenceI> getSequences(
368 Map<SequenceI, SequenceCollectionI> hiddenReps)
370 if (hiddenReps == null)
372 // TODO: need a synchronizedCollection here ?
377 List<SequenceI> allSequences = new ArrayList<>();
378 for (SequenceI seq : sequences)
380 allSequences.add(seq);
381 if (hiddenReps.containsKey(seq))
383 SequenceCollectionI hsg = hiddenReps.get(seq);
384 for (SequenceI seq2 : hsg.getSequences())
386 if (seq2 != seq && !allSequences.contains(seq2))
388 allSequences.add(seq2);
398 public SequenceI[] getSequencesAsArray(
399 Map<SequenceI, SequenceCollectionI> map)
401 List<SequenceI> tmp = getSequences(map);
406 return tmp.toArray(new SequenceI[tmp.size()]);
415 * @return DOCUMENT ME!
417 public boolean adjustForRemoveLeft(int col)
419 // return value is true if the group still exists
422 startRes = startRes - col;
427 endRes = endRes - col;
429 if (startRes > endRes)
436 // must delete this group!!
449 * @return DOCUMENT ME!
451 public boolean adjustForRemoveRight(int col)
470 * @return DOCUMENT ME!
472 public String getName()
477 public String getDescription()
488 public void setName(String name)
491 // TODO: URGENT: update dependent objects (annotation row)
494 public void setDescription(String desc)
502 * @return DOCUMENT ME!
504 public Conservation getConservation()
515 public void setConservation(Conservation c)
521 * Add s to this sequence group. If aligment sequence is already contained in
522 * group, it will not be added again, but recalculation may happen if the flag
526 * alignment sequence to be added
528 * true means Group's conservation should be recalculated
530 public void addSequence(SequenceI s, boolean recalc)
532 synchronized (sequences)
534 if (s != null && !sequences.contains(s))
537 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED,
538 sequences.size() - 1, sequences.size());
543 recalcConservation();
549 * Max Gaps Threshold (percent) for performing a conservation calculation
551 private int consPercGaps = 25;
554 * @return Max Gaps Threshold for performing a conservation calculation
556 public int getConsPercGaps()
562 * set Max Gaps Threshold (percent) for performing a conservation calculation
564 * @param consPercGaps
566 public void setConsPercGaps(int consPercGaps)
568 this.consPercGaps = consPercGaps;
572 * calculate residue conservation and colourschemes for group - but only if
573 * necessary. returns true if the calculation resulted in a visible change to
576 public boolean recalcConservation()
578 return recalcConservation(false);
582 * calculate residue conservation for group - but only if necessary. returns
583 * true if the calculation resulted in a visible change to group
586 * when set, colourschemes for this group are not refreshed after
589 public boolean recalcConservation(boolean defer)
591 if (cs == null && consensus == null && conservation == null)
595 // TODO: try harder to detect changes in state in order to minimise
596 // recalculation effort
600 ProfilesI cnsns = AAFrequency.calculate(sequences, startRes,
601 endRes + 1, showSequenceLogo);
602 if (consensus != null)
604 _updateConsensusRow(cnsns, sequences.size());
609 cs.setConsensus(cnsns);
613 if ((conservation != null)
614 || (cs != null && cs.conservationApplied()))
616 Conservation c = new Conservation(groupName, sequences, startRes,
619 c.verdict(false, consPercGaps);
620 if (conservation != null)
622 _updateConservationRow(c);
626 if (cs.conservationApplied())
628 cs.setConservation(c);
631 // eager update - will cause a refresh of overview regardless
634 if (cs != null && !defer)
636 // TODO: JAL-2034 should cs.alignmentChanged modify return state
637 cs.alignmentChanged(context != null ? context : this, null);
644 } catch (java.lang.OutOfMemoryError err)
647 System.out.println("Out of memory loading groups: " + err);
652 private void _updateConservationRow(Conservation c)
654 if (conservation == null)
659 conservation.label = "Conservation for " + getName();
660 conservation.description = "Conservation for group " + getName()
661 + " less than " + consPercGaps + "% gaps";
662 // preserve width if already set
663 int aWidth = (conservation.annotations != null)
664 ? (endRes < conservation.annotations.length
665 ? conservation.annotations.length
668 conservation.annotations = null;
669 conservation.annotations = new Annotation[aWidth]; // should be alignment
671 c.completeAnnotations(conservation, null, startRes, endRes + 1);
674 public ProfilesI consensusData = null;
676 private void _updateConsensusRow(ProfilesI cnsns, long nseq)
678 if (consensus == null)
682 consensus.label = "Consensus for " + getName();
683 consensus.description = "Percent Identity";
684 consensusData = cnsns;
685 // preserve width if already set
686 int aWidth = (consensus.annotations != null)
687 ? (endRes < consensus.annotations.length
688 ? consensus.annotations.length
691 consensus.annotations = null;
692 consensus.annotations = new Annotation[aWidth]; // should be alignment width
694 AAFrequency.completeConsensus(consensus, cnsns, startRes, endRes + 1,
695 ignoreGapsInConsensus, showSequenceLogo, nseq); // TODO: setting
698 // ignoreGapsInConsensusCalculation);
703 * sequence to either add or remove from group
705 * flag passed to delete/addSequence to indicate if group properties
706 * should be recalculated
708 public void addOrRemove(SequenceI s, boolean recalc)
710 synchronized (sequences)
712 if (sequences.contains(s))
714 deleteSequence(s, recalc);
718 addSequence(s, recalc);
729 * true means recalculate conservation
731 public void deleteSequence(SequenceI s, boolean recalc)
733 synchronized (sequences)
736 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED,
737 sequences.size() + 1, sequences.size());
741 recalcConservation();
749 * @return the first column selected by this group. Runs from 0<=i<N_cols
752 public int getStartRes()
759 * @return the groups last selected column. Runs from 0<=i<N_cols
762 public int getEndRes()
768 * Set the first column selected by this group. Runs from 0<=i<N_cols
772 public void setStartRes(int newStart)
774 int before = startRes;
775 startRes = Math.max(0, newStart); // sanity check for negative start column
777 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, startRes);
782 * Set the groups last selected column. Runs from 0<=i<N_cols
786 public void setEndRes(int i)
790 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, endRes);
794 * @return number of sequences in group
798 return sequences.size();
803 * @return the ith sequence
805 public SequenceI getSequenceAt(int i)
807 return sequences.get(i);
814 public void setColourText(boolean state)
822 * @return DOCUMENT ME!
824 public boolean getColourText()
835 public void setDisplayText(boolean state)
843 * @return DOCUMENT ME!
845 public boolean getDisplayText()
856 public void setDisplayBoxes(boolean state)
858 displayBoxes = state;
864 * @return DOCUMENT ME!
866 public boolean getDisplayBoxes()
872 * computes the width of current set of sequences and returns it
874 * @return DOCUMENT ME!
877 public int getWidth()
879 synchronized (sequences)
881 // MC This needs to get reset when characters are inserted and deleted
882 boolean first = true;
883 for (SequenceI seq : sequences)
885 if (first || seq.getLength() > width)
887 width = seq.getLength();
901 public void setOutlineColour(Color c)
909 * @return DOCUMENT ME!
911 public Color getOutlineColour()
913 return outlineColour;
918 * returns the sequences in the group ordered by the ordering given by al.
919 * this used to return an array with null entries regardless, new behaviour is
920 * below. TODO: verify that this does not affect use in applet or application
924 * @return SequenceI[] intersection of sequences in group with al, ordered by
925 * al, or null if group does not intersect with al
927 public SequenceI[] getSequencesInOrder(AlignmentI al)
929 return getSequencesInOrder(al, true);
933 * return an array representing the intersection of the group with al,
934 * optionally returning an array the size of al.getHeight() where nulls mark
935 * the non-intersected sequences
939 * @return null or array
941 public SequenceI[] getSequencesInOrder(AlignmentI al, boolean trim)
943 synchronized (sequences)
945 int sSize = sequences.size();
946 int alHeight = al.getHeight();
948 SequenceI[] seqs = new SequenceI[(trim) ? sSize : alHeight];
951 for (int i = 0; i < alHeight && index < sSize; i++)
953 if (sequences.contains(al.getSequenceAt(i)))
955 seqs[(trim) ? index : i] = al.getSequenceAt(i);
967 if (index < seqs.length)
969 SequenceI[] dummy = seqs;
970 seqs = new SequenceI[index];
973 seqs[index] = dummy[index];
982 * @return the idColour
984 public Color getIdColour()
991 * the idColour to set
993 public void setIdColour(Color idColour)
995 this.idColour = idColour;
999 * @return the representative sequence for this group
1002 public SequenceI getSeqrep()
1008 * set the representative sequence for this group. Note - this affects the
1009 * interpretation of the Hidereps attribute.
1012 * the seqrep to set (null means no sequence representative)
1015 public void setSeqrep(SequenceI seqrep)
1017 this.seqrep = seqrep;
1022 * @return true if group has a sequence representative
1025 public boolean hasSeqrep()
1027 return seqrep != null;
1031 * set visibility of sequences covered by (if no sequence representative is
1032 * defined) or represented by this group.
1036 public void setHidereps(boolean visibility)
1038 hidereps = visibility;
1043 * @return true if sequences represented (or covered) by this group should be
1046 public boolean isHidereps()
1052 * set intended visibility of columns covered by this group
1056 public void setHideCols(boolean visibility)
1058 hidecols = visibility;
1063 * @return true if columns covered by group should be hidden
1065 public boolean isHideCols()
1071 * create a new sequence group from the intersection of this group with an
1072 * alignment Hashtable of hidden representatives
1078 * @return new group containing sequences common to this group and alignment
1080 public SequenceGroup intersect(AlignmentI alignment,
1081 Map<SequenceI, SequenceCollectionI> map)
1083 SequenceGroup sgroup = new SequenceGroup(this);
1084 SequenceI[] insect = getSequencesInOrder(alignment);
1085 sgroup.sequences = new ArrayList<>();
1086 for (int s = 0; insect != null && s < insect.length; s++)
1088 if (map == null || map.containsKey(insect[s]))
1090 sgroup.sequences.add(insect[s]);
1097 * @return the showUnconserved
1099 public boolean getShowNonconserved()
1101 return showNonconserved;
1105 * @param showNonconserved
1106 * the showUnconserved to set
1108 public void setShowNonconserved(boolean displayNonconserved)
1110 this.showNonconserved = displayNonconserved;
1114 * set this alignmentAnnotation object as the one used to render consensus
1119 public void setConsensus(AlignmentAnnotation aan)
1121 if (consensus == null)
1129 * @return automatically calculated consensus row note: the row is a stub if a
1130 * consensus calculation has not yet been performed on the group
1132 public AlignmentAnnotation getConsensus()
1134 // TODO get or calculate and get consensus annotation row for this group
1135 int aWidth = this.getWidth();
1143 if (consensus == null)
1145 consensus = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1146 100f, AlignmentAnnotation.BAR_GRAPH);
1147 consensus.hasText = true;
1148 consensus.autoCalculated = true;
1149 consensus.groupRef = this;
1150 consensus.label = "Consensus for " + getName();
1151 consensus.description = "Percent Identity";
1157 * set this alignmentAnnotation object as the one used to render consensus
1162 public void setConservationRow(AlignmentAnnotation aan)
1164 if (conservation == null)
1171 * get the conservation annotation row for this group
1173 * @return autoCalculated annotation row
1175 public AlignmentAnnotation getConservationRow()
1177 if (conservation == null)
1179 conservation = new AlignmentAnnotation("", "", new Annotation[1], 0f,
1180 11f, AlignmentAnnotation.BAR_GRAPH);
1183 conservation.hasText = true;
1184 conservation.autoCalculated = true;
1185 conservation.groupRef = this;
1186 conservation.label = "Conservation for " + getName();
1187 conservation.description = "Conservation for group " + getName()
1188 + " less than " + consPercGaps + "% gaps";
1189 return conservation;
1194 * @return true if annotation rows have been instantiated for this group
1196 public boolean hasAnnotationRows()
1198 return consensus != null || conservation != null;
1201 public SequenceI getConsensusSeq()
1204 StringBuffer seqs = new StringBuffer();
1205 for (int i = 0; i < consensus.annotations.length; i++)
1207 if (consensus.annotations[i] != null)
1209 String desc = consensus.annotations[i].description;
1210 if (desc.length() > 1 && desc.charAt(0) == '[')
1212 seqs.append(desc.charAt(1));
1216 seqs.append(consensus.annotations[i].displayCharacter);
1221 SequenceI sq = new Sequence("Group" + getName() + " Consensus",
1223 sq.setDescription("Percentage Identity Consensus "
1224 + ((ignoreGapsInConsensus) ? " without gaps" : ""));
1228 public void setIgnoreGapsConsensus(boolean state)
1230 if (this.ignoreGapsInConsensus != state && consensus != null)
1232 ignoreGapsInConsensus = state;
1233 recalcConservation();
1235 ignoreGapsInConsensus = state;
1238 public boolean getIgnoreGapsConsensus()
1240 return ignoreGapsInConsensus;
1244 * @param showSequenceLogo
1245 * indicates if a sequence logo is shown for consensus annotation
1247 public void setshowSequenceLogo(boolean showSequenceLogo)
1249 // TODO: decouple calculation from settings update
1250 if (this.showSequenceLogo != showSequenceLogo && consensus != null)
1252 this.showSequenceLogo = showSequenceLogo;
1253 recalcConservation();
1255 this.showSequenceLogo = showSequenceLogo;
1260 * @param showConsHist
1261 * flag indicating if the consensus histogram for this group should
1264 public void setShowConsensusHistogram(boolean showConsHist)
1267 if (showConsensusHistogram != showConsHist && consensus != null)
1269 this.showConsensusHistogram = showConsHist;
1270 recalcConservation();
1272 this.showConsensusHistogram = showConsHist;
1276 * @return the showConsensusHistogram
1278 public boolean isShowConsensusHistogram()
1280 return showConsensusHistogram;
1284 * set flag indicating if logo should be normalised when rendered
1288 public void setNormaliseSequenceLogo(boolean norm)
1290 normaliseSequenceLogo = norm;
1293 public boolean isNormaliseSequenceLogo()
1295 return normaliseSequenceLogo;
1300 * returns a new array with all annotation involving this group
1302 public AlignmentAnnotation[] getAlignmentAnnotation()
1304 // TODO add in other methods like 'getAlignmentAnnotation(String label),
1306 ArrayList<AlignmentAnnotation> annot = new ArrayList<>();
1307 synchronized (sequences)
1309 for (SequenceI seq : sequences)
1311 AlignmentAnnotation[] aa = seq.getAnnotation();
1314 for (AlignmentAnnotation al : aa)
1316 if (al.groupRef == this)
1323 if (consensus != null)
1325 annot.add(consensus);
1327 if (conservation != null)
1329 annot.add(conservation);
1332 return annot.toArray(new AlignmentAnnotation[0]);
1336 public Iterable<AlignmentAnnotation> findAnnotation(String calcId)
1338 return AlignmentAnnotation.findAnnotation(
1339 Arrays.asList(getAlignmentAnnotation()), calcId);
1343 public Iterable<AlignmentAnnotation> findAnnotations(SequenceI seq,
1344 String calcId, String label)
1346 return AlignmentAnnotation.findAnnotations(
1347 Arrays.asList(getAlignmentAnnotation()), seq, calcId, label);
1351 * Answer true if any annotation matches the calcId passed in (if not null).
1356 public boolean hasAnnotation(String calcId)
1358 return AlignmentAnnotation
1359 .hasAnnotation(Arrays.asList(getAlignmentAnnotation()), calcId);
1363 * Remove all sequences from the group (leaving other properties unchanged).
1367 synchronized (sequences)
1369 int before = sequences.size();
1371 changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before,
1377 * Sets the alignment or group context for this group, and whether it is
1378 * defined as a group
1381 * the context for the group
1383 * whether the group is defined on the alignment or is just a
1385 * @throws IllegalArgumentException
1386 * if setting the context would result in a circular reference chain
1388 public void setContext(AnnotatedCollectionI ctx, boolean defined)
1391 this.isDefined = defined;
1395 * Sets the alignment or group context for this group
1398 * the context for the group
1399 * @throws IllegalArgumentException
1400 * if setting the context would result in a circular reference chain
1402 public void setContext(AnnotatedCollectionI ctx)
1404 AnnotatedCollectionI ref = ctx;
1407 if (ref == this || ref.getContext() == ctx)
1409 throw new IllegalArgumentException(
1410 "Circular reference in SequenceGroup.context");
1412 ref = ref.getContext();
1420 * @see jalview.datamodel.AnnotatedCollectionI#getContext()
1423 public AnnotatedCollectionI getContext()
1428 public boolean isDefined()
1433 public void setColourScheme(ColourSchemeI scheme)
1437 cs = new ResidueShader();
1439 cs.setColourScheme(scheme);
1442 public void setGroupColourScheme(ResidueShaderI scheme)
1447 public ColourSchemeI getColourScheme()
1449 return cs == null ? null : cs.getColourScheme();
1452 public ResidueShaderI getGroupColourScheme()
1458 public boolean isNucleotide()
1460 if (context != null)
1462 return context.isNucleotide();
1469 * @return true if seq is a member of the group
1472 public boolean contains(SequenceI seq1)
1474 return sequences.contains(seq1);
1480 * @return true if startRes<=apos and endRes>=apos and seq is in the group
1482 public boolean contains(SequenceI seq, int apos)
1484 return (startRes <= apos && endRes >= apos) && sequences.contains(seq);
1488 //// Contact Matrix Holder Boilerplate
1490 ContactMapHolder cmholder = new ContactMapHolder();
1493 public Collection<ContactMatrixI> getContactMaps()
1495 return cmholder.getContactMaps();
1499 public ContactMatrixI getContactMatrixFor(AlignmentAnnotation ann)
1501 return cmholder.getContactMatrixFor(ann);
1505 public ContactListI getContactListFor(AlignmentAnnotation _aa, int column)
1507 return cmholder.getContactListFor(_aa, column);
1511 public AlignmentAnnotation addContactList(ContactMatrixI cm)
1513 AlignmentAnnotation aa = cmholder.addContactList(cm);
1515 Annotation _aa[] = new Annotation[getWidth()];
1516 Annotation dummy = new Annotation(0.0f);
1517 for (int i = 0; i < _aa.length; _aa[i++] = dummy)
1521 aa.annotations = _aa;
1522 // TODO passing annotations back to context to be added
1527 public void addContactListFor(AlignmentAnnotation annotation,
1530 cmholder.addContactListFor(annotation, cm);