Horrible bugfix to decodeLoc() in BCF2Codec

-- Just completely wrong.
-- BCF2 shadowBCF now checks that the shadow bcf can be written to avoid /dev/null.bcf problem
-- Added samtools ex2.bcf file for decoding to our integrationtests
This commit is contained in:
Mark DePristo 2012-06-22 17:03:59 -04:00
parent 896df0d6b0
commit 11dbfc92a7
3 changed files with 28 additions and 18 deletions

View File

@ -101,15 +101,7 @@ public final class BCF2Codec implements FeatureCodec<VariantContext>, ReferenceD
@Override
public Feature decodeLoc( final PositionalBufferedStream inputStream ) {
recordNo++;
final VariantContextBuilder builder = new VariantContextBuilder();
final int sitesBlockSize = decoder.readBlockSize(inputStream);
final int genotypeBlockSize = decoder.readBlockSize(inputStream); // necessary because it's in the stream
decoder.readNextBlock(sitesBlockSize, inputStream);
decodeSiteLoc(builder);
return builder.fullyDecoded(true).make();
return decode(inputStream);
}
@Override

View File

@ -32,10 +32,7 @@ import org.broadinstitute.sting.utils.codecs.vcf.VCFHeaderLine;
import org.broadinstitute.sting.utils.codecs.vcf.VCFIDHeaderLine;
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.*;
import java.util.*;
/**
@ -207,14 +204,27 @@ public final class BCF2Utils {
* @return the BCF
*/
@Requires("vcfFile != null")
@Ensures("result != null")
public static final File shadowBCF(final File vcfFile) {
final String path = vcfFile.getAbsolutePath();
if ( path.contains(".vcf") )
return new File(path.replace(".vcf", ".bcf"));
else {
final File bcf = new File( path + ".bcf" );
return bcf.canWrite() ? bcf : null;
if ( bcf.canRead() )
return bcf;
else {
try {
// this is the only way to robustly decide if we could actually write to BCF
final FileOutputStream o = new FileOutputStream(bcf);
o.close();
bcf.delete();
return bcf;
} catch ( FileNotFoundException e ) {
return null;
} catch ( IOException e ) {
return null;
}
}
}
}

View File

@ -30,7 +30,6 @@ public class VCFIntegrationTest extends WalkerTest {
// See https://getsatisfaction.com/gsa/topics/support_vcf_4_1_structural_variation_breakend_alleles?utm_content=topic_link&utm_medium=email&utm_source=new_topic
public void testReadingAndWritingBreakpointAlleles() {
String testVCF = privateTestDir + "breakpoint-example.vcf";
//String testVCF = validationDataLocation + "multiallelic.vcf";
String baseCommand = "-R " + b37KGReference + " --no_cmdline_in_header -o %s ";
@ -51,11 +50,20 @@ public class VCFIntegrationTest extends WalkerTest {
}
@Test
public void testReadingAndWritingSamtoolsWExBCFExample() {
public void testWritingSamtoolsWExBCFExample() {
String testVCF = privateTestDir + "ex2.vcf";
String baseCommand = "-R " + b36KGReference + " --no_cmdline_in_header -o %s ";
String test1 = baseCommand + "-T SelectVariants -V " + testVCF;
WalkerTestSpec spec1 = new WalkerTestSpec(test1, 1, Arrays.asList("9773d6a121cfcb18d090965bc520f120"));
executeTest("Test reading and writing samtools WEx vcf/BCF example", spec1);
executeTest("Test writing samtools WEx BCF example", spec1);
}
@Test
public void testReadingSamtoolsWExBCFExample() {
String testVCF = privateTestDir + "ex2.bcf";
String baseCommand = "-R " + b36KGReference + " --no_cmdline_in_header -o %s ";
String test1 = baseCommand + "-T SelectVariants -V " + testVCF;
WalkerTestSpec spec1 = new WalkerTestSpec(test1, 1, Arrays.asList("63a2e0484ae37b0680514f53e0bf0c94"));
executeTest("Test reading samtools WEx BCF example", spec1);
}
}