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 final String jabawsUrl = aparser.getValue("jabaws");
323 if (jabawsUrl != null)
327 Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl);
329 "CMD [-jabaws " + jabawsUrl + "] executed successfully!");
330 } catch (MalformedURLException e)
333 "Invalid jabaws parameter: " + jabawsUrl + " ignored");
338 String defs = aparser.getValue("setprop");
341 int p = defs.indexOf('=');
344 System.err.println("Ignoring invalid setprop argument : " + defs);
348 System.out.println("Executing setprop argument: " + defs);
351 Cache.setProperty(defs.substring(0, p), defs.substring(p + 1));
353 // DISABLED FOR SECURITY REASONS
354 // TODO: add a property to allow properties to be overriden by cli args
355 // Cache.setProperty(defs.substring(0,p), defs.substring(p+1));
357 defs = aparser.getValue("setprop");
359 if (System.getProperty("java.awt.headless") != null
360 && System.getProperty("java.awt.headless").equals("true"))
364 System.setProperty("http.agent",
365 "Jalview Desktop/" + Cache.getDefault("VERSION", "Unknown"));
369 } catch (NoClassDefFoundError error)
371 error.printStackTrace();
372 System.out.println("\nEssential logging libraries not found."
373 + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview");
382 * configure 'full' SO model if preferences say to, else use the default (full SO)
383 * - as JS currently doesn't have OBO parsing, it must use 'Lite' version
385 boolean soDefault = !Platform.isJS();
386 if (Cache.getDefault("USE_FULL_SO", soDefault))
388 SequenceOntologyFactory.setInstance(new SequenceOntology());
393 Desktop.nosplash = aparser.contains("nosplash");
394 desktop = new Desktop();
395 desktop.setInBatchMode(true); // indicate we are starting up
399 JalviewTaskbar.setTaskbar(this);
400 } catch (Exception e)
402 Cache.log.info("Cannot set Taskbar");
403 Cache.log.error(e.getMessage());
404 // e.printStackTrace();
405 } catch (Throwable t)
407 Cache.log.info("Cannot set Taskbar");
408 Cache.log.error(t.getMessage());
409 // t.printStackTrace();
412 // set Proxy settings before all the internet calls
413 Cache.setProxyPropertiesFromPreferences();
415 desktop.setVisible(true);
417 if (!Platform.isJS())
424 if (!aparser.contains("nowebservicediscovery"))
426 desktop.startServiceDiscovery();
428 if (!aparser.contains("nousagestats"))
430 startUsageStats(desktop);
434 System.err.println("CMD [-nousagestats] executed successfully!");
437 if (!aparser.contains("noquestionnaire"))
439 String url = aparser.getValue("questionnaire");
442 // Start the desktop questionnaire prompter with the specified
444 Cache.log.debug("Starting questionnaire url at " + url);
445 desktop.checkForQuestionnaire(url);
446 System.out.println("CMD questionnaire[-" + url
447 + "] executed successfully!");
451 if (Cache.getProperty("NOQUESTIONNAIRES") == null)
453 // Start the desktop questionnaire prompter with the specified
456 // "http://anaplog.compbio.dundee.ac.uk/cgi-bin/questionnaire.pl";
458 String defurl = "https://www.jalview.org/cgi-bin/questionnaire.pl";
460 "Starting questionnaire with default url: " + defurl);
461 desktop.checkForQuestionnaire(defurl);
468 .println("CMD [-noquestionnaire] executed successfully!");
471 if (!aparser.contains("nonews"))
473 desktop.checkForNews();
476 BioJsHTMLOutput.updateBioJS();
480 // Move any new getdown-launcher-new.jar into place over old
481 // getdown-launcher.jar
482 String appdirString = System.getProperty("getdownappdir");
483 if (appdirString != null && appdirString.length() > 0)
485 final File appdir = new File(appdirString);
491 LaunchUtil.upgradeGetdown(
492 new File(appdir, "getdown-launcher-old.jar"),
493 new File(appdir, "getdown-launcher.jar"),
494 new File(appdir, "getdown-launcher-new.jar"));
499 String file = null, data = null;
500 FileFormatI format = null;
501 DataSourceType protocol = null;
502 FileLoader fileLoader = new FileLoader(!headless);
504 String groovyscript = null; // script to execute after all loading is
505 // completed one way or another
506 // extract groovy argument and execute if necessary
507 groovyscript = aparser.getValue("groovy", true);
508 file = aparser.getValue("open", true);
510 if (file == null && desktop == null)
512 System.out.println("No files to open!");
516 // Finally, deal with the remaining input data.
521 desktop.setProgressBar(
523 .getString("status.processing_commandline_args"),
524 progress = System.currentTimeMillis());
526 System.out.println("CMD [-open " + file + "] executed successfully!");
528 if (!Platform.isJS())
530 * ignore in JavaScript -- can't just file existence - could load it?
535 if (!HttpUtils.startsWithHttpOrHttps(file))
537 if (!(new File(file)).exists())
539 System.out.println("Can't find " + file);
548 protocol = AppletFormatAdapter.checkProtocol(file);
552 format = new IdentifyFile().identify(file, protocol);
553 } catch (FileFormatException e1)
558 AlignFrame af = fileLoader.LoadFileWaitTillLoaded(file, protocol,
562 System.out.println("error");
566 setCurrentAlignFrame(af);
567 data = aparser.getValue("colour", true);
570 data.replaceAll("%20", " ");
572 ColourSchemeI cs = ColourSchemeProperty.getColourScheme(
573 af.getViewport(), af.getViewport().getAlignment(), data);
578 "CMD [-color " + data + "] executed successfully!");
583 // Must maintain ability to use the groups flag
584 data = aparser.getValue("groups", true);
587 af.parseFeaturesFile(data,
588 AppletFormatAdapter.checkProtocol(data));
589 // System.out.println("Added " + data);
591 "CMD groups[-" + data + "] executed successfully!");
593 data = aparser.getValue("features", true);
596 af.parseFeaturesFile(data,
597 AppletFormatAdapter.checkProtocol(data));
598 // System.out.println("Added " + data);
600 "CMD [-features " + data + "] executed successfully!");
603 data = aparser.getValue("annotations", true);
606 af.loadJalviewDataFile(data, null, null, null);
607 // System.out.println("Added " + data);
609 "CMD [-annotations " + data + "] executed successfully!");
611 // set or clear the sortbytree flag.
612 if (aparser.contains("sortbytree"))
614 af.getViewport().setSortByTree(true);
615 if (af.getViewport().getSortByTree())
617 System.out.println("CMD [-sortbytree] executed successfully!");
620 if (aparser.contains("no-annotation"))
622 af.getViewport().setShowAnnotation(false);
623 if (!af.getViewport().isShowAnnotation())
625 System.out.println("CMD no-annotation executed successfully!");
628 if (aparser.contains("nosortbytree"))
630 af.getViewport().setSortByTree(false);
631 if (!af.getViewport().getSortByTree())
634 .println("CMD [-nosortbytree] executed successfully!");
637 data = aparser.getValue("tree", true);
643 "CMD [-tree " + data + "] executed successfully!");
644 NewickFile nf = new NewickFile(data,
645 AppletFormatAdapter.checkProtocol(data));
647 .setCurrentTree(af.showNewickTree(nf, data).getTree());
648 } catch (IOException ex)
650 System.err.println("Couldn't add tree " + data);
651 ex.printStackTrace(System.err);
654 // TODO - load PDB structure(s) to alignment JAL-629
655 // (associate with identical sequence in alignment, or a specified
657 if (groovyscript != null)
659 // Execute the groovy script after we've done all the rendering stuff
660 // and before any images or figures are generated.
661 System.out.println("Executing script " + groovyscript);
662 executeGroovyScript(groovyscript, af);
663 System.out.println("CMD groovy[" + groovyscript
664 + "] executed successfully!");
667 String imageName = "unnamed.png";
668 while (aparser.getSize() > 1)
670 String outputFormat = aparser.nextValue();
671 file = aparser.nextValue();
673 if (outputFormat.equalsIgnoreCase("png"))
675 af.createPNG(new File(file));
676 imageName = (new File(file)).getName();
677 System.out.println("Creating PNG image: " + file);
680 else if (outputFormat.equalsIgnoreCase("svg"))
682 File imageFile = new File(file);
683 imageName = imageFile.getName();
684 af.createSVG(imageFile);
685 System.out.println("Creating SVG image: " + file);
688 else if (outputFormat.equalsIgnoreCase("html"))
690 File imageFile = new File(file);
691 imageName = imageFile.getName();
692 HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel);
693 htmlSVG.exportHTML(file);
695 System.out.println("Creating HTML image: " + file);
698 else if (outputFormat.equalsIgnoreCase("biojsmsa"))
702 System.err.println("The output html file must not be null");
707 BioJsHTMLOutput.refreshVersionInfo(
708 BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
709 } catch (URISyntaxException e)
713 BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel);
714 bjs.exportHTML(file);
716 .println("Creating BioJS MSA Viwer HTML file: " + file);
719 else if (outputFormat.equalsIgnoreCase("imgMap"))
721 af.createImageMap(new File(file), imageName);
722 System.out.println("Creating image map: " + file);
725 else if (outputFormat.equalsIgnoreCase("eps"))
727 File outputFile = new File(file);
729 "Creating EPS file: " + outputFile.getAbsolutePath());
730 af.createEPS(outputFile);
733 FileFormatI outFormat = null;
736 outFormat = FileFormats.getInstance().forName(outputFormat);
737 } catch (Exception formatP)
739 System.out.println("Couldn't parse " + outFormat
740 + " as a valid Jalview format string.");
742 if (outFormat != null)
744 if (!outFormat.isWritable())
747 "This version of Jalview does not support alignment export as "
752 af.saveAlignment(file, outFormat);
753 if (af.isSaveAlignmentSuccessful())
755 System.out.println("Written alignment in "
756 + outFormat.getName() + " format to " + file);
760 System.out.println("Error writing file " + file + " in "
761 + outFormat.getName() + " format!!");
768 while (aparser.getSize() > 0)
770 System.out.println("Unknown arg: " + aparser.nextValue());
774 AlignFrame startUpAlframe = null;
775 // We'll only open the default file if the desktop is visible.
777 // ////////////////////
779 if (!Platform.isJS() && !headless && file == null
780 && Cache.getDefault("SHOW_STARTUP_FILE", true))
787 file = jalview.bin.Cache.getDefault("STARTUP_FILE",
788 jalview.bin.Cache.getDefault("www.jalview.org",
789 "https://www.jalview.org")
790 + "/examples/exampleFile_2_7.jvp");
792 "http://www.jalview.org/examples/exampleFile_2_3.jar") || file.equals(
793 "http://www.jalview.org/examples/exampleFile_2_7.jar"))
795 file.replace("http:", "https:");
796 // hardwire upgrade of the startup file
797 file.replace("_2_3", "_2_7");
798 file.replace("2_7.jar", "2_7.jvp");
799 // and remove the stale setting
800 Cache.removeProperty("STARTUP_FILE");
803 protocol = AppletFormatAdapter.checkProtocol(file);
805 if (file.endsWith(".jar"))
807 format = FileFormat.Jalview;
813 format = new IdentifyFile().identify(file, protocol);
814 } catch (FileFormatException e)
820 startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol,
822 // extract groovy arguments before anything else.
825 // Once all other stuff is done, execute any groovy scripts (in order)
826 if (groovyscript != null)
828 if (Cache.groovyJarsPresent())
830 System.out.println("Executing script " + groovyscript);
831 executeGroovyScript(groovyscript, startUpAlframe);
836 "Sorry. Groovy Support is not available, so ignoring the provided groovy script "
840 // and finally, turn off batch mode indicator - if the desktop still exists
845 desktop.setProgressBar(null, progress);
847 desktop.setInBatchMode(false);
851 private static void setLookAndFeel()
853 // property laf = "crossplatform", "system", "gtk", "metal", "nimbus" or
855 // If not set (or chosen laf fails), use the normal SystemLaF and if on Mac,
857 String lafProp = System.getProperty("laf");
858 String lafSetting = Cache.getDefault("PREFERRED_LAF", null);
864 else if (lafSetting != null)
868 boolean lafSet = false;
871 case "crossplatform":
872 lafSet = setCrossPlatformLookAndFeel();
875 Cache.log.error("Could not set requested laf=" + laf);
879 lafSet = setSystemLookAndFeel();
882 Cache.log.error("Could not set requested laf=" + laf);
886 lafSet = setGtkLookAndFeel();
889 Cache.log.error("Could not set requested laf=" + laf);
893 lafSet = setMetalLookAndFeel();
896 Cache.log.error("Could not set requested laf=" + laf);
900 lafSet = setNimbusLookAndFeel();
903 Cache.log.error("Could not set requested laf=" + laf);
907 lafSet = setQuaquaLookAndFeel();
910 Cache.log.error("Could not set requested laf=" + laf);
914 lafSet = setVaquaLookAndFeel();
917 Cache.log.error("Could not set requested laf=" + laf);
921 lafSet = setMacLookAndFeel();
924 Cache.log.error("Could not set requested laf=" + laf);
930 Cache.log.error("Requested laf=" + laf + " not implemented");
934 setSystemLookAndFeel();
935 if (Platform.isLinux())
937 setMetalLookAndFeel();
939 if (Platform.isMac())
946 private static boolean setCrossPlatformLookAndFeel()
951 UIManager.setLookAndFeel(
952 UIManager.getCrossPlatformLookAndFeelClassName());
954 } catch (Exception ex)
956 Cache.log.error("Unexpected Look and Feel Exception");
957 Cache.log.error(ex.getMessage());
958 Cache.log.debug(Cache.getStackTraceString(ex));
963 private static boolean setSystemLookAndFeel()
968 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
970 } catch (Exception ex)
972 Cache.log.error("Unexpected Look and Feel Exception");
973 Cache.log.error(ex.getMessage());
974 Cache.log.debug(Cache.getStackTraceString(ex));
979 private static boolean setSpecificLookAndFeel(String name,
980 String className, boolean nameStartsWith)
985 for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels())
987 if (info.getName() != null && nameStartsWith
988 ? info.getName().toLowerCase(Locale.ROOT)
989 .startsWith(name.toLowerCase(Locale.ROOT))
990 : info.getName().toLowerCase(Locale.ROOT).equals(name.toLowerCase(Locale.ROOT)))
992 className = info.getClassName();
996 UIManager.setLookAndFeel(className);
998 } catch (Exception ex)
1000 Cache.log.error("Unexpected Look and Feel Exception");
1001 Cache.log.error(ex.getMessage());
1002 Cache.log.debug(Cache.getStackTraceString(ex));
1007 private static boolean setGtkLookAndFeel()
1009 return setSpecificLookAndFeel("gtk",
1010 "com.sun.java.swing.plaf.gtk.GTKLookAndFeel", true);
1013 private static boolean setMetalLookAndFeel()
1015 return setSpecificLookAndFeel("metal",
1016 "javax.swing.plaf.metal.MetalLookAndFeel", false);
1019 private static boolean setNimbusLookAndFeel()
1021 return setSpecificLookAndFeel("nimbus",
1022 "javax.swing.plaf.nimbus.NimbusLookAndFeel", false);
1025 private static boolean setQuaquaLookAndFeel()
1027 return setSpecificLookAndFeel("quaqua",
1028 ch.randelshofer.quaqua.QuaquaManager.getLookAndFeel().getClass()
1033 private static boolean setVaquaLookAndFeel()
1035 return setSpecificLookAndFeel("vaqua",
1036 "org.violetlib.aqua.AquaLookAndFeel", false);
1039 private static boolean setMacLookAndFeel()
1041 boolean set = false;
1042 System.setProperty("com.apple.mrj.application.apple.menu.about.name",
1043 ChannelProperties.getProperty("app_name"));
1044 System.setProperty("apple.laf.useScreenMenuBar", "true");
1045 set = setQuaquaLookAndFeel();
1046 if ((!set) || !UIManager.getLookAndFeel().getClass().toString()
1047 .toLowerCase(Locale.ROOT).contains("quaqua"))
1049 set = setVaquaLookAndFeel();
1054 private static void showUsage()
1057 "Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n"
1058 + "-nodisplay\tRun Jalview without User Interface.\n"
1059 + "-props FILE\tUse the given Jalview properties file instead of users default.\n"
1060 + "-colour COLOURSCHEME\tThe colourscheme to be applied to the alignment\n"
1061 + "-annotations FILE\tAdd precalculated annotations to the alignment.\n"
1062 + "-tree FILE\tLoad the given newick format tree file onto the alignment\n"
1063 + "-features FILE\tUse the given file to mark features on the alignment.\n"
1064 + "-fasta FILE\tCreate alignment file FILE in Fasta format.\n"
1065 + "-clustal FILE\tCreate alignment file FILE in Clustal format.\n"
1066 + "-pfam FILE\tCreate alignment file FILE in PFAM format.\n"
1067 + "-msf FILE\tCreate alignment file FILE in MSF format.\n"
1068 + "-pileup FILE\tCreate alignment file FILE in Pileup format\n"
1069 + "-pir FILE\tCreate alignment file FILE in PIR format.\n"
1070 + "-blc FILE\tCreate alignment file FILE in BLC format.\n"
1071 + "-json FILE\tCreate alignment file FILE in JSON format.\n"
1072 + "-jalview FILE\tCreate alignment file FILE in Jalview format.\n"
1073 + "-png FILE\tCreate PNG image FILE from alignment.\n"
1074 + "-svg FILE\tCreate SVG image FILE from alignment.\n"
1075 + "-html FILE\tCreate HTML file from alignment.\n"
1076 + "-biojsMSA FILE\tCreate BioJS MSA Viewer HTML file from alignment.\n"
1077 + "-imgMap FILE\tCreate HTML file FILE with image map of PNG image.\n"
1078 + "-eps FILE\tCreate EPS file FILE from alignment.\n"
1079 + "-questionnaire URL\tQueries the given URL for information about any Jalview user questionnaires.\n"
1080 + "-noquestionnaire\tTurn off questionnaire check.\n"
1081 + "-nonews\tTurn off check for Jalview news.\n"
1082 + "-nousagestats\tTurn off google analytics tracking for this session.\n"
1083 + "-sortbytree OR -nosortbytree\tEnable or disable sorting of the given alignment by the given tree\n"
1085 // "-setprop PROPERTY=VALUE\tSet the given Jalview property,
1086 // after all other properties files have been read\n\t
1087 // (quote the 'PROPERTY=VALUE' pair to ensure spaces are
1088 // passed in correctly)"
1089 + "-jabaws URL\tSpecify URL for Jabaws services (e.g. for a local installation).\n"
1090 + "-fetchfrom nickname\tQuery nickname for features for the alignments and display them.\n"
1091 + "-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"
1092 + "-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"
1093 + "-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"
1094 + "\n~Read documentation in Application or visit https://www.jalview.org for description of Features and Annotations file~\n\n");
1097 private static void startUsageStats(final Desktop desktop)
1100 * start a User Config prompt asking if we can log usage statistics.
1102 PromptUserConfig prompter = new PromptUserConfig(Desktop.desktop,
1103 "USAGESTATS", "Jalview Usage Statistics",
1104 "Do you want to help make Jalview better by enabling "
1105 + "the collection of usage statistics with Google Analytics ?"
1106 + "\n\n(you can enable or disable usage tracking in the preferences)",
1113 "Initialising googletracker for usage stats.");
1114 Cache.initGoogleTracker();
1115 Cache.log.debug("Tracking enabled.");
1122 Cache.log.debug("Not enabling Google Tracking.");
1125 desktop.addDialogThread(prompter);
1129 * Locate the given string as a file and pass it to the groovy interpreter.
1131 * @param groovyscript
1132 * the script to execute
1133 * @param jalviewContext
1134 * the Jalview Desktop object passed in to the groovy binding as the
1137 private void executeGroovyScript(String groovyscript, AlignFrame af)
1140 * for scripts contained in files
1147 if (groovyscript.trim().equals("STDIN"))
1149 // read from stdin into a tempfile and execute it
1152 tfile = File.createTempFile("jalview", "groovy");
1153 PrintWriter outfile = new PrintWriter(
1154 new OutputStreamWriter(new FileOutputStream(tfile)));
1155 BufferedReader br = new BufferedReader(
1156 new InputStreamReader(System.in));
1158 while ((line = br.readLine()) != null)
1160 outfile.write(line + "\n");
1166 } catch (Exception ex)
1168 System.err.println("Failed to read from STDIN into tempfile "
1169 + ((tfile == null) ? "(tempfile wasn't created)"
1170 : tfile.toString()));
1171 ex.printStackTrace();
1176 sfile = tfile.toURI().toURL();
1177 } catch (Exception x)
1180 "Unexpected Malformed URL Exception for temporary file created from STDIN: "
1182 x.printStackTrace();
1190 sfile = new URI(groovyscript).toURL();
1191 } catch (Exception x)
1193 tfile = new File(groovyscript);
1194 if (!tfile.exists())
1196 System.err.println("File '" + groovyscript + "' does not exist.");
1199 if (!tfile.canRead())
1201 System.err.println("File '" + groovyscript + "' cannot be read.");
1204 if (tfile.length() < 1)
1206 System.err.println("File '" + groovyscript + "' is empty.");
1211 sfile = tfile.getAbsoluteFile().toURI().toURL();
1212 } catch (Exception ex)
1214 System.err.println("Failed to create a file URL for "
1215 + tfile.getAbsoluteFile());
1222 Map<String, java.lang.Object> vbinding = new HashMap<>();
1223 vbinding.put("Jalview", this);
1226 vbinding.put("currentAlFrame", af);
1228 Binding gbinding = new Binding(vbinding);
1229 GroovyScriptEngine gse = new GroovyScriptEngine(new URL[] { sfile });
1230 gse.run(sfile.toString(), gbinding);
1231 if ("STDIN".equals(groovyscript))
1233 // delete temp file that we made -
1234 // only if it was successfully executed
1237 } catch (Exception e)
1239 System.err.println("Exception Whilst trying to execute file " + sfile
1240 + " as a groovy script.");
1241 e.printStackTrace(System.err);
1246 public static boolean isHeadlessMode()
1248 String isheadless = System.getProperty("java.awt.headless");
1249 if (isheadless != null && isheadless.equalsIgnoreCase("true"))
1256 public AlignFrame[] getAlignFrames()
1258 return desktop == null ? new AlignFrame[] { getCurrentAlignFrame() }
1259 : Desktop.getAlignFrames();
1264 * Quit method delegates to Desktop.quit - unless running in headless mode
1265 * when it just ends the JVM
1269 if (desktop != null)
1279 public static AlignFrame getCurrentAlignFrame()
1281 return Jalview.currentAlignFrame;
1284 public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)
1286 Jalview.currentAlignFrame = currentAlignFrame;