X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FAlignment.java;h=70a3cc2b82749c6d1f8b8cf165a7d138ee864957;hb=a3bed79406073da41d03e8278733e4beae172e6e;hp=3ae46b8ac4167b59a47edea353a067e2c9a187b8;hpb=4306800413a28da102c15fe7301bcac7816445fe;p=jalview.git diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 3ae46b8..70a3cc2 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -47,14 +47,12 @@ import java.util.Vector; * @author JimP * */ -public class Alignment implements AlignmentI +public class Alignment implements AlignmentI, AutoCloseable { private Alignment dataset; private List sequences; - private SequenceI hmmConsensus; - protected List groups; protected char gapCharacter = '-'; @@ -330,15 +328,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(); } /** @@ -740,39 +743,21 @@ public class Alignment implements AlignmentI for (int i = 0; i < sequences.size(); i++) { - if (getSequenceAt(i).getLength() > maxLength) - { - maxLength = getSequenceAt(i).getLength(); - } + maxLength = Math.max(maxLength, getSequenceAt(i).getLength()); } - return maxLength; } - /* + @Override - public int getWidth() + public int getVisibleWidth() { - final Wrapper temp = new Wrapper(); - - forEachSequence(new Consumer() + int w = getWidth(); + if (hiddenCols != null) { - @Override - public void accept(SequenceI s) - { - if (s.getLength() > temp.inner) - { - temp.inner = s.getLength(); - } - } - }, 0, sequences.size() - 1); - - return temp.inner; + w -= hiddenCols.getSize(); + } + return w; } - - public static class Wrapper - { - public int inner; - }*/ /** * DOCUMENT ME! @@ -1661,7 +1646,7 @@ public class Alignment implements AlignmentI annot.hasText = false; if (calcId != null) { - annot.setCalcId(new String(calcId)); + annot.setCalcId(calcId); } annot.autoCalculated = autoCalc; if (seqRef != null) @@ -1950,21 +1935,12 @@ public class Alignment implements AlignmentI } @Override - public void setHiddenColumns(HiddenColumns cols) + public boolean setHiddenColumns(HiddenColumns cols) { + boolean changed = cols == null ? hiddenCols != null + : !cols.equals(hiddenCols); hiddenCols = cols; - } - - @Override - public SequenceI getHmmConsensus() - { - return hmmConsensus; - } - - @Override - public void setHmmConsensus(SequenceI hmmConsensus) - { - this.hmmConsensus = hmmConsensus; + return changed; } @Override @@ -2078,4 +2054,19 @@ public class Alignment implements AlignmentI } } } + + @Override + public List getHmmSequences() + { + List result = new ArrayList<>(); + for (int i = 0; i < sequences.size(); i++) + { + SequenceI seq = sequences.get(i); + if (seq.hasHMMProfile()) + { + result.add(seq); + } + } + return result; + } }