public class NeedlemanWunsch extends SequenceAlignment
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
alignment
The result of a successful alignment as a simple String.
|
protected int[][] |
CostMatrix
A matrix with the size length(sequence1) times length(sequence2)
|
protected Alignment |
pairalign
The result of a successful alignment
|
protected SubstitutionMatrix |
subMatrix
A matrix with the size length(alphabet) times length(alphabet)
|
Constructor and Description |
---|
NeedlemanWunsch(short match,
short replace,
short insert,
short delete,
short gapExtend,
SubstitutionMatrix subMat)
Constructs a new Object with the given parameters based on the
Needleman-Wunsch algorithm The alphabet of sequences to be aligned will be
taken from the given substitution matrix.
|
Modifier and Type | Method and Description |
---|---|
java.util.List<Alignment> |
alignAll(SequenceIterator source,
SequenceDB subjectDB) |
Alignment |
getAlignment(SymbolList query,
SymbolList target)
This method is good if one wants to reuse the alignment calculated by this
class in another BioJava class.
|
java.lang.String |
getAlignmentString() |
short |
getDelete()
Returns the current expenses of a single delete operation.
|
int |
getEditDistance()
This gives the edit distance according to the given parameters of this
certain object.
|
short |
getGapExt()
Returns the current expenses of any extension of a gap operation.
|
short |
getInsert()
Returns the current expenses of a single insert operation.
|
short |
getMatch()
Returns the current expenses of a single match operation.
|
short |
getReplace()
Returns the current expenses of a single replace operation.
|
protected static int |
min(int x,
int y,
int z)
This just computes the minimum of three integer values.
|
int |
pairwiseAlignment(SymbolList query,
SymbolList subject)
Global pairwise sequence alignment of two BioJava-Sequence objects
according to the Needleman-Wunsch-algorithm.
|
static void |
printAlignment(java.lang.String align)
prints the alignment String on the screen (standard output).
|
static java.lang.String |
printCostMatrix(int[][] CostMatrix,
char[] queryChar,
char[] targetChar)
Prints a String representation of the CostMatrix for the given Alignment on
the screen.
|
void |
setDelete(short del)
Sets the penalty for a delete operation to the specified value.
|
void |
setGapExt(short ge)
Sets the penalty for an extension of any gap (insert or delete) to the
specified value.
|
void |
setInsert(short ins)
Sets the penalty for an insert operation to the specified value.
|
void |
setMatch(short ma)
Sets the penalty for a match operation to the specified value.
|
void |
setReplace(short rep)
Sets the penalty for a replace operation to the specified value.
|
void |
setSubstitutionMatrix(SubstitutionMatrix matrix)
Sets the substitution matrix to be used to the specified one.
|
formatOutput
protected int[][] CostMatrix
protected SubstitutionMatrix subMatrix
protected Alignment pairalign
protected java.lang.String alignment
public NeedlemanWunsch(short match, short replace, short insert, short delete, short gapExtend, SubstitutionMatrix subMat)
match
- This gives the costs for a match operation. It is only used, if
there is no entry for a certain match of two symbols in the
substitution matrix (default value).replace
- This is like the match parameter just the default, if there is no
entry in the substitution matrix object.insert
- The costs of a single insert operation.delete
- The expenses of a single delete operation.gapExtend
- The expenses of an extension of a existing gap (that is a previous
insert or delete. If the costs for insert and delete are equal and
also equal to gapExtend, no affine gap penalties will be used,
which saves a significant amount of memory.subMat
- The substitution matrix object which gives the costs for matches
and replaces.public void setSubstitutionMatrix(SubstitutionMatrix matrix)
matrix
- an instance of a substitution matrix.public void setInsert(short ins)
ins
- costs for a single insert operationpublic void setDelete(short del)
del
- costs for a single deletion operationpublic void setGapExt(short ge)
ge
- costs for any gap extensionpublic void setMatch(short ma)
ma
- costs for a single match operationpublic void setReplace(short rep)
rep
- costs for a single replace operationpublic short getInsert()
public short getDelete()
public short getGapExt()
public short getMatch()
public short getReplace()
public static java.lang.String printCostMatrix(int[][] CostMatrix, char[] queryChar, char[] targetChar)
CostMatrix
- The matrix that contains all expenses for swapping symbols.queryChar
- a character representation of the query sequence (mySequence.seqString().toCharArray()
).targetChar
- a character representation of the target sequence.public static void printAlignment(java.lang.String align)
align
- The parameter is typically given by the
getAlignmentString()
method.public Alignment getAlignment(SymbolList query, SymbolList target) throws java.lang.Exception
pairwiseAlignment
and
returns an Alignment
instance containing the two aligned
sequences.getAlignment
in class SequenceAlignment
java.lang.Exception
public int getEditDistance()
int myDistanceValue = foo; this.CostMatrix = new int[1][1]; this.CostMatrix[0][0] = myDistanceValue;
protected static int min(int x, int y, int z)
x
- y
- z
- public java.lang.String getAlignmentString() throws BioException
getAlignmentString
in class SequenceAlignment
BioException
public java.util.List<Alignment> alignAll(SequenceIterator source, SequenceDB subjectDB) throws java.util.NoSuchElementException, BioException
alignAll
in class SequenceAlignment
source
- a SequenceIterator containing a set of sequences to be aligned
withsubjectDB
- the SequenceDB containing another set of sequences.NoSuchElementException
BioException
public int pairwiseAlignment(SymbolList query, SymbolList subject) throws BioRuntimeException
pairwiseAlignment
in class SequenceAlignment
BioRuntimeException
SequenceAlignment.pairwiseAlignment(org.biojava.bio.symbol.SymbolList,
org.biojava.bio.symbol.SymbolList)