add HMMER colour scheme
authorTZVanaalten <TZVanaalten@LS30916.ad.lifesci.dundee.ac.uk>
Fri, 23 Jun 2017 11:52:54 +0000 (12:52 +0100)
committerTZVanaalten <TZVanaalten@LS30916.ad.lifesci.dundee.ac.uk>
Fri, 23 Jun 2017 11:52:54 +0000 (12:52 +0100)
src/jalview/datamodel/Alignment.java
src/jalview/datamodel/AlignmentI.java
src/jalview/datamodel/AnnotatedCollectionI.java
src/jalview/datamodel/HiddenMarkovModel.java
src/jalview/datamodel/SequenceGroup.java
src/jalview/gui/AlignFrame.java
src/jalview/schemes/JalviewColourScheme.java

index 5d91b36..a88995d 100755 (executable)
@@ -68,6 +68,8 @@ public class Alignment implements AlignmentI
 
   private List<AlignedCodonFrame> codonFrameList;
 
+  HiddenMarkovModel hmm;
+
   private void initAlignment(SequenceI[] seqs)
   {
     groups = Collections.synchronizedList(new ArrayList<SequenceGroup>());
@@ -1959,4 +1961,19 @@ public class Alignment implements AlignmentI
   {
     hiddenCols = cols;
   }
+
+  @Override
+  public HiddenMarkovModel getHMM()
+  {
+
+    return hmm;
+  }
+
+  @Override
+  public void setHMM(HiddenMarkovModel markov)
+  {
+
+    hmm = markov;
+  }
+
 }
index 2e61f9d..948fd1b 100755 (executable)
@@ -591,4 +591,6 @@ public interface AlignmentI extends AnnotatedCollectionI
 
   public void setHiddenColumns(HiddenColumns cols);
 
+  
+
 }
index 2963fd5..45a3787 100644 (file)
@@ -61,4 +61,8 @@ public interface AnnotatedCollectionI extends SequenceCollectionI
    *         alignment, parent group).
    */
   AnnotatedCollectionI getContext();
+
+  public HiddenMarkovModel getHMM();
+
+  public void setHMM(HiddenMarkovModel hmm);
 }
index f614013..e214373 100644 (file)
@@ -290,10 +290,22 @@ public class HiddenMarkovModel
     int symbolIndex;
     int nodeIndex;
     Double probability;
+    if (symbol == '-')
+    {
+      return 0d;
+    }
     symbolIndex = symbolIndexLookup.get(symbol);
-    nodeIndex = nodeLookup.get(alignColumn);
-    probability = getNode(nodeIndex).getMatchEmissions().get(symbolIndex);
-    return probability;
+    if (nodeLookup.containsKey(alignColumn + 1))
+    {
+      nodeIndex = nodeLookup.get(alignColumn + 1);
+      probability = getNode(nodeIndex).getMatchEmissions().get(symbolIndex);
+      probability = Math.pow(Math.E, -probability);
+      return probability;
+    }
+    else
+    {
+      return 0d;
+    }
 
   }
 
@@ -310,10 +322,23 @@ public class HiddenMarkovModel
     int symbolIndex;
     int nodeIndex;
     Double probability;
+    if (symbol == '-')
+    {
+      return 0d;
+    }
     symbolIndex = symbolIndexLookup.get(symbol);
-    nodeIndex = nodeLookup.get(alignColumn);
-    probability = getNode(nodeIndex).getInsertEmissions().get(symbolIndex);
-    return probability;
+    if (nodeLookup.containsKey(alignColumn + 1))
+    {
+      nodeIndex = nodeLookup.get(alignColumn + 1);
+      probability = getNode(nodeIndex).getInsertEmissions()
+              .get(symbolIndex);
+      probability = Math.pow(Math.E, -probability);
+      return probability;
+    }
+    else
+    {
+      return 0d;
+    }
 
   }
   
@@ -332,10 +357,18 @@ public class HiddenMarkovModel
     int nodeIndex;
     Double probability;
     transitionIndex = getTransitionType(transition);
-    nodeIndex = nodeLookup.get(alignColumn);
-    probability = getNode(nodeIndex).getStateTransitions()
+    if (nodeLookup.containsKey(alignColumn + 1))
+    {
+      nodeIndex = nodeLookup.get(alignColumn + 1);
+      probability = getNode(nodeIndex).getStateTransitions()
             .get(transitionIndex);
-    return probability;
+      probability = Math.pow(Math.E, -probability);
+      return probability;
+    }
+    else
+    {
+      return 0d;
+    }
 
   }
   
index 463b909..a1a655e 100755 (executable)
@@ -51,6 +51,8 @@ public class SequenceGroup implements AnnotatedCollectionI
 
   boolean colourText = false;
 
+  HiddenMarkovModel hmm;
+
   /**
    * True if the group is defined as a group on the alignment, false if it is
    * just a selection.
@@ -1457,4 +1459,18 @@ public class SequenceGroup implements AnnotatedCollectionI
   {
     return (startRes <= apos && endRes >= apos) && sequences.contains(seq);
   }
+
+  @Override
+  public HiddenMarkovModel getHMM()
+  {
+    // TODO Auto-generated method stub
+    return hmm;
+  }
+
+  @Override
+  public void setHMM(HiddenMarkovModel markov)
+  {
+    hmm = markov;
+
+  }
 }
index 2140ed9..080e260 100644 (file)
@@ -4654,7 +4654,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
           {
             HMMFile hmm = new HMMFile(new FileParse(file, sourceType));
             hmm.parse();
-            System.out.println("successful");
+
+            getViewport().getAlignment().setHMM(hmm.getHMM());
+
+
+
+
+
           }
           else if (FileFormat.Jnet.equals(format))
           {
index 185d2b4..c3a3873 100644 (file)
@@ -22,7 +22,8 @@ public enum JalviewColourScheme
           NucleotideColourScheme.class), PurinePyrimidine(
           "Purine/Pyrimidine", PurinePyrimidineColourScheme.class),
   RNAHelices("RNA Helices", RNAHelicesColour.class), TCoffee(
-          "T-Coffee Scores", TCoffeeColourScheme.class);
+          "T-Coffee Scores", TCoffeeColourScheme.class),
+  HMMER("HMMER", HMMERColourScheme.class);
   // RNAInteraction("RNA Interaction type", RNAInteractionColourScheme.class)
 
   private String name;