From: tcofoegbu Date: Wed, 18 May 2016 15:48:39 +0000 (+0100) Subject: JAL-1563 smarter support for advanced querying of Uniprot FTS X-Git-Tag: Release_2_10_0~222 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=479c44e27a46c7cbee33e293dbc38cbca4fd2e0b;p=jalview.git JAL-1563 smarter support for advanced querying of Uniprot FTS --- diff --git a/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java b/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java index a4f82cf..dfdf715 100644 --- a/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java +++ b/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java @@ -63,22 +63,20 @@ public class UniProtFTSRestClient extends FTSRestClient : uniportRestRequest.getResponseSize(); int offSet = uniportRestRequest.getOffSet(); + String query; + if (isAdvancedQuery(uniportRestRequest.getSearchTerm())) + { + query = uniportRestRequest.getSearchTerm(); + } + else + { + query = uniportRestRequest.getFieldToSearchBy().equalsIgnoreCase( + "Search All") ? uniportRestRequest.getSearchTerm() + + " or mnemonic:" + uniportRestRequest.getSearchTerm() + : uniportRestRequest.getFieldToSearchBy() + ":" + + uniportRestRequest.getSearchTerm(); + } - String query = uniportRestRequest.getFieldToSearchBy() - .equalsIgnoreCase("Search All") ? uniportRestRequest - .getSearchTerm() - + " or mnemonic:" - + uniportRestRequest - .getSearchTerm() : uniportRestRequest.getFieldToSearchBy() - + ":" + uniportRestRequest.getSearchTerm(); - - // + (uniportRestRequest.isAllowUnpublishedEntries() ? "" - // : " AND status:REL"); - // System.out.println(">>>>> Query : " + query); - // System.out.println(">>>>> Columns : " + wantedFields); - // System.out.println(">>>>> Response size: " + responseSize - // + " offset : " - // + offSet); WebResource webResource = null; webResource = client.resource(UNIPROT_SEARCH_ENDPOINT) .queryParam("format", "tab") @@ -131,6 +129,17 @@ public class UniProtFTSRestClient extends FTSRestClient } } + public boolean isAdvancedQuery(String query) + { + if (query.contains(" AND ") || query.contains(" OR ") + || query.contains(" NOT ") || query.contains(" ! ") + || query.contains(" || ") || query.contains(" && ") + || query.contains(":") || query.contains("-")) + { + return true; + } + return false; + } public FTSRestResponse parseUniprotResponse( String uniProtTabDelimittedResponseString,