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 java.util.Locale;
25 import java.io.BufferedReader;
27 import java.io.FileOutputStream;
28 import java.io.IOException;
29 import java.io.InputStreamReader;
30 import java.io.OutputStreamWriter;
31 import java.io.PrintWriter;
32 import java.net.MalformedURLException;
34 import java.net.URISyntaxException;
36 import java.security.AllPermission;
37 import java.security.CodeSource;
38 import java.security.PermissionCollection;
39 import java.security.Permissions;
40 import java.security.Policy;
41 import java.util.HashMap;
43 import java.util.Vector;
44 import java.util.logging.ConsoleHandler;
45 import java.util.logging.Level;
46 import java.util.logging.Logger;
48 import javax.swing.UIManager;
49 import javax.swing.UIManager.LookAndFeelInfo;
51 import com.threerings.getdown.util.LaunchUtil;
53 import groovy.lang.Binding;
54 import groovy.util.GroovyScriptEngine;
55 import jalview.ext.so.SequenceOntology;
56 import jalview.gui.AlignFrame;
57 import jalview.gui.Desktop;
58 import jalview.gui.PromptUserConfig;
59 import jalview.io.AppletFormatAdapter;
60 import jalview.io.BioJsHTMLOutput;
61 import jalview.io.DataSourceType;
62 import jalview.io.FileFormat;
63 import jalview.io.FileFormatException;
64 import jalview.io.FileFormatI;
65 import jalview.io.FileFormats;
66 import jalview.io.FileLoader;
67 import jalview.io.HtmlSvgOutput;
68 import jalview.io.IdentifyFile;
69 import jalview.io.NewickFile;
70 import jalview.io.gff.SequenceOntologyFactory;
71 import jalview.schemes.ColourSchemeI;
72 import jalview.schemes.ColourSchemeProperty;
73 import jalview.util.ChannelProperties;
74 import jalview.util.HttpUtils;
75 import jalview.util.MessageManager;
76 import jalview.util.Platform;
77 import jalview.ws.jws2.Jws2Discoverer;
80 * Main class for Jalview Application <br>
82 * start with: java -classpath "$PATH_TO_LIB$/*:$PATH_TO_CLASSES$" \
85 * or on Windows: java -classpath "$PATH_TO_LIB$/*;$PATH_TO_CLASSES$" \
86 * jalview.bin.Jalview jalview.bin.Jalview
88 * (ensure -classpath arg is quoted to avoid shell expansion of '*' and do not
89 * embellish '*' to e.g. '*.jar')
98 Platform.getURLCommandArguments();
102 * singleton instance of this class
104 private static Jalview instance;
106 private Desktop desktop;
108 public static AlignFrame currentAlignFrame;
112 if (!Platform.isJS())
119 // grab all the rights we can for the JVM
120 Policy.setPolicy(new Policy()
123 public PermissionCollection getPermissions(CodeSource codesource)
125 Permissions perms = new Permissions();
126 perms.add(new AllPermission());
131 public void refresh()
139 * keep track of feature fetching tasks.
147 * TODO: generalise to track all jalview events to orchestrate batch processing
151 private int queued = 0;
153 private int running = 0;
155 public FeatureFetcher()
160 public void addFetcher(final AlignFrame af,
161 final Vector<String> dasSources)
163 final long id = System.currentTimeMillis();
165 final FeatureFetcher us = this;
166 new Thread(new Runnable()
178 af.setProgressBar(MessageManager
179 .getString("status.das_features_being_retrived"), id);
180 af.featureSettings_actionPerformed(null);
181 af.setProgressBar(null, id);
190 public synchronized boolean allFinished()
192 return queued == 0 && running == 0;
197 public static Jalview getInstance()
203 * main class for Jalview application
206 * open <em>filename</em>
208 public static void main(String[] args)
210 // setLogging(); // BH - for event debugging in JavaScript
211 instance = new Jalview();
212 instance.doMain(args);
215 private static void logClass(String name)
217 // BH - for event debugging in JavaScript
218 ConsoleHandler consoleHandler = new ConsoleHandler();
219 consoleHandler.setLevel(Level.ALL);
220 Logger logger = Logger.getLogger(name);
221 logger.setLevel(Level.ALL);
222 logger.addHandler(consoleHandler);
225 @SuppressWarnings("unused")
226 private static void setLogging()
234 System.out.println("not in js");
237 // BH - for event debugging in JavaScript (Java mode only)
238 if (!Platform.isJS())
245 Logger.getLogger("").setLevel(Level.ALL);
246 logClass("java.awt.EventDispatchThread");
247 logClass("java.awt.EventQueue");
248 logClass("java.awt.Component");
249 logClass("java.awt.focus.Component");
250 logClass("java.awt.focus.DefaultKeyboardFocusManager");
258 void doMain(String[] args)
261 if (!Platform.isJS())
263 System.setSecurityManager(null);
267 .println("Java version: " + System.getProperty("java.version"));
268 System.out.println("Java Home: " + System.getProperty("java.home"));
269 System.out.println(System.getProperty("os.arch") + " "
270 + System.getProperty("os.name") + " "
271 + System.getProperty("os.version"));
272 String val = System.getProperty("sys.install4jVersion");
275 System.out.println("Install4j version: " + val);
277 val = System.getProperty("installer_template_version");
280 System.out.println("Install4j template version: " + val);
282 val = System.getProperty("launcher_version");
285 System.out.println("Launcher version: " + val);
288 // report Jalview version
289 Cache.loadBuildProperties(true);
291 ArgsParser aparser = new ArgsParser(args);
292 boolean headless = false;
294 String usrPropsFile = aparser.getValue("props");
295 Cache.loadProperties(usrPropsFile); // must do this before
296 if (usrPropsFile != null)
299 "CMD [-props " + usrPropsFile + "] executed successfully!");
302 if (!Platform.isJS())
309 if (aparser.contains("help") || aparser.contains("h"))
314 if (aparser.contains("nodisplay") || aparser.contains("nogui")
315 || aparser.contains("headless"))
317 System.setProperty("java.awt.headless", "true");
322 // allow https handshakes to download intermediate certs if necessary
323 System.setProperty("com.sun.security.enableAIAcaIssuers", "true");
325 final String jabawsUrl = aparser.getValue("jabaws");
326 if (jabawsUrl != null)
330 Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl);
332 "CMD [-jabaws " + jabawsUrl + "] executed successfully!");
333 } catch (MalformedURLException e)
336 "Invalid jabaws parameter: " + jabawsUrl + " ignored");
341 String defs = aparser.getValue("setprop");
344 int p = defs.indexOf('=');
347 System.err.println("Ignoring invalid setprop argument : " + defs);
351 System.out.println("Executing setprop argument: " + defs);
354 Cache.setProperty(defs.substring(0, p), defs.substring(p + 1));
356 // DISABLED FOR SECURITY REASONS
357 // TODO: add a property to allow properties to be overriden by cli args
358 // Cache.setProperty(defs.substring(0,p), defs.substring(p+1));
360 defs = aparser.getValue("setprop");
362 if (System.getProperty("java.awt.headless") != null
363 && System.getProperty("java.awt.headless").equals("true"))
367 System.setProperty("http.agent",
368 "Jalview Desktop/" + Cache.getDefault("VERSION", "Unknown"));
372 } catch (NoClassDefFoundError error)
374 error.printStackTrace();
375 System.out.println("\nEssential logging libraries not found."
376 + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview");
385 * configure 'full' SO model if preferences say to, else use the default (full SO)
386 * - as JS currently doesn't have OBO parsing, it must use 'Lite' version
388 boolean soDefault = !Platform.isJS();
389 if (Cache.getDefault("USE_FULL_SO", soDefault))
391 SequenceOntologyFactory.setInstance(new SequenceOntology());
396 Desktop.nosplash = aparser.contains("nosplash");
397 desktop = new Desktop();
398 desktop.setInBatchMode(true); // indicate we are starting up
402 JalviewTaskbar.setTaskbar(this);
403 } catch (Exception e)
405 Cache.log.info("Cannot set Taskbar");
406 Cache.log.error(e.getMessage());
407 // e.printStackTrace();
408 } catch (Throwable t)
410 Cache.log.info("Cannot set Taskbar");
411 Cache.log.error(t.getMessage());
412 // t.printStackTrace();
415 // set Proxy settings before all the internet calls
416 Cache.setProxyPropertiesFromPreferences();
418 desktop.setVisible(true);
420 if (!Platform.isJS())
427 if (!aparser.contains("nowebservicediscovery"))
429 desktop.startServiceDiscovery();
431 if (!aparser.contains("nousagestats"))
433 startUsageStats(desktop);
437 System.err.println("CMD [-nousagestats] executed successfully!");
440 if (!aparser.contains("noquestionnaire"))
442 String url = aparser.getValue("questionnaire");
445 // Start the desktop questionnaire prompter with the specified
447 Cache.log.debug("Starting questionnaire url at " + url);
448 desktop.checkForQuestionnaire(url);
449 System.out.println("CMD questionnaire[-" + url
450 + "] executed successfully!");
454 if (Cache.getProperty("NOQUESTIONNAIRES") == null)
456 // Start the desktop questionnaire prompter with the specified
459 // "http://anaplog.compbio.dundee.ac.uk/cgi-bin/questionnaire.pl";
461 String defurl = "https://www.jalview.org/cgi-bin/questionnaire.pl";
463 "Starting questionnaire with default url: " + defurl);
464 desktop.checkForQuestionnaire(defurl);
471 .println("CMD [-noquestionnaire] executed successfully!");
474 if (!aparser.contains("nonews"))
476 desktop.checkForNews();
479 BioJsHTMLOutput.updateBioJS();
483 // Move any new getdown-launcher-new.jar into place over old
484 // getdown-launcher.jar
485 String appdirString = System.getProperty("getdownappdir");
486 if (appdirString != null && appdirString.length() > 0)
488 final File appdir = new File(appdirString);
494 LaunchUtil.upgradeGetdown(
495 new File(appdir, "getdown-launcher-old.jar"),
496 new File(appdir, "getdown-launcher.jar"),
497 new File(appdir, "getdown-launcher-new.jar"));
502 String file = null, data = null;
503 FileFormatI format = null;
504 DataSourceType protocol = null;
505 FileLoader fileLoader = new FileLoader(!headless);
507 String groovyscript = null; // script to execute after all loading is
508 // completed one way or another
509 // extract groovy argument and execute if necessary
510 groovyscript = aparser.getValue("groovy", true);
511 file = aparser.getValue("open", true);
513 if (file == null && desktop == null)
515 System.out.println("No files to open!");
519 // Finally, deal with the remaining input data.
524 desktop.setProgressBar(
526 .getString("status.processing_commandline_args"),
527 progress = System.currentTimeMillis());
529 System.out.println("CMD [-open " + file + "] executed successfully!");
531 if (!Platform.isJS())
533 * ignore in JavaScript -- can't just file existence - could load it?
538 if (!HttpUtils.startsWithHttpOrHttps(file))
540 if (!(new File(file)).exists())
542 System.out.println("Can't find " + file);
551 protocol = AppletFormatAdapter.checkProtocol(file);
555 format = new IdentifyFile().identify(file, protocol);
556 } catch (FileFormatException e1)
561 AlignFrame af = fileLoader.LoadFileWaitTillLoaded(file, protocol,
565 System.out.println("error");
569 setCurrentAlignFrame(af);
570 data = aparser.getValue("colour", true);
573 data.replaceAll("%20", " ");
575 ColourSchemeI cs = ColourSchemeProperty.getColourScheme(
576 af.getViewport(), af.getViewport().getAlignment(), data);
581 "CMD [-color " + data + "] executed successfully!");
586 // Must maintain ability to use the groups flag
587 data = aparser.getValue("groups", true);
590 af.parseFeaturesFile(data,
591 AppletFormatAdapter.checkProtocol(data));
592 // System.out.println("Added " + data);
594 "CMD groups[-" + data + "] executed successfully!");
596 data = aparser.getValue("features", true);
599 af.parseFeaturesFile(data,
600 AppletFormatAdapter.checkProtocol(data));
601 // System.out.println("Added " + data);
603 "CMD [-features " + data + "] executed successfully!");
606 data = aparser.getValue("annotations", true);
609 af.loadJalviewDataFile(data, null, null, null);
610 // System.out.println("Added " + data);
612 "CMD [-annotations " + data + "] executed successfully!");
614 // set or clear the sortbytree flag.
615 if (aparser.contains("sortbytree"))
617 af.getViewport().setSortByTree(true);
618 if (af.getViewport().getSortByTree())
620 System.out.println("CMD [-sortbytree] executed successfully!");
623 if (aparser.contains("no-annotation"))
625 af.getViewport().setShowAnnotation(false);
626 if (!af.getViewport().isShowAnnotation())
628 System.out.println("CMD no-annotation executed successfully!");
631 if (aparser.contains("nosortbytree"))
633 af.getViewport().setSortByTree(false);
634 if (!af.getViewport().getSortByTree())
637 .println("CMD [-nosortbytree] executed successfully!");
640 data = aparser.getValue("tree", true);
646 "CMD [-tree " + data + "] executed successfully!");
647 NewickFile nf = new NewickFile(data,
648 AppletFormatAdapter.checkProtocol(data));
650 .setCurrentTree(af.showNewickTree(nf, data).getTree());
651 } catch (IOException ex)
653 System.err.println("Couldn't add tree " + data);
654 ex.printStackTrace(System.err);
657 // TODO - load PDB structure(s) to alignment JAL-629
658 // (associate with identical sequence in alignment, or a specified
660 if (groovyscript != null)
662 // Execute the groovy script after we've done all the rendering stuff
663 // and before any images or figures are generated.
664 System.out.println("Executing script " + groovyscript);
665 executeGroovyScript(groovyscript, af);
666 System.out.println("CMD groovy[" + groovyscript
667 + "] executed successfully!");
670 String imageName = "unnamed.png";
671 while (aparser.getSize() > 1)
673 String outputFormat = aparser.nextValue();
674 file = aparser.nextValue();
676 if (outputFormat.equalsIgnoreCase("png"))
678 af.createPNG(new File(file));
679 imageName = (new File(file)).getName();
680 System.out.println("Creating PNG image: " + file);
683 else if (outputFormat.equalsIgnoreCase("svg"))
685 File imageFile = new File(file);
686 imageName = imageFile.getName();
687 af.createSVG(imageFile);
688 System.out.println("Creating SVG image: " + file);
691 else if (outputFormat.equalsIgnoreCase("html"))
693 File imageFile = new File(file);
694 imageName = imageFile.getName();
695 HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel);
696 htmlSVG.exportHTML(file);
698 System.out.println("Creating HTML image: " + file);
701 else if (outputFormat.equalsIgnoreCase("biojsmsa"))
705 System.err.println("The output html file must not be null");
710 BioJsHTMLOutput.refreshVersionInfo(
711 BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
712 } catch (URISyntaxException e)
716 BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel);
717 bjs.exportHTML(file);
719 .println("Creating BioJS MSA Viwer HTML file: " + file);
722 else if (outputFormat.equalsIgnoreCase("imgMap"))
724 af.createImageMap(new File(file), imageName);
725 System.out.println("Creating image map: " + file);
728 else if (outputFormat.equalsIgnoreCase("eps"))
730 File outputFile = new File(file);
732 "Creating EPS file: " + outputFile.getAbsolutePath());
733 af.createEPS(outputFile);
736 FileFormatI outFormat = null;
739 outFormat = FileFormats.getInstance().forName(outputFormat);
740 } catch (Exception formatP)
742 System.out.println("Couldn't parse " + outFormat
743 + " as a valid Jalview format string.");
745 if (outFormat != null)
747 if (!outFormat.isWritable())
750 "This version of Jalview does not support alignment export as "
755 af.saveAlignment(file, outFormat);
756 if (af.isSaveAlignmentSuccessful())
758 System.out.println("Written alignment in "
759 + outFormat.getName() + " format to " + file);
763 System.out.println("Error writing file " + file + " in "
764 + outFormat.getName() + " format!!");
771 while (aparser.getSize() > 0)
773 System.out.println("Unknown arg: " + aparser.nextValue());
777 AlignFrame startUpAlframe = null;
778 // We'll only open the default file if the desktop is visible.
780 // ////////////////////
782 if (!Platform.isJS() && !headless && file == null
783 && Cache.getDefault("SHOW_STARTUP_FILE", true))
790 file = jalview.bin.Cache.getDefault("STARTUP_FILE",
791 jalview.bin.Cache.getDefault("www.jalview.org",
792 "https://www.jalview.org")
793 + "/examples/exampleFile_2_7.jvp");
795 "http://www.jalview.org/examples/exampleFile_2_3.jar") || file.equals(
796 "http://www.jalview.org/examples/exampleFile_2_7.jar"))
798 file.replace("http:", "https:");
799 // hardwire upgrade of the startup file
800 file.replace("_2_3", "_2_7");
801 file.replace("2_7.jar", "2_7.jvp");
802 // and remove the stale setting
803 Cache.removeProperty("STARTUP_FILE");
806 protocol = AppletFormatAdapter.checkProtocol(file);
808 if (file.endsWith(".jar"))
810 format = FileFormat.Jalview;
816 format = new IdentifyFile().identify(file, protocol);
817 } catch (FileFormatException e)
823 startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol,
825 // extract groovy arguments before anything else.
828 // Once all other stuff is done, execute any groovy scripts (in order)
829 if (groovyscript != null)
831 if (Cache.groovyJarsPresent())
833 System.out.println("Executing script " + groovyscript);
834 executeGroovyScript(groovyscript, startUpAlframe);
839 "Sorry. Groovy Support is not available, so ignoring the provided groovy script "
843 // and finally, turn off batch mode indicator - if the desktop still exists
848 desktop.setProgressBar(null, progress);
850 desktop.setInBatchMode(false);
854 private static void setLookAndFeel()
856 // property laf = "crossplatform", "system", "gtk", "metal", "nimbus" or
858 // If not set (or chosen laf fails), use the normal SystemLaF and if on Mac,
860 String lafProp = System.getProperty("laf");
861 String lafSetting = Cache.getDefault("PREFERRED_LAF", null);
867 else if (lafSetting != null)
871 boolean lafSet = false;
874 case "crossplatform":
875 lafSet = setCrossPlatformLookAndFeel();
878 Cache.log.error("Could not set requested laf=" + laf);
882 lafSet = setSystemLookAndFeel();
885 Cache.log.error("Could not set requested laf=" + laf);
889 lafSet = setGtkLookAndFeel();
892 Cache.log.error("Could not set requested laf=" + laf);
896 lafSet = setMetalLookAndFeel();
899 Cache.log.error("Could not set requested laf=" + laf);
903 lafSet = setNimbusLookAndFeel();
906 Cache.log.error("Could not set requested laf=" + laf);
910 lafSet = setQuaquaLookAndFeel();
913 Cache.log.error("Could not set requested laf=" + laf);
917 lafSet = setVaquaLookAndFeel();
920 Cache.log.error("Could not set requested laf=" + laf);
924 lafSet = setMacLookAndFeel();
927 Cache.log.error("Could not set requested laf=" + laf);
933 Cache.log.error("Requested laf=" + laf + " not implemented");
937 setSystemLookAndFeel();
938 if (Platform.isLinux())
940 setMetalLookAndFeel();
942 if (Platform.isMac())
949 private static boolean setCrossPlatformLookAndFeel()
954 UIManager.setLookAndFeel(
955 UIManager.getCrossPlatformLookAndFeelClassName());
957 } catch (Exception ex)
959 Cache.log.error("Unexpected Look and Feel Exception");
960 Cache.log.error(ex.getMessage());
961 Cache.log.debug(Cache.getStackTraceString(ex));
966 private static boolean setSystemLookAndFeel()
971 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
973 } catch (Exception ex)
975 Cache.log.error("Unexpected Look and Feel Exception");
976 Cache.log.error(ex.getMessage());
977 Cache.log.debug(Cache.getStackTraceString(ex));
982 private static boolean setSpecificLookAndFeel(String name,
983 String className, boolean nameStartsWith)
988 for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels())
990 if (info.getName() != null && nameStartsWith
991 ? info.getName().toLowerCase(Locale.ROOT)
992 .startsWith(name.toLowerCase(Locale.ROOT))
993 : info.getName().toLowerCase(Locale.ROOT).equals(name.toLowerCase(Locale.ROOT)))
995 className = info.getClassName();
999 UIManager.setLookAndFeel(className);
1001 } catch (Exception ex)
1003 Cache.log.error("Unexpected Look and Feel Exception");
1004 Cache.log.error(ex.getMessage());
1005 Cache.log.debug(Cache.getStackTraceString(ex));
1010 private static boolean setGtkLookAndFeel()
1012 return setSpecificLookAndFeel("gtk",
1013 "com.sun.java.swing.plaf.gtk.GTKLookAndFeel", true);
1016 private static boolean setMetalLookAndFeel()
1018 return setSpecificLookAndFeel("metal",
1019 "javax.swing.plaf.metal.MetalLookAndFeel", false);
1022 private static boolean setNimbusLookAndFeel()
1024 return setSpecificLookAndFeel("nimbus",
1025 "javax.swing.plaf.nimbus.NimbusLookAndFeel", false);
1028 private static boolean setQuaquaLookAndFeel()
1030 return setSpecificLookAndFeel("quaqua",
1031 ch.randelshofer.quaqua.QuaquaManager.getLookAndFeel().getClass()
1036 private static boolean setVaquaLookAndFeel()
1038 return setSpecificLookAndFeel("vaqua",
1039 "org.violetlib.aqua.AquaLookAndFeel", false);
1042 private static boolean setMacLookAndFeel()
1044 boolean set = false;
1045 System.setProperty("com.apple.mrj.application.apple.menu.about.name",
1046 ChannelProperties.getProperty("app_name"));
1047 System.setProperty("apple.laf.useScreenMenuBar", "true");
1048 set = setQuaquaLookAndFeel();
1049 if ((!set) || !UIManager.getLookAndFeel().getClass().toString()
1050 .toLowerCase(Locale.ROOT).contains("quaqua"))
1052 set = setVaquaLookAndFeel();
1057 private static void showUsage()
1060 "Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n"
1061 + "-nodisplay\tRun Jalview without User Interface.\n"
1062 + "-props FILE\tUse the given Jalview properties file instead of users default.\n"
1063 + "-colour COLOURSCHEME\tThe colourscheme to be applied to the alignment\n"
1064 + "-annotations FILE\tAdd precalculated annotations to the alignment.\n"
1065 + "-tree FILE\tLoad the given newick format tree file onto the alignment\n"
1066 + "-features FILE\tUse the given file to mark features on the alignment.\n"
1067 + "-fasta FILE\tCreate alignment file FILE in Fasta format.\n"
1068 + "-clustal FILE\tCreate alignment file FILE in Clustal format.\n"
1069 + "-pfam FILE\tCreate alignment file FILE in PFAM format.\n"
1070 + "-msf FILE\tCreate alignment file FILE in MSF format.\n"
1071 + "-pileup FILE\tCreate alignment file FILE in Pileup format\n"
1072 + "-pir FILE\tCreate alignment file FILE in PIR format.\n"
1073 + "-blc FILE\tCreate alignment file FILE in BLC format.\n"
1074 + "-json FILE\tCreate alignment file FILE in JSON format.\n"
1075 + "-jalview FILE\tCreate alignment file FILE in Jalview format.\n"
1076 + "-png FILE\tCreate PNG image FILE from alignment.\n"
1077 + "-svg FILE\tCreate SVG image FILE from alignment.\n"
1078 + "-html FILE\tCreate HTML file from alignment.\n"
1079 + "-biojsMSA FILE\tCreate BioJS MSA Viewer HTML file from alignment.\n"
1080 + "-imgMap FILE\tCreate HTML file FILE with image map of PNG image.\n"
1081 + "-eps FILE\tCreate EPS file FILE from alignment.\n"
1082 + "-questionnaire URL\tQueries the given URL for information about any Jalview user questionnaires.\n"
1083 + "-noquestionnaire\tTurn off questionnaire check.\n"
1084 + "-nonews\tTurn off check for Jalview news.\n"
1085 + "-nousagestats\tTurn off google analytics tracking for this session.\n"
1086 + "-sortbytree OR -nosortbytree\tEnable or disable sorting of the given alignment by the given tree\n"
1088 // "-setprop PROPERTY=VALUE\tSet the given Jalview property,
1089 // after all other properties files have been read\n\t
1090 // (quote the 'PROPERTY=VALUE' pair to ensure spaces are
1091 // passed in correctly)"
1092 + "-jabaws URL\tSpecify URL for Jabaws services (e.g. for a local installation).\n"
1093 + "-fetchfrom nickname\tQuery nickname for features for the alignments and display them.\n"
1094 + "-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"
1095 + "-jvmmempc=PERCENT\tOnly available with standalone executable jar or jalview.bin.Launcher. Limit maximum heap size (memory) to PERCENT% of total physical memory detected. This defaults to 90 if total physical memory can be detected. See https://www.jalview.org/help/html/memory.html for more details.\n"
1096 + "-jvmmemmax=MAXMEMORY\tOnly available with standalone executable jar or jalview.bin.Launcher. Limit maximum heap size (memory) to MAXMEMORY. MAXMEMORY can be specified in bytes, kilobytes(k), megabytes(m), gigabytes(g) or if you're lucky enough, terabytes(t). This defaults to 32g if total physical memory can be detected, or to 8g if total physical memory cannot be detected. See https://www.jalview.org/help/html/memory.html for more details.\n"
1097 + "\n~Read documentation in Application or visit https://www.jalview.org for description of Features and Annotations file~\n\n");
1100 private static void startUsageStats(final Desktop desktop)
1103 * start a User Config prompt asking if we can log usage statistics.
1105 PromptUserConfig prompter = new PromptUserConfig(Desktop.desktop,
1106 "USAGESTATS", "Jalview Usage Statistics",
1107 "Do you want to help make Jalview better by enabling "
1108 + "the collection of usage statistics with Google Analytics ?"
1109 + "\n\n(you can enable or disable usage tracking in the preferences)",
1116 "Initialising googletracker for usage stats.");
1117 Cache.initGoogleTracker();
1118 Cache.log.debug("Tracking enabled.");
1125 Cache.log.debug("Not enabling Google Tracking.");
1128 desktop.addDialogThread(prompter);
1132 * Locate the given string as a file and pass it to the groovy interpreter.
1134 * @param groovyscript
1135 * the script to execute
1136 * @param jalviewContext
1137 * the Jalview Desktop object passed in to the groovy binding as the
1140 private void executeGroovyScript(String groovyscript, AlignFrame af)
1143 * for scripts contained in files
1150 if (groovyscript.trim().equals("STDIN"))
1152 // read from stdin into a tempfile and execute it
1155 tfile = File.createTempFile("jalview", "groovy");
1156 PrintWriter outfile = new PrintWriter(
1157 new OutputStreamWriter(new FileOutputStream(tfile)));
1158 BufferedReader br = new BufferedReader(
1159 new InputStreamReader(System.in));
1161 while ((line = br.readLine()) != null)
1163 outfile.write(line + "\n");
1169 } catch (Exception ex)
1171 System.err.println("Failed to read from STDIN into tempfile "
1172 + ((tfile == null) ? "(tempfile wasn't created)"
1173 : tfile.toString()));
1174 ex.printStackTrace();
1179 sfile = tfile.toURI().toURL();
1180 } catch (Exception x)
1183 "Unexpected Malformed URL Exception for temporary file created from STDIN: "
1185 x.printStackTrace();
1193 sfile = new URI(groovyscript).toURL();
1194 } catch (Exception x)
1196 tfile = new File(groovyscript);
1197 if (!tfile.exists())
1199 System.err.println("File '" + groovyscript + "' does not exist.");
1202 if (!tfile.canRead())
1204 System.err.println("File '" + groovyscript + "' cannot be read.");
1207 if (tfile.length() < 1)
1209 System.err.println("File '" + groovyscript + "' is empty.");
1214 sfile = tfile.getAbsoluteFile().toURI().toURL();
1215 } catch (Exception ex)
1217 System.err.println("Failed to create a file URL for "
1218 + tfile.getAbsoluteFile());
1225 Map<String, java.lang.Object> vbinding = new HashMap<>();
1226 vbinding.put("Jalview", this);
1229 vbinding.put("currentAlFrame", af);
1231 Binding gbinding = new Binding(vbinding);
1232 GroovyScriptEngine gse = new GroovyScriptEngine(new URL[] { sfile });
1233 gse.run(sfile.toString(), gbinding);
1234 if ("STDIN".equals(groovyscript))
1236 // delete temp file that we made -
1237 // only if it was successfully executed
1240 } catch (Exception e)
1242 System.err.println("Exception Whilst trying to execute file " + sfile
1243 + " as a groovy script.");
1244 e.printStackTrace(System.err);
1249 public static boolean isHeadlessMode()
1251 String isheadless = System.getProperty("java.awt.headless");
1252 if (isheadless != null && isheadless.equalsIgnoreCase("true"))
1259 public AlignFrame[] getAlignFrames()
1261 return desktop == null ? new AlignFrame[] { getCurrentAlignFrame() }
1262 : Desktop.getAlignFrames();
1267 * Quit method delegates to Desktop.quit - unless running in headless mode
1268 * when it just ends the JVM
1272 if (desktop != null)
1282 public static AlignFrame getCurrentAlignFrame()
1284 return Jalview.currentAlignFrame;
1287 public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)
1289 Jalview.currentAlignFrame = currentAlignFrame;