JAL-1853 refactor clip routine from getSequenceStrings
authorJim Procter <jprocter@issues.jalview.org>
Tue, 1 Sep 2015 16:19:38 +0000 (17:19 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Tue, 1 Sep 2015 16:19:38 +0000 (17:19 +0100)
src/jalview/datamodel/AlignmentView.java

index a6f4310..7ccd9cf 100644 (file)
@@ -515,8 +515,38 @@ public class AlignmentView
   }
 
   /**
+   * build a string excluding hidden regions from a particular sequence in the
+   * view
+   * 
+   * @param c
+   * @param n
+   * @return
+   */
+  private String getASequenceString(char c, int n)
+  {
+    String sqn;
+    String fullseq = sequences[n].getSequenceString(c);
+    if (contigs != null)
+    {
+      sqn = "";
+      int p = 0;
+      for (int h = 0; h < contigs.length; h += 3)
+      {
+        sqn += fullseq.substring(p, contigs[h + 1]);
+        p = contigs[h + 1] + contigs[h + 2];
+      }
+      sqn += fullseq.substring(p);
+    }
+    else
+    {
+      sqn = fullseq;
+    }
+    return sqn;
+  }
+
+  /**
    * get an array of visible sequence strings for a view on an alignment using
-   * the given gap character
+   * the given gap character uses getASequenceString
    * 
    * @param c
    *          char
@@ -527,22 +557,7 @@ public class AlignmentView
     String[] seqs = new String[sequences.length];
     for (int n = 0; n < sequences.length; n++)
     {
-      String fullseq = sequences[n].getSequenceString(c);
-      if (contigs != null)
-      {
-        seqs[n] = "";
-        int p = 0;
-        for (int h = 0; h < contigs.length; h += 3)
-        {
-          seqs[n] += fullseq.substring(p, contigs[h + 1]);
-          p = contigs[h + 1] + contigs[h + 2];
-        }
-        seqs[n] += fullseq.substring(p);
-      }
-      else
-      {
-        seqs[n] = fullseq;
-      }
+      seqs[n] = getASequenceString(c, n);
     }
     return seqs;
   }