JAL-2668 add tests for HMMER commands, annotation and io
[jalview.git] / src / jalview / datamodel / Sequence.java
index 56a89a1..0da30ba 100755 (executable)
@@ -51,14 +51,20 @@ public class Sequence extends ASequence implements SequenceI
 
   private char[] sequence;
 
+  int previousPosition;
+
   String description;
 
   int start;
 
   int end;
 
+  boolean hasInfo;
+
   HiddenMarkovModel hmm;
 
+  boolean isHMMConsensusSequence = false;
+
   Vector<PDBEntry> pdbIds;
 
   String vamsasId;
@@ -292,6 +298,10 @@ public class Sequence extends ASequence implements SequenceI
         this.addPDBId(new PDBEntry(pdb));
       }
     }
+    if (seq.getHMM() != null)
+    {
+      this.hmm = new HiddenMarkovModel(seq.getHMM());
+    }
   }
 
   @Override
@@ -1489,4 +1499,77 @@ public class Sequence extends ASequence implements SequenceI
     this.hmm = hmm;
   }
 
+  @Override
+  public void updateHMMMapping()
+  {
+    int node = 1;
+    int column = 0;
+    for (char residue : sequence)
+    {
+      if (!Comparison.isGap(residue))
+      {
+        hmm.setAlignmentColumn(node, column);
+        hmm.getNodeLookup().put(column, node);
+        node++;
+      }
+      else
+      {
+        hmm.getNodeLookup().remove(column);
+      }
+      column++;
+    }
+
+  }
+
+  @Override
+  public boolean isHMMConsensusSequence()
+  {
+    return isHMMConsensusSequence;
+  }
+
+  @Override
+  public void setIsHMMConsensusSequence(boolean isHMMConsensusSequence)
+  {
+    this.isHMMConsensusSequence = isHMMConsensusSequence;
+  }
+
+  @Override
+  public boolean hasHMMAnnotation()
+  {
+    return hasInfo;
+    /*
+    if (annotation == null)
+    {
+      return false;
+    }
+    
+    for (AlignmentAnnotation annot : annotation)
+    {
+      if (annot.label.contains("_HMM"))
+      {
+        return true;
+      }
+    }
+    return false;
+    */
+  }
+
+  @Override
+  public void setHasInfo(boolean status)
+  {
+    hasInfo = true;
+  }
+
+  @Override
+  public int getPreviousPosition()
+  {
+    return previousPosition;
+  }
+
+  @Override
+  public void setPreviousPosition(int previousPosition)
+  {
+    this.previousPosition = previousPosition;
+  }
+
 }