{
/*
* Parse name from ScoreMatrix <name>
+ * we allow any delimiter after ScoreMatrix then take the rest of the line
*/
if (name != null)
{
+ lineNo);
}
StringTokenizer nameLine = new StringTokenizer(data, DELIMITERS);
- if (nameLine.countTokens() != 2)
+ if (nameLine.countTokens() < 2)
{
err = "Format error: expected 'ScoreMatrix <name>', found '"
+ data + "' at line " + lineNo;
throw new FileFormatException(err);
}
- nameLine.nextToken();
- name = nameLine.nextToken();
+ nameLine.nextToken(); // 'ScoreMatrix'
+ name = nameLine.nextToken(); // next field
+ name = data.substring(1).substring(data.substring(1).indexOf(name));
continue;
}
else if (name == null)
* or tab (or combinations) as score value delimiters
* this example includes 'guide' symbols on score rows
*/
- String data = "ScoreMatrix MyTest\n" + "ATU tx-\n"
+ String data = "ScoreMatrix MyTest (example)\n" + "ATU tx-\n"
+ "A,1.1,1.2,1.3,1.4, 1.5, 1.6, 1.7\n"
+ "T,2.1 2.2 2.3 2.4 2.5 2.6 2.7\n"
+ "U\t3.1\t3.2\t3.3\t3.4\t3.5\t3.6\t3.7\n"
ScoreMatrix sm = parser.parseMatrix();
assertNotNull(sm);
- assertEquals(sm.getName(), "MyTest");
+ assertEquals(sm.getName(), "MyTest (example)");
assertTrue(sm.isDNA());
assertFalse(sm.isProtein());
assertEquals(sm.getPairwiseScore('A', 'A'), 1.1f);