import java.io.BufferedReader;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
assertEquals(getStateTransition(209, 0, hmm), 0.99, 0.001d);
assertEquals(getStateTransition(243, 1, hmm), 0.0066, 0.001d);
- assertEquals(hmm.getNodeAlignmentColumn(3).intValue(), 3);
+ assertEquals(hmm.getNodeAlignmentColumn(3).intValue(), 2);
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.getNodeAlignmentColumn(78).intValue(), 135);
assertEquals(hmm.getReferenceAnnotation(93), '-');
assertEquals(hmm.getConsensusResidue(145), 'a');
assertEquals(hmm.getMaskedValue(183), '-');
HiddenMarkovModel hmm = testFile.getHMM();
- assertEquals(hmm.getNodeAlignmentColumn(1).intValue(), 1345);
+ assertEquals(hmm.getNodeAlignmentColumn(1).intValue(), 1344);
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);
+ assertEquals(hmm.findNodeIndex(1344).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();
}
/**
}
@Test(priority = 1)
- public void testAppendFileProperties()
+ public void testAppendFileProperties() throws FileNotFoundException
{
- StringBuilder testBuilder = new StringBuilder();
- fn3.appendFileProperties(testBuilder);
- Scanner testScanner = new Scanner(testBuilder.toString());
+ PrintWriter writer = new PrintWriter(
+ "test/jalview/io/test_export_hmm.txt");
+ fn3.appendFileProperties(writer);
+ writer.close();
+ String content;
+ File file = new File("test/jalview/io/test_export_hmm.txt");
+
+ Scanner testScanner = new Scanner(file);
+ testScanner.useDelimiter("\\Z");
String[] expected = new String[] { "HMMER3/f [3.1b1 | May 2013]",
"NAME fn3", "ACC PF00041.13",
}
@Test(priority = 2)
- public void testAppendModel()
+ public void testAppendModel() throws FileNotFoundException
{
- StringBuilder testBuilder = new StringBuilder();
- fn3.appendModel(testBuilder);
- String string = testBuilder.toString();
+ PrintWriter writer = new PrintWriter(
+ "test/jalview/io/test_export_hmm.txt");
+ fn3.appendModel(writer);
+ writer.close();
+ String string;
+ File file = new File("test/jalview/io/test_export_hmm.txt");
+ Scanner scanner = new Scanner(file);
+ scanner.useDelimiter("\\Z");
+ string = scanner.next();
+
assertEquals(findValue(2, 2, 2, string), "4.42225");
assertEquals(findValue(12, 14, 1, string), "2.79307");
assertEquals(findValue(6, 24, 3, string), "0.48576");