X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSequenceGroup.java;h=326793d054437d76271172dfd8a7646603cd1cb7;hb=b117912a656de4b937e3684d58254c215b357ad5;hp=1e579ec9e047c724b4b54ebeea2d8d8554e40358;hpb=26b115b0a77d521da92a06572d9b7819c2d0d49a;p=jalview.git diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index 1e579ec..326793d 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -20,21 +20,21 @@ */ package jalview.datamodel; -import jalview.analysis.AAFrequency; -import jalview.analysis.Conservation; -import jalview.renderer.ResidueShader; -import jalview.renderer.ResidueShaderI; -import jalview.schemes.ColourSchemeI; -import jalview.ws.params.InvalidArgumentException; - import java.awt.Color; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.Map; +import jalview.analysis.AAFrequency; +import jalview.analysis.Conservation; +import jalview.renderer.ResidueShader; +import jalview.renderer.ResidueShaderI; +import jalview.schemes.ColourSchemeI; + /** * Collects a set contiguous ranges on a set of sequences * @@ -89,7 +89,7 @@ public class SequenceGroup implements AnnotatedCollectionI /** * group members */ - private List sequences = new ArrayList<>(); + private List sequences; /** * representative sequence for this group (if any) @@ -109,7 +109,7 @@ public class SequenceGroup implements AnnotatedCollectionI private int startRes = 0; /** - * end column (base 0) + * end column (base 0) */ private int endRes = 0; @@ -163,6 +163,7 @@ public class SequenceGroup implements AnnotatedCollectionI { groupName = "JGroup:" + this.hashCode(); cs = new ResidueShader(); + sequences = new ArrayList<>(); } /** @@ -214,7 +215,7 @@ public class SequenceGroup implements AnnotatedCollectionI displayBoxes = seqsel.displayBoxes; displayText = seqsel.displayText; colourText = seqsel.colourText; - + startRes = seqsel.startRes; endRes = seqsel.endRes; cs = new ResidueShader((ResidueShader) seqsel.cs); @@ -244,6 +245,17 @@ public class SequenceGroup implements AnnotatedCollectionI } } + /** + * Constructor that copies the given list of sequences + * + * @param seqs + */ + public SequenceGroup(List seqs) + { + this(); + this.sequences.addAll(seqs); + } + public boolean isShowSequenceLogo() { return showSequenceLogo; @@ -258,17 +270,10 @@ public class SequenceGroup implements AnnotatedCollectionI for (int i = 0, ipos = 0; i < inorder.length; i++) { SequenceI seq = inorder[i]; - SequenceI seqipos = seqs[ipos] = seq.getSubSequence(startRes, endRes + 1); + SequenceI seqipos = seqs[ipos] = seq.getSubSequence(startRes, + endRes + 1); if (seqipos != null) { - seqipos.setDescription(seq.getDescription()); - seqipos.getDBRefsFrom(seq); - seqipos.setSequenceFeatures(seq.getSequenceFeatures()); - if (seq.getDatasetSequence() != null) - { - seqipos.setDatasetSequence(seq.getDatasetSequence()); - } - if (seq.getAnnotation() != null) { AlignmentAnnotation[] alann = align.getAlignmentAnnotation(); @@ -298,6 +303,11 @@ public class SequenceGroup implements AnnotatedCollectionI newannot.restrict(startRes, endRes); newannot.setSequenceRef(seqs[ipos]); newannot.adjustForAlignment(); + ContactMatrixI cm = seq.getContactMatrixFor(seq.getAnnotation()[a]); + if (cm!=null) + { + seqs[ipos].addContactListFor(newannot, cm); + } seqipos.addAlignmentAnnotation(newannot); } } @@ -762,10 +772,9 @@ public class SequenceGroup implements AnnotatedCollectionI public void setStartRes(int newStart) { int before = startRes; - startRes= Math.max(0,newStart); // sanity check for negative start column positions - changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, startRes); - - + startRes = Math.max(0, newStart); // sanity check for negative start column + // positions + changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, startRes); } @@ -1474,4 +1483,51 @@ public class SequenceGroup implements AnnotatedCollectionI { return (startRes <= apos && endRes >= apos) && sequences.contains(seq); } + + //// + //// Contact Matrix Holder Boilerplate + //// + ContactMapHolder cmholder = new ContactMapHolder(); + + @Override + public Collection getContactMaps() + { + return cmholder.getContactMaps(); + } + + @Override + public ContactMatrixI getContactMatrixFor(AlignmentAnnotation ann) + { + return cmholder.getContactMatrixFor(ann); + } + + @Override + public ContactListI getContactListFor(AlignmentAnnotation _aa, int column) + { + return cmholder.getContactListFor(_aa, column); + } + + @Override + public AlignmentAnnotation addContactList(ContactMatrixI cm) + { + AlignmentAnnotation aa = cmholder.addContactList(cm); + + Annotation _aa[] = new Annotation[getWidth()]; + Annotation dummy = new Annotation(0.0f); + for (int i = 0; i < _aa.length; _aa[i++] = dummy) + { + ; + } + aa.annotations = _aa; + // TODO passing annotations back to context to be added + return aa; + } + + @Override + public void addContactListFor(AlignmentAnnotation annotation, + ContactMatrixI cm) + { + cmholder.addContactListFor(annotation, cm); + } + }