Correct label for end res in copy
authoramwaterhouse <Andrew Waterhouse>
Fri, 29 Jul 2005 09:39:20 +0000 (09:39 +0000)
committeramwaterhouse <Andrew Waterhouse>
Fri, 29 Jul 2005 09:39:20 +0000 (09:39 +0000)
src/jalview/appletgui/AlignFrame.java
src/jalview/gui/AlignFrame.java

index caa0321..476dbbd 100755 (executable)
@@ -80,6 +80,14 @@ public class AlignFrame
       }\r
     }\r
 \r
+\r
+      if( applet.getParameter("servletAllowed") !=null)\r
+     {\r
+       ServletGUI plug = new ServletGUI(this, fileMenu, calculateMenu);\r
+     }\r
+\r
+\r
+\r
   }\r
 \r
   public void inputText_actionPerformed(ActionEvent e)\r
@@ -278,30 +286,55 @@ public class AlignFrame
       orderedSeqs.put(index + "", seq);\r
     }\r
 \r
-    int index = 0;\r
+    int index = 0, startRes, endRes;\r
+    char ch;\r
+\r
     for (int i = 0; i < sg.getSize(); i++)\r
     {\r
-      SequenceI seq = null;\r
-      while (seq == null)\r
-      {\r
-        if (orderedSeqs.containsKey(index + ""))\r
+        SequenceI seq = null;\r
+\r
+        while (seq == null)\r
         {\r
-          seq = (SequenceI) orderedSeqs.get(index + "");\r
-          index++;\r
-          break;\r
+            if (orderedSeqs.containsKey(index + ""))\r
+            {\r
+                seq = (SequenceI) orderedSeqs.get(index + "");\r
+                index++;\r
+\r
+                break;\r
+            }\r
+            else\r
+            {\r
+                index++;\r
+            }\r
         }\r
-        else\r
+\r
+        //FIND START RES\r
+        //Returns residue following index if gap\r
+        startRes = seq.findPosition(sg.getStartRes());\r
+\r
+        //FIND END RES\r
+        //Need to find the residue preceeding index if gap\r
+        endRes = 0;\r
+\r
+        for (int j = 0; j < sg.getEndRes()+1 && j < seq.getLength(); j++)\r
+        {\r
+          ch = seq.getCharAt(j);\r
+          if (!jalview.util.Comparison.isGap( (ch)))\r
+          {\r
+            endRes++;\r
+          }\r
+        }\r
+\r
+        if(endRes>0)\r
         {\r
-          index++;\r
+          endRes += seq.getStart() -1;\r
         }\r
-      }\r
 \r
-      copiedSequences.append(seq.getName() + "\t" +\r
-                             seq.findPosition(sg.getStartRes()) + "\t"\r
-                             + seq.findPosition(sg.getEndRes()) + "\t"\r
-                             +\r
-                             seq.getSequence(sg.getStartRes(),\r
-          sg.getEndRes() + 1) + "\n");\r
+        copiedSequences.append(seq.getName() + "\t" +\r
+            startRes + "\t" +\r
+            endRes + "\t" +\r
+            seq.getSequence(sg.getStartRes(),\r
+                sg.getEndRes() + 1) + "\n");\r
     }\r
 \r
   }\r
@@ -1068,7 +1101,21 @@ public class AlignFrame
     //are the sequences aligned?\r
     if (!viewport.alignment.isAligned())\r
     {\r
-      return;\r
+      SequenceI current;\r
+      int Width = viewport.getAlignment().getWidth();\r
+\r
+      for (int i = 0; i < viewport.getAlignment().getSequences().size();\r
+           i++)\r
+      {\r
+        current = viewport.getAlignment().getSequenceAt(i);\r
+\r
+        if (current.getLength() < Width)\r
+        {\r
+          current.insertCharAt(Width - 1, viewport.getGapCharacter());\r
+        }\r
+      }\r
+      alignPanel.repaint();\r
+\r
     }\r
 \r
     final TreePanel tp;\r
index 3ea7ed0..727e1c6 100755 (executable)
@@ -521,7 +521,8 @@ public class AlignFrame extends GAlignFrame
             orderedSeqs.put(index + "", seq);\r
         }\r
 \r
-        int index = 0;\r
+        int index = 0, startRes, endRes;\r
+        char ch;\r
 \r
         for (int i = 0; i < sg.getSize(); i++)\r
         {\r
@@ -542,9 +543,31 @@ public class AlignFrame extends GAlignFrame
                 }\r
             }\r
 \r
+            //FIND START RES\r
+            //Returns residue following index if gap\r
+            startRes = seq.findPosition(sg.getStartRes());\r
+\r
+            //FIND END RES\r
+            //Need to find the residue preceeding index if gap\r
+            endRes = 0;\r
+\r
+            for (int j = 0; j < sg.getEndRes()+1 && j < seq.getLength(); j++)\r
+            {\r
+              ch = seq.getCharAt(j);\r
+              if (!jalview.util.Comparison.isGap( (ch)))\r
+              {\r
+                endRes++;\r
+              }\r
+            }\r
+\r
+            if(endRes>0)\r
+            {\r
+              endRes += seq.getStart() -1;\r
+            }\r
+\r
             buffer.append(seq.getName() + "\t" +\r
-                seq.findPosition(sg.getStartRes()) + "\t" +\r
-                seq.findPosition(sg.getEndRes()) + "\t" +\r
+                startRes + "\t" +\r
+                endRes + "\t" +\r
                 seq.getSequence(sg.getStartRes(),\r
                     sg.getEndRes() + 1) + "\n");\r
         }\r
@@ -762,7 +785,7 @@ public class AlignFrame extends GAlignFrame
             sg.addSequence(viewport.getAlignment().getSequenceAt(i), false);\r
         }\r
 \r
-        sg.setEndRes(viewport.alignment.getWidth());\r
+        sg.setEndRes(viewport.alignment.getWidth()-1);\r
         viewport.setSelectionGroup(sg);\r
         PaintRefresher.Refresh(null, viewport.alignment);\r
     }\r