merge from 2_4_Release branch
[jalview.git] / src / jalview / datamodel / CigarArray.java
index c17e01e..6842f4a 100644 (file)
@@ -1,36 +1,37 @@
 /*\r
- * Jalview - A Sequence Alignment Editor and Viewer\r
- * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
- *\r
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)\r
+ * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ * \r
  * This program is free software; you can redistribute it and/or\r
  * modify it under the terms of the GNU General Public License\r
  * as published by the Free Software Foundation; either version 2\r
  * of the License, or (at your option) any later version.\r
- *\r
+ * \r
  * This program is distributed in the hope that it will be useful,\r
  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
  * GNU General Public License for more details.\r
- *\r
+ * \r
  * You should have received a copy of the GNU General Public License\r
  * along with this program; if not, write to the Free Software\r
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
  */\r
 package jalview.datamodel;\r
 \r
-public class CigarArray\r
-    extends CigarBase\r
+public class CigarArray extends CigarBase\r
 {\r
   /**\r
-   * Do CIGAR operations on a set of sequences from many other cigars\r
-   * BAD THINGS WILL HAPPEN IF A CIGARARRAY IS PASSED TO A CIGARARRAY\r
-   * or a CIGARCIGAR is given a CIGARARRAY to insert gaps into.\r
+   * Do CIGAR operations on a set of sequences from many other cigars BAD THINGS\r
+   * WILL HAPPEN IF A CIGARARRAY IS PASSED TO A CIGARARRAY or a CIGARCIGAR is\r
+   * given a CIGARARRAY to insert gaps into.\r
    */\r
   /**\r
    * array of subject cigars\r
    */\r
   public CigarSimple refCigars[] = null;\r
+\r
   private boolean seqcigararray = false;\r
+\r
   private CigarArray()\r
   {\r
     super();\r
@@ -38,6 +39,7 @@ public class CigarArray
 \r
   /**\r
    * isSeqCigarArray()\r
+   * \r
    * @return boolean true if all refCigars resolve to a SeqCigar or a CigarCigar\r
    */\r
   public boolean isSeqCigarArray()\r
@@ -46,9 +48,11 @@ public class CigarArray
   }\r
 \r
   /**\r
-   * Apply CIGAR operations to several cigars in parallel\r
-   * will throw an error if any of cigar are actually CigarArrays.\r
-   * @param cigar Cigar[]\r
+   * Apply CIGAR operations to several cigars in parallel will throw an error if\r
+   * any of cigar are actually CigarArrays.\r
+   * \r
+   * @param cigar\r
+   *                Cigar[]\r
    */\r
   public CigarArray(CigarSimple[] cigars)\r
   {\r
@@ -60,8 +64,7 @@ public class CigarArray
       for (int c = 0; c < cigars.length; c++)\r
       {\r
         refCigars[c] = cigars[c];\r
-        if (! ( (cigars[c] instanceof SeqCigar)\r
-               || cigars[c] instanceof CigarCigar))\r
+        if (!((cigars[c] instanceof SeqCigar) || cigars[c] instanceof CigarCigar))\r
         {\r
           seqcigararray = false;\r
         }\r
@@ -71,7 +74,8 @@ public class CigarArray
 \r
   /**\r
    * @see Cigar.getSequenceAndDeletions\r
-   * @param GapChar char\r
+   * @param GapChar\r
+   *                char\r
    * @return Object[][]\r
    */\r
   protected Object[][] getArrayofSequenceAndDeletions(char GapChar)\r
@@ -98,8 +102,11 @@ public class CigarArray
 \r
   /**\r
    * NOTE: this is an improper sequence string function\r
-   * @return String formed by newline concatenated results of applying CIGAR operations to each reference object in turn.\r
-   * @param GapChar char\r
+   * \r
+   * @return String formed by newline concatenated results of applying CIGAR\r
+   *         operations to each reference object in turn.\r
+   * @param GapChar\r
+   *                char\r
    * @return '\n' separated strings (empty results included as \n\n)\r
    */\r
   public String getSequenceString(char GapChar)\r
@@ -114,7 +121,7 @@ public class CigarArray
     {\r
       if (sqanddels[c] != null)\r
       {\r
-        seqStrings.append( (String) sqanddels[c][0]);\r
+        seqStrings.append((String) sqanddels[c][0]);\r
         sqanddels[c][0] = null;\r
       }\r
       seqStrings.append('\n');\r
@@ -124,7 +131,9 @@ public class CigarArray
 \r
   /**\r
    * return string results of applying cigar string to all reference cigars\r
-   * @param GapChar char\r
+   * \r
+   * @param GapChar\r
+   *                char\r
    * @return String[]\r
    */\r
   public String[] getSequenceStrings(char GapChar)\r
@@ -146,18 +155,19 @@ public class CigarArray
   /**\r
    * Combines the CigarArray cigar operations with the operations in each\r
    * reference cigar - creating a new reference cigar\r
+   * \r
    * @return Cigar[]\r
-\r
-     public CigarBase[] getEditedCigars() {\r
-\r
-    return new CigarBase[] {};\r
-     }\r
+   * \r
+   * public CigarBase[] getEditedCigars() {\r
+   * \r
+   * return new CigarBase[] {}; }\r
    */\r
   /**\r
-   * applyDeletions\r
-   * edits underlying refCigars to propagate deleted regions, and removes deletion\r
-   * operations from CigarArray operation list.\r
-   * @return int[] position after deletion occured and range of deletion in cigarArray or null if none occured\r
+   * applyDeletions edits underlying refCigars to propagate deleted regions, and\r
+   * removes deletion operations from CigarArray operation list.\r
+   * \r
+   * @return int[] position after deletion occured and range of deletion in\r
+   *         cigarArray or null if none occured\r
    */\r
   public int[] applyDeletions()\r
   {\r
@@ -188,18 +198,16 @@ public class CigarArray
         }\r
         int delstart = cursor, delend = cursor + range[i] - 1; // inclusive\r
         delpos.addElement(new int[]\r
-                          {vcursor + offset, range[i]}); // index of right hand column after hidden region boundary\r
+        { vcursor + offset, range[i] }); // index of right hand column after\r
+                                          // hidden region boundary\r
         offset += range[i] - 1; // shift in visible column coordinates\r
         System.arraycopy(operation, i + 1, operation, i, length - i);\r
         System.arraycopy(range, i + 1, range, i, length - i);\r
         length--;\r
-        /*        int dmax=0;\r
-         for (int s=0; s<refCigars.length; s++) {\r
-           int d = refCigars[s].deleteRange(delstart, delend);\r
-           if (d>dmax)\r
-             dmax=d;\r
-         }\r
-         offset+=dmax; // shift in visible column coordinates\r
+        /*\r
+         * int dmax=0; for (int s=0; s<refCigars.length; s++) { int d =\r
+         * refCigars[s].deleteRange(delstart, delend); if (d>dmax) dmax=d; }\r
+         * offset+=dmax; // shift in visible column coordinates\r
          */\r
         for (int s = 0; s < refCigars.length; s++)\r
         {\r
@@ -213,7 +221,7 @@ public class CigarArray
       int[] pos = new int[delpos.size() * 2];\r
       for (int k = 0, l = delpos.size(); k < l; k++)\r
       {\r
-        int[] dr = ( (int[]) delpos.elementAt(k));\r
+        int[] dr = ((int[]) delpos.elementAt(k));\r
         pos[k * 2] = dr[0];\r
         pos[k * 2 + 1] = dr[1];\r
         delpos.setElementAt(null, k);\r
@@ -225,8 +233,9 @@ public class CigarArray
   }\r
 \r
   /**\r
-   *\r
-   * @return SeqCigar[] or null if CigarArray is not a SeqCigarArray (ie it does not resolve to set of seqCigars)\r
+   * \r
+   * @return SeqCigar[] or null if CigarArray is not a SeqCigarArray (ie it does\r
+   *         not resolve to set of seqCigars)\r
    */\r
   public SeqCigar[] getSeqCigarArray()\r
   {\r