X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2Fstructurechooser%2FStructureChooserQuerySource.java;h=a4cf4ab877dc7c3f3c0c22723d11d57cf32aa58f;hb=57738a1f3c19b1c3a00bd3ac5108f8cd0af32f99;hp=b5646db46ad46ceefb8aab178cf2051b0845bebc;hpb=896b63f7908297dfe7a48e198d7bce847e2804b8;p=jalview.git diff --git a/src/jalview/gui/structurechooser/StructureChooserQuerySource.java b/src/jalview/gui/structurechooser/StructureChooserQuerySource.java index b5646db..a4cf4ab 100644 --- a/src/jalview/gui/structurechooser/StructureChooserQuerySource.java +++ b/src/jalview/gui/structurechooser/StructureChooserQuerySource.java @@ -1,5 +1,7 @@ package jalview.gui.structurechooser; +import java.util.Locale; + import java.util.Collection; import java.util.List; import java.util.Objects; @@ -42,7 +44,7 @@ public abstract class StructureChooserQuerySource public static StructureChooserQuerySource getPDBfts() { - return new PDBStructureChooserQuerySource(); + return new PDBStructureChooserQuerySource(); } public static StructureChooserQuerySource getTDBfts() @@ -65,7 +67,6 @@ public abstract class StructureChooserQuerySource return docFieldPrefs; } - /** * Builds a query string for a given sequences using its DBRef entries * @@ -75,7 +76,6 @@ public abstract class StructureChooserQuerySource */ public abstract String buildQuery(SequenceI seq); - /** * Remove the following special characters from input string +, -, &, !, (, ), @@ -110,7 +110,7 @@ public abstract class StructureChooserQuerySource { return false; } - seqName = seqName.toLowerCase(); + seqName = seqName.toLowerCase(Locale.ROOT); for (String ignoredEntry : ignoreList.split(",")) { if (seqName.contains(ignoredEntry)) @@ -167,7 +167,8 @@ public abstract class StructureChooserQuerySource * * @param seq * - seq to generate a query for - * @param discoveredStructuresSet - existing set of entries - allows client side selection + * @param discoveredStructuresSet + * - existing set of entries - allows client side selection * @param wantedFields * - fields to retrieve * @param selectedFilterOpt @@ -178,7 +179,8 @@ public abstract class StructureChooserQuerySource * @throws Exception */ public abstract FTSRestResponse selectFirstRankedQuery(SequenceI seq, - Collection discoveredStructuresSet, Collection wantedFields, String fieldToFilterBy, + Collection discoveredStructuresSet, + Collection wantedFields, String fieldToFilterBy, boolean b) throws Exception; /** @@ -200,15 +202,17 @@ public abstract class StructureChooserQuerySource /** * @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 + * - 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); + 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 */ @@ -216,22 +220,44 @@ public abstract class StructureChooserQuerySource SequenceI[] selectedSeqs) { ThreeDBStructureChooserQuerySource tdbSource = new ThreeDBStructureChooserQuerySource(); - boolean hasUniprot=false; - boolean hasNA=false,hasProtein=false; - for (SequenceI seq:selectedSeqs) + boolean hasUniprot = false, hasCanonical = false; + boolean hasNA = false, hasProtein = false; + int protWithoutUni = 0; + int protWithoutCanon = 0; + for (SequenceI seq : selectedSeqs) { - hasNA|=!seq.isProtein(); + hasNA |= !seq.isProtein(); hasProtein |= seq.isProtein(); if (seq.isProtein()) { - String query = tdbSource.buildQuery(seq); - if (query!=null && query.length()>0) + int refsAvailable = ThreeDBStructureChooserQuerySource + .checkUniprotRefs(seq.getDBRefs()); + if (refsAvailable > -2) + { + if (refsAvailable > -1) + { + hasCanonical = true; + } + else + { + protWithoutCanon++; + } + hasUniprot = true; + } + else { - hasUniprot=true; + protWithoutUni++; + } } } - if (hasProtein && hasUniprot && !hasNA) + // + // 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; } @@ -239,17 +265,17 @@ public abstract class StructureChooserQuerySource } /** - * some filter options may mean the original query needs to be executed again. + * 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 + + } +} \ No newline at end of file