2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.ext.so.SequenceOntology;
24 import jalview.gui.AlignFrame;
25 import jalview.gui.Desktop;
26 import jalview.gui.PromptUserConfig;
27 import jalview.io.AppletFormatAdapter;
28 import jalview.io.BioJsHTMLOutput;
29 import jalview.io.DataSourceType;
30 import jalview.io.FileFormat;
31 import jalview.io.FileFormatException;
32 import jalview.io.FileFormatI;
33 import jalview.io.FileLoader;
34 import jalview.io.HtmlSvgOutput;
35 import jalview.io.IdentifyFile;
36 import jalview.io.NewickFile;
37 import jalview.io.gff.SequenceOntologyFactory;
38 import jalview.schemes.ColourSchemeI;
39 import jalview.schemes.ColourSchemeProperty;
40 import jalview.util.MessageManager;
41 import jalview.util.Platform;
42 import jalview.ws.jws2.Jws2Discoverer;
44 import java.io.BufferedReader;
46 import java.io.FileOutputStream;
47 import java.io.IOException;
48 import java.io.InputStreamReader;
49 import java.io.OutputStreamWriter;
50 import java.io.PrintWriter;
51 import java.net.MalformedURLException;
53 import java.net.URISyntaxException;
55 import java.security.AllPermission;
56 import java.security.CodeSource;
57 import java.security.PermissionCollection;
58 import java.security.Permissions;
59 import java.security.Policy;
60 import java.util.HashMap;
62 import java.util.Vector;
64 import javax.swing.LookAndFeel;
65 import javax.swing.UIManager;
67 import groovy.lang.Binding;
68 import groovy.util.GroovyScriptEngine;
71 * Main class for Jalview Application <br>
73 * start with java -Djava.ext.dirs=$PATH_TO_LIB$ jalview.bin.Jalview
81 * singleton instance of this class
83 private static Jalview instance;
85 private Desktop desktop;
87 public static AlignFrame currentAlignFrame;
91 // grab all the rights we can the JVM
92 Policy.setPolicy(new Policy()
95 public PermissionCollection getPermissions(CodeSource codesource)
97 Permissions perms = new Permissions();
98 perms.add(new AllPermission());
103 public void refresh()
110 * keep track of feature fetching tasks.
118 * TODO: generalise to track all jalview events to orchestrate batch
122 private int queued = 0;
124 private int running = 0;
126 public FeatureFetcher()
131 public void addFetcher(final AlignFrame af,
132 final Vector<String> dasSources)
134 final long id = System.currentTimeMillis();
136 final FeatureFetcher us = this;
137 new Thread(new Runnable()
149 af.setProgressBar(MessageManager
150 .getString("status.das_features_being_retrived"), id);
151 af.featureSettings_actionPerformed(null);
152 af.featureSettings.fetchDasFeatures(dasSources, true);
153 af.setProgressBar(null, id);
162 public synchronized boolean allFinished()
164 return queued == 0 && running == 0;
169 public static Jalview getInstance()
175 * main class for Jalview application
178 * open <em>filename</em>
180 public static void main(String[] args)
182 instance = new Jalview();
183 instance.doMain(args);
189 void doMain(String[] args)
191 System.setSecurityManager(null);
193 .println("Java version: " + System.getProperty("java.version"));
194 System.out.println(System.getProperty("os.arch") + " "
195 + System.getProperty("os.name") + " "
196 + System.getProperty("os.version"));
198 ArgsParser aparser = new ArgsParser(args);
199 boolean headless = false;
201 if (aparser.contains("help") || aparser.contains("h"))
206 if (aparser.contains("nodisplay") || aparser.contains("nogui")
207 || aparser.contains("headless"))
209 System.setProperty("java.awt.headless", "true");
212 String usrPropsFile = aparser.getValue("props");
213 Cache.loadProperties(usrPropsFile); // must do this before
214 if (usrPropsFile != null)
217 "CMD [-props " + usrPropsFile + "] executed successfully!");
222 final String jabawsUrl = aparser.getValue("jabaws");
223 if (jabawsUrl != null)
227 Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl);
229 "CMD [-jabaws " + jabawsUrl + "] executed successfully!");
230 } catch (MalformedURLException e)
233 "Invalid jabaws parameter: " + jabawsUrl + " ignored");
237 String defs = aparser.getValue("setprop");
240 int p = defs.indexOf('=');
243 System.err.println("Ignoring invalid setprop argument : " + defs);
247 System.out.println("Executing setprop argument: " + defs);
248 // DISABLED FOR SECURITY REASONS
249 // TODO: add a property to allow properties to be overriden by cli args
250 // Cache.setProperty(defs.substring(0,p), defs.substring(p+1));
252 defs = aparser.getValue("setprop");
254 if (System.getProperty("java.awt.headless") != null
255 && System.getProperty("java.awt.headless").equals("true"))
259 System.setProperty("http.agent",
260 "Jalview Desktop/" + Cache.getDefault("VERSION", "Unknown"));
264 } catch (NoClassDefFoundError error)
266 error.printStackTrace();
267 System.out.println("\nEssential logging libraries not found."
268 + "\nUse: java -Djava.ext.dirs=$PATH_TO_LIB$ jalview.bin.Jalview");
276 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
277 } catch (Exception ex)
279 System.err.println("Unexpected Look and Feel Exception");
280 ex.printStackTrace();
282 if (Platform.isAMac())
285 LookAndFeel lookAndFeel = ch.randelshofer.quaqua.QuaquaManager
287 System.setProperty("com.apple.mrj.application.apple.menu.about.name",
289 System.setProperty("apple.laf.useScreenMenuBar", "true");
290 if (lookAndFeel != null)
294 UIManager.setLookAndFeel(lookAndFeel);
295 } catch (Throwable e)
298 "Failed to set QuaQua look and feel: " + e.toString());
301 if (lookAndFeel == null || !(lookAndFeel.getClass()
302 .isAssignableFrom(UIManager.getLookAndFeel().getClass()))
303 || !UIManager.getLookAndFeel().getClass().toString()
304 .toLowerCase().contains("quaqua"))
309 "Quaqua LaF not available on this plaform. Using VAqua(4).\nSee https://issues.jalview.org/browse/JAL-2976");
310 UIManager.setLookAndFeel("org.violetlib.aqua.AquaLookAndFeel");
311 } catch (Throwable e)
314 "Failed to reset look and feel: " + e.toString());
320 * configure 'full' SO model if preferences say to,
321 * else use the default (SO Lite)
323 if (Cache.getDefault("USE_FULL_SO", false))
325 SequenceOntologyFactory.setInstance(new SequenceOntology());
330 desktop = new Desktop();
331 desktop.setInBatchMode(true); // indicate we are starting up
332 desktop.setVisible(true);
333 desktop.startServiceDiscovery();
334 if (!aparser.contains("nousagestats"))
336 startUsageStats(desktop);
340 System.err.println("CMD [-nousagestats] executed successfully!");
343 if (!aparser.contains("noquestionnaire"))
345 String url = aparser.getValue("questionnaire");
348 // Start the desktop questionnaire prompter with the specified
350 Cache.log.debug("Starting questionnaire url at " + url);
351 desktop.checkForQuestionnaire(url);
353 "CMD questionnaire[-" + url + "] executed successfully!");
357 if (Cache.getProperty("NOQUESTIONNAIRES") == null)
359 // Start the desktop questionnaire prompter with the specified
362 // "http://anaplog.compbio.dundee.ac.uk/cgi-bin/questionnaire.pl";
364 String defurl = "http://www.jalview.org/cgi-bin/questionnaire.pl";
366 "Starting questionnaire with default url: " + defurl);
367 desktop.checkForQuestionnaire(defurl);
373 System.err.println("CMD [-noquestionnaire] executed successfully!");
376 if (!aparser.contains("nonews"))
378 desktop.checkForNews();
381 BioJsHTMLOutput.updateBioJS();
384 String file = null, data = null;
385 FileFormatI format = null;
386 DataSourceType protocol = null;
387 FileLoader fileLoader = new FileLoader(!headless);
388 Vector<String> getFeatures = null; // vector of das source nicknames to
392 String groovyscript = null; // script to execute after all loading is
393 // completed one way or another
394 // extract groovy argument and execute if necessary
395 groovyscript = aparser.getValue("groovy", true);
396 file = aparser.getValue("open", true);
398 if (file == null && desktop == null)
400 System.out.println("No files to open!");
403 String vamsasImport = aparser.getValue("vdoc");
404 String vamsasSession = aparser.getValue("vsess");
405 if (vamsasImport != null || vamsasSession != null)
407 if (desktop == null || headless)
410 "Headless vamsas sessions not yet supported. Sorry.");
413 // if we have a file, start a new session and import it.
414 boolean inSession = false;
415 if (vamsasImport != null)
419 DataSourceType viprotocol = AppletFormatAdapter
420 .checkProtocol(vamsasImport);
421 if (viprotocol == DataSourceType.FILE)
423 inSession = desktop.vamsasImport(new File(vamsasImport));
425 else if (viprotocol == DataSourceType.URL)
427 inSession = desktop.vamsasImport(new URL(vamsasImport));
430 } catch (Exception e)
432 System.err.println("Exeption when importing " + vamsasImport
433 + " as a vamsas document.");
438 System.err.println("Failed to import " + vamsasImport
439 + " as a vamsas document.");
443 System.out.println("Imported Successfully into new session "
444 + desktop.getVamsasApplication().getCurrentSession());
447 if (vamsasSession != null)
449 if (vamsasImport != null)
451 // close the newly imported session and import the Jalview specific
452 // remnants into the new session later on.
453 desktop.vamsasStop_actionPerformed(null);
455 // now join the new session
458 if (desktop.joinVamsasSession(vamsasSession))
461 "Successfully joined vamsas session " + vamsasSession);
465 System.err.println("WARNING: Failed to join vamsas session "
468 } catch (Exception e)
471 "ERROR: Failed to join vamsas session " + vamsasSession);
474 if (vamsasImport != null)
476 // the Jalview specific remnants can now be imported into the new
477 // session at the user's leisure.
479 "Skipping Push for import of data into existing vamsas session."); // TODO:
484 // desktop.getVamsasApplication().push_update();
489 // Finally, deal with the remaining input data.
494 desktop.setProgressBar(
496 .getString("status.processing_commandline_args"),
497 progress = System.currentTimeMillis());
499 System.out.println("CMD [-open " + file + "] executed successfully!");
501 if (!file.startsWith("http://"))
503 if (!(new File(file)).exists())
505 System.out.println("Can't find " + file);
513 protocol = AppletFormatAdapter.checkProtocol(file);
517 format = new IdentifyFile().identify(file, protocol);
518 } catch (FileFormatException e1)
523 AlignFrame af = fileLoader.LoadFileWaitTillLoaded(file, protocol,
527 System.out.println("error");
531 setCurrentAlignFrame(af);
532 data = aparser.getValue("colour", true);
535 data.replaceAll("%20", " ");
537 ColourSchemeI cs = ColourSchemeProperty
538 .getColourScheme(af.getViewport().getAlignment(), data);
543 "CMD [-color " + data + "] executed successfully!");
548 // Must maintain ability to use the groups flag
549 data = aparser.getValue("groups", true);
552 af.parseFeaturesFile(data,
553 AppletFormatAdapter.checkProtocol(data));
554 // System.out.println("Added " + data);
556 "CMD groups[-" + data + "] executed successfully!");
558 data = aparser.getValue("features", true);
561 af.parseFeaturesFile(data,
562 AppletFormatAdapter.checkProtocol(data));
563 // System.out.println("Added " + data);
565 "CMD [-features " + data + "] executed successfully!");
568 data = aparser.getValue("annotations", true);
571 af.loadJalviewDataFile(data, null, null, null);
572 // System.out.println("Added " + data);
574 "CMD [-annotations " + data + "] executed successfully!");
576 // set or clear the sortbytree flag.
577 if (aparser.contains("sortbytree"))
579 af.getViewport().setSortByTree(true);
580 if (af.getViewport().getSortByTree())
582 System.out.println("CMD [-sortbytree] executed successfully!");
585 if (aparser.contains("no-annotation"))
587 af.getViewport().setShowAnnotation(false);
588 if (!af.getViewport().isShowAnnotation())
590 System.out.println("CMD no-annotation executed successfully!");
593 if (aparser.contains("nosortbytree"))
595 af.getViewport().setSortByTree(false);
596 if (!af.getViewport().getSortByTree())
599 .println("CMD [-nosortbytree] executed successfully!");
602 data = aparser.getValue("tree", true);
608 "CMD [-tree " + data + "] executed successfully!");
609 NewickFile nf = new NewickFile(data,
610 AppletFormatAdapter.checkProtocol(data));
612 .setCurrentTree(af.showNewickTree(nf, data).getTree());
613 } catch (IOException ex)
615 System.err.println("Couldn't add tree " + data);
616 ex.printStackTrace(System.err);
619 // TODO - load PDB structure(s) to alignment JAL-629
620 // (associate with identical sequence in alignment, or a specified
623 getFeatures = checkDasArguments(aparser);
624 if (af != null && getFeatures != null)
626 FeatureFetcher ff = startFeatureFetching(getFeatures);
629 while (!ff.allFinished() || af.operationInProgress())
631 // wait around until fetching is finished.
635 } catch (Exception e)
641 getFeatures = null; // have retrieved features - forget them now.
643 if (groovyscript != null)
645 // Execute the groovy script after we've done all the rendering stuff
646 // and before any images or figures are generated.
647 System.out.println("Executing script " + groovyscript);
648 executeGroovyScript(groovyscript, af);
649 System.out.println("CMD groovy[" + groovyscript
650 + "] executed successfully!");
653 String imageName = "unnamed.png";
654 while (aparser.getSize() > 1)
656 String outputFormat = aparser.nextValue();
657 file = aparser.nextValue();
659 if (outputFormat.equalsIgnoreCase("png"))
661 af.createPNG(new File(file));
662 imageName = (new File(file)).getName();
663 System.out.println("Creating PNG image: " + file);
666 else if (outputFormat.equalsIgnoreCase("svg"))
668 File imageFile = new File(file);
669 imageName = imageFile.getName();
670 af.createSVG(imageFile);
671 System.out.println("Creating SVG image: " + file);
674 else if (outputFormat.equalsIgnoreCase("html"))
676 File imageFile = new File(file);
677 imageName = imageFile.getName();
678 HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel);
679 htmlSVG.exportHTML(file);
681 System.out.println("Creating HTML image: " + file);
684 else if (outputFormat.equalsIgnoreCase("biojsmsa"))
688 System.err.println("The output html file must not be null");
693 BioJsHTMLOutput.refreshVersionInfo(
694 BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
695 } catch (URISyntaxException e)
699 BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel);
700 bjs.exportHTML(file);
702 .println("Creating BioJS MSA Viwer HTML file: " + file);
705 else if (outputFormat.equalsIgnoreCase("imgMap"))
707 af.createImageMap(new File(file), imageName);
708 System.out.println("Creating image map: " + file);
711 else if (outputFormat.equalsIgnoreCase("eps"))
713 File outputFile = new File(file);
715 "Creating EPS file: " + outputFile.getAbsolutePath());
716 af.createEPS(outputFile);
720 if (af.saveAlignment(file, format))
722 System.out.println("Written alignment in " + format
723 + " format to " + file);
727 System.out.println("Error writing file " + file + " in "
728 + format + " format!!");
733 while (aparser.getSize() > 0)
735 System.out.println("Unknown arg: " + aparser.nextValue());
739 AlignFrame startUpAlframe = null;
740 // We'll only open the default file if the desktop is visible.
742 // ////////////////////
744 if (!headless && file == null && vamsasImport == null
745 && jalview.bin.Cache.getDefault("SHOW_STARTUP_FILE", true))
747 file = jalview.bin.Cache.getDefault("STARTUP_FILE",
748 jalview.bin.Cache.getDefault("www.jalview.org",
749 "http://www.jalview.org")
750 + "/examples/exampleFile_2_7.jar");
752 "http://www.jalview.org/examples/exampleFile_2_3.jar"))
754 // hardwire upgrade of the startup file
755 file.replace("_2_3.jar", "_2_7.jar");
756 // and remove the stale setting
757 jalview.bin.Cache.removeProperty("STARTUP_FILE");
760 protocol = DataSourceType.FILE;
762 if (file.indexOf("http:") > -1)
764 protocol = DataSourceType.URL;
767 if (file.endsWith(".jar"))
769 format = FileFormat.Jalview;
775 format = new IdentifyFile().identify(file, protocol);
776 } catch (FileFormatException e)
782 startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol,
784 getFeatures = checkDasArguments(aparser);
785 // extract groovy arguments before anything else.
787 // If the user has specified features to be retrieved,
788 // or a groovy script to be executed, do them if they
789 // haven't been done already
790 // fetch features for the default alignment
791 if (getFeatures != null)
793 if (startUpAlframe != null)
795 startFeatureFetching(getFeatures);
798 // Once all other stuff is done, execute any groovy scripts (in order)
799 if (groovyscript != null)
801 if (Cache.groovyJarsPresent())
803 System.out.println("Executing script " + groovyscript);
804 executeGroovyScript(groovyscript, startUpAlframe);
809 "Sorry. Groovy Support is not available, so ignoring the provided groovy script "
813 // and finally, turn off batch mode indicator - if the desktop still exists
818 desktop.setProgressBar(null, progress);
820 desktop.setInBatchMode(false);
824 private static void showUsage()
827 "Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n"
828 + "-nodisplay\tRun Jalview without User Interface.\n"
829 + "-props FILE\tUse the given Jalview properties file instead of users default.\n"
830 + "-colour COLOURSCHEME\tThe colourscheme to be applied to the alignment\n"
831 + "-annotations FILE\tAdd precalculated annotations to the alignment.\n"
832 + "-tree FILE\tLoad the given newick format tree file onto the alignment\n"
833 + "-features FILE\tUse the given file to mark features on the alignment.\n"
834 + "-fasta FILE\tCreate alignment file FILE in Fasta format.\n"
835 + "-clustal FILE\tCreate alignment file FILE in Clustal format.\n"
836 + "-pfam FILE\tCreate alignment file FILE in PFAM format.\n"
837 + "-msf FILE\tCreate alignment file FILE in MSF format.\n"
838 + "-pileup FILE\tCreate alignment file FILE in Pileup format\n"
839 + "-pir FILE\tCreate alignment file FILE in PIR format.\n"
840 + "-blc FILE\tCreate alignment file FILE in BLC format.\n"
841 + "-json FILE\tCreate alignment file FILE in JSON format.\n"
842 + "-jalview FILE\tCreate alignment file FILE in Jalview format.\n"
843 + "-png FILE\tCreate PNG image FILE from alignment.\n"
844 + "-svg FILE\tCreate SVG image FILE from alignment.\n"
845 + "-html FILE\tCreate HTML file from alignment.\n"
846 + "-biojsMSA FILE\tCreate BioJS MSA Viewer HTML file from alignment.\n"
847 + "-imgMap FILE\tCreate HTML file FILE with image map of PNG image.\n"
848 + "-eps FILE\tCreate EPS file FILE from alignment.\n"
849 + "-questionnaire URL\tQueries the given URL for information about any Jalview user questionnaires.\n"
850 + "-noquestionnaire\tTurn off questionnaire check.\n"
851 + "-nonews\tTurn off check for Jalview news.\n"
852 + "-nousagestats\tTurn off google analytics tracking for this session.\n"
853 + "-sortbytree OR -nosortbytree\tEnable or disable sorting of the given alignment by the given tree\n"
855 // "-setprop PROPERTY=VALUE\tSet the given Jalview property,
856 // after all other properties files have been read\n\t
857 // (quote the 'PROPERTY=VALUE' pair to ensure spaces are
858 // passed in correctly)"
859 + "-jabaws URL\tSpecify URL for Jabaws services (e.g. for a local installation).\n"
860 + "-dasserver nickname=URL\tAdd and enable a das server with given nickname\n\t\t\t(alphanumeric or underscores only) for retrieval of features for all alignments.\n"
861 + "\t\t\tSources that also support the sequence command may be specified by prepending the URL with sequence:\n"
862 + "\t\t\t e.g. sequence:http://localdas.somewhere.org/das/source)\n"
863 + "-fetchfrom nickname\tQuery nickname for features for the alignments and display them.\n"
865 // "-vdoc vamsas-document\tImport vamsas document into new
866 // session or join existing session with same URN\n"
867 // + "-vses vamsas-session\tJoin session with given URN\n"
868 + "-groovy FILE\tExecute groovy script in FILE, after all other arguments have been processed (if FILE is the text 'STDIN' then the file will be read from STDIN)\n"
869 + "\n~Read documentation in Application or visit http://www.jalview.org for description of Features and Annotations file~\n\n");
872 private static void startUsageStats(final Desktop desktop)
875 * start a User Config prompt asking if we can log usage statistics.
877 PromptUserConfig prompter = new PromptUserConfig(Desktop.desktop,
878 "USAGESTATS", "Jalview Usage Statistics",
879 "Do you want to help make Jalview better by enabling "
880 + "the collection of usage statistics with Google Analytics ?"
881 + "\n\n(you can enable or disable usage tracking in the preferences)",
888 "Initialising googletracker for usage stats.");
889 Cache.initGoogleTracker();
890 Cache.log.debug("Tracking enabled.");
897 Cache.log.debug("Not enabling Google Tracking.");
900 desktop.addDialogThread(prompter);
904 * Locate the given string as a file and pass it to the groovy interpreter.
906 * @param groovyscript
907 * the script to execute
908 * @param jalviewContext
909 * the Jalview Desktop object passed in to the groovy binding as the
912 private void executeGroovyScript(String groovyscript, AlignFrame af)
915 * for scripts contained in files
922 if (groovyscript.trim().equals("STDIN"))
924 // read from stdin into a tempfile and execute it
927 tfile = File.createTempFile("jalview", "groovy");
928 PrintWriter outfile = new PrintWriter(
929 new OutputStreamWriter(new FileOutputStream(tfile)));
930 BufferedReader br = new BufferedReader(
931 new InputStreamReader(System.in));
933 while ((line = br.readLine()) != null)
935 outfile.write(line + "\n");
941 } catch (Exception ex)
943 System.err.println("Failed to read from STDIN into tempfile "
944 + ((tfile == null) ? "(tempfile wasn't created)"
945 : tfile.toString()));
946 ex.printStackTrace();
951 sfile = tfile.toURI().toURL();
952 } catch (Exception x)
955 "Unexpected Malformed URL Exception for temporary file created from STDIN: "
965 sfile = new URI(groovyscript).toURL();
966 } catch (Exception x)
968 tfile = new File(groovyscript);
971 System.err.println("File '" + groovyscript + "' does not exist.");
974 if (!tfile.canRead())
976 System.err.println("File '" + groovyscript + "' cannot be read.");
979 if (tfile.length() < 1)
981 System.err.println("File '" + groovyscript + "' is empty.");
986 sfile = tfile.getAbsoluteFile().toURI().toURL();
987 } catch (Exception ex)
989 System.err.println("Failed to create a file URL for "
990 + tfile.getAbsoluteFile());
997 Map<String, Object> vbinding = new HashMap<>();
998 vbinding.put("Jalview", this);
1001 vbinding.put("currentAlFrame", af);
1003 Binding gbinding = new Binding(vbinding);
1004 GroovyScriptEngine gse = new GroovyScriptEngine(new URL[] { sfile });
1005 gse.run(sfile.toString(), gbinding);
1006 if ("STDIN".equals(groovyscript))
1008 // delete temp file that we made -
1009 // only if it was successfully executed
1012 } catch (Exception e)
1014 System.err.println("Exception Whilst trying to execute file " + sfile
1015 + " as a groovy script.");
1016 e.printStackTrace(System.err);
1022 * Check commandline for any das server definitions or any fetchfrom switches
1024 * @return vector of DAS source nicknames to retrieve from
1026 private static Vector<String> checkDasArguments(ArgsParser aparser)
1028 Vector<String> source = null;
1030 String locsources = Cache.getProperty(Cache.DAS_LOCAL_SOURCE);
1031 while ((data = aparser.getValue("dasserver", true)) != null)
1033 String nickname = null;
1035 int pos = data.indexOf('=');
1036 // determine capabilities
1039 nickname = data.substring(0, pos);
1041 url = data.substring(pos + 1);
1042 if (url != null && (url.startsWith("http:")
1043 || url.startsWith("sequence:http:")))
1045 if (nickname == null)
1049 if (locsources == null)
1057 locsources = locsources + nickname + "|" + url;
1059 "NOTE! dasserver parameter not yet really supported (got args of "
1060 + nickname + "|" + url);
1063 source = new Vector<>();
1065 source.addElement(nickname);
1068 "CMD [-dasserver " + data + "] executed successfully!");
1069 } // loop until no more server entries are found.
1070 if (locsources != null && locsources.indexOf('|') > -1)
1072 Cache.log.debug("Setting local source list in properties file to:\n"
1074 Cache.setProperty(Cache.DAS_LOCAL_SOURCE, locsources);
1076 while ((data = aparser.getValue("fetchfrom", true)) != null)
1078 System.out.println("adding source '" + data + "'");
1081 source = new Vector<>();
1083 source.addElement(data);
1089 * start a feature fetcher for every alignment frame
1093 private FeatureFetcher startFeatureFetching(
1094 final Vector<String> dasSources)
1096 FeatureFetcher ff = new FeatureFetcher();
1097 AlignFrame afs[] = Desktop.getAlignFrames();
1098 if (afs == null || afs.length == 0)
1102 for (int i = 0; i < afs.length; i++)
1104 ff.addFetcher(afs[i], dasSources);
1109 public static boolean isHeadlessMode()
1111 String isheadless = System.getProperty("java.awt.headless");
1112 if (isheadless != null && isheadless.equalsIgnoreCase("true"))
1119 public AlignFrame[] getAlignFrames()
1121 return desktop == null ? new AlignFrame[] { getCurrentAlignFrame() }
1122 : Desktop.getAlignFrames();
1127 * Quit method delegates to Desktop.quit - unless running in headless mode
1128 * when it just ends the JVM
1132 if (desktop != null)
1142 public static AlignFrame getCurrentAlignFrame()
1144 return Jalview.currentAlignFrame;
1147 public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)
1149 Jalview.currentAlignFrame = currentAlignFrame;