import jalview.datamodel.HiddenMarkovModel;
import java.io.BufferedReader;
-import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
FileReader fr = new FileReader(fn3.getDataObject());
BufferedReader br = new BufferedReader(fr);
fn3.parseFileProperties(br);
+ fn3.parseModel(br); // this is for a later test
HiddenMarkovModel testHMM = new HiddenMarkovModel();
testHMM = fn3.getHmm();
br.close();
assertEquals(testHMM.getMSV(), "-8.5786 0.71858");
assertEquals(testHMM.getForward(), "-3.4823 0.71858");
+
}
@Test
scanner2.close();
}
- @Test(priority = 2)
+ @Test(priority = 3)
public void testExportFile() throws IOException
{
- File file = new File(fn3.getDataObject());
- FileReader fr = new FileReader(file);
- BufferedReader br = new BufferedReader(fr);
- for (int i = 0; i < 23; i++)
- {
- br.readLine();
- }
- fn3.parseModel(br);
+
fn3.exportFile("H:/WriteFileTest.hmm");
}
testScanner.close();
}
- public moveAheadBy(Scanner scanner, int nodeChange, int indexChange)
+ @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");
+ }
+
+ public String findValue(int symbolIndex, int nodeIndex, int line,
+ String model)
{
- for (int y = 0; y < nodeChange; y++)
+
+ 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;
+
}
+
}
+