X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2Fstructurechooser%2FThreeDBStructureChooserQuerySource.java;h=9e4ee21ec8915b7f730baebe36be6a8912c80a3f;hb=d654b1f014790b7ae25e6eec631847170a930987;hp=9b6d8e872393a3e2d83c9a294c73e194bf403462;hpb=9018c06add8548b4921a4c21f21a1b85a0bea1de;p=jalview.git
diff --git a/src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java b/src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java
index 9b6d8e8..9e4ee21 100644
--- a/src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java
+++ b/src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java
@@ -1,3 +1,23 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.gui.structurechooser;
import java.util.ArrayList;
@@ -12,6 +32,7 @@ import java.util.Set;
import javax.swing.JTable;
+import jalview.bin.Console;
import jalview.datamodel.DBRefEntry;
import jalview.datamodel.DBRefSource;
import jalview.datamodel.PDBEntry;
@@ -23,6 +44,7 @@ import jalview.fts.core.FTSDataColumnPreferences;
import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
import jalview.fts.core.FTSRestRequest;
import jalview.fts.core.FTSRestResponse;
+import jalview.fts.service.threedbeacons.TDB_FTSData;
import jalview.fts.service.threedbeacons.TDBeaconsFTSRestClient;
import jalview.jbgui.FilterOption;
@@ -43,8 +65,6 @@ public class ThreeDBStructureChooserQuerySource
private static final String FILTER_SOURCE_PREFIX = "only_";
- private static int MAX_QLENGTH = 7820;
-
protected FTSRestRequest lastTdbRequest;
protected FTSRestClientI tdbRestClient;
@@ -74,19 +94,9 @@ public class ThreeDBStructureChooserQuerySource
public String buildQuery(SequenceI seq)
{
- boolean isPDBRefsFound = false;
- boolean isUniProtRefsFound = false;
- StringBuilder queryBuilder = new StringBuilder();
- Set seqRefs = new LinkedHashSet<>();
-
- /*
- * note PDBs as DBRefEntry so they are not duplicated in query
- */
- Set pdbids = new HashSet<>();
-
List refs = seq.getDBRefs();
int ib = checkUniprotRefs(refs);
- if (ib>-1)
+ if (ib > -1)
{
return getDBRefId(refs.get(ib));
}
@@ -95,8 +105,10 @@ public class ThreeDBStructureChooserQuerySource
/**
* Searches DBRefEntry for uniprot refs
+ *
* @param seq
- * @return -2 if no uniprot refs, -1 if no canonical ref., otherwise index of Uniprot canonical DBRefEntry
+ * @return -2 if no uniprot refs, -1 if no canonical ref., otherwise index of
+ * Uniprot canonical DBRefEntry
*/
public static int checkUniprotRefs(List refs)
{
@@ -128,7 +140,6 @@ public class ThreeDBStructureChooserQuerySource
*/
static boolean isValidSeqName(String seqName)
{
- // System.out.println("seqName : " + seqName);
String ignoreList = "pdb,uniprot,swiss-prot";
if (seqName.length() < 3)
{
@@ -138,7 +149,7 @@ public class ThreeDBStructureChooserQuerySource
{
return false;
}
- seqName = seqName.toLowerCase();
+ seqName = seqName.toLowerCase(Locale.ROOT);
for (String ignoredEntry : ignoreList.split(","))
{
if (seqName.contains(ignoredEntry))
@@ -180,13 +191,14 @@ public class ThreeDBStructureChooserQuerySource
{
FTSRestRequest tdbRequest = getTDBeaconsRequest(seq, wantedFields);
resultList = tdbRestClient.executeRequest(tdbRequest);
-
+
lastTdbRequest = tdbRequest;
- if (resultList!=null)
+ if (resultList != null)
{ // Query the PDB and add additional metadata
FTSRestResponse pdbResponse = fetchStructuresMetaDataFor(
getPDBQuerySource(), resultList);
- FTSRestResponse joinedResp = joinResponses(resultList, pdbResponse);
+
+ resultList = joinResponses(resultList, pdbResponse);
}
return resultList;
}
@@ -249,11 +261,12 @@ public class ThreeDBStructureChooserQuerySource
{
if (tdbEntries != null && lastTdbRequest != null)
{
- int prov_idx = lastTdbRequest.getFieldIndex("Provider");
- boolean hasPDBe=false;
- for (FTSData row : tdbEntries)
+ boolean hasPDBe = false;
+ for (FTSData _row : tdbEntries)
{
- String provider = (String) row.getSummaryData()[prov_idx];
+ // tdb returns custom object
+ TDB_FTSData row = (TDB_FTSData) _row;
+ String provider = (String) row.getProvider();
FilterOption providerOpt = new FilterOption(
"3DB Provider - " + provider,
FILTER_SOURCE_PREFIX + provider, VIEWS_FILTER, false, this);
@@ -263,21 +276,24 @@ public class ThreeDBStructureChooserQuerySource
tdBeaconsFilters.add(FILTER_SOURCE_PREFIX + provider);
if ("PDBe".equalsIgnoreCase(provider))
{
- hasPDBe=true;
+ hasPDBe = true;
}
}
}
if (!hasPDBe)
{
// remove the PDBe options from the available filters
- int op=0;
- while (op pdbIds = new ArrayList();
+ Set pdbIds = new HashSet();
int idx_modelId = getLastFTSRequest().getFieldIndex("Model id");
int idx_provider = getLastFTSRequest().getFieldIndex("Provider");
for (FTSData row : upResponse.getSearchSummary())
@@ -513,7 +535,6 @@ public class ThreeDBStructureChooserQuerySource
: -1;
int tdbTitle_idx = getLastFTSRequest().getFieldIndex("Title");
- List joinedRows = new ArrayList();
for (final FTSData row : upResponse.getSearchSummary())
{
String id = (String) row.getSummaryData()[idx_modelId];
@@ -547,4 +568,22 @@ public class ThreeDBStructureChooserQuerySource
return upResponse;
}
+ public TDB_FTSData getFTSDataFor(JTable restable, int selectedRow,
+ Collection discoveredStructuresSet)
+ {
+ int idColumnIndex = restable.getColumn("Model id").getModelIndex();
+
+ String modelId = (String) restable.getValueAt(selectedRow,
+ idColumnIndex);
+ for (FTSData row : discoveredStructuresSet)
+ {
+ if (row instanceof TDB_FTSData
+ && ((TDB_FTSData) row).getModelId().equals(modelId))
+ {
+ return ((TDB_FTSData) row);
+ }
+ }
+ return null;
+ }
+
}
\ No newline at end of file