package com.github.sparkcaller.variantdiscovery;

import com.github.sparkcaller.BaseGATKProgram;
import com.github.sparkcaller.Utils;
import org.apache.spark.api.java.function.Function;

import java.io.File;

public class HaplotypeCaller extends BaseGATKProgram implements Function<File, File> {

    public HaplotypeCaller(String pathToReference, String extraArgsString, String availableCoresPerNode) {
        super("HaplotypeCaller", extraArgsString);
        setReference(pathToReference);
        setThreads(availableCoresPerNode);
    }

    public File call(File bamFile) throws Exception {
        String outputFilename = Utils.removeExtenstion(bamFile.getPath(), "bam")  + ".vcf";
        setInputFile(bamFile.getAbsolutePath());
        setOutputFile(outputFilename);

        executeProgram();
        return new File(outputFilename);
    }
}

@@ -178,16 +178,37 @@
 unction;
+%0Aimport scala.Tuple2;
 %0A%0Aimport
@@ -296,20 +296,36 @@
 unction%3C
+Tuple2%3CString, 
 File
+%3E
 , File%3E 
@@ -599,18 +599,38 @@
 all(
-File bamFi
+Tuple2%3CString, File%3E contigTup
 le) 
@@ -648,16 +648,97 @@
 ption %7B%0A
+        String contig = contigTuple._1;%0A        File inputBam = contigTuple._2;%0A%0A
         
@@ -784,23 +784,24 @@
 enstion(
-bamFile
+inputBam
 .getPath
@@ -822,16 +822,51 @@
 %22.vcf%22;%0A
+        addArgument(%22-L%22, contig);%0A
         
@@ -882,15 +882,16 @@
 ile(
-bamFile
+inputBam
 .get
@@ -959,25 +959,168 @@
     
-executeProgram();
+try %7B%0A            executeProgram();%0A        %7D catch (org.broadinstitute.gatk.utils.exceptions.ReviewedGATKException e) %7B%0A            executeProgram();%0A        %7D
 %0A   

Make it possible to run the HaplotypeCaller per contig.