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 = "http://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 = Cache.getDefault("STARTUP_FILE",
786 Cache.getDefault("www.jalview.org", "http://www.jalview.org")
787 + "/examples/exampleFile_2_7.jar");
789 "http://www.jalview.org/examples/exampleFile_2_3.jar"))
791 // hardwire upgrade of the startup file
792 file.replace("_2_3.jar", "_2_7.jar");
793 // and remove the stale setting
794 Cache.removeProperty("STARTUP_FILE");
797 protocol = AppletFormatAdapter.checkProtocol(file);
799 if (file.endsWith(".jar"))
801 format = FileFormat.Jalview;
807 format = new IdentifyFile().identify(file, protocol);
808 } catch (FileFormatException e)
814 startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol,
816 // extract groovy arguments before anything else.
819 // Once all other stuff is done, execute any groovy scripts (in order)
820 if (groovyscript != null)
822 if (Cache.groovyJarsPresent())
824 System.out.println("Executing script " + groovyscript);
825 executeGroovyScript(groovyscript, startUpAlframe);
830 "Sorry. Groovy Support is not available, so ignoring the provided groovy script "
834 // and finally, turn off batch mode indicator - if the desktop still exists
839 desktop.setProgressBar(null, progress);
841 desktop.setInBatchMode(false);
845 private static void setLookAndFeel()
847 // property laf = "crossplatform", "system", "gtk", "metal", "nimbus" or
849 // If not set (or chosen laf fails), use the normal SystemLaF and if on Mac,
851 String lafProp = System.getProperty("laf");
852 String lafSetting = Cache.getDefault("PREFERRED_LAF", null);
858 else if (lafSetting != null)
862 boolean lafSet = false;
865 case "crossplatform":
866 lafSet = setCrossPlatformLookAndFeel();
869 Cache.log.error("Could not set requested laf=" + laf);
873 lafSet = setSystemLookAndFeel();
876 Cache.log.error("Could not set requested laf=" + laf);
880 lafSet = setGtkLookAndFeel();
883 Cache.log.error("Could not set requested laf=" + laf);
887 lafSet = setMetalLookAndFeel();
890 Cache.log.error("Could not set requested laf=" + laf);
894 lafSet = setNimbusLookAndFeel();
897 Cache.log.error("Could not set requested laf=" + laf);
901 lafSet = setQuaquaLookAndFeel();
904 Cache.log.error("Could not set requested laf=" + laf);
908 lafSet = setVaquaLookAndFeel();
911 Cache.log.error("Could not set requested laf=" + laf);
915 lafSet = setMacLookAndFeel();
918 Cache.log.error("Could not set requested laf=" + laf);
924 Cache.log.error("Requested laf=" + laf + " not implemented");
928 setSystemLookAndFeel();
929 if (Platform.isLinux())
931 setMetalLookAndFeel();
933 if (Platform.isMac())
940 private static boolean setCrossPlatformLookAndFeel()
945 UIManager.setLookAndFeel(
946 UIManager.getCrossPlatformLookAndFeelClassName());
948 } catch (Exception ex)
950 Cache.log.error("Unexpected Look and Feel Exception");
951 Cache.log.error(ex.getMessage());
952 Cache.log.debug(Cache.getStackTraceString(ex));
957 private static boolean setSystemLookAndFeel()
962 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
964 } catch (Exception ex)
966 Cache.log.error("Unexpected Look and Feel Exception");
967 Cache.log.error(ex.getMessage());
968 Cache.log.debug(Cache.getStackTraceString(ex));
973 private static boolean setSpecificLookAndFeel(String name,
974 String className, boolean nameStartsWith)
979 for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels())
981 if (info.getName() != null && nameStartsWith
982 ? info.getName().toLowerCase()
983 .startsWith(name.toLowerCase())
984 : info.getName().toLowerCase().equals(name.toLowerCase()))
986 className = info.getClassName();
990 UIManager.setLookAndFeel(className);
992 } catch (Exception ex)
994 Cache.log.error("Unexpected Look and Feel Exception");
995 Cache.log.error(ex.getMessage());
996 Cache.log.debug(Cache.getStackTraceString(ex));
1001 private static boolean setGtkLookAndFeel()
1003 return setSpecificLookAndFeel("gtk",
1004 "com.sun.java.swing.plaf.gtk.GTKLookAndFeel", true);
1007 private static boolean setMetalLookAndFeel()
1009 return setSpecificLookAndFeel("metal",
1010 "javax.swing.plaf.metal.MetalLookAndFeel", false);
1013 private static boolean setNimbusLookAndFeel()
1015 return setSpecificLookAndFeel("nimbus",
1016 "javax.swing.plaf.nimbus.NimbusLookAndFeel", false);
1019 private static boolean setQuaquaLookAndFeel()
1021 return setSpecificLookAndFeel("quaqua",
1022 ch.randelshofer.quaqua.QuaquaManager.getLookAndFeel().getClass()
1027 private static boolean setVaquaLookAndFeel()
1029 return setSpecificLookAndFeel("vaqua",
1030 "org.violetlib.aqua.AquaLookAndFeel", false);
1033 private static boolean setMacLookAndFeel()
1035 boolean set = false;
1036 System.setProperty("com.apple.mrj.application.apple.menu.about.name",
1037 ChannelProperties.getProperty("app_name"));
1038 System.setProperty("apple.laf.useScreenMenuBar", "true");
1039 set = setQuaquaLookAndFeel();
1040 if ((!set) || !UIManager.getLookAndFeel().getClass().toString()
1041 .toLowerCase().contains("quaqua"))
1043 set = setVaquaLookAndFeel();
1048 private static void showUsage()
1051 "Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n"
1052 + "-nodisplay\tRun Jalview without User Interface.\n"
1053 + "-props FILE\tUse the given Jalview properties file instead of users default.\n"
1054 + "-colour COLOURSCHEME\tThe colourscheme to be applied to the alignment\n"
1055 + "-annotations FILE\tAdd precalculated annotations to the alignment.\n"
1056 + "-tree FILE\tLoad the given newick format tree file onto the alignment\n"
1057 + "-features FILE\tUse the given file to mark features on the alignment.\n"
1058 + "-fasta FILE\tCreate alignment file FILE in Fasta format.\n"
1059 + "-clustal FILE\tCreate alignment file FILE in Clustal format.\n"
1060 + "-pfam FILE\tCreate alignment file FILE in PFAM format.\n"
1061 + "-msf FILE\tCreate alignment file FILE in MSF format.\n"
1062 + "-pileup FILE\tCreate alignment file FILE in Pileup format\n"
1063 + "-pir FILE\tCreate alignment file FILE in PIR format.\n"
1064 + "-blc FILE\tCreate alignment file FILE in BLC format.\n"
1065 + "-json FILE\tCreate alignment file FILE in JSON format.\n"
1066 + "-jalview FILE\tCreate alignment file FILE in Jalview format.\n"
1067 + "-png FILE\tCreate PNG image FILE from alignment.\n"
1068 + "-svg FILE\tCreate SVG image FILE from alignment.\n"
1069 + "-html FILE\tCreate HTML file from alignment.\n"
1070 + "-biojsMSA FILE\tCreate BioJS MSA Viewer HTML file from alignment.\n"
1071 + "-imgMap FILE\tCreate HTML file FILE with image map of PNG image.\n"
1072 + "-eps FILE\tCreate EPS file FILE from alignment.\n"
1073 + "-questionnaire URL\tQueries the given URL for information about any Jalview user questionnaires.\n"
1074 + "-noquestionnaire\tTurn off questionnaire check.\n"
1075 + "-nonews\tTurn off check for Jalview news.\n"
1076 + "-nousagestats\tTurn off google analytics tracking for this session.\n"
1077 + "-sortbytree OR -nosortbytree\tEnable or disable sorting of the given alignment by the given tree\n"
1079 // "-setprop PROPERTY=VALUE\tSet the given Jalview property,
1080 // after all other properties files have been read\n\t
1081 // (quote the 'PROPERTY=VALUE' pair to ensure spaces are
1082 // passed in correctly)"
1083 + "-jabaws URL\tSpecify URL for Jabaws services (e.g. for a local installation).\n"
1084 + "-fetchfrom nickname\tQuery nickname for features for the alignments and display them.\n"
1085 + "-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"
1086 + "-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"
1087 + "-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"
1088 + "\n~Read documentation in Application or visit http://www.jalview.org for description of Features and Annotations file~\n\n");
1091 private static void startUsageStats(final Desktop desktop)
1094 * start a User Config prompt asking if we can log usage statistics.
1096 PromptUserConfig prompter = new PromptUserConfig(Desktop.desktop,
1097 "USAGESTATS", "Jalview Usage Statistics",
1098 "Do you want to help make Jalview better by enabling "
1099 + "the collection of usage statistics with Google Analytics ?"
1100 + "\n\n(you can enable or disable usage tracking in the preferences)",
1107 "Initialising googletracker for usage stats.");
1108 Cache.initGoogleTracker();
1109 Cache.log.debug("Tracking enabled.");
1116 Cache.log.debug("Not enabling Google Tracking.");
1119 desktop.addDialogThread(prompter);
1123 * Locate the given string as a file and pass it to the groovy interpreter.
1125 * @param groovyscript
1126 * the script to execute
1127 * @param jalviewContext
1128 * the Jalview Desktop object passed in to the groovy binding as the
1131 private void executeGroovyScript(String groovyscript, AlignFrame af)
1134 * for scripts contained in files
1141 if (groovyscript.trim().equals("STDIN"))
1143 // read from stdin into a tempfile and execute it
1146 tfile = File.createTempFile("jalview", "groovy");
1147 PrintWriter outfile = new PrintWriter(
1148 new OutputStreamWriter(new FileOutputStream(tfile)));
1149 BufferedReader br = new BufferedReader(
1150 new InputStreamReader(System.in));
1152 while ((line = br.readLine()) != null)
1154 outfile.write(line + "\n");
1160 } catch (Exception ex)
1162 System.err.println("Failed to read from STDIN into tempfile "
1163 + ((tfile == null) ? "(tempfile wasn't created)"
1164 : tfile.toString()));
1165 ex.printStackTrace();
1170 sfile = tfile.toURI().toURL();
1171 } catch (Exception x)
1174 "Unexpected Malformed URL Exception for temporary file created from STDIN: "
1176 x.printStackTrace();
1184 sfile = new URI(groovyscript).toURL();
1185 } catch (Exception x)
1187 tfile = new File(groovyscript);
1188 if (!tfile.exists())
1190 System.err.println("File '" + groovyscript + "' does not exist.");
1193 if (!tfile.canRead())
1195 System.err.println("File '" + groovyscript + "' cannot be read.");
1198 if (tfile.length() < 1)
1200 System.err.println("File '" + groovyscript + "' is empty.");
1205 sfile = tfile.getAbsoluteFile().toURI().toURL();
1206 } catch (Exception ex)
1208 System.err.println("Failed to create a file URL for "
1209 + tfile.getAbsoluteFile());
1216 Map<String, java.lang.Object> vbinding = new HashMap<>();
1217 vbinding.put("Jalview", this);
1220 vbinding.put("currentAlFrame", af);
1222 Binding gbinding = new Binding(vbinding);
1223 GroovyScriptEngine gse = new GroovyScriptEngine(new URL[] { sfile });
1224 gse.run(sfile.toString(), gbinding);
1225 if ("STDIN".equals(groovyscript))
1227 // delete temp file that we made -
1228 // only if it was successfully executed
1231 } catch (Exception e)
1233 System.err.println("Exception Whilst trying to execute file " + sfile
1234 + " as a groovy script.");
1235 e.printStackTrace(System.err);
1240 public static boolean isHeadlessMode()
1242 String isheadless = System.getProperty("java.awt.headless");
1243 if (isheadless != null && isheadless.equalsIgnoreCase("true"))
1250 public AlignFrame[] getAlignFrames()
1252 return desktop == null ? new AlignFrame[] { getCurrentAlignFrame() }
1253 : Desktop.getAlignFrames();
1258 * Quit method delegates to Desktop.quit - unless running in headless mode
1259 * when it just ends the JVM
1263 if (desktop != null)
1273 public static AlignFrame getCurrentAlignFrame()
1275 return Jalview.currentAlignFrame;
1278 public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)
1280 Jalview.currentAlignFrame = currentAlignFrame;