JAL-2089 patch broken merge to master for Release 2.10.0b1
[jalview.git] / src / jalview / analysis / scoremodels / SWScoreModel.java
index d8c6230..d5d998e 100644 (file)
@@ -1,3 +1,23 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * 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 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
 package jalview.analysis.scoremodels;
 
 import jalview.analysis.AlignSeq;
@@ -12,24 +32,40 @@ public class SWScoreModel implements ScoreModelI
   @Override
   public float[][] findDistances(AlignmentView seqData)
   {
-    SequenceI[] sequenceString = seqData
-            .getVisibleAlignment(Comparison.GapChars.charAt(0)).getSequencesArray();
+    SequenceI[] sequenceString = seqData.getVisibleAlignment(
+            Comparison.GapChars.charAt(0)).getSequencesArray();
     int noseqs = sequenceString.length;
     float[][] distance = new float[noseqs][noseqs];
-    
-     float max = -1;
-      
-      for (int i = 0; i < (noseqs - 1); i++) { for (int j = i; j < noseqs; j++)
-      { AlignSeq as = new AlignSeq(sequenceString[i], sequenceString[j], seqData.isNa() ? "dna" : "pep");
-      as.calcScoreMatrix(); as.traceAlignment(); as.printAlignment(System.out);
-      distance[i][j] = (float) as.maxscore;
-      
-      if (max < distance[i][j]) { max = distance[i][j]; } } }
-     
-      for (int i = 0; i < (noseqs - 1); i++) { for (int j = i; j < noseqs; j++)
-      { distance[i][j] = max - distance[i][j]; distance[j][i] = distance[i][j];
-      } } 
-     
+
+    float max = -1;
+
+    for (int i = 0; i < (noseqs - 1); i++)
+    {
+      for (int j = i; j < noseqs; j++)
+      {
+        AlignSeq as = new AlignSeq(sequenceString[i], sequenceString[j],
+                seqData.isNa() ? "dna" : "pep");
+        as.calcScoreMatrix();
+        as.traceAlignment();
+        as.printAlignment(System.out);
+        distance[i][j] = (float) as.maxscore;
+
+        if (max < distance[i][j])
+        {
+          max = distance[i][j];
+        }
+      }
+    }
+
+    for (int i = 0; i < (noseqs - 1); i++)
+    {
+      for (int j = i; j < noseqs; j++)
+      {
+        distance[i][j] = max - distance[i][j];
+        distance[j][i] = distance[i][j];
+      }
+    }
+
     return distance;
   }
 
@@ -38,17 +74,21 @@ public class SWScoreModel implements ScoreModelI
   {
     return "Smith Waterman Score";
   }
+
   @Override
   public boolean isDNA()
   {
     return true;
   }
+
   @Override
   public boolean isProtein()
   {
     return true;
   }
-  public String toString() {
+
+  public String toString()
+  {
     return "Score between two sequences aligned with Smith Waterman with default Peptide/Nucleotide matrix";
   }
 }