X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FAlignment.java;h=375e6b455e0a05a13b8f5673883bf626b969e2f1;hb=b122ba188c2ffcbb302809bafc02058e355643ee;hp=c4098e26594753f3caa175ca4ae6922e41e0856f;hpb=17e4ea278bc9a5fb280db1252ce78b7a295215f5;p=jalview.git diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index c4098e2..375e6b4 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -20,16 +20,10 @@ */ package jalview.datamodel; -import jalview.analysis.AlignmentUtils; -import jalview.datamodel.AlignedCodonFrame.SequenceToSequenceMapping; -import jalview.io.FastaFile; -import jalview.util.Comparison; -import jalview.util.LinkedIdentityHashSet; -import jalview.util.MessageManager; - import java.util.ArrayList; import java.util.Arrays; import java.util.BitSet; +import java.util.Collection; import java.util.Collections; import java.util.Enumeration; import java.util.HashSet; @@ -40,6 +34,13 @@ import java.util.Map; import java.util.Set; import java.util.Vector; +import jalview.analysis.AlignmentUtils; +import jalview.datamodel.AlignedCodonFrame.SequenceToSequenceMapping; +import jalview.io.FastaFile; +import jalview.util.Comparison; +import jalview.util.LinkedIdentityHashSet; +import jalview.util.MessageManager; + /** * Data structure to hold and manipulate a multiple sequence alignment */ @@ -195,7 +196,7 @@ public class Alignment implements AlignmentI, AutoCloseable { synchronized (sequences) { - + if (i > -1 && i < sequences.size()) { return sequences.get(i); @@ -716,7 +717,7 @@ public class Alignment implements AlignmentI, AutoCloseable public int getWidth() { int maxLength = -1; - + for (int i = 0; i < sequences.size(); i++) { maxLength = Math.max(maxLength, getSequenceAt(i).getLength()); @@ -1652,8 +1653,10 @@ public class Alignment implements AlignmentI, AutoCloseable public Iterable findAnnotations(SequenceI seq, String calcId, String label) { - return AlignmentAnnotation.findAnnotations( - Arrays.asList(getAlignmentAnnotation()), seq, calcId, label); + return annotations == null ? null + : AlignmentAnnotation.findAnnotations( + Arrays.asList(getAlignmentAnnotation()), seq, calcId, + label); } @Override @@ -2032,4 +2035,90 @@ public class Alignment implements AlignmentI, AutoCloseable } } + //// + //// Contact Matrix Holder Boilerplate + //// + ContactMapHolder cmholder = new ContactMapHolder(); + + @Override + public Collection getContactMaps() + { + return cmholder.getContactMaps(); + } + + @Override + public ContactMatrixI getContactMatrixFor(AlignmentAnnotation _aa) + { + ContactMatrixI cm = cmholder.getContactMatrixFor(_aa); + if (cm == null && _aa.groupRef != null) + { + cm = _aa.groupRef.getContactMatrixFor(_aa); + } + if (cm == null && _aa.sequenceRef != null) + { + cm = _aa.sequenceRef.getContactMatrixFor(_aa); + if (cm == null && _aa.sequenceRef.getDatasetSequence()!=null) + { + // TODO fix up this logic and unify with getContactListFor + cm = _aa.sequenceRef.getDatasetSequence().getContactMatrixFor(_aa); + } + } + return cm; + } + + @Override + public ContactListI getContactListFor(AlignmentAnnotation _aa, int column) + { + if (_aa.annotations==null || column>=_aa.annotations.length || column<0) + { + return null; + } + ContactListI cl = cmholder.getContactListFor(_aa, column); + if (cl == null && _aa.groupRef != null) + { + cl = _aa.groupRef.getContactListFor(_aa, column); + } + if (cl == null && _aa.sequenceRef != null) + { + if (_aa.annotations[column] != null) + { + // sequence associated + cl = _aa.sequenceRef.getContactListFor(_aa, column); + if (cl == null && _aa.sequenceRef.getDatasetSequence() != null) + { + int spos = _aa.sequenceRef.findPosition(column); + if (spos >= _aa.sequenceRef.getStart() + && spos <= 1 + _aa.sequenceRef.getEnd()) + { + cl = _aa.sequenceRef.getDatasetSequence().getContactListFor(_aa, + spos - _aa.sequenceRef.getStart()); + } + } + } + } + return cl; + } + + @Override + public AlignmentAnnotation addContactList(ContactMatrixI cm) + { + AlignmentAnnotation aa = cmholder.addContactList(cm); + + Annotation _aa[] = new Annotation[getWidth()]; + for (int i = 0; i < _aa.length; _aa[i++] = new Annotation(0.0f)) + { + ; + } + aa.annotations = _aa; + addAnnotation(aa); + return aa; + } + + @Override + public void addContactListFor(AlignmentAnnotation annotation, + ContactMatrixI cm) + { + cmholder.addContactListFor(annotation, cm); + + } }