*/
package jalview.analysis;
-import java.util.Locale;
-
import jalview.analysis.scoremodels.PIDModel;
import jalview.analysis.scoremodels.ScoreMatrix;
import jalview.analysis.scoremodels.ScoreModels;
import java.util.HashMap;
import java.util.List;
import java.util.StringTokenizer;
+import java.util.Locale;
/**
- *
- *
* @author $author$
* @version $Revision$
*/
{
private static final int MAX_NAME_LENGTH = 30;
- //&!
- //private static final int GAP_OPEN_COST = 120;
- private static final int GAP_OPEN_COST = 100;
+ private static final int DEFAULT_OPENCOST = 120;
+
+ private static final int DEFAULT_EXTENDCOST = 20;
+
+ private int GAP_OPEN_COST=DEFAULT_OPENCOST;
- //private static final int GAP_EXTEND_COST = 20;
- private static final int GAP_EXTEND_COST = 5;
+ private int GAP_EXTEND_COST=DEFAULT_EXTENDCOST;
private static final int GAP_INDEX = -1;
/**
* Creates a new AlignSeq object.
*
- * @param s1
- * DOCUMENT ME!
- * @param s2
- * DOCUMENT ME!
+ * @param s1,string1
+ * s1 reference sequence for string1
+ * @param s2,string2
+ * s2 reference sequence for string2
* @param type
- * DOCUMENT ME!
+ * molecule type, either AlignSeq.PEP or AlignSeq.DNA
*/
public AlignSeq(SequenceI s1, String string1, SequenceI s2,
String string2, String type)
string2.toUpperCase(Locale.ROOT), type);
}
+ public AlignSeq(SequenceI s1, SequenceI s2, String type, int opencost,
+ int extcost)
+ {
+ this(s1,s2,type);
+ GAP_OPEN_COST=opencost;
+ GAP_EXTEND_COST=extcost;
+ }
+
+ public AlignSeq(SequenceI s12, String string1, SequenceI s22,
+ String string2, String type2, int defaultOpencost,
+ int defaultExtendcost)
+ {
+ this(s12,string1,s22,string2,type2);
+ GAP_OPEN_COST=defaultOpencost;
+ GAP_EXTEND_COST=defaultExtendcost;
+ }
+
/**
* DOCUMENT ME!
*
public void seqInit(SequenceI s1, String string1, SequenceI s2,
String string2, String type)
{
+ seqInit(s1,string1,s2,string2,type,GAP_OPEN_COST,GAP_EXTEND_COST);
+ }
+ public void seqInit(SequenceI s1, String string1, SequenceI s2,
+ String string2, String type, int opening,int extension)
+ {
+ GAP_OPEN_COST=opening;
+ GAP_EXTEND_COST=extension;
this.s1 = s1;
this.s2 = s2;
setDefaultParams(type);
{
int n = seq1.length;
int m = seq2.length;
-
+ final int GAP_EX_COST=GAP_EXTEND_COST;
+ final int GAP_OP_COST = GAP_OPEN_COST;
// top left hand element
score[0][0] = scoreMatrix.getPairwiseScore(s1str.charAt(0),
s2str.charAt(0)) * 10;
- E[0][0] = -GAP_EXTEND_COST;
+ E[0][0] = -GAP_EX_COST;
F[0][0] = 0;
// Calculate the top row first
for (int j = 1; j < m; j++)
{
// What should these values be? 0 maybe
- E[0][j] = max(score[0][j - 1] - GAP_OPEN_COST,
- E[0][j - 1] - GAP_EXTEND_COST);
- F[0][j] = -GAP_EXTEND_COST;
+ E[0][j] = max(score[0][j - 1] - GAP_OP_COST,
+ E[0][j - 1] - GAP_EX_COST);
+ F[0][j] = -GAP_EX_COST;
float pairwiseScore = scoreMatrix.getPairwiseScore(s1str.charAt(0),
s2str.charAt(j));
- score[0][j] = max(pairwiseScore * 10, -GAP_OPEN_COST,
- -GAP_EXTEND_COST);
+ score[0][j] = max(pairwiseScore * 10, -GAP_OP_COST,
+ -GAP_EX_COST);
traceback[0][j] = 1;
}
// Now do the left hand column
for (int i = 1; i < n; i++)
{
- E[i][0] = -GAP_OPEN_COST;
- F[i][0] = max(score[i - 1][0] - GAP_OPEN_COST,
- F[i - 1][0] - GAP_EXTEND_COST);
+ E[i][0] = -GAP_OP_COST;
+ F[i][0] = max(score[i - 1][0] - GAP_OP_COST,
+ F[i - 1][0] - GAP_EX_COST);
float pairwiseScore = scoreMatrix.getPairwiseScore(s1str.charAt(i),
s2str.charAt(0));
{
for (int j = 1; j < m; j++)
{
- E[i][j] = max(score[i][j - 1] - GAP_OPEN_COST,
- E[i][j - 1] - GAP_EXTEND_COST);
- F[i][j] = max(score[i - 1][j] - GAP_OPEN_COST,
- F[i - 1][j] - GAP_EXTEND_COST);
+ E[i][j] = max(score[i][j - 1] - GAP_OP_COST,
+ E[i][j - 1] - GAP_EX_COST);
+ F[i][j] = max(score[i - 1][j] - GAP_OP_COST,
+ F[i - 1][j] - GAP_EX_COST);
float pairwiseScore = scoreMatrix.getPairwiseScore(s1str.charAt(i),
s2str.charAt(j));
public static AlignSeq doGlobalNWAlignment(SequenceI s1, SequenceI s2,
String type)
{
- AlignSeq as = new AlignSeq(s1, s2, type);
+ return doGlobalNWAlignment(s1, s2, type, DEFAULT_OPENCOST,DEFAULT_EXTENDCOST);
+ }
+ public static AlignSeq doGlobalNWAlignment(SequenceI s1, SequenceI s2,
+ String type, int opencost,int extcost)
+ {
+
+ AlignSeq as = new AlignSeq(s1, s2, type,opencost,extcost);
as.calcScoreMatrix();
as.traceAlignment();