Bugfixes for VCFWriterUnitTest and TestProvider to deal with stricter VCFWriter behavior
This commit is contained in:
parent
9c81f45c9f
commit
d015a5738d
|
|
@ -10,6 +10,7 @@ import org.broadinstitute.sting.BaseTest;
|
||||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||||
import org.broadinstitute.sting.utils.fasta.CachingIndexedFastaSequenceFile;
|
import org.broadinstitute.sting.utils.fasta.CachingIndexedFastaSequenceFile;
|
||||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||||
|
import org.broadinstitute.sting.utils.variantcontext.writer.Options;
|
||||||
import org.broadinstitute.sting.utils.variantcontext.writer.VariantContextWriter;
|
import org.broadinstitute.sting.utils.variantcontext.writer.VariantContextWriter;
|
||||||
import org.broadinstitute.sting.utils.variantcontext.writer.VariantContextWriterFactory;
|
import org.broadinstitute.sting.utils.variantcontext.writer.VariantContextWriterFactory;
|
||||||
import org.testng.annotations.BeforeTest;
|
import org.testng.annotations.BeforeTest;
|
||||||
|
|
@ -19,6 +20,7 @@ import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tests out the various functions in the index factory class
|
* tests out the various functions in the index factory class
|
||||||
|
|
@ -56,7 +58,8 @@ public class IndexFactoryUnitTest extends BaseTest {
|
||||||
AbstractFeatureReader<VariantContext> source = AbstractFeatureReader.getFeatureReader(inputFile.getAbsolutePath(), new VCFCodec(), indexFromInputFile);
|
AbstractFeatureReader<VariantContext> source = AbstractFeatureReader.getFeatureReader(inputFile.getAbsolutePath(), new VCFCodec(), indexFromInputFile);
|
||||||
|
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
VariantContextWriter writer = VariantContextWriterFactory.create(outputFile, dict);
|
final EnumSet<Options> options = EnumSet.of(Options.ALLOW_MISSING_FIELDS_IN_HEADER);
|
||||||
|
VariantContextWriter writer = VariantContextWriterFactory.create(outputFile, dict, options);
|
||||||
writer.writeHeader((VCFHeader)source.getHeader());
|
writer.writeHeader((VCFHeader)source.getHeader());
|
||||||
CloseableTribbleIterator<VariantContext> it = source.iterator();
|
CloseableTribbleIterator<VariantContext> it = source.iterator();
|
||||||
while (it.hasNext() && (counter++ < maxRecords || maxRecords == -1) ) {
|
while (it.hasNext() && (counter++ < maxRecords || maxRecords == -1) ) {
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,8 @@ public class VariantContextTestProvider {
|
||||||
|
|
||||||
logger.warn("Reading records from " + file);
|
logger.warn("Reading records from " + file);
|
||||||
for ( final VariantContext raw : x.getSecond() ) {
|
for ( final VariantContext raw : x.getSecond() ) {
|
||||||
fullyDecoded.add(raw.fullyDecode(x.getFirst()));
|
if ( raw != null )
|
||||||
|
fullyDecoded.add(raw.fullyDecode(x.getFirst()));
|
||||||
}
|
}
|
||||||
logger.warn("Done reading " + file);
|
logger.warn("Done reading " + file);
|
||||||
|
|
||||||
|
|
@ -328,7 +329,7 @@ public class VariantContextTestProvider {
|
||||||
addGenotypeTests(site, homRef, het, homVar);
|
addGenotypeTests(site, homRef, het, homVar);
|
||||||
|
|
||||||
// test no GT at all
|
// test no GT at all
|
||||||
addGenotypeTests(site);
|
addGenotypeTests(site, new GenotypeBuilder("noGT", new ArrayList<Allele>(0)).attribute("INT1", 10).make());
|
||||||
|
|
||||||
final List<Allele> noCall = Arrays.asList(Allele.NO_CALL, Allele.NO_CALL);
|
final List<Allele> noCall = Arrays.asList(Allele.NO_CALL, Allele.NO_CALL);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,8 @@ public class VCFWriterUnitTest extends BaseTest {
|
||||||
@Test
|
@Test
|
||||||
public void testBasicWriteAndRead() {
|
public void testBasicWriteAndRead() {
|
||||||
VCFHeader header = createFakeHeader(metaData,additionalColumns);
|
VCFHeader header = createFakeHeader(metaData,additionalColumns);
|
||||||
VariantContextWriter writer = VariantContextWriterFactory.create(fakeVCFFile, seq.getSequenceDictionary());
|
final EnumSet<Options> options = EnumSet.of(Options.ALLOW_MISSING_FIELDS_IN_HEADER);
|
||||||
|
VariantContextWriter writer = VariantContextWriterFactory.create(fakeVCFFile, seq.getSequenceDictionary(), options);
|
||||||
writer.writeHeader(header);
|
writer.writeHeader(header);
|
||||||
writer.add(createVC(header));
|
writer.add(createVC(header));
|
||||||
writer.add(createVC(header));
|
writer.add(createVC(header));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue