for (SequenceI seq : selectedSequences)
{
PDBRestRequest pdbRequest = new PDBRestRequest();
- pdbRequest.setAllowEmptySeq(false);
- pdbRequest.setResponseSize(1);
- pdbRequest.setFieldToSearchBy("(");
- pdbRequest.setFieldToSortBy(fieldToFilterBy,
- !chk_invertFilter.isSelected());
- pdbRequest.setSearchTerm(buildQuery(seq) + ")");
- pdbRequest.setWantedFields(wantedFields);
- pdbRequest.setAssociatedSequence(seq);
+ if (fieldToFilterBy.equalsIgnoreCase("uniprot_coverage"))
+ {
+ System.out.println(">>>>>> Filtering with uniprot coverate");
+ pdbRequest.setAllowEmptySeq(false);
+ pdbRequest.setResponseSize(1);
+ pdbRequest.setFieldToSearchBy("(");
+ pdbRequest.setSearchTerm(buildQuery(seq) + ")");
+ pdbRequest.setWantedFields(wantedFields);
+ pdbRequest.setAssociatedSequence(seq);
+ pdbRequest.setFacet(true);
+ pdbRequest.setFacetPivot(fieldToFilterBy + ",entry_entity");
+ pdbRequest.setFacetPivotMinCount(1);
+ }
+ else
+ {
+ pdbRequest.setAllowEmptySeq(false);
+ pdbRequest.setResponseSize(1);
+ pdbRequest.setFieldToSearchBy("(");
+ pdbRequest.setFieldToSortBy(fieldToFilterBy,
+ !chk_invertFilter.isSelected());
+ pdbRequest.setSearchTerm(buildQuery(seq) + ")");
+ pdbRequest.setWantedFields(wantedFields);
+ pdbRequest.setAssociatedSequence(seq);
+ }
pdbRestCleint = new PDBRestClient();
PDBRestResponse resultList;
try
.getFieldToSortBy().trim().isEmpty()) ? "" : (pdbRestRequest
.getFieldToSortBy() + (pdbRestRequest.isAscending() ? " asc"
: " desc"));
+ String facetPivot = (pdbRestRequest.getFacetPivot() == null || pdbRestRequest
+ .getFacetPivot().isEmpty()) ? "" : pdbRestRequest
+ .getFacetPivot();
+ String facetPivotMinCount = String.valueOf(pdbRestRequest
+ .getFacetPivotMinCount());
+
// Build request parameters for the REST Request
- WebResource webResource = client.resource(PDB_SEARCH_ENDPOINT)
- .queryParam("wt", "json").queryParam("fl", wantedFields)
- .queryParam("rows", String.valueOf(responseSize))
- .queryParam("q", pdbRestRequest.getQuery())
- .queryParam("sort", sortParam);
-
+ WebResource webResource = null;
+ if (pdbRestRequest.isFacet())
+ {
+ webResource = client.resource(PDB_SEARCH_ENDPOINT)
+ .queryParam("wt", "json").queryParam("fl", wantedFields)
+ .queryParam("rows", String.valueOf(responseSize))
+ .queryParam("q", pdbRestRequest.getQuery())
+ .queryParam("sort", sortParam).queryParam("facet", "true")
+ .queryParam("facet.pivot", facetPivot)
+ .queryParam("facet.pivot.mincount", facetPivotMinCount);
+ }
+ else
+ {
+ webResource = client.resource(PDB_SEARCH_ENDPOINT)
+ .queryParam("wt", "json").queryParam("fl", wantedFields)
+ .queryParam("rows", String.valueOf(responseSize))
+ .queryParam("q", pdbRestRequest.getQuery())
+ .queryParam("sort", sortParam);
+ }
// Execute the REST request
ClientResponse clientResponse = webResource.accept(
MediaType.APPLICATION_JSON).get(ClientResponse.class);
// Get the JSON string from the response object
String responseString = clientResponse.getEntity(String.class);
+ System.out.println("query >>>>>>> " + pdbRestRequest.toString());
// Check the response status and report exception if one occurs
if (clientResponse.getStatus() != 200)
return code;
}
+ @Override
public String toString()
{
return name;
private boolean allowUnpublishedEntries = Cache.getDefault(
"ALLOW_UNPUBLISHED_PDB_QUERYING", false);
+ private boolean facet;
+
+ private String facetPivot;
+
+ private int facetPivotMinCount;
+
private int responseSize;
private boolean isSortAscending;
+ (isAllowUnpublishedEntries() ? "" : " AND status:REL");
}
+ @Override
public String toString()
{
return "Query : " + getQuery() + " sort field: " + fieldToSortBy
{
this.allowUnpublishedEntries = allowUnpublishedEntries;
}
+
+ public boolean isFacet()
+ {
+ return facet;
+ }
+
+ public void setFacet(boolean facet)
+ {
+ this.facet = facet;
+ }
+
+ public String getFacetPivot()
+ {
+ return facetPivot;
+ }
+
+ public void setFacetPivot(String facetPivot)
+ {
+ this.facetPivot = facetPivot;
+ }
+
+ public int getFacetPivotMinCount()
+ {
+ return facetPivotMinCount;
+ }
+
+ public void setFacetPivotMinCount(int facetPivotMinCount)
+ {
+ this.facetPivotMinCount = facetPivotMinCount;
+ }
}