Simple refactoring to make formating functions public

This commit is contained in:
Mark DePristo 2011-09-02 21:13:08 -04:00
parent 124ef6c483
commit 03aa04e37c
3 changed files with 11 additions and 4 deletions

View File

@ -227,7 +227,7 @@ public abstract class AbstractVCFCodec implements FeatureCodec, NameAwareCodec,
throw new UserException.MalformedVCF(message, lineNo); throw new UserException.MalformedVCF(message, lineNo);
} }
private static void generateException(String message, int lineNo) { protected static void generateException(String message, int lineNo) {
throw new UserException.MalformedVCF(message, lineNo); throw new UserException.MalformedVCF(message, lineNo);
} }

View File

@ -275,7 +275,7 @@ public class StandardVCFWriter implements VCFWriter {
mWriter.write(VCFConstants.FIELD_SEPARATOR); mWriter.write(VCFConstants.FIELD_SEPARATOR);
// FILTER // FILTER
String filters = vc.isFiltered() ? ParsingUtils.join(";", ParsingUtils.sortList(vc.getFilters())) : (filtersWereAppliedToContext || vc.filtersWereApplied() ? VCFConstants.PASSES_FILTERS_v4 : VCFConstants.UNFILTERED); String filters = getFilterString(vc, filtersWereAppliedToContext);
mWriter.write(filters); mWriter.write(filters);
mWriter.write(VCFConstants.FIELD_SEPARATOR); mWriter.write(VCFConstants.FIELD_SEPARATOR);
@ -319,7 +319,14 @@ public class StandardVCFWriter implements VCFWriter {
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException("Unable to write the VCF object to " + locationString()); throw new RuntimeException("Unable to write the VCF object to " + locationString());
} }
}
public static final String getFilterString(final VariantContext vc) {
return getFilterString(vc, false);
}
public static final String getFilterString(final VariantContext vc, boolean forcePASS) {
return vc.isFiltered() ? ParsingUtils.join(";", ParsingUtils.sortList(vc.getFilters())) : (forcePASS || vc.filtersWereApplied() ? VCFConstants.PASSES_FILTERS_v4 : VCFConstants.UNFILTERED);
} }
private String getQualValue(double qual) { private String getQualValue(double qual) {
@ -462,7 +469,7 @@ public class StandardVCFWriter implements VCFWriter {
mWriter.write(encoding); mWriter.write(encoding);
} }
private static String formatVCFField(Object val) { public static String formatVCFField(Object val) {
String result; String result;
if ( val == null ) if ( val == null )
result = VCFConstants.MISSING_VALUE_v4; result = VCFConstants.MISSING_VALUE_v4;

View File

@ -118,7 +118,7 @@ public class VCFCodec extends AbstractVCFCodec {
if ( filterString.equals(VCFConstants.PASSES_FILTERS_v3) ) if ( filterString.equals(VCFConstants.PASSES_FILTERS_v3) )
generateException(VCFConstants.PASSES_FILTERS_v3 + " is an invalid filter name in vcf4", lineNo); generateException(VCFConstants.PASSES_FILTERS_v3 + " is an invalid filter name in vcf4", lineNo);
if ( filterString.length() == 0 ) if ( filterString.length() == 0 )
generateException("The VCF specification requires a valid filter status", lineNo); generateException("The VCF specification requires a valid filter status: filter was " + filterString, lineNo);
// do we have the filter string cached? // do we have the filter string cached?
if ( cache != null && cache.containsKey(filterString) ) if ( cache != null && cache.containsKey(filterString) )