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:
parent
9c206abb97
commit
c9c4999354
Binary file not shown.
|
|
@ -228,7 +228,6 @@ JNIEXPORT jobjectArray JNICALL Java_org_broadinstitute_sting_alignment_bwa_c_BWA
|
||||||
Alignment* alignments = NULL;
|
Alignment* alignments = NULL;
|
||||||
unsigned num_alignments = 0;
|
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);
|
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);
|
jobjectArray java_alignments = env->NewObjectArray(num_alignments, env->FindClass("org/broadinstitute/sting/alignment/Alignment"), NULL);
|
||||||
if(java_alignments == NULL) return NULL;
|
if(java_alignments == NULL) return NULL;
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ public class Alignment {
|
||||||
read.setMappingQuality(alignment.getMappingQuality());
|
read.setMappingQuality(alignment.getMappingQuality());
|
||||||
read.setCigar(alignment.getCigar());
|
read.setCigar(alignment.getCigar());
|
||||||
if(alignment.isNegativeStrand()) {
|
if(alignment.isNegativeStrand()) {
|
||||||
read.setReadBases(BaseUtils.reverse(read.getReadBases()));
|
read.setReadBases(BaseUtils.simpleReverseComplement(read.getReadBases()));
|
||||||
read.setBaseQualities(BaseUtils.reverse(read.getBaseQualities()));
|
read.setBaseQualities(BaseUtils.reverse(read.getBaseQualities()));
|
||||||
}
|
}
|
||||||
read.setAttribute("NM",alignment.getEditDistance());
|
read.setAttribute("NM",alignment.getEditDistance());
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,6 @@ public class AlignmentValidationWalker extends ReadWalker<Integer,Integer> {
|
||||||
*/
|
*/
|
||||||
private BWACAligner aligner = null;
|
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.
|
* 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()));
|
throw new StingException(String.format("Read %s mismatches!", read.getReadName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(++count % 10000 == 0) {
|
|
||||||
logger.info(String.format("Processed %d reads", count));
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package org.broadinstitute.sting.alignment;
|
package org.broadinstitute.sting.alignment;
|
||||||
|
|
||||||
import org.broadinstitute.sting.utils.cmdLine.Argument;
|
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.ReadWalker;
|
||||||
import org.broadinstitute.sting.gatk.walkers.WalkerName;
|
import org.broadinstitute.sting.gatk.walkers.WalkerName;
|
||||||
import org.broadinstitute.sting.alignment.bwa.c.BWACAligner;
|
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.samtools.*;
|
||||||
import net.sf.picard.reference.ReferenceSequenceFileFactory;
|
import net.sf.picard.reference.ReferenceSequenceFileFactory;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Align reads to the reference specified by BWTPrefix.
|
* Align reads to the reference specified by BWTPrefix.
|
||||||
*
|
*
|
||||||
|
|
@ -25,7 +26,7 @@ public class AlignmentWalker extends ReadWalker<Integer,Integer> {
|
||||||
String outputBamFile = null;
|
String outputBamFile = null;
|
||||||
|
|
||||||
@Argument(fullName = "bam_compression", shortName = "compress", doc = "Compression level to use for writing BAM files", required = false)
|
@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.
|
* The actual aligner.
|
||||||
|
|
@ -40,7 +41,7 @@ public class AlignmentWalker extends ReadWalker<Integer,Integer> {
|
||||||
/**
|
/**
|
||||||
* New header to use, if desired.
|
* 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
|
/** 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.
|
* 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();
|
BWAConfiguration configuration = new BWAConfiguration();
|
||||||
aligner = new BWACAligner(bwtFiles,configuration);
|
aligner = new BWACAligner(bwtFiles,configuration);
|
||||||
|
|
||||||
// HACK: If the sequence dictionary in the existing header is null, stuff the contents of the current reference
|
// Take the header of the SAM file, tweak it by adding in the reference dictionary and specifying that the target file is unsorted.
|
||||||
// into it, so that the sequence has something to which to back-align.
|
header = getToolkit().getSAMFileHeader().clone();
|
||||||
SAMFileHeader originalHeader = getToolkit().getSAMFileHeader();
|
SAMSequenceDictionary referenceDictionary =
|
||||||
if(originalHeader.getSequenceDictionary().isEmpty()) {
|
ReferenceSequenceFileFactory.getReferenceSequenceFile(getToolkit().getArguments().referenceFile).getSequenceDictionary();
|
||||||
header = originalHeader.clone();
|
header.setSequenceDictionary(referenceDictionary);
|
||||||
SAMSequenceDictionary referenceDictionary =
|
header.setSortOrder(SAMFileHeader.SortOrder.unsorted);
|
||||||
ReferenceSequenceFileFactory.getReferenceSequenceFile(getToolkit().getArguments().referenceFile).getSequenceDictionary();
|
|
||||||
header.setSequenceDictionary(referenceDictionary);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
header = originalHeader;
|
|
||||||
|
|
||||||
if ( outputBamFile != null ) {
|
if (outputBamFile != null) {
|
||||||
// Stuff the header from the fasta into that of the sequence dictionary.
|
SAMFileWriterFactory factory = new SAMFileWriterFactory();
|
||||||
outputBam = Utils.createSAMFileWriterWithCompression(header, false, outputBamFile, bamCompression);
|
outputBam = factory.makeBAMWriter(header, false, new File(outputBamFile), bamCompression);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,6 +115,8 @@ public class AlignmentWalker extends ReadWalker<Integer,Integer> {
|
||||||
@Override
|
@Override
|
||||||
public void onTraversalDone(Integer result) {
|
public void onTraversalDone(Integer result) {
|
||||||
aligner.close();
|
aligner.close();
|
||||||
|
if (outputBam != null)
|
||||||
|
outputBam.close();
|
||||||
super.onTraversalDone(result);
|
super.onTraversalDone(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue