-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
118 changed files
with
504,378 additions
and
0 deletions.
There are no files selected for viewing
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,6 @@ | ||
/target/ | ||
/.settings/ | ||
/logs/ | ||
.project | ||
.classpath | ||
|
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,170 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>utilities</artifactId> | ||
<name>utilities</name> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
<distributionManagement> | ||
<repository> | ||
<id>internal</id> | ||
<url>http://sealion.scripps.edu/archiva/repository/internal/</url> | ||
</repository> | ||
<snapshotRepository> | ||
<id>snapshots</id> | ||
<url>http://sealion.scripps.edu/archiva/repository/snapshots/</url> | ||
</snapshotRepository> | ||
</distributionManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>log4j</groupId> | ||
<artifactId>log4j</artifactId> | ||
<version>1.2.16</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.compomics</groupId> | ||
<artifactId>dbtoolkit</artifactId> | ||
<version>4.2.5</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>batik</groupId> | ||
<artifactId>batik-all</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<artifactId>pdf-transcoder</artifactId> | ||
<groupId>batik</groupId> | ||
</exclusion> | ||
<exclusion> | ||
<artifactId>servlet-api</artifactId> | ||
<groupId>javax.servlet</groupId> | ||
</exclusion> | ||
<exclusion> | ||
<artifactId>ssj</artifactId> | ||
<groupId>umontreal.iro.lecuyer.gof</groupId> | ||
</exclusion> | ||
<exclusion> | ||
<artifactId>jshortcut</artifactId> | ||
<groupId>net.jimmc</groupId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.jcraft</groupId> | ||
<artifactId>jsch</artifactId> | ||
<version>0.1.50</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-exec</artifactId> | ||
<version>1.2</version> | ||
</dependency> | ||
|
||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.10</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-core</artifactId> | ||
<version>2.0.8</version> | ||
<exclusions> | ||
<exclusion> | ||
<artifactId>servlet-api</artifactId> | ||
<groupId>javax.servlet</groupId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.mail</groupId> | ||
<artifactId>javax.mail-api</artifactId> | ||
<version>1.5.5</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>psidev.psi.tools</groupId> | ||
<artifactId>validator</artifactId> | ||
<version>2.0.4</version> | ||
<exclusions> | ||
<exclusion> | ||
<artifactId>servlet-api</artifactId> | ||
<groupId>javax.servlet</groupId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-lang3</artifactId> | ||
<version>3.4</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-math3</artifactId> | ||
<version>3.5</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<resources> | ||
<!-- regular resource processsing for everything except logback.xml --> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
</resource> | ||
</resources> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.3</version> | ||
<configuration> | ||
<source>1.7</source> | ||
<target>1.7</target> | ||
</configuration> | ||
</plugin> | ||
<!-- <plugin> --> | ||
<!-- <artifactId>maven-assembly-plugin</artifactId> --> | ||
<!-- <executions> --> | ||
<!-- <execution> --> | ||
<!-- <phase>package</phase> --> | ||
<!-- <goals> --> | ||
<!-- <goal>single</goal> --> | ||
<!-- </goals> --> | ||
<!-- </execution> --> | ||
<!-- </executions> --> | ||
<!-- <configuration> --> | ||
<!-- <descriptorRefs> --> | ||
<!-- <descriptorRef>jar-with-dependencies</descriptorRef> --> | ||
<!-- </descriptorRefs> --> | ||
<!-- </configuration> --> | ||
<!-- </plugin> --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<version>2.2.1</version> | ||
<executions> | ||
<execution> | ||
<id>attach-sources</id> | ||
<phase>verify</phase> | ||
<goals> | ||
<goal>jar-no-fork</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<organization> | ||
<name>TSRI</name> | ||
</organization> | ||
<version>1.1</version> | ||
<repositories> | ||
<!-- UGent Genesis Maven 2 repository --> | ||
<repository> | ||
<id>genesis-maven2-repository</id> | ||
<name>Genesis maven2 repository</name> | ||
<url>http://genesis.UGent.be/maven2</url> | ||
<layout>default</layout> | ||
</repository> | ||
</repositories> | ||
<groupId>edu.scripps.yates</groupId> | ||
</project> |
104 changes: 104 additions & 0 deletions
104
src/main/java/edu/scripps/yates/utilities/alignment/NeedlemanWunschSimple.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,104 @@ | ||
package edu.scripps.yates.utilities.alignment; | ||
|
||
public class NeedlemanWunschSimple { | ||
char[] mSeqA; | ||
char[] mSeqB; | ||
int[][] mD; | ||
int mScore; | ||
String mAlignmentSeqA = ""; | ||
String mAlignmentSeqB = ""; | ||
|
||
void init(char[] seqA, char[] seqB) { | ||
mSeqA = seqA; | ||
mSeqB = seqB; | ||
mD = new int[mSeqA.length + 1][mSeqB.length + 1]; | ||
for (int i = 0; i <= mSeqA.length; i++) { | ||
for (int j = 0; j <= mSeqB.length; j++) { | ||
if (i == 0) { | ||
mD[i][j] = -j; | ||
} else if (j == 0) { | ||
mD[i][j] = -i; | ||
} else { | ||
mD[i][j] = 0; | ||
} | ||
} | ||
} | ||
} | ||
|
||
void process() { | ||
for (int i = 1; i <= mSeqA.length; i++) { | ||
for (int j = 1; j <= mSeqB.length; j++) { | ||
int scoreDiag = mD[i - 1][j - 1] + weight(i, j); | ||
int scoreLeft = mD[i][j - 1] - 1; | ||
int scoreUp = mD[i - 1][j] - 1; | ||
mD[i][j] = Math.max(Math.max(scoreDiag, scoreLeft), scoreUp); | ||
} | ||
} | ||
} | ||
|
||
void backtrack() { | ||
int i = mSeqA.length; | ||
int j = mSeqB.length; | ||
mScore = mD[i][j]; | ||
while (i > 0 && j > 0) { | ||
if (mD[i][j] == mD[i - 1][j - 1] + weight(i, j)) { | ||
mAlignmentSeqA += mSeqA[i - 1]; | ||
mAlignmentSeqB += mSeqB[j - 1]; | ||
i--; | ||
j--; | ||
continue; | ||
} else if (mD[i][j] == mD[i][j - 1] - 1) { | ||
mAlignmentSeqA += "-"; | ||
mAlignmentSeqB += mSeqB[j - 1]; | ||
j--; | ||
continue; | ||
} else { | ||
mAlignmentSeqA += mSeqA[i - 1]; | ||
mAlignmentSeqB += "-"; | ||
i--; | ||
continue; | ||
} | ||
} | ||
mAlignmentSeqA = new StringBuffer(mAlignmentSeqA).reverse().toString(); | ||
mAlignmentSeqB = new StringBuffer(mAlignmentSeqB).reverse().toString(); | ||
} | ||
|
||
private int weight(int i, int j) { | ||
if (mSeqA[i - 1] == mSeqB[j - 1]) { | ||
return 1; | ||
} else { | ||
return -1; | ||
} | ||
} | ||
|
||
void printMatrix() { | ||
System.out.println("D ="); | ||
for (int i = 0; i < mSeqA.length + 1; i++) { | ||
for (int j = 0; j < mSeqB.length + 1; j++) { | ||
System.out.print(String.format("%4d ", mD[i][j])); | ||
} | ||
System.out.println(); | ||
} | ||
System.out.println(); | ||
} | ||
|
||
void printScoreAndAlignments() { | ||
System.out.println("Score: " + mScore); | ||
System.out.println("Sequence A: " + mAlignmentSeqA); | ||
System.out.println("Sequence B: " + mAlignmentSeqB); | ||
System.out.println(); | ||
} | ||
|
||
public static void main(String[] args) { | ||
char[] seqA = { 'A', 'C', 'G', 'T', 'C' }; | ||
char[] seqB = { 'A', 'G', 'T', 'C' }; | ||
|
||
NeedlemanWunschSimple nw = new NeedlemanWunschSimple(); | ||
nw.init(seqA, seqB); | ||
nw.process(); | ||
nw.backtrack(); | ||
|
||
nw.printMatrix(); | ||
nw.printScoreAndAlignments(); | ||
} | ||
} |
Oops, something went wrong.