-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Aligning using native SSE2 striped smith-watermann through JNI when p…
…ossible Decoupled alignment from jaligner
- Loading branch information
Showing
16 changed files
with
198 additions
and
78 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
d00d0e5c5a3b5a1dbc6a5a9b5566bdca |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3ce9cfbb055f1b91f6720dbd3325930f6995c20b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>ssw</groupId> | ||
<artifactId>ssw</artifactId> | ||
<version>1.0</version> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3a18003c5d37f085a61043040df5adc1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6520d4a19af74e977b1bf07834c10618deca41c4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<metadata> | ||
<groupId>ssw</groupId> | ||
<artifactId>ssw</artifactId> | ||
<versioning> | ||
<release>1.0</release> | ||
<versions> | ||
<version>1.0</version> | ||
</versions> | ||
<lastUpdated>20150223004749</lastUpdated> | ||
</versioning> | ||
</metadata> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2c99ce3336f85f1d50d5b7eac707ebbf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a42b905a2ae1c0cf17e96afbe6b68a55d33d5efd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package au.edu.wehi.idsv.alignment; | ||
|
||
public interface Aligner { | ||
/** | ||
* Performs Smith-Waterman alignment of the given sequence against the given reference | ||
* @param seq sequence to align | ||
* @param ref reference sequence | ||
* @return Alignment of sequence relative to reference | ||
*/ | ||
public Alignment align_smith_waterman(byte[] seq, byte[] ref); | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/au/edu/wehi/idsv/alignment/AlignerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package au.edu.wehi.idsv.alignment; | ||
|
||
import htsjdk.samtools.util.Log; | ||
import au.edu.wehi.idsv.Idsv; | ||
|
||
public class AlignerFactory { | ||
private static final Log log = Log.getInstance(Idsv.class); | ||
private static boolean sswjniLoaded; | ||
static { | ||
try { | ||
System.loadLibrary("sswjni"); | ||
sswjniLoaded = true; | ||
} catch (UnsatisfiedLinkError e) { | ||
sswjniLoaded = false; | ||
log.warn("Unable to load sswjni library - assembly will be 10x slower than normal. Please ensure libsswjni.so can be found by setting LD_LIBRARY_PATH or java.library.path"); | ||
} | ||
} | ||
public static Aligner create(int match, int mismatch, int ambiguous, int gapOpen, int gapExtend) { | ||
if (sswjniLoaded) { | ||
return new SswJniAligner(match, mismatch, ambiguous, gapOpen, gapExtend); | ||
} else { | ||
return new JAlignerAligner(match, mismatch, ambiguous, gapOpen, gapExtend); | ||
} | ||
} | ||
public static Aligner create() { | ||
return create(1, -4, -4, 6, 1); // bwa mem | ||
//return create(2, -6, -1, 5, 3); // bowtie2 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package au.edu.wehi.idsv.alignment; | ||
|
||
/** | ||
* Alignment of a sequence relative to a reference | ||
* @author cameron.d | ||
* | ||
*/ | ||
public class Alignment { | ||
private final int startPosition; | ||
private final String cigar; | ||
/** | ||
* Sequence pair alignment outcome | ||
* @param startPosition Zero-based start position of sequence relative to reference | ||
* @param cigar sequence alignment CIGAR | ||
*/ | ||
public Alignment(int startPosition, String cigar) { | ||
this.startPosition = startPosition; | ||
this.cigar = cigar; | ||
} | ||
/** | ||
* Zero-based start position of sequence relative to reference | ||
* @return | ||
*/ | ||
public int getStartPosition() { | ||
return startPosition; | ||
} | ||
/** | ||
* sequence alignment CIGAR | ||
* @return CIGAR string of sequence alignment | ||
*/ | ||
public String getCigar() { | ||
return cigar; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/au/edu/wehi/idsv/alignment/SswJniAligner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package au.edu.wehi.idsv.alignment; | ||
|
||
import htsjdk.samtools.util.SequenceUtil; | ||
|
||
public class SswJniAligner implements Aligner { | ||
private static final int MATRIX_SIZE = 128; | ||
private final int gapOpen; | ||
private final int gapExtend; | ||
private final int[][] matrix; | ||
public SswJniAligner(int match, int mismatch, int ambiguous, int gapOpen, int gapExtend) { | ||
this.gapOpen = gapOpen; | ||
this.gapExtend = gapExtend; | ||
this.matrix = createMatrix(match, mismatch, ambiguous); | ||
} | ||
private static int[][] createMatrix(int match, int mismatch, int ambiguous) { | ||
int[][] scores = new int[MATRIX_SIZE][MATRIX_SIZE]; | ||
// Fill the matrix with the scores | ||
for (int i = 0; i < MATRIX_SIZE; i++) { | ||
for (int j = 0; j < MATRIX_SIZE; j++) { | ||
if (Character.toUpperCase(i) == Character.toUpperCase(j)) { | ||
scores[i][j] = match; | ||
} else if (SequenceUtil.isValidBase((byte) i) && SequenceUtil.isValidBase((byte) j)) { | ||
scores[i][j] = mismatch; | ||
} else { | ||
scores[i][j] = ambiguous; | ||
} | ||
} | ||
} | ||
return scores; | ||
} | ||
@Override | ||
public Alignment align_smith_waterman(byte[] seq, byte[] ref) { | ||
ssw.Alignment result = ssw.Aligner.align(seq, ref, matrix, gapOpen, gapExtend, true); | ||
String cigar = result.cigar; | ||
if (result.read_begin1 != 0) { | ||
cigar = Integer.toString(result.read_begin1) + "S" + cigar; | ||
} | ||
int endOffset = seq.length - result.read_end1 - 1; | ||
if (endOffset != 0) { | ||
cigar += Integer.toString(endOffset) + "S"; | ||
} | ||
return new Alignment(result.ref_begin1, cigar); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters