JAL-1483 reformatting and use new feature renderer/settings api from JAL-1482
authorj.procter@dundee.ac.uk <jprocter@Jims-MacBook-Pro-2.local>
Fri, 8 Aug 2014 17:13:32 +0000 (18:13 +0100)
committerj.procter@dundee.ac.uk <jprocter@Jims-MacBook-Pro-2.local>
Fri, 8 Aug 2014 17:13:32 +0000 (18:13 +0100)
src/jalview/analysis/scoremodels/FeatureScoreModel.java

index e9347e4..b946bba 100644 (file)
@@ -1,6 +1,7 @@
 package jalview.analysis.scoremodels;
 
 import java.awt.Color;
+import java.util.List;
 
 import jalview.analysis.AlignSeq;
 import jalview.api.analysis.ScoreModelI;
@@ -11,12 +12,13 @@ import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
 import jalview.util.Comparison;
 
-public class FeatureScoreModel implements ScoreModelI,ViewBasedAnalysisI
+public class FeatureScoreModel implements ScoreModelI, ViewBasedAnalysisI
 {
   jalview.api.FeatureRenderer fr;
-  
-  @Override 
-  public boolean configureFromAlignmentView(jalview.api.AlignmentViewPanel view)
+
+  @Override
+  public boolean configureFromAlignmentView(
+          jalview.api.AlignmentViewPanel view)
   {
     fr = view.cloneFeatureRenderer();
     return true;
@@ -25,31 +27,34 @@ public class FeatureScoreModel implements ScoreModelI,ViewBasedAnalysisI
   @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;
     int cpwidth = seqData.getWidth();
     float[][] distance = new float[noseqs][noseqs];
-    float max=0;
-    for (int cpos = 0;cpos<cpwidth;cpos++)
+    float max = 0;
+    for (int cpos = 0; cpos < cpwidth; cpos++)
     {
-      // get visible features at cpos under view's display settings and compare them
+      // get visible features at cpos under view's display settings and compare
+      // them
       for (int i = 0; i < (noseqs - 1); i++)
       {
-        SequenceFeature[] sf = fr.getVisible(sequenceString[i],cpos);
-        for (int j=i+1;j<noseqs;j++)
+        List<SequenceFeature> sf = fr.findFeaturesAtRes(sequenceString[i],
+                cpos);
+        for (int j = i + 1; j < noseqs; j++)
         {
-          SequenceFeature[] jsf = fr.getVisible(sequenceString[i],cpos);
+          List<SequenceFeature> jsf = fr.findFeaturesAtRes(
+                  sequenceString[i], cpos);
+          // compare the two lists of features...
 
-          
-        if (max < distance[i][j])
-        {
-          max = distance[i][j];
+          if (max < distance[i][j])
+          {
+            max = distance[i][j];
+          }
         }
       }
     }
-    }
 
     for (int i = 0; i < (noseqs - 1); i++)
     {
@@ -59,7 +64,7 @@ public class FeatureScoreModel implements ScoreModelI,ViewBasedAnalysisI
         distance[j][i] = distance[i][j];
       }
     }
-     
+
     return distance;
   }
 
@@ -68,17 +73,21 @@ public class FeatureScoreModel implements ScoreModelI,ViewBasedAnalysisI
   {
     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";
   }
 }