diff --git a/c/bwa/libbwa.so b/c/bwa/libbwa.so new file mode 100755 index 000000000..bfa3c2847 Binary files /dev/null and b/c/bwa/libbwa.so differ diff --git a/c/bwa/org_broadinstitute_sting_alignment_bwa_c_BWACAligner.cpp b/c/bwa/org_broadinstitute_sting_alignment_bwa_c_BWACAligner.cpp index 580d9c74c..14a1c04c4 100644 --- a/c/bwa/org_broadinstitute_sting_alignment_bwa_c_BWACAligner.cpp +++ b/c/bwa/org_broadinstitute_sting_alignment_bwa_c_BWACAligner.cpp @@ -228,7 +228,6 @@ JNIEXPORT jobjectArray JNICALL Java_org_broadinstitute_sting_alignment_bwa_c_BWA Alignment* alignments = NULL; unsigned num_alignments = 0; bwa->generate_alignments_from_paths((const char*)read_bases,read_length,paths,num_paths,best_count,second_best_count,alignments,num_alignments); - num_alignments = 0; jobjectArray java_alignments = env->NewObjectArray(num_alignments, env->FindClass("org/broadinstitute/sting/alignment/Alignment"), NULL); if(java_alignments == NULL) return NULL; diff --git a/java/src/org/broadinstitute/sting/alignment/Alignment.java b/java/src/org/broadinstitute/sting/alignment/Alignment.java index 5f5b53070..1bc1465fa 100644 --- a/java/src/org/broadinstitute/sting/alignment/Alignment.java +++ b/java/src/org/broadinstitute/sting/alignment/Alignment.java @@ -202,7 +202,7 @@ public class Alignment { read.setMappingQuality(alignment.getMappingQuality()); read.setCigar(alignment.getCigar()); if(alignment.isNegativeStrand()) { - read.setReadBases(BaseUtils.reverse(read.getReadBases())); + read.setReadBases(BaseUtils.simpleReverseComplement(read.getReadBases())); read.setBaseQualities(BaseUtils.reverse(read.getBaseQualities())); } read.setAttribute("NM",alignment.getEditDistance()); diff --git a/java/src/org/broadinstitute/sting/alignment/AlignmentValidationWalker.java b/java/src/org/broadinstitute/sting/alignment/AlignmentValidationWalker.java index b64c34fbd..667ed47a1 100644 --- a/java/src/org/broadinstitute/sting/alignment/AlignmentValidationWalker.java +++ b/java/src/org/broadinstitute/sting/alignment/AlignmentValidationWalker.java @@ -29,11 +29,6 @@ public class AlignmentValidationWalker extends ReadWalker { */ private BWACAligner aligner = null; - /** - * Number of reads processed. - */ - private int count = 0; - /** * Create an aligner object. The aligner object will load and hold the BWT until close() is called. */ @@ -105,10 +100,6 @@ public class AlignmentValidationWalker extends ReadWalker { throw new StingException(String.format("Read %s mismatches!", read.getReadName())); } - if(++count % 10000 == 0) { - logger.info(String.format("Processed %d reads", count)); - } - return 1; } diff --git a/java/src/org/broadinstitute/sting/alignment/AlignmentWalker.java b/java/src/org/broadinstitute/sting/alignment/AlignmentWalker.java index 632ec97a1..6127c7ac9 100644 --- a/java/src/org/broadinstitute/sting/alignment/AlignmentWalker.java +++ b/java/src/org/broadinstitute/sting/alignment/AlignmentWalker.java @@ -1,7 +1,6 @@ package org.broadinstitute.sting.alignment; import org.broadinstitute.sting.utils.cmdLine.Argument; -import org.broadinstitute.sting.utils.Utils; import org.broadinstitute.sting.gatk.walkers.ReadWalker; import org.broadinstitute.sting.gatk.walkers.WalkerName; import org.broadinstitute.sting.alignment.bwa.c.BWACAligner; @@ -10,6 +9,8 @@ import org.broadinstitute.sting.alignment.bwa.BWTFiles; import net.sf.samtools.*; import net.sf.picard.reference.ReferenceSequenceFileFactory; +import java.io.File; + /** * Align reads to the reference specified by BWTPrefix. * @@ -25,7 +26,7 @@ public class AlignmentWalker extends ReadWalker { String outputBamFile = null; @Argument(fullName = "bam_compression", shortName = "compress", doc = "Compression level to use for writing BAM files", required = false) - public Integer bamCompression = 5; + Integer bamCompression = 5; /** * The actual aligner. @@ -40,7 +41,7 @@ public class AlignmentWalker extends ReadWalker { /** * New header to use, if desired. */ - private SAMFileHeader header = null; + private SAMFileHeader header; /** Must return true for reads that need to be processed. Reads, for which this method return false will * be skipped by the engine and never passed to the walker. @@ -59,21 +60,16 @@ public class AlignmentWalker extends ReadWalker { BWAConfiguration configuration = new BWAConfiguration(); aligner = new BWACAligner(bwtFiles,configuration); - // HACK: If the sequence dictionary in the existing header is null, stuff the contents of the current reference - // into it, so that the sequence has something to which to back-align. - SAMFileHeader originalHeader = getToolkit().getSAMFileHeader(); - if(originalHeader.getSequenceDictionary().isEmpty()) { - header = originalHeader.clone(); - SAMSequenceDictionary referenceDictionary = - ReferenceSequenceFileFactory.getReferenceSequenceFile(getToolkit().getArguments().referenceFile).getSequenceDictionary(); - header.setSequenceDictionary(referenceDictionary); - } - else - header = originalHeader; + // Take the header of the SAM file, tweak it by adding in the reference dictionary and specifying that the target file is unsorted. + header = getToolkit().getSAMFileHeader().clone(); + SAMSequenceDictionary referenceDictionary = + ReferenceSequenceFileFactory.getReferenceSequenceFile(getToolkit().getArguments().referenceFile).getSequenceDictionary(); + header.setSequenceDictionary(referenceDictionary); + header.setSortOrder(SAMFileHeader.SortOrder.unsorted); - if ( outputBamFile != null ) { - // Stuff the header from the fasta into that of the sequence dictionary. - outputBam = Utils.createSAMFileWriterWithCompression(header, false, outputBamFile, bamCompression); + if (outputBamFile != null) { + SAMFileWriterFactory factory = new SAMFileWriterFactory(); + outputBam = factory.makeBAMWriter(header, false, new File(outputBamFile), bamCompression); } } @@ -119,6 +115,8 @@ public class AlignmentWalker extends ReadWalker { @Override public void onTraversalDone(Integer result) { aligner.close(); + if (outputBam != null) + outputBam.close(); super.onTraversalDone(result); }