X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FAlignSeq.java;h=1a8318869940705df1c0e9bd3e7a3e1250529e48;hb=840c90a082ffc6f29a512501337c4e4397ad604f;hp=02b3f41f35a8397cd8ad1a0f5d018d2a22432da2;hpb=c9e6efcdf33bcd88bd19a48b2934c28e48892fab;p=jalview.git diff --git a/src/jalview/analysis/AlignSeq.java b/src/jalview/analysis/AlignSeq.java index 02b3f41..1a83188 100755 --- a/src/jalview/analysis/AlignSeq.java +++ b/src/jalview/analysis/AlignSeq.java @@ -54,9 +54,13 @@ public class AlignSeq { private static final int MAX_NAME_LENGTH = 30; - private static final int GAP_OPEN_COST = 120; + private static final int DEFAULT_OPENCOST = 120; - private static final int GAP_EXTEND_COST = 20; + private static final int DEFAULT_EXTENDCOST = 20; + + private int GAP_OPEN_COST=DEFAULT_OPENCOST; + + private int GAP_EXTEND_COST=DEFAULT_EXTENDCOST; private static final int GAP_INDEX = -1; @@ -140,12 +144,12 @@ public class AlignSeq /** * 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) @@ -154,6 +158,23 @@ public class AlignSeq 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! * @@ -299,6 +320,13 @@ public class AlignSeq 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); @@ -635,25 +663,26 @@ public class AlignSeq { 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; } @@ -661,9 +690,9 @@ public class AlignSeq // 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)); @@ -676,10 +705,10 @@ public class AlignSeq { 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)); @@ -857,7 +886,13 @@ public class AlignSeq 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();