X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FAlignment.java;h=6b100ea6e3320246a1f9614e579ba26f74b32edd;hb=af7becd656cba3835394e2dc50c2ad8d189a6d46;hp=b6a5e0f8e0082881f626fa347246c8e78e4123d5;hpb=cfed9d8a9e10be992877d6097260758ee5563630;p=jalview.git diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index b6a5e0f..6b100ea 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -28,6 +28,7 @@ import jalview.util.LinkedIdentityHashSet; import jalview.util.MessageManager; import java.util.ArrayList; +import java.util.Arrays; import java.util.BitSet; import java.util.Collections; import java.util.Enumeration; @@ -50,7 +51,9 @@ public class Alignment implements AlignmentI { private Alignment dataset; - protected List sequences; + private List sequences; + + private SequenceI hmmConsensus; protected List groups; @@ -199,6 +202,7 @@ public class Alignment implements AlignmentI return sequences.get(i); } } + return null; } @@ -289,6 +293,32 @@ public class Alignment implements AlignmentI } /** + * Inserts a sequence at a point in the alignment. + * + * @param i + * the index of the position the sequence is to be inserted in. + */ + @Override + public void insertSequenceAt(int i, SequenceI snew) + { + synchronized (sequences) + { + if (sequences.size() > i) + { + sequences.add(i, snew); + return; + + } + else + { + sequences.add(snew); + hiddenSequences.adjustHeightSequenceAdded(); + } + return; + } + } + + /** * DOCUMENT ME! * * @return DOCUMENT ME! @@ -707,7 +737,7 @@ public class Alignment implements AlignmentI public int getWidth() { int maxLength = -1; - + for (int i = 0; i < sequences.size(); i++) { if (getSequenceAt(i).getLength() > maxLength) @@ -715,9 +745,34 @@ public class Alignment implements AlignmentI maxLength = getSequenceAt(i).getLength(); } } - + return maxLength; } + /* + @Override + public int getWidth() + { + final Wrapper temp = new Wrapper(); + + forEachSequence(new Consumer() + { + @Override + public void accept(SequenceI s) + { + if (s.getLength() > temp.inner) + { + temp.inner = s.getLength(); + } + } + }, 0, sequences.size() - 1); + + return temp.inner; + } + + public static class Wrapper + { + public int inner; + }*/ /** * DOCUMENT ME! @@ -1604,7 +1659,10 @@ public class Alignment implements AlignmentI AlignmentAnnotation annot = new AlignmentAnnotation(name, name, new Annotation[1], 0f, 0f, AlignmentAnnotation.BAR_GRAPH); annot.hasText = false; - annot.setCalcId(new String(calcId)); + if (calcId != null) + { + annot.setCalcId(calcId); + } annot.autoCalculated = autoCalc; if (seqRef != null) { @@ -1619,40 +1677,21 @@ public class Alignment implements AlignmentI @Override public Iterable findAnnotation(String calcId) { - List aa = new ArrayList<>(); AlignmentAnnotation[] alignmentAnnotation = getAlignmentAnnotation(); if (alignmentAnnotation != null) { - for (AlignmentAnnotation a : alignmentAnnotation) - { - if (a.getCalcId() == calcId || (a.getCalcId() != null - && calcId != null && a.getCalcId().equals(calcId))) - { - aa.add(a); - } - } + return AlignmentAnnotation.findAnnotation( + Arrays.asList(getAlignmentAnnotation()), calcId); } - return aa; + return Arrays.asList(new AlignmentAnnotation[] {}); } @Override public Iterable findAnnotations(SequenceI seq, String calcId, String label) { - ArrayList aa = new ArrayList<>(); - for (AlignmentAnnotation ann : getAlignmentAnnotation()) - { - if ((calcId == null || (ann.getCalcId() != null - && ann.getCalcId().equals(calcId))) - && (seq == null || (ann.sequenceRef != null - && ann.sequenceRef == seq)) - && (label == null - || (ann.label != null && ann.label.equals(label)))) - { - aa.add(ann); - } - } - return aa; + return AlignmentAnnotation.findAnnotations( + Arrays.asList(getAlignmentAnnotation()), seq, calcId, label); } @Override @@ -1917,6 +1956,18 @@ public class Alignment implements AlignmentI } @Override + public SequenceI getHmmConsensus() + { + return hmmConsensus; + } + + @Override + public void setHmmConsensus(SequenceI hmmConsensus) + { + this.hmmConsensus = hmmConsensus; + } + + @Override public void setupJPredAlignment() { SequenceI repseq = getSequenceAt(0); @@ -2027,5 +2078,4 @@ public class Alignment implements AlignmentI } } } - }