@@ -0,0 +1,905 @@
+package com.github.sparkcaller.preprocessing;%0A%0Aimport org.apache.spark.api.java.function.Function;%0Aimport picard.sam.SortSam;%0A%0Aimport java.io.File;%0Aimport java.util.ArrayList;%0A%0Apublic class SamToSortedBam implements Function%3CFile, File%3E %7B%0A    public File call(File file) throws Exception %7B%0A        final String ext = %22sam%22;%0A        String newFileName = file.getPath().substring(0, file.getPath().length() - ext.length()) + %22bam%22;%0A        File outputSamFile = new File(newFileName);%0A%0A        ArrayList%3CString%3E sorterArgs = new ArrayList%3CString%3E();%0A        sorterArgs.add(%22INPUT=%22);%0A        sorterArgs.add(file.getPath());%0A%0A        sorterArgs.add(%22OUTPUT=%22);%0A        sorterArgs.add(outputSamFile.getPath());%0A%0A        sorterArgs.add(%22SORT_ORDER=coordinate%22);%0A        SortSam samSorter = new SortSam();%0A        samSorter.instanceMain(sorterArgs.toArray(new String%5B0%5D));%0A%0A        return outputSamFile;%0A    %7D%0A%7D%0A

Add a class used to convert a SAM file to a sorted BAM file.