bug fixed if featureEnd is beyond end of sequence
authoramwaterhouse <Andrew Waterhouse>
Fri, 11 Feb 2005 10:39:20 +0000 (10:39 +0000)
committeramwaterhouse <Andrew Waterhouse>
Fri, 11 Feb 2005 10:39:20 +0000 (10:39 +0000)
src/jalview/analysis/SequenceFeatureFetcher.java
src/jalview/gui/FeatureRenderer.java

index e034b3f..6560504 100755 (executable)
@@ -2,6 +2,7 @@ package jalview.analysis;
 \r
 import java.io.*;\r
 import java.util.*;\r
+import javax.swing.*;\r
 import jalview.io.*;\r
 import jalview.gui.*;\r
 import jalview.datamodel.*;\r
@@ -11,6 +12,9 @@ public class SequenceFeatureFetcher implements Runnable
   AlignmentI align;\r
   AlignmentPanel ap;\r
   ArrayList unknownSequences;\r
+  JInternalFrame outputFrame = new JInternalFrame();\r
+  CutAndPasteTransfer output = new CutAndPasteTransfer(false);\r
+  StringBuffer sbuffer = new StringBuffer();\r
 \r
   public SequenceFeatureFetcher(AlignmentI align, AlignmentPanel ap)\r
   {\r
@@ -80,7 +84,6 @@ public class SequenceFeatureFetcher implements Runnable
           remainingIds.append(ids.get(i) + ";");\r
 \r
          EBIFetchClient ebi = new EBIFetchClient();\r
-         System.out.println(remainingIds.toString());\r
          String[] result = ebi.fetchData(remainingIds.toString(), "xml", null);\r
 \r
         if(result!=null)\r
@@ -98,6 +101,16 @@ public class SequenceFeatureFetcher implements Runnable
 \r
   ap.RefreshPanels();\r
   findMissingIds(align);\r
+  if(sbuffer.length()>0)\r
+  {\r
+    output.formatForOutput();\r
+    outputFrame.setContentPane(output);\r
+    output.setText("Your sequences have been matched to Uniprot. Some of the ids have been\n"\r
+                   +"altered, most likely the start/end residue will have been updated.\n"\r
+                   +"Save your alignment to maintain the updated id.\n\n"+sbuffer.toString());\r
+  Desktop.addInternalFrame(outputFrame, "Sequence names updated ", 600,300);\r
+\r
+  }\r
 \r
   if(unknownSequences.size()>0)\r
   {\r
@@ -132,13 +145,13 @@ void ReadUniprotFile(String [] result, RandomAccessFile out, AlignmentI align)
         sequence = align.findName( seqName.substring(0, seqName.indexOf('_')));\r
         if(sequence!=null)\r
         {\r
-          System.out.println("changing "+sequence.getName()+" to "+seqName);\r
+          sbuffer.append("changing "+sequence.getName()+" to "+seqName+"\n");\r
           sequence.setName(seqName);\r
         }\r
       }\r
       if(sequence==null)\r
       {\r
-        System.out.println("UNIPROT updated suggestion is "+result[r]);\r
+        sbuffer.append("UNIPROT updated suggestion is "+result[r]+"\n");\r
         sequence = align.findName( result[r] ) ;\r
 \r
         // this entry has been suggested by ebi.\r
@@ -230,7 +243,7 @@ void ReadUniprotFile(String [] result, RandomAccessFile out, AlignmentI align)
        {\r
          unknownSequences.add(sequence.getName());\r
          features = null;\r
-         System.out.println(sequence.getName()+ "does not match ");\r
+         sbuffer.append(sequence.getName()+ " SEQUENCE NOT %100 MATCH \n");\r
          continue;\r
        }\r
 \r
@@ -238,8 +251,8 @@ void ReadUniprotFile(String [] result, RandomAccessFile out, AlignmentI align)
        absStart+=1;\r
 \r
        if(absStart!=sequence.getStart() || absEnd!=sequence.getEnd())\r
-         System.out.println("Updated: "+sequence.getName()+" "+\r
-                           sequence.getStart()+"/"+sequence.getEnd()+"  to  "+ absStart+"/"+absEnd);\r
+         sbuffer.append("Updated: "+sequence.getName()+" "+\r
+                           sequence.getStart()+"/"+sequence.getEnd()+"  to  "+ absStart+"/"+absEnd+"\n");\r
 \r
 \r
        sequence.setStart(absStart);\r
index 6a0daa8..59f446e 100755 (executable)
@@ -27,6 +27,9 @@ public class FeatureRenderer implements RendererI
     while( e.hasMoreElements() )\r
     {\r
       SequenceFeature sf = (SequenceFeature)e.nextElement();\r
+      if(sf.getStart()>seq.getEnd())\r
+        continue;\r
+\r
       int fstart = seq.findIndex(sf.getStart())-1;\r
       int fend = seq.findIndex(sf.getEnd())-1;\r
 \r