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.io.BufferedReader;
25 import java.io.FileOutputStream;
26 import java.io.IOException;
27 import java.io.InputStreamReader;
28 import java.io.OutputStreamWriter;
29 import java.io.PrintWriter;
30 import java.net.MalformedURLException;
32 import java.net.URISyntaxException;
34 import java.security.AllPermission;
35 import java.security.CodeSource;
36 import java.security.PermissionCollection;
37 import java.security.Permissions;
38 import java.security.Policy;
39 import java.util.HashMap;
41 import java.util.Vector;
42 import java.util.logging.ConsoleHandler;
43 import java.util.logging.Level;
44 import java.util.logging.Logger;
46 import javax.swing.UIManager;
47 import javax.swing.UIManager.LookAndFeelInfo;
49 import com.threerings.getdown.util.LaunchUtil;
51 import groovy.lang.Binding;
52 import groovy.util.GroovyScriptEngine;
53 import jalview.ext.so.SequenceOntology;
54 import jalview.gui.AlignFrame;
55 import jalview.gui.Desktop;
56 import jalview.gui.PromptUserConfig;
57 import jalview.io.AppletFormatAdapter;
58 import jalview.io.BioJsHTMLOutput;
59 import jalview.io.DataSourceType;
60 import jalview.io.FileFormat;
61 import jalview.io.FileFormatException;
62 import jalview.io.FileFormatI;
63 import jalview.io.FileFormats;
64 import jalview.io.FileLoader;
65 import jalview.io.HtmlSvgOutput;
66 import jalview.io.IdentifyFile;
67 import jalview.io.NewickFile;
68 import jalview.io.gff.SequenceOntologyFactory;
69 import jalview.schemes.ColourSchemeI;
70 import jalview.schemes.ColourSchemeProperty;
71 import jalview.util.ChannelProperties;
72 import jalview.util.HttpUtils;
73 import jalview.util.MessageManager;
74 import jalview.util.Platform;
75 import jalview.ws.jws2.Jws2Discoverer;
78 * Main class for Jalview Application <br>
80 * start with: java -classpath "$PATH_TO_LIB$/*:$PATH_TO_CLASSES$" \
83 * or on Windows: java -classpath "$PATH_TO_LIB$/*;$PATH_TO_CLASSES$" \
84 * jalview.bin.Jalview jalview.bin.Jalview
86 * (ensure -classpath arg is quoted to avoid shell expansion of '*' and do not
87 * embellish '*' to e.g. '*.jar')
96 Platform.getURLCommandArguments();
100 * singleton instance of this class
102 private static Jalview instance;
104 private Desktop desktop;
106 public static AlignFrame currentAlignFrame;
110 if (!Platform.isJS())
117 // grab all the rights we can for the JVM
118 Policy.setPolicy(new Policy()
121 public PermissionCollection getPermissions(CodeSource codesource)
123 Permissions perms = new Permissions();
124 perms.add(new AllPermission());
129 public void refresh()
137 * keep track of feature fetching tasks.
145 * TODO: generalise to track all jalview events to orchestrate batch processing
149 private int queued = 0;
151 private int running = 0;
153 public FeatureFetcher()
158 public void addFetcher(final AlignFrame af,
159 final Vector<String> dasSources)
161 final long id = System.currentTimeMillis();
163 final FeatureFetcher us = this;
164 new Thread(new Runnable()
176 af.setProgressBar(MessageManager
177 .getString("status.das_features_being_retrived"), id);
178 af.featureSettings_actionPerformed(null);
179 af.setProgressBar(null, id);
188 public synchronized boolean allFinished()
190 return queued == 0 && running == 0;
195 public static Jalview getInstance()
201 * main class for Jalview application
204 * open <em>filename</em>
206 public static void main(String[] args)
208 // setLogging(); // BH - for event debugging in JavaScript
209 instance = new Jalview();
210 instance.doMain(args);
213 private static void logClass(String name)
215 // BH - for event debugging in JavaScript
216 ConsoleHandler consoleHandler = new ConsoleHandler();
217 consoleHandler.setLevel(Level.ALL);
218 Logger logger = Logger.getLogger(name);
219 logger.setLevel(Level.ALL);
220 logger.addHandler(consoleHandler);
223 @SuppressWarnings("unused")
224 private static void setLogging()
232 System.out.println("not in js");
235 // BH - for event debugging in JavaScript (Java mode only)
236 if (!Platform.isJS())
243 Logger.getLogger("").setLevel(Level.ALL);
244 logClass("java.awt.EventDispatchThread");
245 logClass("java.awt.EventQueue");
246 logClass("java.awt.Component");
247 logClass("java.awt.focus.Component");
248 logClass("java.awt.focus.DefaultKeyboardFocusManager");
256 void doMain(String[] args)
259 if (!Platform.isJS())
261 System.setSecurityManager(null);
265 .println("Java version: " + System.getProperty("java.version"));
266 System.out.println("Java Home: " + System.getProperty("java.home"));
267 System.out.println(System.getProperty("os.arch") + " "
268 + System.getProperty("os.name") + " "
269 + System.getProperty("os.version"));
270 String val = System.getProperty("sys.install4jVersion");
273 System.out.println("Install4j version: " + val);
275 val = System.getProperty("installer_template_version");
278 System.out.println("Install4j template version: " + val);
280 val = System.getProperty("launcher_version");
283 System.out.println("Launcher version: " + val);
286 // report Jalview version
287 Cache.loadBuildProperties(true);
289 ArgsParser aparser = new ArgsParser(args);
290 boolean headless = false;
292 String usrPropsFile = aparser.getValue("props");
293 Cache.loadProperties(usrPropsFile); // must do this before
294 if (usrPropsFile != null)
297 "CMD [-props " + usrPropsFile + "] executed successfully!");
300 if (!Platform.isJS())
307 if (aparser.contains("help") || aparser.contains("h"))
312 if (aparser.contains("nodisplay") || aparser.contains("nogui")
313 || aparser.contains("headless"))
315 System.setProperty("java.awt.headless", "true");
320 final String jabawsUrl = aparser.getValue("jabaws");
321 if (jabawsUrl != null)
325 Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl);
327 "CMD [-jabaws " + jabawsUrl + "] executed successfully!");
328 } catch (MalformedURLException e)
331 "Invalid jabaws parameter: " + jabawsUrl + " ignored");
336 String defs = aparser.getValue("setprop");
339 int p = defs.indexOf('=');
342 System.err.println("Ignoring invalid setprop argument : " + defs);
346 System.out.println("Executing setprop argument: " + defs);
349 Cache.setProperty(defs.substring(0, p), defs.substring(p + 1));
351 // DISABLED FOR SECURITY REASONS
352 // TODO: add a property to allow properties to be overriden by cli args
353 // Cache.setProperty(defs.substring(0,p), defs.substring(p+1));
355 defs = aparser.getValue("setprop");
357 if (System.getProperty("java.awt.headless") != null
358 && System.getProperty("java.awt.headless").equals("true"))
362 System.setProperty("http.agent",
363 "Jalview Desktop/" + Cache.getDefault("VERSION", "Unknown"));
367 } catch (NoClassDefFoundError error)
369 error.printStackTrace();
370 System.out.println("\nEssential logging libraries not found."
371 + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview");
380 * configure 'full' SO model if preferences say to, else use the default (full SO)
381 * - as JS currently doesn't have OBO parsing, it must use 'Lite' version
383 boolean soDefault = !Platform.isJS();
384 if (Cache.getDefault("USE_FULL_SO", soDefault))
386 SequenceOntologyFactory.setInstance(new SequenceOntology());
391 Desktop.nosplash = aparser.contains("nosplash");
392 desktop = new Desktop();
393 desktop.setInBatchMode(true); // indicate we are starting up
397 JalviewTaskbar.setTaskbar(this);
398 } catch (Exception e)
400 Cache.log.info("Cannot set Taskbar");
401 Cache.log.error(e.getMessage());
402 // e.printStackTrace();
403 } catch (Throwable t)
405 Cache.log.info("Cannot set Taskbar");
406 Cache.log.error(t.getMessage());
407 // t.printStackTrace();
410 // set Proxy settings before all the internet calls
411 Cache.setProxyPropertiesFromPreferences();
413 desktop.setVisible(true);
415 if (!Platform.isJS())
422 if (!aparser.contains("nowebservicediscovery"))
424 desktop.startServiceDiscovery();
426 if (!aparser.contains("nousagestats"))
428 startUsageStats(desktop);
432 System.err.println("CMD [-nousagestats] executed successfully!");
435 if (!aparser.contains("noquestionnaire"))
437 String url = aparser.getValue("questionnaire");
440 // Start the desktop questionnaire prompter with the specified
442 Cache.log.debug("Starting questionnaire url at " + url);
443 desktop.checkForQuestionnaire(url);
444 System.out.println("CMD questionnaire[-" + url
445 + "] executed successfully!");
449 if (Cache.getProperty("NOQUESTIONNAIRES") == null)
451 // Start the desktop questionnaire prompter with the specified
454 // "http://anaplog.compbio.dundee.ac.uk/cgi-bin/questionnaire.pl";
456 String defurl = "https://www.jalview.org/cgi-bin/questionnaire.pl";
458 "Starting questionnaire with default url: " + defurl);
459 desktop.checkForQuestionnaire(defurl);
466 .println("CMD [-noquestionnaire] executed successfully!");
469 if (!aparser.contains("nonews"))
471 desktop.checkForNews();
474 BioJsHTMLOutput.updateBioJS();
478 // Move any new getdown-launcher-new.jar into place over old
479 // getdown-launcher.jar
480 String appdirString = System.getProperty("getdownappdir");
481 if (appdirString != null && appdirString.length() > 0)
483 final File appdir = new File(appdirString);
489 LaunchUtil.upgradeGetdown(
490 new File(appdir, "getdown-launcher-old.jar"),
491 new File(appdir, "getdown-launcher.jar"),
492 new File(appdir, "getdown-launcher-new.jar"));
497 String file = null, data = null;
498 FileFormatI format = null;
499 DataSourceType protocol = null;
500 FileLoader fileLoader = new FileLoader(!headless);
502 String groovyscript = null; // script to execute after all loading is
503 // completed one way or another
504 // extract groovy argument and execute if necessary
505 groovyscript = aparser.getValue("groovy", true);
506 file = aparser.getValue("open", true);
508 if (file == null && desktop == null)
510 System.out.println("No files to open!");
514 // Finally, deal with the remaining input data.
519 desktop.setProgressBar(
521 .getString("status.processing_commandline_args"),
522 progress = System.currentTimeMillis());
524 System.out.println("CMD [-open " + file + "] executed successfully!");
526 if (!Platform.isJS())
528 * ignore in JavaScript -- can't just file existence - could load it?
533 if (!HttpUtils.startsWithHttpOrHttps(file))
535 if (!(new File(file)).exists())
537 System.out.println("Can't find " + file);
546 protocol = AppletFormatAdapter.checkProtocol(file);
550 format = new IdentifyFile().identify(file, protocol);
551 } catch (FileFormatException e1)
556 AlignFrame af = fileLoader.LoadFileWaitTillLoaded(file, protocol,
560 System.out.println("error");
564 setCurrentAlignFrame(af);
565 data = aparser.getValue("colour", true);
568 data.replaceAll("%20", " ");
570 ColourSchemeI cs = ColourSchemeProperty.getColourScheme(
571 af.getViewport(), af.getViewport().getAlignment(), data);
576 "CMD [-color " + data + "] executed successfully!");
581 // Must maintain ability to use the groups flag
582 data = aparser.getValue("groups", true);
585 af.parseFeaturesFile(data,
586 AppletFormatAdapter.checkProtocol(data));
587 // System.out.println("Added " + data);
589 "CMD groups[-" + data + "] executed successfully!");
591 data = aparser.getValue("features", true);
594 af.parseFeaturesFile(data,
595 AppletFormatAdapter.checkProtocol(data));
596 // System.out.println("Added " + data);
598 "CMD [-features " + data + "] executed successfully!");
601 data = aparser.getValue("annotations", true);
604 af.loadJalviewDataFile(data, null, null, null);
605 // System.out.println("Added " + data);
607 "CMD [-annotations " + data + "] executed successfully!");
609 // set or clear the sortbytree flag.
610 if (aparser.contains("sortbytree"))
612 af.getViewport().setSortByTree(true);
613 if (af.getViewport().getSortByTree())
615 System.out.println("CMD [-sortbytree] executed successfully!");
618 if (aparser.contains("no-annotation"))
620 af.getViewport().setShowAnnotation(false);
621 if (!af.getViewport().isShowAnnotation())
623 System.out.println("CMD no-annotation executed successfully!");
626 if (aparser.contains("nosortbytree"))
628 af.getViewport().setSortByTree(false);
629 if (!af.getViewport().getSortByTree())
632 .println("CMD [-nosortbytree] executed successfully!");
635 data = aparser.getValue("tree", true);
641 "CMD [-tree " + data + "] executed successfully!");
642 NewickFile nf = new NewickFile(data,
643 AppletFormatAdapter.checkProtocol(data));
645 .setCurrentTree(af.showNewickTree(nf, data).getTree());
646 } catch (IOException ex)
648 System.err.println("Couldn't add tree " + data);
649 ex.printStackTrace(System.err);
652 // TODO - load PDB structure(s) to alignment JAL-629
653 // (associate with identical sequence in alignment, or a specified
655 if (groovyscript != null)
657 // Execute the groovy script after we've done all the rendering stuff
658 // and before any images or figures are generated.
659 System.out.println("Executing script " + groovyscript);
660 executeGroovyScript(groovyscript, af);
661 System.out.println("CMD groovy[" + groovyscript
662 + "] executed successfully!");
665 String imageName = "unnamed.png";
666 while (aparser.getSize() > 1)
668 String outputFormat = aparser.nextValue();
669 file = aparser.nextValue();
671 if (outputFormat.equalsIgnoreCase("png"))
673 af.createPNG(new File(file));
674 imageName = (new File(file)).getName();
675 System.out.println("Creating PNG image: " + file);
678 else if (outputFormat.equalsIgnoreCase("svg"))
680 File imageFile = new File(file);
681 imageName = imageFile.getName();
682 af.createSVG(imageFile);
683 System.out.println("Creating SVG image: " + file);
686 else if (outputFormat.equalsIgnoreCase("html"))
688 File imageFile = new File(file);
689 imageName = imageFile.getName();
690 HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel);
691 htmlSVG.exportHTML(file);
693 System.out.println("Creating HTML image: " + file);
696 else if (outputFormat.equalsIgnoreCase("biojsmsa"))
700 System.err.println("The output html file must not be null");
705 BioJsHTMLOutput.refreshVersionInfo(
706 BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
707 } catch (URISyntaxException e)
711 BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel);
712 bjs.exportHTML(file);
714 .println("Creating BioJS MSA Viwer HTML file: " + file);
717 else if (outputFormat.equalsIgnoreCase("imgMap"))
719 af.createImageMap(new File(file), imageName);
720 System.out.println("Creating image map: " + file);
723 else if (outputFormat.equalsIgnoreCase("eps"))
725 File outputFile = new File(file);
727 "Creating EPS file: " + outputFile.getAbsolutePath());
728 af.createEPS(outputFile);
731 FileFormatI outFormat = null;
734 outFormat = FileFormats.getInstance().forName(outputFormat);
735 } catch (Exception formatP)
737 System.out.println("Couldn't parse " + outFormat
738 + " as a valid Jalview format string.");
740 if (outFormat != null)
742 if (!outFormat.isWritable())
745 "This version of Jalview does not support alignment export as "
750 af.saveAlignment(file, outFormat);
751 if (af.isSaveAlignmentSuccessful())
753 System.out.println("Written alignment in "
754 + outFormat.getName() + " format to " + file);
758 System.out.println("Error writing file " + file + " in "
759 + outFormat.getName() + " format!!");
766 while (aparser.getSize() > 0)
768 System.out.println("Unknown arg: " + aparser.nextValue());
772 AlignFrame startUpAlframe = null;
773 // We'll only open the default file if the desktop is visible.
775 // ////////////////////
777 if (!Platform.isJS() && !headless && file == null
778 && Cache.getDefault("SHOW_STARTUP_FILE", true))
785 file = jalview.bin.Cache.getDefault("STARTUP_FILE",
786 jalview.bin.Cache.getDefault("www.jalview.org",
787 "https://www.jalview.org")
788 + "/examples/exampleFile_2_7.jvp");
790 "http://www.jalview.org/examples/exampleFile_2_3.jar") || file.equals(
791 "http://www.jalview.org/examples/exampleFile_2_7.jar"))
793 file.replace("http:", "https:");
794 // hardwire upgrade of the startup file
795 file.replace("_2_3", "_2_7");
796 file.replace("2_7.jar", "2_7.jvp");
797 // and remove the stale setting
798 Cache.removeProperty("STARTUP_FILE");
801 protocol = AppletFormatAdapter.checkProtocol(file);
803 if (file.endsWith(".jar"))
805 format = FileFormat.Jalview;
811 format = new IdentifyFile().identify(file, protocol);
812 } catch (FileFormatException e)
818 startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol,
820 // extract groovy arguments before anything else.
823 // Once all other stuff is done, execute any groovy scripts (in order)
824 if (groovyscript != null)
826 if (Cache.groovyJarsPresent())
828 System.out.println("Executing script " + groovyscript);
829 executeGroovyScript(groovyscript, startUpAlframe);
834 "Sorry. Groovy Support is not available, so ignoring the provided groovy script "
838 // and finally, turn off batch mode indicator - if the desktop still exists
843 desktop.setProgressBar(null, progress);
845 desktop.setInBatchMode(false);
849 private static void setLookAndFeel()
851 // property laf = "crossplatform", "system", "gtk", "metal", "nimbus" or
853 // If not set (or chosen laf fails), use the normal SystemLaF and if on Mac,
855 String lafProp = System.getProperty("laf");
856 String lafSetting = Cache.getDefault("PREFERRED_LAF", null);
862 else if (lafSetting != null)
866 boolean lafSet = false;
869 case "crossplatform":
870 lafSet = setCrossPlatformLookAndFeel();
873 Cache.log.error("Could not set requested laf=" + laf);
877 lafSet = setSystemLookAndFeel();
880 Cache.log.error("Could not set requested laf=" + laf);
884 lafSet = setGtkLookAndFeel();
887 Cache.log.error("Could not set requested laf=" + laf);
891 lafSet = setMetalLookAndFeel();
894 Cache.log.error("Could not set requested laf=" + laf);
898 lafSet = setNimbusLookAndFeel();
901 Cache.log.error("Could not set requested laf=" + laf);
905 lafSet = setQuaquaLookAndFeel();
908 Cache.log.error("Could not set requested laf=" + laf);
912 lafSet = setVaquaLookAndFeel();
915 Cache.log.error("Could not set requested laf=" + laf);
919 lafSet = setMacLookAndFeel();
922 Cache.log.error("Could not set requested laf=" + laf);
928 Cache.log.error("Requested laf=" + laf + " not implemented");
932 setSystemLookAndFeel();
933 if (Platform.isLinux())
935 setMetalLookAndFeel();
937 if (Platform.isMac())
944 private static boolean setCrossPlatformLookAndFeel()
949 UIManager.setLookAndFeel(
950 UIManager.getCrossPlatformLookAndFeelClassName());
952 } catch (Exception ex)
954 Cache.log.error("Unexpected Look and Feel Exception");
955 Cache.log.error(ex.getMessage());
956 Cache.log.debug(Cache.getStackTraceString(ex));
961 private static boolean setSystemLookAndFeel()
966 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
968 } catch (Exception ex)
970 Cache.log.error("Unexpected Look and Feel Exception");
971 Cache.log.error(ex.getMessage());
972 Cache.log.debug(Cache.getStackTraceString(ex));
977 private static boolean setSpecificLookAndFeel(String name,
978 String className, boolean nameStartsWith)
983 for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels())
985 if (info.getName() != null && nameStartsWith
986 ? info.getName().toLowerCase()
987 .startsWith(name.toLowerCase())
988 : info.getName().toLowerCase().equals(name.toLowerCase()))
990 className = info.getClassName();
994 UIManager.setLookAndFeel(className);
996 } catch (Exception ex)
998 Cache.log.error("Unexpected Look and Feel Exception");
999 Cache.log.error(ex.getMessage());
1000 Cache.log.debug(Cache.getStackTraceString(ex));
1005 private static boolean setGtkLookAndFeel()
1007 return setSpecificLookAndFeel("gtk",
1008 "com.sun.java.swing.plaf.gtk.GTKLookAndFeel", true);
1011 private static boolean setMetalLookAndFeel()
1013 return setSpecificLookAndFeel("metal",
1014 "javax.swing.plaf.metal.MetalLookAndFeel", false);
1017 private static boolean setNimbusLookAndFeel()
1019 return setSpecificLookAndFeel("nimbus",
1020 "javax.swing.plaf.nimbus.NimbusLookAndFeel", false);
1023 private static boolean setQuaquaLookAndFeel()
1025 return setSpecificLookAndFeel("quaqua",
1026 ch.randelshofer.quaqua.QuaquaManager.getLookAndFeel().getClass()
1031 private static boolean setVaquaLookAndFeel()
1033 return setSpecificLookAndFeel("vaqua",
1034 "org.violetlib.aqua.AquaLookAndFeel", false);
1037 private static boolean setMacLookAndFeel()
1039 boolean set = false;
1040 System.setProperty("com.apple.mrj.application.apple.menu.about.name",
1041 ChannelProperties.getProperty("app_name"));
1042 System.setProperty("apple.laf.useScreenMenuBar", "true");
1043 set = setQuaquaLookAndFeel();
1044 if ((!set) || !UIManager.getLookAndFeel().getClass().toString()
1045 .toLowerCase().contains("quaqua"))
1047 set = setVaquaLookAndFeel();
1052 private static void showUsage()
1055 "Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n"
1056 + "-nodisplay\tRun Jalview without User Interface.\n"
1057 + "-props FILE\tUse the given Jalview properties file instead of users default.\n"
1058 + "-colour COLOURSCHEME\tThe colourscheme to be applied to the alignment\n"
1059 + "-annotations FILE\tAdd precalculated annotations to the alignment.\n"
1060 + "-tree FILE\tLoad the given newick format tree file onto the alignment\n"
1061 + "-features FILE\tUse the given file to mark features on the alignment.\n"
1062 + "-fasta FILE\tCreate alignment file FILE in Fasta format.\n"
1063 + "-clustal FILE\tCreate alignment file FILE in Clustal format.\n"
1064 + "-pfam FILE\tCreate alignment file FILE in PFAM format.\n"
1065 + "-msf FILE\tCreate alignment file FILE in MSF format.\n"
1066 + "-pileup FILE\tCreate alignment file FILE in Pileup format\n"
1067 + "-pir FILE\tCreate alignment file FILE in PIR format.\n"
1068 + "-blc FILE\tCreate alignment file FILE in BLC format.\n"
1069 + "-json FILE\tCreate alignment file FILE in JSON format.\n"
1070 + "-jalview FILE\tCreate alignment file FILE in Jalview format.\n"
1071 + "-png FILE\tCreate PNG image FILE from alignment.\n"
1072 + "-svg FILE\tCreate SVG image FILE from alignment.\n"
1073 + "-html FILE\tCreate HTML file from alignment.\n"
1074 + "-biojsMSA FILE\tCreate BioJS MSA Viewer HTML file from alignment.\n"
1075 + "-imgMap FILE\tCreate HTML file FILE with image map of PNG image.\n"
1076 + "-eps FILE\tCreate EPS file FILE from alignment.\n"
1077 + "-questionnaire URL\tQueries the given URL for information about any Jalview user questionnaires.\n"
1078 + "-noquestionnaire\tTurn off questionnaire check.\n"
1079 + "-nonews\tTurn off check for Jalview news.\n"
1080 + "-nousagestats\tTurn off google analytics tracking for this session.\n"
1081 + "-sortbytree OR -nosortbytree\tEnable or disable sorting of the given alignment by the given tree\n"
1083 // "-setprop PROPERTY=VALUE\tSet the given Jalview property,
1084 // after all other properties files have been read\n\t
1085 // (quote the 'PROPERTY=VALUE' pair to ensure spaces are
1086 // passed in correctly)"
1087 + "-jabaws URL\tSpecify URL for Jabaws services (e.g. for a local installation).\n"
1088 + "-fetchfrom nickname\tQuery nickname for features for the alignments and display them.\n"
1089 + "-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"
1090 + "-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"
1091 + "-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"
1092 + "\n~Read documentation in Application or visit https://www.jalview.org for description of Features and Annotations file~\n\n");
1095 private static void startUsageStats(final Desktop desktop)
1098 * start a User Config prompt asking if we can log usage statistics.
1100 PromptUserConfig prompter = new PromptUserConfig(Desktop.desktop,
1101 "USAGESTATS", "Jalview Usage Statistics",
1102 "Do you want to help make Jalview better by enabling "
1103 + "the collection of usage statistics with Google Analytics ?"
1104 + "\n\n(you can enable or disable usage tracking in the preferences)",
1111 "Initialising googletracker for usage stats.");
1112 Cache.initGoogleTracker();
1113 Cache.log.debug("Tracking enabled.");
1120 Cache.log.debug("Not enabling Google Tracking.");
1123 desktop.addDialogThread(prompter);
1127 * Locate the given string as a file and pass it to the groovy interpreter.
1129 * @param groovyscript
1130 * the script to execute
1131 * @param jalviewContext
1132 * the Jalview Desktop object passed in to the groovy binding as the
1135 private void executeGroovyScript(String groovyscript, AlignFrame af)
1138 * for scripts contained in files
1145 if (groovyscript.trim().equals("STDIN"))
1147 // read from stdin into a tempfile and execute it
1150 tfile = File.createTempFile("jalview", "groovy");
1151 PrintWriter outfile = new PrintWriter(
1152 new OutputStreamWriter(new FileOutputStream(tfile)));
1153 BufferedReader br = new BufferedReader(
1154 new InputStreamReader(System.in));
1156 while ((line = br.readLine()) != null)
1158 outfile.write(line + "\n");
1164 } catch (Exception ex)
1166 System.err.println("Failed to read from STDIN into tempfile "
1167 + ((tfile == null) ? "(tempfile wasn't created)"
1168 : tfile.toString()));
1169 ex.printStackTrace();
1174 sfile = tfile.toURI().toURL();
1175 } catch (Exception x)
1178 "Unexpected Malformed URL Exception for temporary file created from STDIN: "
1180 x.printStackTrace();
1188 sfile = new URI(groovyscript).toURL();
1189 } catch (Exception x)
1191 tfile = new File(groovyscript);
1192 if (!tfile.exists())
1194 System.err.println("File '" + groovyscript + "' does not exist.");
1197 if (!tfile.canRead())
1199 System.err.println("File '" + groovyscript + "' cannot be read.");
1202 if (tfile.length() < 1)
1204 System.err.println("File '" + groovyscript + "' is empty.");
1209 sfile = tfile.getAbsoluteFile().toURI().toURL();
1210 } catch (Exception ex)
1212 System.err.println("Failed to create a file URL for "
1213 + tfile.getAbsoluteFile());
1220 Map<String, java.lang.Object> vbinding = new HashMap<>();
1221 vbinding.put("Jalview", this);
1224 vbinding.put("currentAlFrame", af);
1226 Binding gbinding = new Binding(vbinding);
1227 GroovyScriptEngine gse = new GroovyScriptEngine(new URL[] { sfile });
1228 gse.run(sfile.toString(), gbinding);
1229 if ("STDIN".equals(groovyscript))
1231 // delete temp file that we made -
1232 // only if it was successfully executed
1235 } catch (Exception e)
1237 System.err.println("Exception Whilst trying to execute file " + sfile
1238 + " as a groovy script.");
1239 e.printStackTrace(System.err);
1244 public static boolean isHeadlessMode()
1246 String isheadless = System.getProperty("java.awt.headless");
1247 if (isheadless != null && isheadless.equalsIgnoreCase("true"))
1254 public AlignFrame[] getAlignFrames()
1256 return desktop == null ? new AlignFrame[] { getCurrentAlignFrame() }
1257 : Desktop.getAlignFrames();
1262 * Quit method delegates to Desktop.quit - unless running in headless mode
1263 * when it just ends the JVM
1267 if (desktop != null)
1277 public static AlignFrame getCurrentAlignFrame()
1279 return Jalview.currentAlignFrame;
1282 public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)
1284 Jalview.currentAlignFrame = currentAlignFrame;