X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2Fstructurechooser%2FStructureChooserQuerySource.java;h=cdf0d57405ae6d90aebdb55a09a850b1ad6af35a;hb=d654b1f014790b7ae25e6eec631847170a930987;hp=9861b1a5f3abfa7f5f4d37cd49aa1de019749f27;hpb=55ea4d59b2f4ce51f8310047dd1f8898697dde0c;p=jalview.git
diff --git a/src/jalview/gui/structurechooser/StructureChooserQuerySource.java b/src/jalview/gui/structurechooser/StructureChooserQuerySource.java
index 9861b1a..cdf0d57 100644
--- a/src/jalview/gui/structurechooser/StructureChooserQuerySource.java
+++ b/src/jalview/gui/structurechooser/StructureChooserQuerySource.java
@@ -1,29 +1,45 @@
+/*
+ * 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.Locale;
+
import java.util.Collection;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Objects;
-import java.util.Set;
import java.util.Vector;
import javax.swing.JTable;
import javax.swing.table.TableModel;
import jalview.datamodel.DBRefEntry;
-import jalview.datamodel.DBRefSource;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
import jalview.fts.api.FTSData;
import jalview.fts.api.FTSDataColumnI;
import jalview.fts.api.FTSRestClientI;
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.pdb.PDBFTSRestClient;
-import jalview.jbgui.GStructureChooser.FilterOption;
+import jalview.jbgui.FilterOption;
/**
* logic for querying sources of structural data for structures of sequences
@@ -34,9 +50,6 @@ import jalview.jbgui.GStructureChooser.FilterOption;
*/
public abstract class StructureChooserQuerySource
{
- protected FTSRestRequest lastPdbRequest;
-
- protected FTSRestClientI pdbRestClient;
protected FTSDataColumnPreferences docFieldPrefs;
@@ -51,7 +64,7 @@ public abstract class StructureChooserQuerySource
public static StructureChooserQuerySource getPDBfts()
{
- return new PDBStructureChooserQuerySource();
+ return new PDBStructureChooserQuerySource();
}
public static StructureChooserQuerySource getTDBfts()
@@ -74,7 +87,6 @@ public abstract class StructureChooserQuerySource
return docFieldPrefs;
}
-
/**
* Builds a query string for a given sequences using its DBRef entries
*
@@ -84,7 +96,6 @@ public abstract class StructureChooserQuerySource
*/
public abstract String buildQuery(SequenceI seq);
-
/**
* Remove the following special characters from input string +, -, &, !, (, ),
@@ -119,7 +130,7 @@ public abstract class StructureChooserQuerySource
{
return false;
}
- seqName = seqName.toLowerCase();
+ seqName = seqName.toLowerCase(Locale.ROOT);
for (String ignoredEntry : ignoreList.split(","))
{
if (seqName.contains(ignoredEntry))
@@ -176,6 +187,8 @@ public abstract class StructureChooserQuerySource
*
* @param seq
* - seq to generate a query for
+ * @param discoveredStructuresSet
+ * - existing set of entries - allows client side selection
* @param wantedFields
* - fields to retrieve
* @param selectedFilterOpt
@@ -186,6 +199,7 @@ public abstract class StructureChooserQuerySource
* @throws Exception
*/
public abstract FTSRestResponse selectFirstRankedQuery(SequenceI seq,
+ Collection discoveredStructuresSet,
Collection wantedFields, String fieldToFilterBy,
boolean b) throws Exception;
@@ -197,11 +211,91 @@ public abstract class StructureChooserQuerySource
public TableModel getTableModel(
Collection discoveredStructuresSet)
{
- return FTSRestResponse.getTableModel(lastPdbRequest,
+ return FTSRestResponse.getTableModel(getLastFTSRequest(),
discoveredStructuresSet);
}
+ protected abstract FTSRestRequest getLastFTSRequest();
+
public abstract PDBEntry[] collectSelectedRows(JTable restable,
int[] selectedRows, List selectedSeqsToView);
+ /**
+ * @param VIEWS_FILTER
+ * - a String key that can be used by the caller to tag the returned
+ * filter options to distinguish them in a collection
+ * @return list of FilterOption - convention is that the last one in the list
+ * will be constructed with 'addSeparator==true'
+ */
+ public abstract List getAvailableFilterOptions(
+ String VIEWS_FILTER);
+
+ /**
+ * construct a structure chooser query source for the given set of sequences
+ *
+ * @param selectedSeqs
+ * @return PDBe or 3DB query source
+ */
+ public static StructureChooserQuerySource getQuerySourceFor(
+ SequenceI[] selectedSeqs)
+ {
+ ThreeDBStructureChooserQuerySource tdbSource = new ThreeDBStructureChooserQuerySource();
+ boolean hasUniprot = false, hasCanonical = false;
+ boolean hasNA = false, hasProtein = false;
+ int protWithoutUni = 0;
+ int protWithoutCanon = 0;
+ for (SequenceI seq : selectedSeqs)
+ {
+ hasNA |= !seq.isProtein();
+ hasProtein |= seq.isProtein();
+ if (seq.isProtein())
+ {
+ int refsAvailable = ThreeDBStructureChooserQuerySource
+ .checkUniprotRefs(seq.getDBRefs());
+ if (refsAvailable > -2)
+ {
+ if (refsAvailable > -1)
+ {
+ hasCanonical = true;
+ }
+ else
+ {
+ protWithoutCanon++;
+ }
+ hasUniprot = true;
+ }
+ else
+ {
+ protWithoutUni++;
+
+ }
+ }
+ }
+ //
+ // logic: all canonicals - no fetchdb
+ // some uniprot no canonicals: defer to PDB, user can optionally fetch
+ //
+ if (hasProtein && hasCanonical && !hasNA && protWithoutCanon == 0
+ && protWithoutUni == 0)
+
+ {
+ return tdbSource;
+ }
+ return new PDBStructureChooserQuerySource();
+ }
+
+ /**
+ * some filter options may mean the original query needs to be executed again.
+ *
+ * @param selectedFilterOpt
+ * @return true if the fetchStructuresMetadata method needs to be called again
+ */
+ public abstract boolean needsRefetch(FilterOption selectedFilterOpt);
+
+ public void updateAvailableFilterOptions(String VIEWS_FILTER,
+ List xtantOptions, Collection lastFTSData)
+ {
+ // TODO Auto-generated method stub
+
+ }
}
\ No newline at end of file