Allow RODs to specify that incomplete records are okay (i.e. that they allow optional fields)
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1433 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
9b1d7921e8
commit
53153fcd79
|
|
@ -63,6 +63,10 @@ public class SimpleIndelROD extends TabularROD implements Genotype, AllelicVaria
|
||||||
return getFWDAlleles().get(0).length();
|
return getFWDAlleles().get(0).length();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean allowIncompleteRecords() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
sb.append(getLocation().getContig() + "\t" + getLocation().getStart() + "\t");
|
sb.append(getLocation().getContig() + "\t" + getLocation().getStart() + "\t");
|
||||||
|
|
|
||||||
|
|
@ -163,6 +163,16 @@ public class TabularROD extends BasicReferenceOrderedDatum implements Map<String
|
||||||
return readHeader(source);
|
return readHeader(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default, all records (i.e. RODs) must contain the same number of fields as specified
|
||||||
|
* by the header. Subclasses should override this method to disable this requirement.
|
||||||
|
*
|
||||||
|
* @return true if incomplete records are allowed; false otherwise
|
||||||
|
*/
|
||||||
|
public boolean allowIncompleteRecords() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static ArrayList<String> readHeader(final File source) throws FileNotFoundException {
|
public static ArrayList<String> readHeader(final File source) throws FileNotFoundException {
|
||||||
ArrayList<String> header = null;
|
ArrayList<String> header = null;
|
||||||
int linesLookedAt = 0;
|
int linesLookedAt = 0;
|
||||||
|
|
@ -308,7 +318,7 @@ public class TabularROD extends BasicReferenceOrderedDatum implements Map<String
|
||||||
if ( parts.length == 0 || COMMENT_PATTERN.matcher(parts[0]).matches() || HEADER_PATTERN.matcher(parts[0]).matches() )
|
if ( parts.length == 0 || COMMENT_PATTERN.matcher(parts[0]).matches() || HEADER_PATTERN.matcher(parts[0]).matches() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (header.size() != parts.length) {
|
if ( !allowIncompleteRecords() && header.size() != parts.length) {
|
||||||
throw new IOException(String.format("Header length %d not equal to Tabular parts length %d", header.size(), parts.length));
|
throw new IOException(String.format("Header length %d not equal to Tabular parts length %d", header.size(), parts.length));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue