diff --git a/jennite-vcf-store/src/main/java/org/obiba/jennite/vcf/JenniteVCFStore.java b/jennite-vcf-store/src/main/java/org/obiba/jennite/vcf/JenniteVCFStore.java index 64aa0df..1f19f39 100644 --- a/jennite-vcf-store/src/main/java/org/obiba/jennite/vcf/JenniteVCFStore.java +++ b/jennite-vcf-store/src/main/java/org/obiba/jennite/vcf/JenniteVCFStore.java @@ -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 //