From: osboxes Date: Tue, 29 Aug 2017 11:00:15 +0000 (-0400) Subject: JAL-2629 HMMs dropped on the alignment now map to the rf annotation X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=36e82a30ba2cd0c1331d8735214ebbe2139790ce;p=jalview.git JAL-2629 HMMs dropped on the alignment now map to the rf annotation --- diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index a673514..4736981 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -1563,6 +1563,41 @@ public class Sequence extends ASequence implements SequenceI } + /** + * Maps the HMM sequence to the reference annotation. + * + * @param rf + */ + @Override + public void mapToReference(AlignmentAnnotation rf) + { + if (this.isHMMConsensusSequence) + { + int node = 1; + hmm.emptyNodeLookup(); + for (int i = 0; i < getLength(); i++) + { + if (rf.annotations[i].displayCharacter.equals("x") + || rf.annotations[i].displayCharacter.equals("X")) + { + if (i < hmm.getNodeAlignmentColumn(node)) + { + this.deleteChars(i, hmm.getNodeAlignmentColumn(node)); + updateHMMMapping(); + } + else if (i > hmm.getNodeAlignmentColumn(node)) + { + int length = i - hmm.getNodeAlignmentColumn(node); + this.insertCharAt(hmm.getNodeAlignmentColumn(node), length, + '-'); + updateHMMMapping(); + } + node++; + } + } + } + } + @Override public boolean isHMMConsensusSequence() { diff --git a/src/jalview/datamodel/SequenceI.java b/src/jalview/datamodel/SequenceI.java index 20362dd..fed3eff 100755 --- a/src/jalview/datamodel/SequenceI.java +++ b/src/jalview/datamodel/SequenceI.java @@ -502,4 +502,6 @@ public interface SequenceI extends ASequenceI * returns true. */ BitSet getInsertionsAsBits(); + + void mapToReference(AlignmentAnnotation rf); } diff --git a/src/jalview/io/FileLoader.java b/src/jalview/io/FileLoader.java index 73fbc88..90c509e 100755 --- a/src/jalview/io/FileLoader.java +++ b/src/jalview/io/FileLoader.java @@ -26,6 +26,7 @@ import jalview.api.FeaturesDisplayedI; import jalview.api.FeaturesSourceI; import jalview.bin.Cache; import jalview.bin.Jalview; +import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.HiddenColumns; import jalview.datamodel.PDBEntry; @@ -426,6 +427,17 @@ public class FileLoader implements Runnable SequenceI seq = alignment .getSequenceAt(alignment.getAbsoluteHeight() - 1); seq.setIsHMMConsensusSequence(true); + AlignmentAnnotation[] annots = viewport.getAlignment() + .getAlignmentAnnotation(); + for (AlignmentAnnotation annot : annots) + { + if ("RF".equals(annot.label) + || annot.label.contains("Reference")) + { + seq.mapToReference(annot); + break; + } + } alignment.deleteSequence(alignment.getAbsoluteHeight() - 1); alignment.insertSequenceAt(0, seq); viewport.getAlignPanel().adjustAnnotationHeight();