CatVariants now allows different input / output file types.
Escaping the CatVariantsIntegrationTest classpaths for possible spaces in the directory names.
This commit is contained in:
parent
2053afe52a
commit
90b579c78e
|
|
@ -147,37 +147,30 @@ public class CatVariants extends CommandLineProgram {
|
|||
INVALID
|
||||
}
|
||||
|
||||
private FileType fileExtensionCheck(File inFile, File outFile) {
|
||||
private FileType fileExtensionCheck(File inFile, FileType previousFileType) {
|
||||
final String inFileName = inFile.toString().toLowerCase();
|
||||
final String outFileName = outFile.toString().toLowerCase();
|
||||
|
||||
FileType inFileType = FileType.INVALID;
|
||||
|
||||
if (inFileName.endsWith(".vcf")) {
|
||||
inFileType = FileType.VCF;
|
||||
if (outFileName.endsWith(".vcf"))
|
||||
return inFileType;
|
||||
if (previousFileType == FileType.VCF || previousFileType == null) {
|
||||
return FileType.VCF;
|
||||
}
|
||||
}
|
||||
|
||||
if (inFileName.endsWith(".bcf")) {
|
||||
inFileType = FileType.BCF;
|
||||
if (outFileName.endsWith(".bcf"))
|
||||
return inFileType;
|
||||
if (previousFileType == FileType.BCF || previousFileType == null) {
|
||||
return FileType.BCF;
|
||||
}
|
||||
}
|
||||
|
||||
for (String extension : AbstractFeatureReader.BLOCK_COMPRESSED_EXTENSIONS) {
|
||||
if (inFileName.endsWith(".vcf" + extension)) {
|
||||
inFileType = FileType.BLOCK_COMPRESSED_VCF;
|
||||
if (outFileName.endsWith(".vcf" + extension))
|
||||
return inFileType;
|
||||
if (previousFileType == FileType.BLOCK_COMPRESSED_VCF || previousFileType == null) {
|
||||
return FileType.BLOCK_COMPRESSED_VCF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inFileType == FileType.INVALID)
|
||||
System.err.println(String.format("File extension for input file %s is not valid for CatVariants", inFile));
|
||||
else
|
||||
System.err.println(String.format("File extension mismatch between input %s and output %s", inFile, outFile));
|
||||
|
||||
System.err.println(String.format("File extension for input file %s is not valid for CatVariants", inFile));
|
||||
printUsage();
|
||||
return FileType.INVALID;
|
||||
}
|
||||
|
|
@ -241,10 +234,10 @@ public class CatVariants extends CommandLineProgram {
|
|||
else
|
||||
priorityQueue = new PriorityQueue<>(10000, positionComparator);
|
||||
|
||||
FileType fileType = FileType.INVALID;
|
||||
FileType fileType = null;
|
||||
for (File file : variant) {
|
||||
// if it returns a valid type, it will be the same for all files
|
||||
fileType = fileExtensionCheck(file, outputFile);
|
||||
fileType = fileExtensionCheck(file, fileType);
|
||||
if (fileType == FileType.INVALID)
|
||||
return 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import org.broadinstitute.gatk.engine.GATKVCFUtils;
|
|||
import org.broadinstitute.gatk.utils.BaseTest;
|
||||
import org.broadinstitute.gatk.utils.MD5DB;
|
||||
import org.broadinstitute.gatk.utils.MD5Mismatch;
|
||||
import org.broadinstitute.gatk.utils.Utils;
|
||||
import org.broadinstitute.gatk.utils.runtime.ProcessController;
|
||||
import org.broadinstitute.gatk.utils.runtime.ProcessSettings;
|
||||
import org.broadinstitute.gatk.utils.runtime.RuntimeUtils;
|
||||
|
|
@ -44,6 +45,10 @@ import org.testng.annotations.Test;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class CatVariantsIntegrationTest {
|
||||
private final MD5DB md5db = new MD5DB();
|
||||
|
|
@ -69,13 +74,13 @@ public class CatVariantsIntegrationTest {
|
|||
}
|
||||
|
||||
public final String getCmdLine() {
|
||||
return String.format("java -cp %s %s -R %s -V %s -V %s -out %s",
|
||||
return String.format("java -cp \"%s\" %s -R %s -V %s -V %s -out %s",
|
||||
StringUtils.join(RuntimeUtils.getAbsoluteClassPaths(), File.pathSeparatorChar),
|
||||
CatVariants.class.getCanonicalName(), BaseTest.b37KGReference, file1, file2, outputFile);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "CatVariantsTestProvider " + outputFile;
|
||||
return String.format("CatVariantsTestProvider %s + %s -> %s", file1.getName(), file2.getName(), outputFile.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -87,17 +92,22 @@ public class CatVariantsIntegrationTest {
|
|||
new CatVariantsTestProvider(CatVariantsVcf1, CatVariantsVcf2, BaseTest.createTempFile("CatVariantsTest", ".vcf"), "d0d81eb7fd3905256c4ac7c0fc480094");
|
||||
new CatVariantsTestProvider(CatVariantsBcf1, CatVariantsBcf2, BaseTest.createTempFile("CatVariantsTest", ".bcf"), "6a57fcbbf3cae490896d13a288670d83");
|
||||
|
||||
for (String extension : AbstractFeatureReader.BLOCK_COMPRESSED_EXTENSIONS) {
|
||||
final File file1 = new File(CatVariantsDir, "CatVariantsTest1.vcf" + extension);
|
||||
final File file2 = new File(CatVariantsDir, "CatVariantsTest2.vcf" + extension);
|
||||
final File outputFile = BaseTest.createTempFile("CatVariantsTest", ".vcf" + extension);
|
||||
new CatVariantsTestProvider(file1, file2, outputFile, "33f728ac5c70ce2994f3619a27f47088");
|
||||
for (String extension1 : AbstractFeatureReader.BLOCK_COMPRESSED_EXTENSIONS) {
|
||||
for (String extension2 : AbstractFeatureReader.BLOCK_COMPRESSED_EXTENSIONS) {
|
||||
final File file1 = new File(CatVariantsDir, "CatVariantsTest1.vcf" + extension1);
|
||||
final File file2 = new File(CatVariantsDir, "CatVariantsTest2.vcf" + extension2);
|
||||
new CatVariantsTestProvider(file1, file2, BaseTest.createTempFile("CatVariantsTest.", ".vcf"), "d0d81eb7fd3905256c4ac7c0fc480094");
|
||||
new CatVariantsTestProvider(file1, file2, BaseTest.createTempFile("CatVariantsTest.", ".bcf"), "6a57fcbbf3cae490896d13a288670d83");
|
||||
new CatVariantsTestProvider(file1, file2, BaseTest.createTempFile("CatVariantsTest.", ".vcf" + extension1), "33f728ac5c70ce2994f3619a27f47088");
|
||||
}
|
||||
new CatVariantsTestProvider(CatVariantsVcf1, CatVariantsVcf2, BaseTest.createTempFile("CatVariantsTest.", ".vcf" + extension1), "33f728ac5c70ce2994f3619a27f47088");
|
||||
new CatVariantsTestProvider(CatVariantsBcf1, CatVariantsBcf2, BaseTest.createTempFile("CatVariantsTest.", ".vcf" + extension1), "f1a55575f59707f80b8c17e2591fbf53");
|
||||
}
|
||||
|
||||
//Test list parsing functionality
|
||||
new CatVariantsTestProvider(catVariantsTempList1, CatVariantsVcf2, BaseTest.createTempFile("CatVariantsTest", ".vcf"), "d0d81eb7fd3905256c4ac7c0fc480094");
|
||||
new CatVariantsTestProvider(CatVariantsVcf1, catVariantsTempList2, BaseTest.createTempFile("CatVariantsTest", ".vcf"), "d0d81eb7fd3905256c4ac7c0fc480094");
|
||||
new CatVariantsTestProvider(catVariantsTempList1, catVariantsTempList2, BaseTest.createTempFile("CatVariantsTest", ".vcf"), "d0d81eb7fd3905256c4ac7c0fc480094");
|
||||
new CatVariantsTestProvider(catVariantsTempList1, CatVariantsVcf2, BaseTest.createTempFile("CatVariantsTest.", ".vcf"), "d0d81eb7fd3905256c4ac7c0fc480094");
|
||||
new CatVariantsTestProvider(CatVariantsVcf1, catVariantsTempList2, BaseTest.createTempFile("CatVariantsTest.", ".vcf"), "d0d81eb7fd3905256c4ac7c0fc480094");
|
||||
new CatVariantsTestProvider(catVariantsTempList1, catVariantsTempList2, BaseTest.createTempFile("CatVariantsTest.", ".vcf"), "d0d81eb7fd3905256c4ac7c0fc480094");
|
||||
|
||||
return CatVariantsTestProvider.getTests(CatVariantsTestProvider.class);
|
||||
}
|
||||
|
|
@ -106,7 +116,7 @@ public class CatVariantsIntegrationTest {
|
|||
public void testExtensions(final CatVariantsTestProvider cfg) throws IOException {
|
||||
|
||||
ProcessController pc = ProcessController.getThreadLocal();
|
||||
ProcessSettings ps = new ProcessSettings(cfg.getCmdLine().split("\\s+"));
|
||||
ProcessSettings ps = new ProcessSettings(Utils.escapeExpressions(cfg.getCmdLine()));
|
||||
pc.execAndCheck(ps);
|
||||
|
||||
MD5DB.MD5Match result = md5db.testFileMD5("testExtensions", "CatVariantsTestProvider", cfg.outputFile, cfg.md5, false);
|
||||
|
|
@ -116,35 +126,46 @@ public class CatVariantsIntegrationTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IOException.class)
|
||||
public void testMismatchedExtensions1() throws IOException {
|
||||
@DataProvider(name = "MismatchedExtensionsTest")
|
||||
public Object[][] makeMismatchedExtensionsTestProvider() {
|
||||
return new Object[][]{
|
||||
{".vcf", ".vcf.gz"},
|
||||
{".vcf.gz", ".vcf"},
|
||||
{".bcf", ".vcf.gz"},
|
||||
{".vcf.gz", ".bcf"},
|
||||
{".vcf", ".bcf"},
|
||||
{".bcf", ".vcf"}
|
||||
};
|
||||
}
|
||||
|
||||
String cmdLine = String.format("java -cp %s %s -R %s -V %s -V %s -out %s",
|
||||
@Test(dataProvider = "MismatchedExtensionsTest", expectedExceptions = IOException.class)
|
||||
public void testMismatchedExtensions1(final String extension1, final String extension2) throws IOException {
|
||||
String cmdLine = String.format("java -cp \"%s\" %s -R %s -V %s -V %s -out %s",
|
||||
StringUtils.join(RuntimeUtils.getAbsoluteClassPaths(), File.pathSeparatorChar),
|
||||
CatVariants.class.getCanonicalName(),
|
||||
BaseTest.b37KGReference,
|
||||
CatVariantsVcf1,
|
||||
CatVariantsVcf2,
|
||||
new File(CatVariantsDir, "CatVariantsTest1" + extension1),
|
||||
new File(CatVariantsDir, "CatVariantsTest2" + extension2),
|
||||
BaseTest.createTempFile("CatVariantsTest", ".bcf"));
|
||||
|
||||
ProcessController pc = ProcessController.getThreadLocal();
|
||||
ProcessSettings ps = new ProcessSettings(cmdLine.split("\\s+"));
|
||||
ProcessSettings ps = new ProcessSettings(Utils.escapeExpressions(cmdLine));
|
||||
pc.execAndCheck(ps);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IOException.class)
|
||||
public void testMismatchedExtensions2() throws IOException {
|
||||
@Test(dataProvider = "MismatchedExtensionsTest", expectedExceptions = IOException.class)
|
||||
public void testMismatchedExtensions2(final String extension1, final String extension2) throws IOException {
|
||||
|
||||
String cmdLine = String.format("java -cp %s %s -R %s -V %s -V %s -out %s",
|
||||
String cmdLine = String.format("java -cp \"%s\" %s -R %s -V %s -V %s -out %s",
|
||||
StringUtils.join(RuntimeUtils.getAbsoluteClassPaths(), File.pathSeparatorChar),
|
||||
CatVariants.class.getCanonicalName(),
|
||||
BaseTest.b37KGReference,
|
||||
CatVariantsVcf1,
|
||||
CatVariantsBcf2,
|
||||
new File(CatVariantsDir, "CatVariantsTest1" + extension1),
|
||||
new File(CatVariantsDir, "CatVariantsTest2" + extension2),
|
||||
BaseTest.createTempFile("CatVariantsTest", ".vcf"));
|
||||
|
||||
ProcessController pc = ProcessController.getThreadLocal();
|
||||
ProcessSettings ps = new ProcessSettings(cmdLine.split("\\s+"));
|
||||
ProcessSettings ps = new ProcessSettings(Utils.escapeExpressions(cmdLine));
|
||||
pc.execAndCheck(ps);
|
||||
}
|
||||
|
||||
|
|
@ -195,7 +216,7 @@ public class CatVariantsIntegrationTest {
|
|||
@Test(dataProvider = "IndexDataProvider")
|
||||
public void testCatVariantsVCFIndexCreation(VCFIndexCreatorTest testSpec) throws IOException{
|
||||
|
||||
String cmdLine = String.format("java -cp %s %s -R %s -V %s -V %s --variant_index_type %s --variant_index_parameter %s -out %s",
|
||||
String cmdLine = String.format("java -cp \"%s\" %s -R %s -V %s -V %s --variant_index_type %s --variant_index_parameter %s -out %s",
|
||||
StringUtils.join(RuntimeUtils.getAbsoluteClassPaths(), File.pathSeparatorChar),
|
||||
CatVariants.class.getCanonicalName(),
|
||||
BaseTest.b37KGReference,
|
||||
|
|
@ -206,14 +227,14 @@ public class CatVariantsIntegrationTest {
|
|||
BaseTest.createTempFile("CatVariantsVCFIndexCreationTest", ".vcf"));
|
||||
|
||||
ProcessController pc = ProcessController.getThreadLocal();
|
||||
ProcessSettings ps = new ProcessSettings(cmdLine.split("\\s+"));
|
||||
ProcessSettings ps = new ProcessSettings(Utils.escapeExpressions(cmdLine));
|
||||
pc.execAndCheck(ps);
|
||||
}
|
||||
|
||||
@Test()
|
||||
public void testCatVariantsGVCFIndexCreation() throws IOException{
|
||||
|
||||
String cmdLine = String.format("java -cp %s %s -R %s -V %s -V %s -out %s",
|
||||
String cmdLine = String.format("java -cp \"%s\" %s -R %s -V %s -V %s -out %s",
|
||||
StringUtils.join(RuntimeUtils.getAbsoluteClassPaths(), File.pathSeparatorChar),
|
||||
CatVariants.class.getCanonicalName(),
|
||||
BaseTest.b37KGReference,
|
||||
|
|
@ -222,7 +243,7 @@ public class CatVariantsIntegrationTest {
|
|||
BaseTest.createTempFile("CatVariantsGVCFIndexCreationTest", "." + GATKVCFUtils.GVCF_EXT));
|
||||
|
||||
ProcessController pc = ProcessController.getThreadLocal();
|
||||
ProcessSettings ps = new ProcessSettings(cmdLine.split("\\s+"));
|
||||
ProcessSettings ps = new ProcessSettings(Utils.escapeExpressions(cmdLine));
|
||||
pc.execAndCheck(ps);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue