Support for whitespace only lines

This commit is contained in:
Mark DePristo 2011-10-03 09:30:10 -07:00
parent 0604ce55d1
commit 93fba06cb5
2 changed files with 11 additions and 1 deletions

View File

@ -166,7 +166,9 @@ public class PedReader {
final List<String[]> splits = new ArrayList<String[]>(lines.size());
for ( final String line : lines ) {
if ( line.startsWith(commentMarker)) continue;
String[] parts = line.split("\\s+");
if ( line.trim().equals("") ) continue;
final String[] parts = line.split("\\s+");
if ( parts.length != nExpectedFields )
throw new UserException.MalformedFile(reader.toString(), "Bad PED line " + lineNo + ": wrong number of fields");

View File

@ -107,6 +107,14 @@ public class PedReaderUnitTest extends BaseTest {
"fam1 s1 0 0 1 1",
"fam2 s2 0 0 2 2"));
new PedReaderTest("multipleUnrelatedExtraLine",
Arrays.asList(
new Sample("s1", "fam1", null, null, Gender.MALE, Affection.UNAFFECTED),
new Sample("s2", "fam2", null, null, Gender.FEMALE, Affection.AFFECTED)),
String.format("%s%n%s%n %n", // note extra newlines and whitespace
"fam1 s1 0 0 1 1",
"fam2 s2 0 0 2 2"));
new PedReaderTest("explicitTrio",
Arrays.asList(
new Sample("kid", "fam1", "dad", "mom", Gender.MALE, Affection.AFFECTED),