X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSequenceGroup.java;h=98371046013cb2e93c12cb083c26b3d994a7daa7;hb=ae3fad8019274ca3ab1258a480ba15dd9adac1e9;hp=62f9fd8fe2a5eb5d3d9c884f6b87bccd18e5470f;hpb=beff7ac7ab7be2c24ccb179be16b8816d2c18610;p=jalview.git diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index 62f9fd8..9837104 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -20,20 +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 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 * @@ -88,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) @@ -108,7 +109,7 @@ public class SequenceGroup implements AnnotatedCollectionI private int startRes = 0; /** - * end column (base 0) + * end column (base 0) */ private int endRes = 0; @@ -162,6 +163,7 @@ public class SequenceGroup implements AnnotatedCollectionI { groupName = "JGroup:" + this.hashCode(); cs = new ResidueShader(); + sequences = new ArrayList<>(); } /** @@ -213,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); @@ -243,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; @@ -257,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.setDBRefs(seq.getDBRefs()); - seqipos.setSequenceFeatures(seq.getSequenceFeatures()); - if (seq.getDatasetSequence() != null) - { - seqipos.setDatasetSequence(seq.getDatasetSequence()); - } - if (seq.getAnnotation() != null) { AlignmentAnnotation[] alann = align.getAlignmentAnnotation(); @@ -297,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); } } @@ -633,7 +644,7 @@ public class SequenceGroup implements AnnotatedCollectionI } catch (java.lang.OutOfMemoryError err) { // TODO: catch OOM - System.out.println("Out of memory loading groups: " + err); + jalview.bin.Console.outPrintln("Out of memory loading groups: " + err); } return upd; } @@ -761,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); } @@ -1473,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); + } + }