Correct mapping for pdb file
authoramwaterhouse <Andrew Waterhouse>
Fri, 25 Nov 2005 16:08:06 +0000 (16:08 +0000)
committeramwaterhouse <Andrew Waterhouse>
Fri, 25 Nov 2005 16:08:06 +0000 (16:08 +0000)
src/jalview/analysis/AlignSeq.java

index 1b7351b..3f3bab1 100755 (executable)
@@ -406,31 +406,43 @@ public class AlignSeq
     public int [] getExactMapping()\r
     {\r
         // Print out the matching chars\r
-        int [] mapping = new int[astr1.length()];\r
-        int agap=0, bgap=0;\r
-        boolean gap;\r
+        int size = s2.getLength();\r
+        int [] mapping = new int[size];\r
+        for(int i=0; i<size; i++)\r
+          mapping[i] = -1;\r
+\r
+        int pdbpos = seq2start-2;\r
+        int alignpos = seq1start-2;\r
+\r
+\r
         for(int i=0; i<astr1.length(); i++)\r
         {\r
-          mapping[i] = -1;\r
-          gap = false;\r
-\r
-          if(astr1.charAt(i)=='-')\r
-          {\r
-            agap++;gap = true;\r
-          }\r
-          if(astr2.charAt(i)=='-')\r
-          {\r
-            bgap++;gap = true;\r
-          }\r
-\r
-          if(!gap && astr1.charAt(i)==astr2.charAt(i))\r
-          {\r
-            mapping[i-agap] = i - bgap;\r
-          }\r
-\r
-          System.out.println(astr1.charAt(i)+" "+i + " "+mapping[i-agap]+" "+astr2.charAt(i));\r
+            if (astr1.charAt(i) != '-')\r
+            {\r
+              alignpos++;\r
+            }\r
+\r
+            if (astr2.charAt(i) != '-')\r
+            {\r
+              pdbpos++;\r
+            }\r
+\r
+            if (astr1.charAt(i) == astr2.charAt(i))\r
+            {\r
+              mapping[pdbpos] = alignpos;\r
+            }\r
         }\r
 \r
+       /* for(int i=0; i<mapping.length; i++)\r
+        {\r
+          if(mapping[i]!=-1)\r
+            System.out.println(i+" "+s2.getCharAt(i) + " " + mapping[i] + " " +\r
+                               s1.findIndex(mapping[i])+" "+\r
+                               s1.getCharAt(s1.findIndex(mapping[i])-1));\r
+          else\r
+            System.out.println(i+" "+"XX"+s2.getCharAt(i));\r
+        }*/\r
+\r
         return mapping;\r
     }\r
 \r