Update for Picard refactoring which improves block-compressed VCF reading

[Delivers #69215404]
This commit is contained in:
Joel Thibault 2014-04-16 13:11:06 -04:00
parent fd09cb7143
commit 4c74319578
4 changed files with 13 additions and 28 deletions

View File

@ -25,6 +25,7 @@
package org.broadinstitute.sting.gatk.io.stubs;
import org.broad.tribble.AbstractFeatureReader;
import org.broadinstitute.sting.commandline.*;
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
import org.broadinstitute.variant.variantcontext.writer.VariantContextWriter;
@ -49,8 +50,6 @@ public class VCFWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor {
public static final String NO_HEADER_ARG_NAME = "no_cmdline_in_header";
public static final String SITES_ONLY_ARG_NAME = "sites_only";
public static final String FORCE_BCF = "bcf";
public static final HashSet<String> SUPPORTED_ZIPPED_SUFFIXES =
new HashSet<>(Arrays.asList(VariantContextWriterFactory.BLOCK_COMPRESSED_EXTENSIONS));
/**
* The engine into which output stubs should be fed.
@ -223,19 +222,6 @@ public class VCFWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor {
* @return true if the file will be compressed.
*/
public static boolean isCompressed(String writerFileName) {
return writerFileName != null && SUPPORTED_ZIPPED_SUFFIXES.contains(getFileSuffix(writerFileName));
return writerFileName != null && AbstractFeatureReader.hasBlockCompressedExtension(writerFileName);
}
/**
* Returns a lower-cased version of the suffix of the provided file.
* @param fileName the file name. Must not be null.
* @return lower-cased version of the file suffix. Will not be null.
*/
private static String getFileSuffix(String fileName) {
int indexOfLastDot = fileName.lastIndexOf(".");
if ( indexOfLastDot == -1 )
return "";
return fileName.substring(indexOfLastDot).toLowerCase();
}
}

View File

@ -37,6 +37,7 @@ import org.broad.tribble.util.LittleEndianOutputStream;
import org.broadinstitute.sting.commandline.Tags;
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
import org.broadinstitute.sting.gatk.arguments.ValidationExclusion;
import org.broadinstitute.sting.gatk.io.stubs.VCFWriterArgumentTypeDescriptor;
import org.broadinstitute.sting.gatk.refdata.utils.RMDTriplet;
import org.broadinstitute.sting.gatk.refdata.utils.RMDTriplet.RMDStorageType;
import org.broadinstitute.sting.utils.GenomeLocParser;
@ -141,7 +142,7 @@ public class RMDTrackBuilder { // extends PluginManager<FeatureCodec> {
// return a feature reader track
Pair<AbstractFeatureReader, SAMSequenceDictionary> pair;
if (inputFile.getAbsolutePath().endsWith(".gz"))
if (VCFWriterArgumentTypeDescriptor.isCompressed(inputFile.toString()))
pair = createTabixIndexedFeatureSource(descriptor, name, inputFile);
else
pair = getFeatureSource(descriptor, name, inputFile, fileDescriptor.getStorageType());
@ -178,9 +179,8 @@ public class RMDTrackBuilder { // extends PluginManager<FeatureCodec> {
// we might not know the index type, try loading with the default reader constructor
logger.debug("Attempting to load " + inputFile + " as a tabix indexed file without validating it");
try {
final File indexFile = null;//new File(inputFile.getAbsoluteFile() + TabixUtils.STANDARD_INDEX_EXTENSION);
final SAMSequenceDictionary dict = null; //TabixUtils.getSequenceDictionary(indexFile);
return new Pair<>(AbstractFeatureReader.getFeatureReader(inputFile.getAbsolutePath(), createCodec(descriptor, name, inputFile)), dict);
// getFeatureReader will detect that it's Tabix
return new Pair<>(AbstractFeatureReader.getFeatureReader(inputFile.getAbsolutePath(), createCodec(descriptor, name, inputFile)), null);
} catch (TribbleException e) {
throw new UserException(e.getMessage(), e);
}

View File

@ -26,13 +26,13 @@
package org.broadinstitute.sting.tools;
import org.apache.commons.lang.StringUtils;
import org.broad.tribble.AbstractFeatureReader;
import org.broadinstitute.sting.BaseTest;
import org.broadinstitute.sting.MD5DB;
import org.broadinstitute.sting.MD5Mismatch;
import org.broadinstitute.sting.utils.runtime.ProcessController;
import org.broadinstitute.sting.utils.runtime.ProcessSettings;
import org.broadinstitute.sting.utils.runtime.RuntimeUtils;
import org.broadinstitute.variant.variantcontext.writer.VariantContextWriterFactory;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@ -75,7 +75,7 @@ public class CatVariantsIntegrationTest {
new CatVariantsTestProvider("CatVariantsTest1.vcf", "CatVariantsTest2.vcf", BaseTest.createTempFile("CatVariantsTest", ".vcf"), "d0d81eb7fd3905256c4ac7c0fc480094");
new CatVariantsTestProvider("CatVariantsTest1.bcf", "CatVariantsTest2.bcf", BaseTest.createTempFile("CatVariantsTest", ".bcf"), "6a57fcbbf3cae490896d13a288670d83");
for (String extension : VariantContextWriterFactory.BLOCK_COMPRESSED_EXTENSIONS)
for (String extension : AbstractFeatureReader.BLOCK_COMPRESSED_EXTENSIONS)
new CatVariantsTestProvider("CatVariantsTest1.vcf" + extension, "CatVariantsTest2.vcf" + extension, BaseTest.createTempFile("CatVariantsTest", ".vcf" + extension), "33f728ac5c70ce2994f3619a27f47088");
return CatVariantsTestProvider.getTests(CatVariantsTestProvider.class);

View File

@ -25,6 +25,7 @@
package org.broadinstitute.sting.utils.variant;
import org.broad.tribble.AbstractFeatureReader;
import org.broad.tribble.Tribble;
import org.broad.tribble.index.AbstractIndex;
import org.broad.tribble.index.ChrIndex;
@ -36,7 +37,6 @@ import org.broad.tribble.index.tabix.TabixIndex;
import org.broad.tribble.util.TabixUtils;
import org.broadinstitute.sting.BaseTest;
import org.broadinstitute.sting.WalkerTest;
import org.broadinstitute.sting.gatk.io.stubs.VCFWriterArgumentTypeDescriptor;
import org.broadinstitute.variant.vcf.VCFCodec;
import org.testng.Assert;
import org.testng.TestException;
@ -46,7 +46,6 @@ import org.testng.annotations.Test;
import java.io.File;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
@ -300,8 +299,8 @@ public class VCFIntegrationTest extends WalkerTest {
@DataProvider(name = "BlockCompressedIndexDataProvider")
public Object[][] blockCompressedIndexCreatorData() {
for (String suffix : VCFWriterArgumentTypeDescriptor.SUPPORTED_ZIPPED_SUFFIXES)
new BlockCompressedIndexCreatorTest(".vcf" + suffix);
for (final String extension : AbstractFeatureReader.BLOCK_COMPRESSED_EXTENSIONS)
new BlockCompressedIndexCreatorTest(".vcf" + extension);
return TestDataProvider.getTests(BlockCompressedIndexCreatorTest.class);
}
@ -353,8 +352,8 @@ public class VCFIntegrationTest extends WalkerTest {
@DataProvider(name = "BlockCompressedInputDataProvider")
public Object[][] blockCompressedInputData() {
for (String suffix : VCFWriterArgumentTypeDescriptor.SUPPORTED_ZIPPED_SUFFIXES)
new BlockCompressedInputTest(".vcf" + suffix);
for (final String extension : AbstractFeatureReader.BLOCK_COMPRESSED_EXTENSIONS)
new BlockCompressedInputTest(".vcf" + extension);
return TestDataProvider.getTests(BlockCompressedInputTest.class);
}