Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPAL-2875 - call to bcftools view command to filter sample ids #4

Merged
merged 1 commit into from
Mar 21, 2017
Merged
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 @@ -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