test HMMER colour scheme
[jalview.git] / test / jalview / io / HMMFileTest.java
index 5fef79b..7350c04 100644 (file)
@@ -3,6 +3,9 @@ package jalview.io;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNull;
 
+import jalview.datamodel.HMMNode;
+import jalview.datamodel.HiddenMarkovModel;
+
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
@@ -15,427 +18,227 @@ import org.testng.annotations.Test;
 
 public class HMMFileTest {
 
-  HMMFile testFile = new HMMFile("H:/HMMERFile.txt");
 
-  File file = new File("H:/HMMERFile.txt");
 
-  HMMFile testFile2 = new HMMFile("H:/EmptyFile.txt");
+  HMMFile fn3 = new HMMFile(
+          new FileParse("test/jalview/io/test_fn3_hmm.txt",
+                  DataSourceType.FILE));
+
+  HMMFile pKinase = new HMMFile(
+          new FileParse("test/jalview/io/test_PKinase_hmm.txt",
+                  DataSourceType.FILE));
 
-  File file2 = new File("H:/EmptyFile.txt");
+  HMMFile made1 = new HMMFile(
+          new FileParse("test/jalview/io/test_MADE1_hmm.txt",
+                  DataSourceType.FILE));
 
-  HMMFile testFile3 = new HMMFile("H:/HMMERFile2.txt");
+  HMMFileTest() throws IOException
+  {
 
-  File file3 = new File("H:/HMMERFile2.txt");
+  }
 
-  HMMFile testFile4 = new HMMFile("H:/HMMERFile.txt");
+  
 
-  File file4 = new File("H:/HMMERFile.txt");
 
   @Test
   public void testParse() throws IOException
   {
-    HMMFile integrationTestFile = new HMMFile("H:/HMMTutorialExample.hmm");
-    integrationTestFile.parse();
-
-    // file properties
-    assertEquals(integrationTestFile.hmm.getName(), "MADE1");
-    assertEquals(integrationTestFile.hmm.getAccessionNumber(),
-            "DF0000629.2");
-    assertEquals(integrationTestFile.hmm.getDescription(),
-            "MADE1 (MAriner Derived Element 1), a TcMar-Mariner DNA transposon");
-    assertEquals(integrationTestFile.hmm.getLength().intValue(), 80);
-    assertEquals(integrationTestFile.hmm.getMaxInstanceLength().intValue(),
-            426);
-    assertEquals(integrationTestFile.hmm.getAlphabetType(), "DNA");
-    assertEquals(integrationTestFile.hmm.getReferenceAnnotationFlag(),
-            true);
-    assertEquals(integrationTestFile.hmm.getModelMaskedFlag(), false);
-    assertEquals(
-            integrationTestFile.hmm.getConsensusResidueAnnotationFlag(),
+  
+    pKinase.parse();
+    HiddenMarkovModel hmm = pKinase.getHMM();
+    assertEquals(hmm.getName(), "Pkinase");
+    assertEquals(hmm.getAccessionNumber(), "PF00069.17");
+    assertEquals(hmm.getDescription(), "Protein kinase domain");
+    assertEquals(hmm.getLength().intValue(), 260);
+    assertNull(hmm.getMaxInstanceLength());
+    assertEquals(hmm.getAlphabetType(), "amino");
+    assertEquals(hmm.referenceAnnotationIsActive(), false);
+    assertEquals(hmm.maskValueIsActive(), false);
+    assertEquals(hmm.consensusResidueIsActive(), true);
+    assertEquals(hmm.consensusStructureIsActive(),
             true);
-    assertEquals(
-            integrationTestFile.hmm.getConsensusStructureAnnotationFlag(),
-            false);
-    assertEquals(integrationTestFile.hmm.getMapAnnotationFlag(), true);
-    assertEquals(integrationTestFile.hmm.getDate(),
-            "Tue Feb 19 20:33:41 2013");
-    assertNull(integrationTestFile.hmm.getCommandLineLog());
-    assertEquals(integrationTestFile.hmm.getSequenceNumber().intValue(),
-            1997);
-    assertEquals(integrationTestFile.hmm.getEffectiveSequenceNumber(),
-            3.911818, 4d);
-    assertEquals(integrationTestFile.hmm.getCheckSum().longValue(),
-            3015610723l);
-    assertNull(integrationTestFile.hmm.getGatheringThreshold1());
-    assertNull(integrationTestFile.hmm.getGatheringThreshold2());
-    assertNull(integrationTestFile.hmm.getTrustedCutoff1());
-    assertNull(integrationTestFile.hmm.getTrustedCutoff2());
-    assertNull(integrationTestFile.hmm.getNoiseCutoff1());
-    assertNull(integrationTestFile.hmm.getNoiseCutoff2());
-    assertEquals(integrationTestFile.hmm.getSlopeOfDistribution("MSV"),
-            -8.5786, 4d);
-    assertEquals(integrationTestFile.hmm.getSlopeOfDistribution("VITERBI"),
-            -9.3632, 4d);
-    assertEquals(integrationTestFile.hmm.getSlopeOfDistribution("FORWARD"),
-            -3.4823, 4d);
-    assertEquals(integrationTestFile.hmm.getLocationOfDistribution("MSV"),
-            0.71858, 4d);
-    assertEquals(
-            integrationTestFile.hmm.getLocationOfDistribution("VITERBI"),
-            0.71858, 4d);
-    assertEquals(
-            integrationTestFile.hmm.getLocationOfDistribution("FORWARD"),
-            0.71858, 4d);
-
+    assertEquals(hmm.mapIsActive(), true);
+    assertEquals(hmm.getDate(), "Thu Jun 16 11:44:06 2011");
+    assertNull(hmm.getCommandLineLog());
+    assertEquals(hmm.getNumberOfSequences().intValue(), 54);
+    assertEquals(hmm.getEffectiveNumberOfSequences(), 3.358521, 4d);
+    assertEquals(hmm.getCheckSum().longValue(), 3106786190l);
+    assertEquals(hmm.getGatheringThreshold(), "70.30 70.30");
+    assertEquals(hmm.getTrustedCutoff(), "70.30 70.30");
+    assertEquals(hmm.getNoiseCutoff(), "70.20 70.20");
+  
     List<Character> symbols = new ArrayList<>();
     symbols.add('A');
     symbols.add('C');
+    symbols.add('D');
+    symbols.add('E');
+    symbols.add('F');
     symbols.add('G');
+    symbols.add('H');
+    symbols.add('I');
+    symbols.add('K');
+    symbols.add('L');
+    symbols.add('M');
+    symbols.add('N');
+    symbols.add('P');
+    symbols.add('Q');
+    symbols.add('R');
+    symbols.add('S');
     symbols.add('T');
-
-    assertEquals(integrationTestFile.hmm.getSymbols(), symbols);
-
-    List<Double> averages = new ArrayList<>();
-    averages.add(1.24257);
-    averages.add(1.59430);
-    averages.add(1.62906);
-    averages.add(1.16413);
-
-    assertEquals(integrationTestFile.hmm
-            .getAverageMatchStateEmissionProbabilities(), averages);
-
-    assertEquals(integrationTestFile.hmm.getInsertZeroEmissions().get(2),
-            1.38629);
-    assertEquals(integrationTestFile.hmm.getInsertZeroEmissions().get(3),
-            1.38629);
-
-    assertEquals(integrationTestFile.hmm.getBeginStateTransitions().get(1),
-            3.94183);
-    assertEquals(integrationTestFile.hmm.getBeginStateTransitions().get(4),
-            0.26236);
-
-    assertEquals(integrationTestFile.hmm.getMatchEmissions().get(1).get(1),
-            2.37873);
-    assertEquals(integrationTestFile.hmm.getMatchEmissions().get(8).get(0),
-            2.16916);
-    assertEquals(integrationTestFile.hmm.getMatchEmissions().get(12).get(2),
-            2.32214);
-    assertEquals(integrationTestFile.hmm.getMatchEmissions().get(43).get(3),
-            2.60783);
-    assertEquals(integrationTestFile.hmm.getMatchEmissions().get(54).get(2),
-            2.46442);
-    assertEquals(integrationTestFile.hmm.getMatchEmissions().get(23).get(2),
-            2.50691);
-    assertEquals(integrationTestFile.hmm.getMatchEmissions().get(56).get(1),
-            2.32720);
-    assertEquals(integrationTestFile.hmm.getMatchEmissions().get(65).get(0),
-            2.79349);
-    assertEquals(integrationTestFile.hmm.getMatchEmissions().get(21).get(0),
-            2.54484);
-    assertEquals(integrationTestFile.hmm.getMatchEmissions().get(79).get(3),
-            2.88183);
-    assertEquals(integrationTestFile.hmm.getMatchEmissions().get(76).get(3),
-            1.84373);
-    
-    assertEquals(integrationTestFile.hmm.getInsertEmissions().get(23).get(0),
-            1.35803);
-    assertEquals(integrationTestFile.hmm.getInsertEmissions().get(54).get(3),
-            1.46331);
-    assertEquals(integrationTestFile.hmm.getInsertEmissions().get(65).get(3),
-            1.39101);
-    assertEquals(integrationTestFile.hmm.getInsertEmissions().get(57).get(2),
-            1.38112);
-    assertEquals(integrationTestFile.hmm.getInsertEmissions().get(42).get(1),
-            1.58747);
-    assertEquals(integrationTestFile.hmm.getInsertEmissions().get(12).get(3),
-            1.38740);
-    assertEquals(integrationTestFile.hmm.getInsertEmissions().get(6).get(1),
-            1.38524);
-    assertEquals(integrationTestFile.hmm.getInsertEmissions().get(59).get(0),
-            1.03649);
-    assertEquals(integrationTestFile.hmm.getInsertEmissions().get(78).get(0),
-            1.38629);
-    assertEquals(integrationTestFile.hmm.getInsertEmissions().get(17).get(2),
-            1.39937);
-    assertEquals(integrationTestFile.hmm.getInsertEmissions().get(0).get(2),
-            1.38629);
-
-    assertEquals(
-            integrationTestFile.hmm.getStateTransitions().get(13).get(1),
-            4.02482);
-    assertEquals(
-            integrationTestFile.hmm.getStateTransitions().get(64).get(2),
-            4.03073);
-    assertEquals(
-            integrationTestFile.hmm.getStateTransitions().get(45).get(6),
-            0.42814);
-    assertEquals(
-            integrationTestFile.hmm.getStateTransitions().get(71).get(4),
-            0.28542);
-    assertEquals(
-            integrationTestFile.hmm.getStateTransitions().get(32).get(5),
-            1.18729);
-    assertEquals(
-            integrationTestFile.hmm.getStateTransitions().get(9).get(0),
-            0.03536);
-    assertEquals(
-            integrationTestFile.hmm.getStateTransitions().get(0).get(3),
-            1.46634);
-    assertEquals(
-            integrationTestFile.hmm.getStateTransitions().get(31).get(6),
-            0.44749);
-    assertNull(
-            integrationTestFile.hmm.getStateTransitions().get(79).get(2));
-    assertEquals(
-            integrationTestFile.hmm.getStateTransitions().get(3).get(1),
-            4.05203);
-    assertEquals(
-            integrationTestFile.hmm.getStateTransitions().get(16).get(4),
-            0.26771);
-
-    assertEquals(integrationTestFile.hmm.getAlignmentColumnIndexes().get(0)
-            .intValue(), 1);
-    assertEquals(integrationTestFile.hmm.getAlignmentColumnIndexes().get(9)
-            .intValue(), 18);
-    assertEquals(integrationTestFile.hmm.getAlignmentColumnIndexes().get(12)
-            .intValue(), 28);
-    assertEquals(integrationTestFile.hmm.getAlignmentColumnIndexes().get(56)
-            .intValue(), 999);
-    assertEquals(integrationTestFile.hmm.getAlignmentColumnIndexes().get(79)
-            .intValue(), 1112);
-
-    assertEquals(integrationTestFile.hmm.getAnnotations().get(0).get("RF")
-            .charValue(), 'x');
-    assertEquals(integrationTestFile.hmm.getAnnotations().get(3).get("CS")
-            .charValue(), '-');
-    assertEquals(integrationTestFile.hmm.getAnnotations().get(65)
-            .get("CONS").charValue(), 't');
-    assertEquals(integrationTestFile.hmm.getAnnotations().get(23).get("MM")
-            .charValue(), '-');
-    assertEquals(integrationTestFile.hmm.getAnnotations().get(56).get("MM")
-            .charValue(), '-');
-    assertEquals(integrationTestFile.hmm.getAnnotations().get(76).get("RF")
-            .charValue(), 'x');
-    assertEquals(integrationTestFile.hmm.getAnnotations().get(79)
-            .get("CONS").charValue(), 'a');
-
+    symbols.add('V');
+    symbols.add('W');
+    symbols.add('Y');
+  
+    assertEquals(hmm.getSymbols(), symbols);
+  
+    assertEquals(getMatchEmission(0, 19, hmm), 3.43274);
+    assertEquals(getMatchEmission(12, 12, hmm), 4.33979);
+    assertEquals(getMatchEmission(23, 7, hmm), 3.65600);
+    assertEquals(getMatchEmission(54, 1, hmm), 4.76187);
+    assertEquals(getMatchEmission(79, 0, hmm), 2.81579);
+    assertEquals(getMatchEmission(100, 0, hmm), 1.86496);
+    assertEquals(getMatchEmission(112, 14, hmm), 2.77179);
+    assertEquals(getMatchEmission(143, 17, hmm), 5.10478);
+    assertEquals(getMatchEmission(156, 4, hmm), 4.69372);
+    assertEquals(getMatchEmission(178, 3, hmm), 2.52594);
+    assertEquals(getMatchEmission(210, 2, hmm), 4.23598);
+    assertEquals(getMatchEmission(260, 19, hmm), 3.81122);
+  
+    assertEquals(getInsertEmission(2, 1, hmm), 4.42225);
+    assertEquals(getInsertEmission(15, 6, hmm), 3.72501);
+    assertEquals(getInsertEmission(22, 9, hmm), 2.69355);
+    assertEquals(getInsertEmission(57, 2, hmm), 2.77519);
+    assertEquals(getInsertEmission(62, 14, hmm), 2.89801);
+    assertEquals(getInsertEmission(95, 17, hmm), 2.98532);
+    assertEquals(getInsertEmission(105, 4, hmm), 3.46354);
+    assertEquals(getInsertEmission(134, 1, hmm), 4.42225);
+    assertEquals(getInsertEmission(143, 0, hmm), 2.68618);
+    assertEquals(getInsertEmission(152, 16, hmm), 2.77519);
+    assertEquals(getInsertEmission(203, 16, hmm), 2.77519);
+    assertEquals(getInsertEmission(255, 12, hmm), 2.73739);
+  
+    assertEquals(getStateTransition(0, 6, hmm),
+            Double.NEGATIVE_INFINITY);
+    assertEquals(getStateTransition(3, 6, hmm), 0.95510);
+    assertEquals(getStateTransition(29, 3, hmm), 0.61958);
+    assertEquals(getStateTransition(46, 4, hmm), 0.77255);
+    assertEquals(getStateTransition(53, 1, hmm), 5.01631);
+    assertEquals(getStateTransition(79, 2, hmm), 5.73865);
+    assertEquals(getStateTransition(101, 2, hmm), 5.73865);
+    assertEquals(getStateTransition(120, 5, hmm), 0.48576);
+    assertEquals(getStateTransition(146, 5, hmm), 0.70219);
+    assertEquals(getStateTransition(169, 3, hmm), 1.23224);
+    assertEquals(getStateTransition(209, 0, hmm), 0.01003);
+    assertEquals(getStateTransition(243, 1, hmm), 5.01631);
+  
+    assertEquals(hmm.getNodeAlignmentColumn(3).intValue(), 3);
+    assertEquals(hmm.getReferenceAnnotation(7), '-');
+    assertEquals(hmm.getConsensusResidue(23), 't');
+    assertEquals(hmm.getMaskedValue(30), '-');
+    assertEquals(hmm.getConsensusStructure(56), 'S');
+  
+    assertEquals(hmm.getNodeAlignmentColumn(78).intValue(), 136);
+    assertEquals(hmm.getReferenceAnnotation(93), '-');
+    assertEquals(hmm.getConsensusResidue(145), 'a');
+    assertEquals(hmm.getMaskedValue(183), '-');
+    assertEquals(hmm.getConsensusStructure(240), 'H');
+  
   }
-
+  
   @Test
   public void testParseFileProperties() throws IOException
   {
-    FileReader fr = new FileReader(file);
+    FileReader fr = new FileReader(
+            new File("test/jalview/io/test_fn3_hmm.txt"));
     BufferedReader br = new BufferedReader(fr);
-    testFile.parseFileProperties(br);
+    fn3.parseFileProperties(br);
+    fn3.parseModel(br); // this is for a later test
+    HiddenMarkovModel testHMM = new HiddenMarkovModel();
+    testHMM = fn3.getHMM();
     br.close();
     fr.close();
-    assertEquals(testFile.hmm.getName(), "fn3");
-    assertEquals(testFile.hmm.getAccessionNumber(), "PF00041.13");
-    assertEquals(testFile.hmm.getDescription(),
+  
+    assertEquals(testHMM.getName(), "fn3");
+    assertEquals(testHMM.getAccessionNumber(), "PF00041.13");
+    assertEquals(testHMM.getDescription(),
             "Fibronectin type III domain");
-    assertEquals(testFile.hmm.getLength().intValue(), 4);
-    assertNull(testFile.hmm.getMaxInstanceLength());
-    assertEquals(testFile.hmm.getAlphabetType(), "amino");
-    assertEquals(testFile.hmm.getReferenceAnnotationFlag(), false);
-    assertEquals(testFile.hmm.getModelMaskedFlag(), false);
-    assertEquals(testFile.hmm.getConsensusResidueAnnotationFlag(), true);
-    assertEquals(testFile.hmm.getConsensusStructureAnnotationFlag(), true);
-    assertEquals(testFile.hmm.getMapAnnotationFlag(), true);
-    assertEquals(testFile.hmm.getDate(), "Fri Feb 15 06:04:13 2013");
-    assertNull(testFile.hmm.getCommandLineLog());
-    assertEquals(testFile.hmm.getSequenceNumber().intValue(), 106);
-    assertEquals(testFile.hmm.getEffectiveSequenceNumber(), 11.415833, 4d);
-    assertEquals(testFile.hmm.getCheckSum().longValue(), 3564431818l);
-    assertEquals(testFile.hmm.getGatheringThreshold1(), 8.00, 2d);
-    assertEquals(testFile.hmm.getGatheringThreshold2(), 7.20, 2d);
-    assertEquals(testFile.hmm.getTrustedCutoff1(), 8.00, 2d);
-    assertEquals(testFile.hmm.getTrustedCutoff2(), 7.20, 2d);
-    assertEquals(testFile.hmm.getNoiseCutoff1(), 7.90, 2d);
-    assertEquals(testFile.hmm.getNoiseCutoff2(), 7.90, 2d);
-    assertEquals(testFile.hmm.getSlopeOfDistribution("MSV"), -9.4043, 4d);
-    assertEquals(testFile.hmm.getSlopeOfDistribution("VITERBI"), -9.7737,
-            4d);
-    assertEquals(testFile.hmm.getSlopeOfDistribution("FORWARD"), -3.8341,
-            4d);
-    assertEquals(testFile.hmm.getLocationOfDistribution("MSV"), 0.71847,
-            4d);
-    assertEquals(testFile.hmm.getLocationOfDistribution("VITERBI"), 0.71847,
-            4d);
-    assertEquals(testFile.hmm.getLocationOfDistribution("FORWARD"), 0.71847,
-            4d);
-
-    FileReader fr2 = new FileReader(file2);
-    BufferedReader br2 = new BufferedReader(fr2);
-    testFile2.parseFileProperties(br2);
-    br2.close();
-    fr2.close();
-
-    assertNull(testFile2.hmm.getName());
-    assertNull(testFile2.hmm.getAccessionNumber());
-    assertNull(testFile2.hmm.getDescription());
-    assertNull(testFile2.hmm.getLength());
-    assertNull(testFile2.hmm.getMaxInstanceLength());
-    assertNull(testFile2.hmm.getAlphabetType());
-    assertEquals(testFile2.hmm.getReferenceAnnotationFlag(), false);
-    assertEquals(testFile2.hmm.getModelMaskedFlag(), false);
-    assertEquals(testFile2.hmm.getConsensusResidueAnnotationFlag(), false);
-    assertEquals(testFile2.hmm.getConsensusStructureAnnotationFlag(),
-            false);
-    assertEquals(testFile2.hmm.getMapAnnotationFlag(), false);
-    assertNull(testFile2.hmm.getDate());
-    assertNull(testFile2.hmm.getCommandLineLog());
-    assertNull(testFile2.hmm.getSequenceNumber());
-    assertNull(testFile2.hmm.getEffectiveSequenceNumber());
-    assertNull(testFile2.hmm.getCheckSum());
-    assertNull(testFile2.hmm.getGatheringThreshold1());
-    assertNull(testFile2.hmm.getGatheringThreshold2());
-    assertNull(testFile2.hmm.getTrustedCutoff1());
-    assertNull(testFile2.hmm.getTrustedCutoff2());
-    assertNull(testFile2.hmm.getNoiseCutoff1());
-    assertNull(testFile2.hmm.getNoiseCutoff2());
-    assertNull(testFile2.hmm.getSlopeOfDistribution("MSV"));
-    assertNull(testFile2.hmm.getSlopeOfDistribution("VITERBI"));
-    assertNull(testFile2.hmm.getSlopeOfDistribution("FORWARD"));
-    assertNull(testFile2.hmm.getLocationOfDistribution("MSV"));
-    assertNull(testFile2.hmm.getLocationOfDistribution("VITERBI"));
-    assertNull(testFile2.hmm.getLocationOfDistribution("FORWARD"));
-
-    FileReader fr3 = new FileReader(file3);
+    assertEquals(testHMM.getLength().intValue(), 86);
+    assertNull(testHMM.getMaxInstanceLength());
+    assertEquals(testHMM.getAlphabetType(), "amino");
+    assertEquals(testHMM.referenceAnnotationIsActive(), false);
+    assertEquals(testHMM.maskValueIsActive(), false);
+    assertEquals(testHMM.consensusResidueIsActive(), true);
+    assertEquals(testHMM.consensusStructureIsActive(), true);
+    assertEquals(testHMM.mapIsActive(), true);
+    assertEquals(testHMM.getDate(), "Fri Jun 20 08:22:31 2014");
+    assertNull(testHMM.getCommandLineLog());
+    assertEquals(testHMM.getNumberOfSequences().intValue(), 106);
+    assertEquals(testHMM.getEffectiveNumberOfSequences(), 11.415833, 4d);
+    assertEquals(testHMM.getCheckSum().longValue(), 3564431818l);
+    assertEquals(testHMM.getGatheringThreshold(), "8.00 7.20");
+    assertEquals(testHMM.getTrustedCutoff(), "8.00 7.20");
+    assertEquals(testHMM.getNoiseCutoff(), "7.90 7.90");
+    assertEquals(testHMM.getViterbi(), "-9.7737  0.71847");
+    assertEquals(testHMM.getMSV(), "-9.4043  0.71847");
+    assertEquals(testHMM.getForward(), "-3.8341  0.71847");
+  
+  
+    FileReader fr3 = new FileReader(
+            new File("test/jalview/io/test_MADE1_hmm.txt"));
     BufferedReader br3 = new BufferedReader(fr3);
-    testFile3.parseFileProperties(br3);
+    made1.parseFileProperties(br3);
+    testHMM = made1.getHMM();
     br3.close();
     fr3.close();
-
-    assertEquals(testFile3.hmm.getName(), "th4");
-    assertEquals(testFile3.hmm.getAccessionNumber(), "PF99041.16");
-    assertEquals(testFile3.hmm.getDescription(),
-            "Fibronectin type I domain");
-    assertEquals(testFile3.hmm.getLength().intValue(), 10);
-    assertEquals(testFile3.hmm.getMaxInstanceLength().intValue(), 6);
-    assertEquals(testFile3.hmm.getAlphabetType(), "amino");
-    assertEquals(testFile3.hmm.getReferenceAnnotationFlag(), true);
-    assertEquals(testFile3.hmm.getModelMaskedFlag(), false);
-    assertEquals(testFile3.hmm.getConsensusResidueAnnotationFlag(), false);
-    assertEquals(testFile3.hmm.getConsensusStructureAnnotationFlag(),
-            false);
-    assertEquals(testFile3.hmm.getMapAnnotationFlag(), false);
-    assertEquals(testFile3.hmm.getDate(), "Tue Jan 01 11:02:59 2000");
-    assertEquals(testFile3.hmm.getCommandLineLog(), "this is the log");
-    assertEquals(testFile3.hmm.getSequenceNumber().intValue(), 567);
-    assertEquals(testFile3.hmm.getEffectiveSequenceNumber(), 15.964683, 4d);
-    assertEquals(testFile3.hmm.getCheckSum().longValue(), 9485949654l);
-    assertEquals(testFile3.hmm.getGatheringThreshold1(), 6.40, 2d);
-    assertEquals(testFile3.hmm.getGatheringThreshold2(), 7.20, 2d);
-    assertEquals(testFile3.hmm.getTrustedCutoff1(), 2.40, 2d);
-    assertEquals(testFile3.hmm.getTrustedCutoff2(), 7.00, 2d);
-    assertNull(testFile3.hmm.getNoiseCutoff1());
-    assertNull(testFile3.hmm.getNoiseCutoff2());
-    assertNull(testFile3.hmm.getSlopeOfDistribution("MSV"));
-    assertNull(testFile3.hmm.getSlopeOfDistribution("VITERBI"));
-    assertNull(testFile3.hmm.getSlopeOfDistribution("FORWARD"));
-    assertNull(testFile3.hmm.getLocationOfDistribution("MSV"));
-    assertNull(testFile3.hmm.getLocationOfDistribution("VITERBI"));
-    assertNull(testFile3.hmm.getLocationOfDistribution("FORWARD"));
+  
+    assertEquals(testHMM.getName(), "MADE1");
+    assertEquals(testHMM.getAccessionNumber(), "DF0000629.2");
+    assertEquals(testHMM.getDescription(),
+            "MADE1 (MAriner Derived Element 1), a TcMar-Mariner DNA transposon");
+    assertEquals(testHMM.getLength().intValue(), 80);
+    assertEquals(testHMM.getMaxInstanceLength().intValue(), 426);
+    assertEquals(testHMM.getAlphabetType(), "DNA");
+    assertEquals(testHMM.referenceAnnotationIsActive(), true);
+    assertEquals(testHMM.maskValueIsActive(), false);
+    assertEquals(testHMM.consensusResidueIsActive(), true);
+    assertEquals(testHMM.consensusStructureIsActive(), false);
+    assertEquals(testHMM.mapIsActive(), true);
+    assertEquals(testHMM.getDate(), "Tue Feb 19 20:33:41 2013");
+    assertNull(testHMM.getCommandLineLog());
+    assertEquals(testHMM.getNumberOfSequences().intValue(), 1997);
+    assertEquals(testHMM.getEffectiveNumberOfSequences(), 3.911818, 4d);
+    assertEquals(testHMM.getCheckSum().longValue(), 3015610723l);
+    assertEquals(testHMM.getGatheringThreshold(), "2.324 4.234");
+    assertEquals(testHMM.getTrustedCutoff(), "2.343 1.212");
+    assertEquals(testHMM.getNoiseCutoff(), "2.354 5.456");
+    assertEquals(testHMM.getViterbi(), "-9.3632  0.71858");
+    assertEquals(testHMM.getMSV(), "-8.5786  0.71858");
+    assertEquals(testHMM.getForward(), "-3.4823  0.71858");
+  
+  
   }
-
-  /**
-   * @Test public void testParseModel() throws IOException { HiddenMarkovModel
-   *       hmm = new HiddenMarkovModel(); HMMFile testFile = new HMMFile(hmm,
-   *       "H:/HMMERFile.txt"); File file = new File("H:/HMMERFile.txt");
-   *       FileReader fr = new FileReader(file); BufferedReader br = new
-   *       BufferedReader(fr); testFile.parseFileProperties(br);
-   *       testFile.parseModel(br); br.close(); fr.close();
-   * 
-   *       }
-   **/
-
+  
   @Test
   public void testGetTransitionType()
   {
-
-    assertEquals(testFile.getTransitionType("mm").intValue(), 0);
-    assertEquals(testFile.getTransitionType("mi").intValue(), 1);
-    assertEquals(testFile.getTransitionType("md").intValue(), 2);
-    assertEquals(testFile.getTransitionType("im").intValue(), 3);
-    assertEquals(testFile.getTransitionType("ii").intValue(), 4);
-    assertEquals(testFile.getTransitionType("dm").intValue(), 5);
-    assertEquals(testFile.getTransitionType("dd").intValue(), 6);
-    assertNull(testFile.getTransitionType("df"));
-
-  }
-
-  @Test
-  public void testReadStats()
-  {
-    Scanner scanner = new Scanner("LOCAL MSV 5.6943 6.2313");
-    testFile.readStats(scanner);
-    assertEquals(testFile.hmm.getEValueStatistics().get("MSV")
-            .getAlignmentModeConfiguration(), "LOCAL");
-    assertEquals(
-            testFile.hmm.getEValueStatistics().get("MSV")
-                    .getSlopeOfDistribution(),
-            5.6943, 4d);
-    assertEquals(testFile.hmm.getEValueStatistics().get("MSV")
-            .getLocationOfDistribution(), 6.2313, 4d);
-    scanner.close();
-
-    Scanner scanner2 = new Scanner("GLOBAL VITERBI 3 -0.234");
-    testFile.readStats(scanner2);
-    assertEquals(testFile.hmm.getEValueStatistics().get("VITERBI")
-            .getAlignmentModeConfiguration(), "GLOBAL");
-    assertEquals(testFile.hmm.getEValueStatistics().get("VITERBI")
-            .getSlopeOfDistribution(), 3, 2d);
-    assertEquals(testFile.hmm.getEValueStatistics().get("VITERBI")
-            .getLocationOfDistribution(), -0.234, 4d);
-    scanner.close();
-
-  }
-
-  @Test
-  public void testParseBeginNodeData() throws IOException
-  {
-    FileReader fr = new FileReader(file4);
-    BufferedReader br = new BufferedReader(fr);
-    for (int i = 0; i < 24; i++)
-    {
-      br.readLine(); // this is done to reach the begin node
-                                         // data in the file
-    }
-
-    testFile4.hmm.fillSymbols("HMM A B C D E F G H I");
-    testFile4.parseBeginNodeData(br);
-    ArrayList<Double> emissions = new ArrayList<>();
-    ArrayList<Double> transitions = new ArrayList<>();
-
-    emissions.add(2.68618);
-    emissions.add(4.42225);
-    emissions.add(2.77519);
-    emissions.add(2.73123);
-    emissions.add(3.46354);
-    emissions.add(2.40513);
-    emissions.add(3.72494);
-    emissions.add(3.29354);
-    emissions.add(3.61503);
-
-    transitions.add(0.00338);
-    transitions.add(6.08833);
-    transitions.add(6.81068);
-    transitions.add(0.61958);
-    transitions.add(0.77255);
-    transitions.add(0.00000);
-    transitions.add(null);
-
-    assertEquals(testFile4.hmm.getInsertZeroEmissions(), emissions);
-    assertEquals(testFile4.hmm.getBeginStateTransitions(), transitions);
-
+    HiddenMarkovModel hmm = fn3.getHMM();
+    assertEquals(hmm.getTransitionType("mm").intValue(), 0);
+    assertEquals(hmm.getTransitionType("mi").intValue(), 1);
+    assertEquals(hmm.getTransitionType("md").intValue(), 2);
+    assertEquals(hmm.getTransitionType("im").intValue(), 3);
+    assertEquals(hmm.getTransitionType("ii").intValue(), 4);
+    assertEquals(hmm.getTransitionType("dm").intValue(), 5);
+    assertEquals(hmm.getTransitionType("dd").intValue(), 6);
+    assertNull(hmm.getTransitionType("df"));
+  
   }
-
+  
   @Test
   public void testFillList()
   {
     Scanner scanner1 = new Scanner("1.3 2.4 5.3 3.9 9.8 4.7 4.3 2.3 6.9");
     ArrayList<Double> filledArray = new ArrayList<>();
-
+  
     filledArray.add(1.3);
     filledArray.add(2.4);
     filledArray.add(5.3);
@@ -445,11 +248,11 @@ public class HMMFileTest {
     filledArray.add(4.3);
     filledArray.add(2.3);
     filledArray.add(6.9);
-
+  
     assertEquals(HMMFile.fillList(scanner1, 9), filledArray);
     filledArray.clear();
     scanner1.close();
-
+  
     Scanner scanner2 = new Scanner(
             "1.346554 5.58756754 35.3523645 12345.3564 1.4");
     filledArray.add(1.346554);
@@ -457,89 +260,344 @@ public class HMMFileTest {
     filledArray.add(35.3523645);
     filledArray.add(12345.3564);
     filledArray.add(1.4);
+  
     assertEquals(HMMFile.fillList(scanner2, 5), filledArray);
     scanner2.close();
-
+  
   }
-
+  
   @Test
   public void testParseModel() throws IOException
   {
-    FileReader fr = new FileReader(file);
+    FileReader fr = new FileReader(
+            new File("test/jalview/io/test_MADE1_hmm.txt"));
     BufferedReader br = new BufferedReader(fr);
-    for (int i = 0; i < 23; i++)
+    HiddenMarkovModel testHMM = new HiddenMarkovModel();
+    for (int i = 0; i < 24; i++)
     {
-      br.readLine(); // this is done to reach the begin node
-                     // data in the file
+      br.readLine();
     }
-
-    testFile.parseModel(br);
-    assertEquals(testFile.hmm.getMatchEmissions().get(0).get(0), 3.16986);
-    assertEquals(testFile.hmm.getMatchEmissions().get(0).get(3), 3.29953);
-    assertEquals(testFile.hmm.getMatchEmissions().get(1).get(2), 2.24744);
-    assertEquals(testFile.hmm.getMatchEmissions().get(1).get(8), 4.25623);
-    assertEquals(testFile.hmm.getMatchEmissions().get(2).get(5), 3.48010);
-    assertEquals(testFile.hmm.getMatchEmissions().get(2).get(6), 4.51877);
-    assertEquals(testFile.hmm.getMatchEmissions().get(3).get(4), 5.26587);
-    assertEquals(testFile.hmm.getMatchEmissions().get(3).get(8), 4.99111);
-    assertEquals(testFile.hmm.getInsertEmissions().get(0).get(3), 2.73088);
-    assertEquals(testFile.hmm.getInsertEmissions().get(0).get(6), 3.72505);
-    assertEquals(testFile.hmm.getInsertEmissions().get(1).get(2), 2.77519);
-    assertEquals(testFile.hmm.getInsertEmissions().get(1).get(8), 3.61503);
-    assertEquals(testFile.hmm.getInsertEmissions().get(2).get(0), 2.68618);
-    assertEquals(testFile.hmm.getInsertEmissions().get(2).get(8), 3.61503);
-    assertEquals(testFile.hmm.getInsertEmissions().get(3).get(2), 2.77519);
-    assertEquals(testFile.hmm.getInsertEmissions().get(3).get(3), 2.73123);
+    made1.parseModel(br);
+    testHMM = made1.getHMM();
+    br.close();
+    fr.close();
+  
+    assertEquals(getMatchEmission(0, 2, testHMM), 1.62906);
+    assertEquals(getMatchEmission(2, 1, testHMM), 2.37873);
+    assertEquals(getMatchEmission(12, 2, testHMM), 2.61355);
+    assertEquals(getMatchEmission(26, 0, testHMM), 1.86925);
+    assertEquals(getMatchEmission(32, 3, testHMM), 2.58263);
+    assertEquals(getMatchEmission(59, 3, testHMM), 2.20507);
+    assertEquals(getMatchEmission(63, 0, testHMM), 0.41244);
+    assertEquals(getMatchEmission(69, 1, testHMM), 3.17398);
+    assertEquals(getMatchEmission(76, 2, testHMM), 2.65861);
+  
+    assertEquals(getInsertEmission(0, 1, testHMM), 1.38629);
+    assertEquals(getInsertEmission(1, 2, testHMM), 1.38629);
+    assertEquals(getInsertEmission(31, 3, testHMM), 1.28150);
+    assertEquals(getInsertEmission(43, 0, testHMM), 1.32290);
+    assertEquals(getInsertEmission(48, 2, testHMM), 1.52606);
+    assertEquals(getInsertEmission(52, 1, testHMM), 1.62259);
+    assertEquals(getInsertEmission(67, 0, testHMM), 1.38141);
+    assertEquals(getInsertEmission(70, 3, testHMM), 1.38629);
+    assertEquals(getInsertEmission(80, 3, testHMM), 1.38629);
+  
+    assertEquals(getStateTransition(2, 0, testHMM), 0.03725);
+    assertEquals(getStateTransition(6, 1, testHMM), 3.89715);
+    assertEquals(getStateTransition(9, 3, testHMM), 1.38021);
+    assertEquals(getStateTransition(20, 4, testHMM), 0.23815);
+    assertEquals(getStateTransition(34, 6, testHMM), 0.33363);
+    assertEquals(getStateTransition(46, 5, testHMM), 1.05474);
+    assertEquals(getStateTransition(57, 6, testHMM), 0.31164);
+    assertEquals(getStateTransition(68, 2, testHMM), 3.99242);
+    assertEquals(getStateTransition(80, 6, testHMM),
+            Double.NEGATIVE_INFINITY);
+  
   }
-
+  
   @Test
   public void testParseAnnotations()
   {
-    testFile4.hmm.setMapAnnotationFlag(true);
-    Scanner scanner = new Scanner("1 t - - -");
-    testFile4.parseAnnotations(scanner, 0);
+    HMMFile testFile = new HMMFile();
+    testFile.getHMM().getNodes().add(new HMMNode());
+    testFile.getHMM().getNodes().add(new HMMNode());
+    testFile.getHMM().getNodes().add(new HMMNode());
+  
+  
+    testFile.getHMM().setConsensusResidueStatus(true);
+    testFile.getHMM().setMAPStatus(true);
+    testFile.getHMM().setReferenceAnnotationStatus(true);
+    testFile.getHMM().setConsensusStructureStatus(true);
+    testFile.getHMM().setMaskedValueStatus(true);
+    Scanner scanner = new Scanner("1345 t t t t");
+    testFile.parseAnnotations(scanner, 1);
+  
+    testFile.getHMM().setConsensusResidueStatus(true);
+    testFile.getHMM().setMAPStatus(false);
+    testFile.getHMM().setReferenceAnnotationStatus(true);
+    testFile.getHMM().setConsensusStructureStatus(false);
+    testFile.getHMM().setMaskedValueStatus(false);
+    Scanner scanner2 = new Scanner("- y x - -");
+    testFile.parseAnnotations(scanner2, 2);
+  
+    HiddenMarkovModel hmm = testFile.getHMM();
+  
+    assertEquals(hmm.getNodeAlignmentColumn(1).intValue(), 1345);
+    assertEquals(hmm.getConsensusResidue(1), 't');
+    assertEquals(hmm.getReferenceAnnotation(1), 't');
+    assertEquals(hmm.getMaskedValue(1), 't');
+    assertEquals(hmm.getConsensusStructure(1), 't');
+  
+    assertEquals(hmm.findNodeIndex(1345).intValue(), 1);
+  
+    scanner.close();
+  
+    assertNull(hmm.getNodeAlignmentColumn(2));
+    assertEquals(hmm.getConsensusResidue(2), 'y');
+    assertEquals(hmm.getReferenceAnnotation(2), 'x');
+    assertEquals(hmm.getMaskedValue(2), '-');
+    assertEquals(hmm.getConsensusStructure(2), '-');
+  
+    assertNull(hmm.findNodeIndex(2));
+  
+    scanner2.close();
+  }
+  
+  /**
+   * tests to see if file produced by the output matches the file from the input
+   * 
+   * @throws IOException
+   */
 
-    assertEquals(
-            testFile4.hmm.getAlignmentColumnIndexes().get(0).intValue(), 1);
-    assertEquals(
-            testFile4.hmm.getAnnotations().get(0).get("CONS").charValue(),
-            't');
-    assertEquals(
-            testFile4.hmm.getAnnotations().get(0).get("RF").charValue(),
-            '-');
-    assertEquals(
-            testFile4.hmm.getAnnotations().get(0).get("MM").charValue(),
-            '-');
-    assertEquals(
-            testFile4.hmm.getAnnotations().get(0).get("CS").charValue(),
-            '-');
 
-    testFile4.hmm.setMapAnnotationFlag(false);
-    testFile4.hmm.getAlignmentColumnIndexes().clear();
-    testFile4.hmm.getAnnotations().clear();
-    Scanner scanner2 = new Scanner("- S g C Y");
-    testFile4.parseAnnotations(scanner2, 0);
+  @Test(priority = 3)
+  public void testExportFile() throws IOException
+  {
+    fn3.exportFile("test/jalview/io/test_export_hmm.txt");
+    HMMFile fn3Clone = new HMMFile(
+            new FileParse("test/jalview/io/test_export_hmm.txt",
+                    DataSourceType.FILE));
+    fn3Clone.parse();
+    HiddenMarkovModel fn3HMM = new HiddenMarkovModel();
+    HiddenMarkovModel fn3CloneHMM = new HiddenMarkovModel();
+    fn3HMM = fn3.getHMM();
+    fn3CloneHMM = fn3Clone.getHMM();
+  
+    for (int i = 0; i < fn3HMM.getLength(); i++)
+    {
+      List<Double> list1;
+      List<Double> list2;
+      boolean result;
+  
+      list1 = fn3HMM.getNode(i).getMatchEmissions();
+      list2 = fn3CloneHMM.getNode(i).getMatchEmissions();
+  
+      result = checkIfListsAreIdentical(list1, list2);
+      assertEquals(result, true);
+  
+      list1 = fn3HMM.getNode(i).getInsertEmissions();
+      list2 = fn3CloneHMM.getNode(i).getInsertEmissions();
+  
+      result = checkIfListsAreIdentical(list1, list2);
+      assertEquals(result, true);
+  
+      list1 = fn3HMM.getNode(i).getStateTransitions();
+      list2 = fn3CloneHMM.getNode(i).getStateTransitions();
+  
+      result = checkIfListsAreIdentical(list1, list2);
+      assertEquals(result, true);
+  
+      if (i > 0)
+      {
+        int alignColumn1;
+        int alignColumn2;
+  
+        alignColumn1 = fn3HMM.getNodeAlignmentColumn(i);
+        alignColumn2 = fn3CloneHMM.getNodeAlignmentColumn(i);
+  
+        assertEquals(alignColumn1, alignColumn2);
+  
+        char annotation1;
+        char annotation2;
+  
+        annotation1 = fn3HMM.getReferenceAnnotation(i);
+        annotation2 = fn3CloneHMM.getReferenceAnnotation(i);
+  
+        assertEquals(annotation1, annotation2);
+  
+        annotation1 = fn3HMM.getConsensusResidue(i);
+        annotation2 = fn3CloneHMM.getConsensusResidue(i);
+  
+        assertEquals(annotation1, annotation2);
+      }
+  
+    }
+  
+  }
+  
+  @Test(priority = 1)
+  public void testAppendFileProperties()
+  {
+    StringBuilder testBuilder = new StringBuilder();
+    fn3.appendFileProperties(testBuilder);
+    Scanner testScanner = new Scanner(testBuilder.toString());
+  
+    String[] expected = new String[] { "HMMER3/f [3.1b1 | May 2013]",
+        "NAME  fn3", "ACC   PF00041.13",
+        "DESC  Fibronectin type III domain", "LENG  86", "ALPH  amino",
+        "RF    no", "MM    no", "CONS  yes", "CS    yes", "MAP   yes",
+        "DATE  Fri Jun 20 08:22:31 2014", "NSEQ  106", "EFFN  11.415833",
+        "CKSUM 3564431818", "GA    8.00 7.20", "TC    8.00 7.20",
+        "NC    7.90 7.90", "STATS LOCAL MSV       -9.4043  0.71847",
+        "STATS LOCAL VITERBI   -9.7737  0.71847",
+        "STATS LOCAL FORWARD   -3.8341  0.71847" };
+  
+    for (String value : expected)
+    {
+      assertEquals(testScanner.nextLine(), value);
+    }
+  
+    testScanner.close();
+  }
+  
+  @Test(priority = 2)
+  public void testAppendModel()
+  {
+    StringBuilder testBuilder = new StringBuilder();
+    fn3.appendModel(testBuilder);
+    String string = testBuilder.toString();
+    assertEquals(findValue(2, 2, 2, string), "4.42225");
+    assertEquals(findValue(12, 14, 1, string), "2.79307");
+    assertEquals(findValue(6, 24, 3, string), "0.48576");
+    assertEquals(findValue(19, 33, 2, string), "4.58477");
+    assertEquals(findValue(20, 64, 2, string), "3.61505");
+    assertEquals(findValue(3, 72, 3, string), "6.81068");
+    assertEquals(findValue(10, 80, 2, string), "2.69355");
+    assertEquals(findValue(16, 65, 1, string), "2.81003");
+    assertEquals(findValue(14, 3, 1, string), "2.69012");
+    assertEquals(findValue(11, 32, 1, string), "4.34805");
+  
+  }
+  
+  /**
+   * 
+   * @param symbolIndex
+   *          index of symbol being searched. First symbol has index 1.
+   * @param nodeIndex
+   *          index of node being searched. Begin node has index 0. First node
+   *          has index 1.
+   * @param line
+   *          index of line being searched in node. First line has index 1.
+   * @param model
+   *          string model being searched
+   * @return value at specified position
+   */
+
+  public String findValue(int symbolIndex, int nodeIndex, int line,
+          String model)
+  {
+  
+    String value = "";
+    Scanner scanner = new Scanner(model);
+    scanner.nextLine();
+    scanner.nextLine();
+  
+    for (int lineIndex = 0; lineIndex < line - 1; lineIndex++)
+    {
+      scanner.nextLine();
+    }
+    for (int node = 0; node < nodeIndex; node++)
+    {
+      scanner.nextLine();
+      scanner.nextLine();
+      scanner.nextLine();
+    }
+  
+    for (int symbol = 0; symbol < symbolIndex; symbol++)
+    {
+      value = scanner.next();
+      if ("COMPO".equals(value))
+      {
+        scanner.next();
+      }
+      else if (value.length() < 7)
+      {
+        scanner.next();
+      }
+  
+    }
+    return value;
+  
+  }
+  
+  public boolean checkIfListsAreIdentical(List<Double> list1,
+          List<Double> list2)
+  {
+    boolean isDifferent = false;
+    for (int i = 0; i < list1.size(); i++)
+    {
+      Double entry1;
+      Double entry2;
+      entry1 = list1.get(i);
+      entry2 = list2.get(i);
+      if (!(entry1 == entry2))
+      {
+        isDifferent = true;
+      }
+    }
+    return isDifferent;
+  }
 
-    assertEquals(
-            testFile4.hmm.getAnnotations().get(0).get("CONS").charValue(),
-            'S');
-    assertEquals(
-            testFile4.hmm.getAnnotations().get(0).get("RF").charValue(),
-            'g');
-    assertEquals(
-            testFile4.hmm.getAnnotations().get(0).get("MM").charValue(),
-            'C');
-    assertEquals(
-            testFile4.hmm.getAnnotations().get(0).get("CS").charValue(),
-            'Y');
+  /**
+   * gets the match emission at a node for a symbol
+   * 
+   * @param nodeIndex
+   *          position of node in model
+   * @param symbolIndex
+   *          index of symbol being searched
+   * @return negative log probability of a match emission of the given symbol
+   */
+  public double getMatchEmission(int nodeIndex, int symbolIndex,
+          HiddenMarkovModel hmm)
+  {
+    double value = hmm.getNodes().get(nodeIndex).getMatchEmissions()
+            .get(symbolIndex);
+    return value;
   }
 
-  @Test
-  public void testExportFile() throws IOException
+  /**
+   * gets the insert emission at a node for a symbol
+   * 
+   * @param nodeIndex
+   *          position of node in model
+   * @param symbolIndex
+   *          index of symbol being searched
+   * @return negative log probability of an insert emission of the given symbol
+   */
+  public double getInsertEmission(int nodeIndex, int symbolIndex,
+          HiddenMarkovModel hmm)
   {
-    HMMFile exportTestFile = new HMMFile("H:/HMMTutorialExample.hmm");
-    exportTestFile.parse();
-    exportTestFile.exportFile("H:/WriteTestFile.hmm");
+    double value = hmm.getNodes().get(nodeIndex).getInsertEmissions()
+            .get(symbolIndex);
+    return value;
+  }
 
+  /**
+   * gets the state transition at a node for a specific transition
+   * 
+   * @param nodeIndex
+   *          position of node in model
+   * @param transitionIndex
+   *          index of stransition being searched
+   * @return negative log probability of a state transition of the given type
+   */
+  public double getStateTransition(int nodeIndex, int transitionIndex,
+          HiddenMarkovModel hmm)
+  {
+    double value = hmm.getNodes().get(nodeIndex).getStateTransitions()
+            .get(transitionIndex);
+    return value;
   }
+
 }
+