From: gmungoc Date: Thu, 28 Sep 2017 13:25:12 +0000 (+0100) Subject: JAL-2738 separate thread to load VCF; update FeatureSettings when done X-Git-Tag: Release_2_11_0~220 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=44b1e9ba73a6d6a321126e153aece11699eb1d2a;p=jalview.git JAL-2738 separate thread to load VCF; update FeatureSettings when done --- diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 5620386..9ffe2ae 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -492,6 +492,8 @@ label.load_associated_tree = Load Associated Tree... label.load_features_annotations = Load Features/Annotations... label.load_vcf = Load SNP variants from plain text or indexed VCF data label.load_vcf_file = Load VCF File +label.searching_vcf = Loading VCF variants... +label.added_vcf = Added {0} VCF variants to {1} sequence(s) label.export_features = Export Features... label.export_annotations = Export Annotations... label.to_upper_case = To Upper Case @@ -1321,4 +1323,4 @@ label.select_hidden_colour = Select hidden colour label.overview = Overview label.reset_to_defaults = Reset to defaults label.oview_calc = Recalculating overview... -label.feature_details = Feature details \ No newline at end of file +label.feature_details = Feature details diff --git a/src/jalview/io/vcf/VCFLoader.java b/src/jalview/io/vcf/VCFLoader.java index 78d2ad5..ddcecfe 100644 --- a/src/jalview/io/vcf/VCFLoader.java +++ b/src/jalview/io/vcf/VCFLoader.java @@ -21,6 +21,7 @@ import jalview.io.gff.Gff3Helper; import jalview.io.gff.SequenceOntologyI; import jalview.util.MapList; import jalview.util.MappingUtils; +import jalview.util.MessageManager; import java.io.IOException; import java.util.HashMap; @@ -66,19 +67,44 @@ public class VCFLoader } /** - * Loads VCF on to an alignment - provided it can be related to one or more - * sequence's chromosomal coordinates. + * Starts a new thread to query and load VCF variant data on to the alignment *

* This method is not thread safe - concurrent threads should use separate * instances of this class. * * @param filePath - * @param status + * @param gui */ - public void loadVCF(String filePath, AlignViewControllerGuiI status) + public void loadVCF(final String filePath, + final AlignViewControllerGuiI gui) { - VCFReader reader = null; + if (gui != null) + { + gui.setStatus(MessageManager.getString("label.searching_vcf")); + } + + new Thread() + { + + @Override + public void run() + { + VCFLoader.this.doLoad(filePath, gui); + } + + }.start(); + } + /** + * Loads VCF on to an alignment - provided it can be related to one or more + * sequence's chromosomal coordinates. + * + * @param filePath + * @param gui + */ + protected void doLoad(String filePath, AlignViewControllerGuiI gui) + { + VCFReader reader = null; try { // long start = System.currentTimeMillis(); @@ -108,17 +134,22 @@ public class VCFLoader transferAddedFeatures(seq); } } - // long elapsed = System.currentTimeMillis() - start; - String msg = String.format("Added %d VCF variants to %d sequence(s)", - varCount, seqCount); - if (status != null) + if (gui != null) { - status.setStatus(msg); + // long elapsed = System.currentTimeMillis() - start; + String msg = MessageManager.formatMessage("label.added_vcf", + varCount, seqCount); + gui.setStatus(msg); + gui.getFeatureSettingsUI().discoverAllFeatureData(); } } catch (Throwable e) { System.err.println("Error processing VCF: " + e.getMessage()); e.printStackTrace(); + if (gui != null) + { + gui.setStatus("Error occurred - see console for details"); + } } finally { if (reader != null)