JAL-1062 use matching region or first section of sequence source regex to select...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Sun, 2 Sep 2012 13:28:28 +0000 (14:28 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Sun, 2 Sep 2012 13:28:28 +0000 (14:28 +0100)
src/jalview/gui/SequenceFetcher.java
src/jalview/ws/dbsources/das/datamodel/DasSequenceSource.java
src/jalview/ws/seqfetcher/DbSourceProxy.java

index 9c51409..bf522ef 100755 (executable)
@@ -25,6 +25,9 @@ import java.awt.event.*;
 
 import javax.swing.*;
 import javax.swing.tree.DefaultMutableTreeNode;
+
+import com.stevesoft.pat.Regex;
+
 import jalview.datamodel.*;
 import jalview.io.*;
 import jalview.util.DBRefUtils;
@@ -569,6 +572,18 @@ public class SequenceFetcher extends JPanel implements Runnable
               {
                 DBRefEntry dbr = new DBRefEntry(), found[] = null;
                 dbr.setSource(proxy.getDbSource());
+                dbr.setVersion(null);
+                if (proxy.getAccessionValidator()!=null) {
+                  Regex vgr=proxy.getAccessionValidator();
+                  vgr.search(q);
+                  if (vgr.numSubs()>0) {
+                    dbr.setAccessionId(vgr.stringMatched(1));
+                  } else {
+                    dbr.setAccessionId(vgr.stringMatched());
+                  }
+                } else {
+                  dbr.setAccessionId(q);
+                }
                 boolean rfound = false;
                 for (int r = 0; r < rs.length; r++)
                 {
index a63727f..ebe0134 100644 (file)
@@ -108,7 +108,7 @@ public class DasSequenceSource extends DbSourceProxyImpl implements
   public Regex getAccessionValidator()\r
   {\r
     /** ? * */\r
-    return Regex.perlCode("\\S+");\r
+    return Regex.perlCode("m/([^:]+)(:\\d+,\\d+)?/");\r
   }\r
 \r
   public String getDbName()\r
index 4b9c472..3dacb12 100644 (file)
@@ -67,7 +67,9 @@ public interface DbSourceProxy
 \r
   /**\r
    * Regular expression for checking form of query string understood by this\r
-   * source.\r
+   * source. If the Regex includes parenthesis, then the first parenthesis\r
+   * should yield the same accession string as the one used to annotate the\r
+   * sequence. This is used to match query strings to returned sequences.\r
    * \r
    * @return null or a validation regex\r
    */\r