Jalview 2.6 source licence
[jalview.git] / src / jalview / schemes / ResidueProperties.java
index ff73050..67211cd 100755 (executable)
@@ -1,20 +1,19 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
- * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
+ * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
  * 
- * This program 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 2
- * of the License, or (at your option) any later version.
+ * This file is part of Jalview.
  * 
- * This program 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.
+ * 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.
  * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ * 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/>.
  */
 package jalview.schemes;
 
@@ -93,7 +92,7 @@ public class ResidueProperties
     aaIndex['z'] = 21;
     aaIndex['x'] = 22;
     aaIndex['u'] = 22; // TODO: selenocystine triplet and codons needed. also
-                        // extend subt. matrices
+    // extend subt. matrices
   }
 
   static
@@ -101,7 +100,7 @@ public class ResidueProperties
     nucleotideIndex = new int[255];
     for (int i = 0; i < 255; i++)
     {
-      nucleotideIndex[i] = -1;
+      nucleotideIndex[i] = 10; // non-nucleotide symbols are all non-gap gaps.
     }
 
     nucleotideIndex['A'] = 0;
@@ -280,7 +279,13 @@ public class ResidueProperties
       new Color(255, 179, 64), // C
       new Color(235, 65, 60), // G
       new Color(60, 136, 238), // T
-      new Color(60, 136, 238) // U
+      new Color(60, 136, 238), // U
+      Color.white, // I
+      Color.white, // X
+      Color.white, // R
+      Color.white, // Y
+      Color.white, // N
+      Color.white, // Gap
   };
 
   // Zappo
@@ -490,7 +495,7 @@ public class ResidueProperties
           -8, -8, -8, -8, -8, -8, 1 }, };
 
   public static final Hashtable ssHash = new Hashtable(); // stores the number
-                                                          // value of the aa
+  // value of the aa
 
   static
   {
@@ -505,13 +510,23 @@ public class ResidueProperties
     ssHash.put("B", Color.yellow);
   }
 
+  /*
+   * new Color(60, 136, 238), // U Color.white, // I Color.white, // X
+   * Color.white, // R Color.white, // Y Color.white, // N Color.white, // Gap
+   */
   static final int[][] DNA =
   {
-  { 5, -4, -4, -4, 1 }, // C
-      { -4, 5, -4, -4, 1 }, // T
-      { -4, -4, 5, -4, 1 }, // A
-      { -4, -4, -4, 5, 1 }, // G
-      { 1, 1, 1, 1, 1 }, // -
+  { 10, -8, -8, -8, 1, 0, 0, 0, 0, 0, 1 }, // C
+      { -8, 10, -8, -8, 1, 0, 0, 0, 0, 0, 1 }, // T
+      { -8, -8, 10, -8, 1, 0, 0, 0, 0, 0, 1 }, // A
+      { -8, -8, -8, 10, 1, 0, 0, 0, 0, 0, 1 }, // G
+      { 1, 1, 1, 1, 10, 0, 0, 0, 0, 0, 1 }, // -
+      { 1, 1, 1, 1, 1, 10, 0, 0, 0, 0, 1 }, // -
+      { 1, 1, 1, 1, 1, 0, 10, 0, 0, 0, 1 }, // -
+      { 1, 1, 1, 1, 1, 0, 0, 10, 0, 0, 1 }, // -
+      { 1, 1, 1, 1, 1, 0, 0, 0, 10, 0, 1 }, // -
+      { 1, 1, 1, 1, 1, 0, 0, 0, 0, 10, 1 }, // -
+      { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // -
   };
   /**
    * register matrices in list
@@ -945,7 +960,9 @@ public class ResidueProperties
     charged.put("E", new Integer(1));
     charged.put("Q", new Integer(0));
     charged.put("D", new Integer(1));
-    charged.put("N", new Integer(1));
+    charged.put("N", new Integer(0)); // Asparagine is polar but not charged.
+                                      // Alternative would be charged and
+                                      // negative (in basic form)?
     charged.put("S", new Integer(0));
     charged.put("T", new Integer(0));
     charged.put("P", new Integer(0));
@@ -1140,9 +1157,9 @@ public class ResidueProperties
 
   public static String codonTranslate(String lccodon)
   {
-    String codon=lccodon.toUpperCase();
+    String codon = lccodon.toUpperCase();
     // all base ambiguity codes yield an 'X' amino acid residue
-    if (codon.indexOf('X')>-1 || codon.indexOf('N')>-1)
+    if (codon.indexOf('X') > -1 || codon.indexOf('N') > -1)
     {
       return "X";
     }