X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FAlignment.java;h=9825bff3e4d88df91faadbba669e0a1acc318a30;hb=fbfbbe26bee37143d5279fe4d254a5a89c96b021;hp=02c423910c1bc010459c8812e563f3af91bca7dc;hpb=3da878124135ff033f42d19d8733891b09e953cd;p=jalview.git diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 02c4239..9825bff 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -32,6 +32,7 @@ import java.util.Arrays; import java.util.BitSet; import java.util.Collections; import java.util.Enumeration; +import java.util.HashMap; import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; @@ -47,7 +48,7 @@ import java.util.Vector; * @author JimP * */ -public class Alignment implements AlignmentI +public class Alignment implements AlignmentI, AutoCloseable { private Alignment dataset; @@ -195,7 +196,7 @@ public class Alignment implements AlignmentI { synchronized (sequences) { - + if (i > -1 && i < sequences.size()) { return sequences.get(i); @@ -303,15 +304,20 @@ public class Alignment implements AlignmentI } @Override - public void finalize() throws Throwable + public void close() { if (getDataset() != null) { - getDataset().removeAlignmentRef(); + try + { + getDataset().removeAlignmentRef(); + } catch (Throwable e) + { + e.printStackTrace(); + } } nullReferences(); - super.finalize(); } /** @@ -711,7 +717,7 @@ public class Alignment implements AlignmentI public int getWidth() { int maxLength = -1; - + for (int i = 0; i < sequences.size(); i++) { maxLength = Math.max(maxLength, getSequenceAt(i).getLength()); @@ -1190,7 +1196,8 @@ public class Alignment implements AlignmentI int maxLength = -1; SequenceI current; - for (int i = 0; i < sequences.size(); i++) + int nseq = sequences.size(); + for (int i = 0; i < nseq; i++) { current = getSequenceAt(i); for (int j = current.getLength(); j > maxLength; j--) @@ -1207,7 +1214,7 @@ public class Alignment implements AlignmentI maxLength++; int cLength; - for (int i = 0; i < sequences.size(); i++) + for (int i = 0; i < nseq; i++) { current = getSequenceAt(i); cLength = current.getLength(); @@ -1908,12 +1915,11 @@ public class Alignment implements AlignmentI @Override public boolean setHiddenColumns(HiddenColumns cols) { - boolean changed = cols == null ? hiddenCols != null - : !cols.equals(hiddenCols); - hiddenCols = cols; - return changed; + boolean changed = cols == null ? hiddenCols != null + : !cols.equals(hiddenCols); + hiddenCols = cols; + return changed; } - @Override public void setupJPredAlignment() { @@ -2026,4 +2032,42 @@ public class Alignment implements AlignmentI } } + Map contactmaps = new HashMap<>(); + @Override + public + ContactListI getContactListFor(AlignmentAnnotation _aa, int column) + { + ContactMatrixI cm = contactmaps.get(_aa.annotationId); + if (cm == null) + { + return null; + } + return cm.getContactList(column); + } + + @Override + public AlignmentAnnotation addContactList(ContactMatrixI cm) + { + Annotation _aa[] = new Annotation[getWidth()]; + Annotation dummy = new Annotation(0.0f); + for (int i = 0; i < _aa.length; _aa[i++] = dummy) + { + ; + } + AlignmentAnnotation aa = new AlignmentAnnotation("Contact Matrix", + "Contact Matrix", _aa); + aa.graph = AlignmentAnnotation.CUSTOMRENDERER; + aa.graphMin = cm.getMin(); + aa.graphMax = cm.getMax(); + aa.editable = false; + // aa.autoCalculated = true; + contactmaps.put(aa.annotationId, cm); + // TODO: contact matrices could be intra or inter - more than one refseq possible! + if (cm.hasReferenceSeq()) + { + aa.setSequenceRef(cm.getReferenceSeq()); + } + addAnnotation(aa); + return aa; + } }