BWA: odds and ends. Get rid of some spurious debug code that was accidentally

checked in.  Add a better way to write out unmapped reads (thanks Kiran!)  Add 
a pre-built version of the shared library to the repository for early adoption.


git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2111 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
hanna 2009-11-22 15:26:07 +00:00
parent 9c206abb97
commit c9c4999354
5 changed files with 16 additions and 28 deletions

BIN
c/bwa/libbwa.so 100755

Binary file not shown.

View File

@ -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;

View File

@ -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());

View File

@ -29,11 +29,6 @@ public class AlignmentValidationWalker extends ReadWalker<Integer,Integer> {
*/
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<Integer,Integer> {
throw new StingException(String.format("Read %s mismatches!", read.getReadName()));
}
if(++count % 10000 == 0) {
logger.info(String.format("Processed %d reads", count));
}
return 1;
}

View File

@ -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<Integer,Integer> {
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<Integer,Integer> {
/**
* 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<Integer,Integer> {
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<Integer,Integer> {
@Override
public void onTraversalDone(Integer result) {
aligner.close();
if (outputBam != null)
outputBam.close();
super.onTraversalDone(result);
}