From 479c44e27a46c7cbee33e293dbc38cbca4fd2e0b Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Wed, 18 May 2016 16:48:39 +0100 Subject: [PATCH] JAL-1563 smarter support for advanced querying of Uniprot FTS --- .../fts/service/uniprot/UniProtFTSRestClient.java | 39 ++++++++++++-------- 1 file changed, 24 insertions(+), 15 deletions(-) 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, -- 1.7.10.2