Update BCF2 to put PASS as offset 0 not at the end
-- Unfortunately this commit breaks backward compatibility with all existing BCF2 files...
This commit is contained in:
parent
25c773ef33
commit
c3c3d18611
|
|
@ -202,7 +202,7 @@ public final class BCF2Decoder {
|
||||||
return null;
|
return null;
|
||||||
else {
|
else {
|
||||||
final String s = new String(bytes, 0, goodLength);
|
final String s = new String(bytes, 0, goodLength);
|
||||||
return BCF2Utils.isCollapsedString(s) ? BCF2Utils.exploreStringList(s) : s;
|
return BCF2Utils.isCollapsedString(s) ? BCF2Utils.explodeStringList(s) : s;
|
||||||
}
|
}
|
||||||
} catch ( IOException e ) {
|
} catch ( IOException e ) {
|
||||||
throw new ReviewedStingException("readByte failure", e);
|
throw new ReviewedStingException("readByte failure", e);
|
||||||
|
|
|
||||||
|
|
@ -79,23 +79,19 @@ public final class BCF2Utils {
|
||||||
final Set<String> seen = new HashSet<String>();
|
final Set<String> seen = new HashSet<String>();
|
||||||
final ArrayList<String> dict = new ArrayList<String>();
|
final ArrayList<String> dict = new ArrayList<String>();
|
||||||
|
|
||||||
boolean sawPASS = false;
|
dict.add(VCFConstants.PASSES_FILTERS_v4); // special case the special PASS field
|
||||||
|
|
||||||
// set up the strings dictionary
|
// set up the strings dictionary
|
||||||
for ( VCFHeaderLine line : header.getMetaDataInInputOrder() ) {
|
for ( VCFHeaderLine line : header.getMetaDataInInputOrder() ) {
|
||||||
if ( line instanceof VCFIDHeaderLine && ! (line instanceof VCFContigHeaderLine) ) {
|
if ( line instanceof VCFIDHeaderLine && ! (line instanceof VCFContigHeaderLine) ) {
|
||||||
final VCFIDHeaderLine idLine = (VCFIDHeaderLine)line;
|
final VCFIDHeaderLine idLine = (VCFIDHeaderLine)line;
|
||||||
if ( ! seen.contains(idLine.getID())) {
|
if ( ! seen.contains(idLine.getID())) {
|
||||||
sawPASS = sawPASS || idLine.getID().equals(VCFConstants.PASSES_FILTERS_v4);
|
|
||||||
dict.add(idLine.getID());
|
dict.add(idLine.getID());
|
||||||
seen.add(idLine.getID());
|
seen.add(idLine.getID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( ! sawPASS )
|
|
||||||
dict.add(VCFConstants.PASSES_FILTERS_v4); // special case the special PASS field
|
|
||||||
|
|
||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -177,7 +173,7 @@ public final class BCF2Utils {
|
||||||
*/
|
*/
|
||||||
@Requires({"collapsed != null", "isCollapsedString(collapsed)"})
|
@Requires({"collapsed != null", "isCollapsedString(collapsed)"})
|
||||||
@Ensures("result != null")
|
@Ensures("result != null")
|
||||||
public static final List<String> exploreStringList(final String collapsed) {
|
public static final List<String> explodeStringList(final String collapsed) {
|
||||||
assert isCollapsedString(collapsed);
|
assert isCollapsedString(collapsed);
|
||||||
final String[] exploded = collapsed.substring(1).split(",");
|
final String[] exploded = collapsed.substring(1).split(",");
|
||||||
return Arrays.asList(exploded);
|
return Arrays.asList(exploded);
|
||||||
|
|
|
||||||
|
|
@ -351,7 +351,7 @@ public class BCF2EncoderDecoderUnitTest extends BaseTest {
|
||||||
public void testEncodingListOfString(List<String> strings, String expected) throws IOException {
|
public void testEncodingListOfString(List<String> strings, String expected) throws IOException {
|
||||||
final String collapsed = BCF2Utils.collapseStringList(strings);
|
final String collapsed = BCF2Utils.collapseStringList(strings);
|
||||||
Assert.assertEquals(collapsed, expected);
|
Assert.assertEquals(collapsed, expected);
|
||||||
Assert.assertEquals(BCF2Utils.exploreStringList(collapsed), strings);
|
Assert.assertEquals(BCF2Utils.explodeStringList(collapsed), strings);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ public class VCFIntegrationTest extends WalkerTest {
|
||||||
String testVCF = privateTestDir + "ex2.vcf";
|
String testVCF = privateTestDir + "ex2.vcf";
|
||||||
String baseCommand = "-R " + b36KGReference + " --no_cmdline_in_header -o %s ";
|
String baseCommand = "-R " + b36KGReference + " --no_cmdline_in_header -o %s ";
|
||||||
String test1 = baseCommand + "-T SelectVariants -V " + testVCF;
|
String test1 = baseCommand + "-T SelectVariants -V " + testVCF;
|
||||||
WalkerTestSpec spec1 = new WalkerTestSpec(test1, 1, Arrays.asList("a04a0fc22fedb516c663e56e51fc1e27"));
|
WalkerTestSpec spec1 = new WalkerTestSpec(test1, 1, Arrays.asList("e8f721ce81e4fdadba13c5291027057f"));
|
||||||
executeTest("Test writing samtools WEx BCF example", spec1);
|
executeTest("Test writing samtools WEx BCF example", spec1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue