Skip to content

Commit

Permalink
Merge pull request #4 from obiba/opal-2875
Browse files Browse the repository at this point in the history
OPAL-2875 - call to bcftools view command to filter sample ids
  • Loading branch information
Ramin Haeri Azad authored Mar 21, 2017
2 parents 4379d96 + 089835d commit f20ccab
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,20 @@ public void readVCFStatistics(String vcfName, OutputStream out) throws NoSuchEle
Files.copy(getStatsFile(vcfName).toPath(), out);
}

@Override
public void filter(String vcfName, Format format, String commaSeparatedSampleIds, File destination) throws NoSuchElementException, IOException {
if (!hasVCF(vcfName)) throw new NoSuchElementException("No VCF with name '" + vcfName + "' can be found");
String outputType = Format.VCF == format ? "-Oz" : "-Ob";
int status = runProcess(vcfName, bcftools("view",
"--force-samples",
outputType,
"-s",
commaSeparatedSampleIds,
getVCFGZFile(vcfName).getAbsolutePath(),
"-o", destination.getAbsolutePath()));
if (status != 0) throw new VCFStoreException("VCF/BCF file sample id filter using bcftools failed");
}

//
// Private methods
//
Expand Down

0 comments on commit f20ccab

Please sign in to comment.