From: jprocter Date: Sun, 2 Sep 2012 13:28:28 +0000 (+0100) Subject: JAL-1062 use matching region or first section of sequence source regex to select... X-Git-Tag: Jalview_2_9~359 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=02b7dff05a9e2b9ce6a95caed86be256da906d3f;p=jalview.git JAL-1062 use matching region or first section of sequence source regex to select accession ID from query that includes range specification --- diff --git a/src/jalview/gui/SequenceFetcher.java b/src/jalview/gui/SequenceFetcher.java index 9c51409..bf522ef 100755 --- a/src/jalview/gui/SequenceFetcher.java +++ b/src/jalview/gui/SequenceFetcher.java @@ -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++) { diff --git a/src/jalview/ws/dbsources/das/datamodel/DasSequenceSource.java b/src/jalview/ws/dbsources/das/datamodel/DasSequenceSource.java index a63727f..ebe0134 100644 --- a/src/jalview/ws/dbsources/das/datamodel/DasSequenceSource.java +++ b/src/jalview/ws/dbsources/das/datamodel/DasSequenceSource.java @@ -108,7 +108,7 @@ public class DasSequenceSource extends DbSourceProxyImpl implements public Regex getAccessionValidator() { /** ? * */ - return Regex.perlCode("\\S+"); + return Regex.perlCode("m/([^:]+)(:\\d+,\\d+)?/"); } public String getDbName() diff --git a/src/jalview/ws/seqfetcher/DbSourceProxy.java b/src/jalview/ws/seqfetcher/DbSourceProxy.java index 4b9c472..3dacb12 100644 --- a/src/jalview/ws/seqfetcher/DbSourceProxy.java +++ b/src/jalview/ws/seqfetcher/DbSourceProxy.java @@ -67,7 +67,9 @@ public interface DbSourceProxy /** * Regular expression for checking form of query string understood by this - * source. + * source. If the Regex includes parenthesis, then the first parenthesis + * should yield the same accession string as the one used to annotate the + * sequence. This is used to match query strings to returned sequences. * * @return null or a validation regex */