Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,19 @@ private boolean checkVcfFiles() throws Exception {
try {

VcfFile vcfFile = VcfFileUtil.load(filename, chunksize, !noIndex);
String chromosome = vcfFile.getChromosome();

if (VcfFileUtil.isChrMT(vcfFile.getChromosome())) {
if (VcfFileUtil.isChrMT(chromosome)) {
vcfFile.setPhased(true);
}

if (!VcfFileUtil.isValidChromosome(vcfFile.getChromosome())) {
output.error("No valid chromosomes found!");
if (!VcfFileUtil.isValidChromosome(chromosome)) {
output.error("Invalid chromosome found: " + chromosome);
return false;
}

validVcfFiles.add(vcfFile);
chromosomes.add(vcfFile.getChromosome());
chromosomes.add(chromosome);

// check if all files have same amount of samples
if (noSamples != 0 && noSamples != vcfFile.getNoSamples()) {
Expand Down Expand Up @@ -210,14 +211,14 @@ private boolean checkVcfFiles() throws Exception {
if (build.equals("hg19") && vcfFile.hasChrPrefix()) {
output.error("Your upload data contains chromosome '" + vcfFile.getRawChromosome()
+ "'. This is not a valid hg19 encoding. Please ensure that your input data is build hg19 and chromosome is encoded as '"
+ vcfFile.getChromosome() + "'.");
+ chromosome + "'.");
return false;
}

if (build.equals("hg38") && !vcfFile.hasChrPrefix()) {
output.error("Your upload data contains chromosome '" + vcfFile.getRawChromosome()
+ "'. This is not a valid hg38 encoding. Please ensure that your input data is build hg38 and chromosome is encoded as 'chr"
+ vcfFile.getChromosome() + "'.");
+ chromosome + "'.");
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,38 @@ public class InputValidationCommandTest extends AbstractTestcase {

private static final String CLOUDGENE_LOG = "cloudgene.report";

@Test
public void testMissingReferencePanel() throws Exception {
String inputFolder = "test-data/data/chr20-phased";

InputValidationCommand command = buildCommand(inputFolder);
command.setReference("this-path/does-not-exist.json");
command.setBuild("hg38");

assertEquals(1, (int)command.call());

OutputReader log = new OutputReader(CLOUDGENE_LOG);
log.view();
assertTrue(log.hasInMemory("::error:: Unable to parse reference panel: this-path/does-not-exist.json (No such file or directory)"));
}

@Test
public void testInvalidChromosome() throws Exception {

String inputFolder = "test-data/data/chrY-fake";

InputValidationCommand command = buildCommand(inputFolder);
command.setReference("test-data/configs/hapmap-chr1/hapmap2.json");
command.setPopulation("mixed");

assertEquals(1, (int)command.call());

OutputReader log = new OutputReader(CLOUDGENE_LOG);
log.view();
assertTrue(log.hasInMemory("::error:: Invalid chromosome found: Y"));

}

@Test
public void testVcfWithHeaderOnly() throws Exception {

Expand Down
Binary file added test-data/data/chrY-fake/fake.chrY.vcf.gz
Binary file not shown.
Binary file added test-data/data/chrY-fake/fake.chrY.vcf.gz.tbi
Binary file not shown.
Loading