From 7c9fbca0e2d9be5fd05e1c89f24f81d558bf6849 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Fri, 17 Feb 2017 13:30:01 +0000 Subject: [PATCH] JAL-2416 allow space in score matrix name --- src/jalview/io/ScoreMatrixFile.java | 8 +++++--- test/jalview/io/ScoreMatrixFileTest.java | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/jalview/io/ScoreMatrixFile.java b/src/jalview/io/ScoreMatrixFile.java index d927b3f..97fe46b 100644 --- a/src/jalview/io/ScoreMatrixFile.java +++ b/src/jalview/io/ScoreMatrixFile.java @@ -89,6 +89,7 @@ public class ScoreMatrixFile extends AlignFile implements { /* * Parse name from ScoreMatrix + * we allow any delimiter after ScoreMatrix then take the rest of the line */ if (name != null) { @@ -97,14 +98,15 @@ public class ScoreMatrixFile extends AlignFile implements + lineNo); } StringTokenizer nameLine = new StringTokenizer(data, DELIMITERS); - if (nameLine.countTokens() != 2) + if (nameLine.countTokens() < 2) { err = "Format error: expected 'ScoreMatrix ', 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) diff --git a/test/jalview/io/ScoreMatrixFileTest.java b/test/jalview/io/ScoreMatrixFileTest.java index 77b7282..123de6b 100644 --- a/test/jalview/io/ScoreMatrixFileTest.java +++ b/test/jalview/io/ScoreMatrixFileTest.java @@ -30,7 +30,7 @@ public class ScoreMatrixFileTest * 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" @@ -43,7 +43,7 @@ public class ScoreMatrixFileTest 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); -- 1.7.10.2