Time for a reorganization. Repackage generally useful alignment classes lower in the package structure, and create a subpackage for bwa-specific code. Repackage BWA alignment code away from BWT representation. Isolate byte- and word-packing streams in another package that will ultimately be killed off en masse.
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1648 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
b4df089b59
commit
c186a49d55
|
|
@ -1,10 +1,16 @@
|
|||
package org.broadinstitute.sting.bwa;
|
||||
package org.broadinstitute.sting.alignment;
|
||||
|
||||
import net.sf.samtools.SAMRecord;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.broadinstitute.sting.alignment.bwa.*;
|
||||
import org.broadinstitute.sting.alignment.bwa.bwt.BWT;
|
||||
import org.broadinstitute.sting.alignment.bwa.bwt.SuffixArray;
|
||||
import org.broadinstitute.sting.alignment.bwa.bwt.BWTReader;
|
||||
import org.broadinstitute.sting.alignment.bwa.bwt.SuffixArrayReader;
|
||||
|
||||
/**
|
||||
* Create perfect alignments from the read to the genome represented by the given BWT / suffix array.
|
||||
*
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.broadinstitute.sting.bwa;
|
||||
package org.broadinstitute.sting.alignment;
|
||||
|
||||
/**
|
||||
* Represents an alignment of a read to a site in the reference genome.
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
package org.broadinstitute.sting.bwa;
|
||||
package org.broadinstitute.sting.alignment.bwa;
|
||||
|
||||
import org.broadinstitute.sting.alignment.Alignment;
|
||||
|
||||
/**
|
||||
* An alignment object to be used incrementally as the BWA aligner
|
||||
|
|
@ -1,10 +1,13 @@
|
|||
package org.broadinstitute.sting.bwa;
|
||||
package org.broadinstitute.sting.alignment.bwa;
|
||||
|
||||
import net.sf.samtools.SAMRecord;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.broadinstitute.sting.alignment.bwa.bwt.Base;
|
||||
import org.broadinstitute.sting.alignment.bwa.bwt.BWT;
|
||||
|
||||
/**
|
||||
* At any point along the given read, what is a good lower bound for the
|
||||
* total number of differences?
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
package org.broadinstitute.sting.bwa;
|
||||
package org.broadinstitute.sting.alignment.bwa;
|
||||
|
||||
import org.broadinstitute.sting.utils.fasta.IndexedFastaSequenceFile;
|
||||
import org.broadinstitute.sting.utils.StingException;
|
||||
import org.broadinstitute.sting.alignment.bwa.bwt.SuffixArrayReader;
|
||||
import org.broadinstitute.sting.alignment.bwa.bwt.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
package org.broadinstitute.sting.bwa;
|
||||
package org.broadinstitute.sting.alignment.bwa.bwt;
|
||||
|
||||
import org.broadinstitute.sting.alignment.bwa.packing.PackUtils;
|
||||
|
||||
/**
|
||||
* Represents the Burrows-Wheeler Transform of a reference sequence.
|
||||
|
|
@ -128,43 +130,3 @@ public class BWT {
|
|||
return sequenceBlocks;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Models a block of bases within the BWT.
|
||||
*/
|
||||
class SequenceBlock {
|
||||
/**
|
||||
* Start position of this sequence within the BWT.
|
||||
*/
|
||||
public final int sequenceStart;
|
||||
|
||||
/**
|
||||
* Length of this sequence within the BWT.
|
||||
*/
|
||||
public final int sequenceLength;
|
||||
|
||||
|
||||
/**
|
||||
* Occurrences of each letter up to this sequence block.
|
||||
*/
|
||||
public final Counts occurrences;
|
||||
|
||||
/**
|
||||
* Sequence for this segment.
|
||||
*/
|
||||
public final byte[] sequence;
|
||||
|
||||
/**
|
||||
* Create a new block within this BWT.
|
||||
* @param sequenceStart Starting position of this sequence within the BWT.
|
||||
* @param sequenceLength Length of this sequence.
|
||||
* @param occurrences How many of each base has been seen before this sequence began.
|
||||
* @param sequence The actual sequence from the BWT.
|
||||
*/
|
||||
SequenceBlock( int sequenceStart, int sequenceLength, Counts occurrences, byte[] sequence ) {
|
||||
this.sequenceStart = sequenceStart;
|
||||
this.sequenceLength = sequenceLength;
|
||||
this.occurrences = occurrences;
|
||||
this.sequence = sequence;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,9 @@
|
|||
package org.broadinstitute.sting.bwa;
|
||||
package org.broadinstitute.sting.alignment.bwa.bwt;
|
||||
|
||||
import org.broadinstitute.sting.utils.StingException;
|
||||
import org.broadinstitute.sting.alignment.bwa.packing.IntPackedInputStream;
|
||||
import org.broadinstitute.sting.alignment.bwa.packing.BasePackedInputStream;
|
||||
import org.broadinstitute.sting.alignment.bwa.packing.PackUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.ByteOrder;
|
||||
|
|
@ -50,7 +53,7 @@ public class BWTReader {
|
|||
sequenceBlocks = new SequenceBlock[PackUtils.numberOfPartitions(bwtSize,BWT.SEQUENCE_BLOCK_SIZE)];
|
||||
|
||||
for( int block = 0; block < sequenceBlocks.length; block++ ) {
|
||||
int sequenceStart = block*BWT.SEQUENCE_BLOCK_SIZE;
|
||||
int sequenceStart = block* BWT.SEQUENCE_BLOCK_SIZE;
|
||||
int sequenceLength = Math.min(BWT.SEQUENCE_BLOCK_SIZE,bwtSize-sequenceStart);
|
||||
|
||||
int[] occurrences = new int[PackUtils.ALPHABET_SIZE];
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
package org.broadinstitute.sting.bwa;
|
||||
package org.broadinstitute.sting.alignment.bwa.bwt;
|
||||
|
||||
import org.broadinstitute.sting.utils.StingException;
|
||||
import org.broadinstitute.sting.alignment.bwa.packing.IntPackedOutputStream;
|
||||
import org.broadinstitute.sting.alignment.bwa.packing.BasePackedOutputStream;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.ByteOrder;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.broadinstitute.sting.bwa;
|
||||
package org.broadinstitute.sting.alignment.bwa.bwt;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Map;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.broadinstitute.sting.bwa;
|
||||
package org.broadinstitute.sting.alignment.bwa.bwt;
|
||||
|
||||
import org.broadinstitute.sting.utils.StingException;
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ public class Counts implements Cloneable {
|
|||
* @param data Count data, broken down by base.
|
||||
* @param cumulative Whether the counts are cumulative, (count_G=numA+numC+numG,for example).
|
||||
*/
|
||||
Counts( int[] data, boolean cumulative ) {
|
||||
public Counts( int[] data, boolean cumulative ) {
|
||||
for( Base base: EnumSet.allOf(Base.class))
|
||||
counts[base.toPack()] = data[base.toPack()];
|
||||
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.broadinstitute.sting.bwa;
|
||||
package org.broadinstitute.sting.alignment.bwa.bwt;
|
||||
|
||||
import net.sf.picard.reference.ReferenceSequenceFile;
|
||||
import net.sf.picard.reference.ReferenceSequenceFileFactory;
|
||||
|
|
@ -35,6 +35,7 @@ import java.util.TreeSet;
|
|||
import java.util.Comparator;
|
||||
|
||||
import org.broadinstitute.sting.utils.StingException;
|
||||
import org.broadinstitute.sting.alignment.bwa.packing.PackUtils;
|
||||
|
||||
/**
|
||||
* Create a suffix array data structure.
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package org.broadinstitute.sting.alignment.bwa.bwt;
|
||||
|
||||
/**
|
||||
* Models a block of bases within the BWT.
|
||||
*/
|
||||
public class SequenceBlock {
|
||||
/**
|
||||
* Start position of this sequence within the BWT.
|
||||
*/
|
||||
public final int sequenceStart;
|
||||
|
||||
/**
|
||||
* Length of this sequence within the BWT.
|
||||
*/
|
||||
public final int sequenceLength;
|
||||
|
||||
|
||||
/**
|
||||
* Occurrences of each letter up to this sequence block.
|
||||
*/
|
||||
public final Counts occurrences;
|
||||
|
||||
/**
|
||||
* Sequence for this segment.
|
||||
*/
|
||||
public final byte[] sequence;
|
||||
|
||||
/**
|
||||
* Create a new block within this BWT.
|
||||
* @param sequenceStart Starting position of this sequence within the BWT.
|
||||
* @param sequenceLength Length of this sequence.
|
||||
* @param occurrences How many of each base has been seen before this sequence began.
|
||||
* @param sequence The actual sequence from the BWT.
|
||||
*/
|
||||
public SequenceBlock( int sequenceStart, int sequenceLength, Counts occurrences, byte[] sequence ) {
|
||||
this.sequenceStart = sequenceStart;
|
||||
this.sequenceLength = sequenceLength;
|
||||
this.occurrences = occurrences;
|
||||
this.sequence = sequence;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.broadinstitute.sting.bwa;
|
||||
package org.broadinstitute.sting.alignment.bwa.bwt;
|
||||
|
||||
/**
|
||||
* An in-memory representation of a suffix array.
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
package org.broadinstitute.sting.bwa;
|
||||
package org.broadinstitute.sting.alignment.bwa.bwt;
|
||||
|
||||
import org.broadinstitute.sting.utils.StingException;
|
||||
import org.broadinstitute.sting.alignment.bwa.packing.IntPackedInputStream;
|
||||
import org.broadinstitute.sting.alignment.bwa.packing.PackUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.ByteOrder;
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package org.broadinstitute.sting.bwa;
|
||||
package org.broadinstitute.sting.alignment.bwa.bwt;
|
||||
|
||||
import org.broadinstitute.sting.utils.StingException;
|
||||
import org.broadinstitute.sting.alignment.bwa.packing.IntPackedOutputStream;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.ByteOrder;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.broadinstitute.sting.bwa;
|
||||
package org.broadinstitute.sting.alignment.bwa.packing;
|
||||
|
||||
import org.broadinstitute.sting.utils.StingException;
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ public class BasePackedInputStream<T> {
|
|||
|
||||
this.targetInputStream = inputStream;
|
||||
this.type = type;
|
||||
this.buffer = ByteBuffer.allocate(PackUtils.bitsInType(type)/PackUtils.BITS_PER_BYTE).order(byteOrder);
|
||||
this.buffer = ByteBuffer.allocate(PackUtils.bitsInType(type)/ PackUtils.BITS_PER_BYTE).order(byteOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.broadinstitute.sting.bwa;
|
||||
package org.broadinstitute.sting.alignment.bwa.packing;
|
||||
|
||||
import org.broadinstitute.sting.utils.StingException;
|
||||
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.broadinstitute.sting.bwa;
|
||||
package org.broadinstitute.sting.alignment.bwa.packing;
|
||||
|
||||
import net.sf.picard.reference.ReferenceSequenceFile;
|
||||
import net.sf.picard.reference.ReferenceSequenceFileFactory;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.broadinstitute.sting.bwa;
|
||||
package org.broadinstitute.sting.alignment.bwa.packing;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.ByteBuffer;
|
||||
|
|
@ -38,7 +38,7 @@ public class IntPackedInputStream {
|
|||
*/
|
||||
public IntPackedInputStream(InputStream inputStream, ByteOrder byteOrder) {
|
||||
this.targetInputStream = inputStream;
|
||||
this.buffer = ByteBuffer.allocate(PackUtils.bitsInType(Integer.class)/PackUtils.BITS_PER_BYTE).order(byteOrder);
|
||||
this.buffer = ByteBuffer.allocate(PackUtils.bitsInType(Integer.class)/ PackUtils.BITS_PER_BYTE).order(byteOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.broadinstitute.sting.bwa;
|
||||
package org.broadinstitute.sting.alignment.bwa.packing;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.ByteBuffer;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.broadinstitute.sting.bwa;
|
||||
package org.broadinstitute.sting.alignment.bwa.packing;
|
||||
|
||||
import org.broadinstitute.sting.utils.StingException;
|
||||
|
||||
Loading…
Reference in New Issue