convenience method for performing pairwise alignment
[jalview.git] / src / jalview / analysis / AlignSeq.java
index e96d208..3ede7a8 100755 (executable)
@@ -1,13 +1,13 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
- * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
+ * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
  * 
  * This file is part of Jalview.
  * 
  * Jalview is free software: you can redistribute it and/or
  * modify it under the terms of the GNU General Public License 
  * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
- * 
+ *  
  * Jalview is distributed in the hope that it will be useful, but 
  * WITHOUT ANY WARRANTY; without even the implied warranty 
  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
@@ -16,7 +16,6 @@
  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
  */
 package jalview.analysis;
-
 import java.util.*;
 
 import java.awt.*;
@@ -267,16 +266,11 @@ public class AlignSeq
   }
 
   /**
-   * DOCUMENT ME!
-   * 
-   * @param s1
-   *          DOCUMENT ME!
-   * @param string1
-   *          - string to align for sequence1
-   * @param s2
-   *          sequence 2
-   * @param string2
-   *          - string to align for sequence2
+   * Construct score matrix for sequences with standard DNA or PEPTIDE matrix
+   * @param s1 - sequence 1
+   * @param string1 - string to use for s1
+   * @param s2 - sequence 2
+   * @param string2 - string to use for s2
    * @param type
    *          DNA or PEPTIDE
    */
@@ -289,6 +283,14 @@ public class AlignSeq
     SeqInit(string1, string2);
   }
 
+  /**
+   * Construct score matrix for sequences with custom substitution matrix
+   * @param s1 - sequence 1
+   * @param string1 - string to use for s1
+   * @param s2 - sequence 2
+   * @param string2 - string to use for s2
+   * @param scoreMatrix - substitution matrix to use for alignment
+   */
   public void SeqInit(SequenceI s1, String string1, SequenceI s2,
           String string2, ScoreMatrix scoreMatrix)
   {
@@ -302,7 +304,7 @@ public class AlignSeq
    * construct score matrix for string1 and string2 (after removing any existing
    * gaps
    * 
-   * @param string1
+   * @param string1 
    * @param string2
    */
   private void SeqInit(String string1, String string2)
@@ -920,6 +922,25 @@ public class AlignSeq
   }
 
   /**
+   * Compute a globally optimal needleman and wunsch alignment between two
+   * sequences
+   * 
+   * @param s1
+   * @param s2
+   * @param type
+   *          AlignSeq.DNA or AlignSeq.PEP
+   */
+  public static AlignSeq doGlobalNWAlignment(SequenceI s1, SequenceI s2,
+          String type)
+  {
+    AlignSeq as = new AlignSeq(s1, s2, type);
+
+    as.calcScoreMatrix();
+    as.traceAlignment();
+    return as;
+  }
+
+
    * compute the PID vector used by the redundancy filter.
    * 
    * @param originalSequences