From: Jim Procter Date: Mon, 24 Jun 2019 17:36:54 +0000 (+0100) Subject: JAL-3330 dbreffetcher: record any feature display models associated with sources... X-Git-Tag: Release_2_11_0~4^2~1^2~7 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=66340a2a1b9937fc8837c184e4998cbebe0e649d;p=jalview.git JAL-3330 dbreffetcher: record any feature display models associated with sources that provide sequences --- diff --git a/src/jalview/ws/DBRefFetcher.java b/src/jalview/ws/DBRefFetcher.java index ae4207b..47d7bde 100644 --- a/src/jalview/ws/DBRefFetcher.java +++ b/src/jalview/ws/DBRefFetcher.java @@ -21,6 +21,7 @@ package jalview.ws; import jalview.analysis.AlignSeq; +import jalview.api.FeatureSettingsModelI; import jalview.bin.Cache; import jalview.datamodel.AlignmentI; import jalview.datamodel.DBRefEntry; @@ -39,8 +40,10 @@ import jalview.ws.seqfetcher.DbSourceProxy; import java.util.ArrayList; import java.util.Arrays; import java.util.Enumeration; +import java.util.HashMap; import java.util.Hashtable; import java.util.List; +import java.util.Map; import java.util.StringTokenizer; import java.util.Vector; @@ -318,6 +321,9 @@ public class DBRefFetcher implements Runnable Arrays.asList(dataset)); List warningMessages = new ArrayList<>(); + // clear any old feature display settings recorded from past sessions + featureDisplaySettings = null; + int db = 0; while (sdataset.size() > 0 && db < dbSources.length) { @@ -384,7 +390,7 @@ public class DBRefFetcher implements Runnable } if (retrieved != null) { - transferReferences(sdataset, dbsource.getDbSource(), retrieved, + transferReferences(sdataset, dbsource, retrieved, trimDsSeqs, warningMessages); } } @@ -512,7 +518,8 @@ public class DBRefFetcher implements Runnable * @param warningMessages * a list of messages to add to */ - boolean transferReferences(Vector sdataset, String dbSource, + boolean transferReferences(Vector sdataset, + DbSourceProxy dbSourceProxy, AlignmentI retrievedAl, boolean trimDatasetSeqs, List warningMessages) { @@ -522,6 +529,7 @@ public class DBRefFetcher implements Runnable return false; } + String dbSource = dbSourceProxy.getDbName(); boolean modified = false; SequenceI[] retrieved = recoverDbSequences( retrievedAl.getSequencesArray()); @@ -592,6 +600,10 @@ public class DBRefFetcher implements Runnable * seqs.elementAt(jj); if (!sequenceMatches.contains(sequence)) { * sequenceMatches.addElement(sequence); } } } } */ + if (sequenceMatches.size() > 0) + { + addFeatureSettings(dbSourceProxy); + } // sequenceMatches now contains the set of all sequences associated with // the returned db record final String retrievedSeqString = retrievedSeq.getSequenceAsString(); @@ -760,6 +772,33 @@ public class DBRefFetcher implements Runnable return modified; } + Map featureDisplaySettings = null; + + private void addFeatureSettings(DbSourceProxy dbSourceProxy) + { + FeatureSettingsModelI fsettings = dbSourceProxy + .getFeatureColourScheme(); + if (fsettings != null) + { + if (featureDisplaySettings == null) + { + featureDisplaySettings = new HashMap<>(); + } + featureDisplaySettings.put(dbSourceProxy.getDbName(), fsettings); + } + } + + /** + * + * @return any feature settings associated with sources that have provided sequences + */ + public ListgetFeatureSettingsModels() + { + return featureDisplaySettings == null + ? Arrays.asList(new FeatureSettingsModelI[0]) + : Arrays.asList(featureDisplaySettings.values() + .toArray(new FeatureSettingsModelI[1])); + } /** * Adds the message to the list unless it already contains it *