throws IOException
{
StringBuilder desc = new StringBuilder(256);
- String line = getValue(firstDescriptionLine);
- while (line != null)
+ desc.append(getValue(firstDescriptionLine));
+ if (!firstDescriptionLine.endsWith(SEMICOLON))
{
- if (line.endsWith(SEMICOLON))
+ String line = nextNonCommentLine();
+ while (line != null)
{
- desc.append(line.substring(0, line.length() - 1));
- break;
- }
- else if (line.length() > 0)
- {
- desc.append(line).append(newline);
+ if (line.endsWith(SEMICOLON))
+ {
+ desc.append(line.substring(0, line.length() - 1));
+ break;
+ }
+ else if (line.length() > 0)
+ {
+ desc.append(line).append(newline);
+ }
+ line = nextNonCommentLine();
}
- line = nextNonCommentLine();
}
setAlignmentProperty(PROP_DESCRIPTION, desc.toString());
}
String propertyValue = (String) al.getProperty(PROP_TITLE);
if (propertyValue != null)
{
- sb.append(BANG).append(TITLE).append(SPACE)
-.append(propertyValue)
- .append(SEMICOLON)
- .append(newline);
+ sb.append(BANG).append(TITLE).append(SPACE).append(propertyValue)
+ .append(SEMICOLON).append(newline);
}
propertyValue = (String) al.getProperty(PROP_DESCRIPTION);
if (propertyValue != null)
.append(newline);
/*
- * !Format NSeqs NSites
- * NSites the length of any sequence (they should all be the same), excluding
- * gaps?!?
+ * !Format NSeqs NSites (the length of sequences - they should all be the
+ * same - including gaps)
*/
sb.append(INDENT).append(N_SEQS).append(EQUALS).append(al.getHeight());
- SequenceI seq = al.getSequenceAt(0);
sb.append(SPACE).append(N_SITES).append(EQUALS)
- .append(seq.getEnd() - seq.getStart() + 1);
+ .append(String.valueOf(al.getWidth()));
sb.append(newline);
/*
+ "#CPZANT MNOPQR\n\n"
+ "#U456 KLMNOP\n";
- // the 'fancy' format, different header format, bases in triplet groups
+ // interleaved with description, bases/gaps in triplet groups
private static final String INTERLEAVED_WITH_DESCRIPTION =
"#MEGA\n"
+ "!Title Data with description;\n"
+ "!Description\n"
+ " Line one of description\n"
+ " Line two of description;\n\n"
- + "#U455 CGC GTA\n"
- + "#CPZANT ATC GGG\n\n"
- + "#U455 CGA TTT\n"
- + "#CPZANT CAA TGC\n";
+ + "#U455 C-- GTA\n"
+ + "#CPZANT ATC -G-\n\n"
+ + "#U455 CGA --T\n"
+ + "#CPZANT CA- -GC\n";
//@formatter:on
assertEquals("Second sequence id wrong", "CPZANT", seqs.get(1)
.getName());
// check sequence data
- assertEquals("First sequence data wrong", "CGCGTACGATTT", seqs.get(0)
+ assertEquals("First sequence data wrong", "C--GTACGA--T", seqs.get(0)
.getSequenceAsString());
- assertEquals("Second sequence data wrong", "ATCGGGCAATGC", seqs.get(1)
+ assertEquals("Second sequence data wrong", "ATC-G-CA--GC", seqs.get(1)
.getSequenceAsString());
assertTrue("File format is not flagged as interleaved",
testee.isInterleaved());
" Line two of description;\n" +
"!Format\n" +
" DataType=DNA CodeTable=Standard\n" +
- " NSeqs=2 NSites=12\n" +
+ " NSeqs=2 NSites=12\n" + // NSites includes gaps
" Indel=- Identical=. Missing=?;\n\n" +
- "#U455 CGC GTA [6]\n" +
- "#CPZANT ATC GGG [6]\n\n" +
- "#U455 CGA TTT [12]\n" +
- "#CPZANT CAA TGC [12]\n";
+ "#U455 C-- GTA [6]\n" +
+ "#CPZANT ATC -G- [6]\n\n" +
+ "#U455 CGA --T [12]\n" +
+ "#CPZANT CA- -GC [12]\n";
//@formatter:on
assertEquals("Roundtrip didn't match", expected,
formatted);
assertTrue("File format is not flagged as interleaved",
testee.isInterleaved());
}
+
+ //@formatter:on
+
}