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;
40 import java.util.Locale;
42 import java.util.Vector;
43 import java.util.logging.ConsoleHandler;
44 import java.util.logging.Level;
45 import java.util.logging.Logger;
47 import javax.swing.UIManager;
48 import javax.swing.UIManager.LookAndFeelInfo;
50 import com.threerings.getdown.util.LaunchUtil;
52 //import edu.stanford.ejalbert.launching.IBrowserLaunching;
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();
99 Platform.addJ2SDirectDatabaseCall("https://www.jalview.org");
100 Platform.addJ2SDirectDatabaseCall("http://www.jalview.org");
101 Platform.addJ2SDirectDatabaseCall("http://www.compbio.dundee.ac.uk");
102 Platform.addJ2SDirectDatabaseCall("https://www.compbio.dundee.ac.uk");
106 * singleton instance of this class
108 private static Jalview instance;
110 private Desktop desktop;
112 public static AlignFrame currentAlignFrame;
116 if (!Platform.isJS())
123 // grab all the rights we can for the JVM
124 Policy.setPolicy(new Policy()
127 public PermissionCollection getPermissions(CodeSource codesource)
129 Permissions perms = new Permissions();
130 perms.add(new AllPermission());
135 public void refresh()
143 * keep track of feature fetching tasks.
151 * TODO: generalise to track all jalview events to orchestrate batch processing
155 private int queued = 0;
157 private int running = 0;
159 public FeatureFetcher()
164 public void addFetcher(final AlignFrame af,
165 final Vector<String> dasSources)
167 final long id = System.currentTimeMillis();
169 final FeatureFetcher us = this;
170 new Thread(new Runnable()
182 af.setProgressBar(MessageManager
183 .getString("status.das_features_being_retrived"), id);
184 af.featureSettings_actionPerformed(null);
185 af.setProgressBar(null, id);
194 public synchronized boolean allFinished()
196 return queued == 0 && running == 0;
201 public static Jalview getInstance()
207 * main class for Jalview application
210 * open <em>filename</em>
212 public static void main(String[] args)
214 // setLogging(); // BH - for event debugging in JavaScript
215 instance = new Jalview();
216 instance.doMain(args);
219 private static void logClass(String name)
221 // BH - for event debugging in JavaScript
222 ConsoleHandler consoleHandler = new ConsoleHandler();
223 consoleHandler.setLevel(Level.ALL);
224 Logger logger = Logger.getLogger(name);
225 logger.setLevel(Level.ALL);
226 logger.addHandler(consoleHandler);
229 @SuppressWarnings("unused")
230 private static void setLogging()
238 System.out.println("not in js");
241 // BH - for event debugging in JavaScript (Java mode only)
242 if (!Platform.isJS())
249 Logger.getLogger("").setLevel(Level.ALL);
250 logClass("java.awt.EventDispatchThread");
251 logClass("java.awt.EventQueue");
252 logClass("java.awt.Component");
253 logClass("java.awt.focus.Component");
254 logClass("java.awt.focus.DefaultKeyboardFocusManager");
262 void doMain(String[] args)
265 if (!Platform.isJS())
267 System.setSecurityManager(null);
271 .println("Java version: " + System.getProperty("java.version"));
272 System.out.println("Java Home: " + System.getProperty("java.home"));
273 System.out.println(System.getProperty("os.arch") + " "
274 + System.getProperty("os.name") + " "
275 + System.getProperty("os.version"));
276 String val = System.getProperty("sys.install4jVersion");
279 System.out.println("Install4j version: " + val);
281 val = System.getProperty("installer_template_version");
284 System.out.println("Install4j template version: " + val);
286 val = System.getProperty("launcher_version");
289 System.out.println("Launcher version: " + val);
292 // report Jalview version
293 Cache.loadBuildProperties(true);
295 ArgsParser aparser = new ArgsParser(args);
296 boolean headless = false;
298 String usrPropsFile = aparser.getValue("props");
299 Cache.loadProperties(usrPropsFile); // must do this before
300 if (usrPropsFile != null)
303 "CMD [-props " + usrPropsFile + "] executed successfully!");
306 if (!Platform.isJS())
313 if (aparser.contains("help") || aparser.contains("h"))
318 if (aparser.contains("nodisplay") || aparser.contains("nogui")
319 || aparser.contains("headless"))
321 System.setProperty("java.awt.headless", "true");
326 // allow https handshakes to download intermediate certs if necessary
327 System.setProperty("com.sun.security.enableAIAcaIssuers", "true");
329 final String jabawsUrl = aparser.getValue("jabaws");
330 if (jabawsUrl != null)
334 Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl);
336 "CMD [-jabaws " + jabawsUrl + "] executed successfully!");
337 } catch (MalformedURLException e)
340 "Invalid jabaws parameter: " + jabawsUrl + " ignored");
345 String defs = aparser.getValue("setprop");
348 int p = defs.indexOf('=');
351 System.err.println("Ignoring invalid setprop argument : " + defs);
355 System.out.println("Executing setprop argument: " + defs);
358 Cache.setProperty(defs.substring(0, p), defs.substring(p + 1));
360 // DISABLED FOR SECURITY REASONS
361 // TODO: add a property to allow properties to be overriden by cli args
362 // Cache.setProperty(defs.substring(0,p), defs.substring(p+1));
364 defs = aparser.getValue("setprop");
366 if (System.getProperty("java.awt.headless") != null
367 && System.getProperty("java.awt.headless").equals("true"))
371 System.setProperty("http.agent",
372 "Jalview Desktop/" + Cache.getDefault("VERSION", "Unknown"));
376 Console.initLogger();
377 } catch (NoClassDefFoundError error)
379 error.printStackTrace();
380 System.out.println("\nEssential logging libraries not found."
381 + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview");
390 * configure 'full' SO model if preferences say to, else use the default (full SO)
391 * - as JS currently doesn't have OBO parsing, it must use 'Lite' version
393 boolean soDefault = !Platform.isJS();
394 if (Cache.getDefault("USE_FULL_SO", soDefault))
396 SequenceOntologyFactory.setInstance(new SequenceOntology());
401 Desktop.nosplash = aparser.contains("nosplash");
402 desktop = new Desktop();
403 desktop.setInBatchMode(true); // indicate we are starting up
407 JalviewTaskbar.setTaskbar(this);
408 } catch (Exception e)
410 Console.info("Cannot set Taskbar");
411 Console.error(e.getMessage());
412 // e.printStackTrace();
413 } catch (Throwable t)
415 Console.info("Cannot set Taskbar");
416 Console.error(t.getMessage());
417 // t.printStackTrace();
420 // set Proxy settings before all the internet calls
421 Cache.setProxyPropertiesFromPreferences();
423 desktop.setVisible(true);
425 if (!Platform.isJS())
432 if (!aparser.contains("nowebservicediscovery"))
434 desktop.startServiceDiscovery();
436 if (!aparser.contains("nousagestats"))
438 startUsageStats(desktop);
442 System.err.println("CMD [-nousagestats] executed successfully!");
445 if (!aparser.contains("noquestionnaire"))
447 String url = aparser.getValue("questionnaire");
450 // Start the desktop questionnaire prompter with the specified
452 Console.debug("Starting questionnaire url at " + url);
453 desktop.checkForQuestionnaire(url);
454 System.out.println("CMD questionnaire[-" + url
455 + "] executed successfully!");
459 if (Cache.getProperty("NOQUESTIONNAIRES") == null)
461 // Start the desktop questionnaire prompter with the specified
464 // "http://anaplog.compbio.dundee.ac.uk/cgi-bin/questionnaire.pl";
466 String defurl = "https://www.jalview.org/cgi-bin/questionnaire.pl";
468 "Starting questionnaire with default url: " + defurl);
469 desktop.checkForQuestionnaire(defurl);
476 .println("CMD [-noquestionnaire] executed successfully!");
479 if (!aparser.contains("nonews")
480 || Cache.getProperty("NONEWS") == null)
482 desktop.checkForNews();
485 if (!aparser.contains("nohtmltemplates")
486 || Cache.getProperty("NOHTMLTEMPLATES") == null)
488 BioJsHTMLOutput.updateBioJS();
493 // Move any new getdown-launcher-new.jar into place over old
494 // getdown-launcher.jar
495 String appdirString = System.getProperty("getdownappdir");
496 if (appdirString != null && appdirString.length() > 0)
498 final File appdir = new File(appdirString);
504 LaunchUtil.upgradeGetdown(
505 new File(appdir, "getdown-launcher-old.jar"),
506 new File(appdir, "getdown-launcher.jar"),
507 new File(appdir, "getdown-launcher-new.jar"));
512 String file = null, data = null;
513 FileFormatI format = null;
514 DataSourceType protocol = null;
515 FileLoader fileLoader = new FileLoader(!headless);
517 String groovyscript = null; // script to execute after all loading is
518 // completed one way or another
519 // extract groovy argument and execute if necessary
520 groovyscript = aparser.getValue("groovy", true);
521 file = aparser.getValue("open", true);
523 if (file == null && desktop == null)
525 System.out.println("No files to open!");
529 // Finally, deal with the remaining input data.
534 desktop.setProgressBar(
536 .getString("status.processing_commandline_args"),
537 progress = System.currentTimeMillis());
539 System.out.println("CMD [-open " + file + "] executed successfully!");
541 if (!Platform.isJS())
543 * ignore in JavaScript -- can't just file existence - could load it?
548 if (!HttpUtils.startsWithHttpOrHttps(file))
550 if (!(new File(file)).exists())
552 System.out.println("Can't find " + file);
561 protocol = AppletFormatAdapter.checkProtocol(file);
565 format = new IdentifyFile().identify(file, protocol);
566 } catch (FileFormatException e1)
571 AlignFrame af = fileLoader.LoadFileWaitTillLoaded(file, protocol,
575 System.out.println("error");
579 setCurrentAlignFrame(af);
580 data = aparser.getValue("colour", true);
583 data.replaceAll("%20", " ");
585 ColourSchemeI cs = ColourSchemeProperty.getColourScheme(
586 af.getViewport(), af.getViewport().getAlignment(), data);
591 "CMD [-color " + data + "] executed successfully!");
596 // Must maintain ability to use the groups flag
597 data = aparser.getValue("groups", true);
600 af.parseFeaturesFile(data,
601 AppletFormatAdapter.checkProtocol(data));
602 // System.out.println("Added " + data);
604 "CMD groups[-" + data + "] executed successfully!");
606 data = aparser.getValue("features", true);
609 af.parseFeaturesFile(data,
610 AppletFormatAdapter.checkProtocol(data));
611 // System.out.println("Added " + data);
613 "CMD [-features " + data + "] executed successfully!");
616 data = aparser.getValue("annotations", true);
619 af.loadJalviewDataFile(data, null, null, null);
620 // System.out.println("Added " + data);
622 "CMD [-annotations " + data + "] executed successfully!");
624 // set or clear the sortbytree flag.
625 if (aparser.contains("sortbytree"))
627 af.getViewport().setSortByTree(true);
628 if (af.getViewport().getSortByTree())
630 System.out.println("CMD [-sortbytree] executed successfully!");
633 if (aparser.contains("no-annotation"))
635 af.getViewport().setShowAnnotation(false);
636 if (!af.getViewport().isShowAnnotation())
638 System.out.println("CMD no-annotation executed successfully!");
641 if (aparser.contains("nosortbytree"))
643 af.getViewport().setSortByTree(false);
644 if (!af.getViewport().getSortByTree())
647 .println("CMD [-nosortbytree] executed successfully!");
650 data = aparser.getValue("tree", true);
656 "CMD [-tree " + data + "] executed successfully!");
657 NewickFile nf = new NewickFile(data,
658 AppletFormatAdapter.checkProtocol(data));
660 .setCurrentTree(af.showNewickTree(nf, data).getTree());
661 } catch (IOException ex)
663 System.err.println("Couldn't add tree " + data);
664 ex.printStackTrace(System.err);
667 // TODO - load PDB structure(s) to alignment JAL-629
668 // (associate with identical sequence in alignment, or a specified
670 if (groovyscript != null)
672 // Execute the groovy script after we've done all the rendering stuff
673 // and before any images or figures are generated.
674 System.out.println("Executing script " + groovyscript);
675 executeGroovyScript(groovyscript, af);
676 System.out.println("CMD groovy[" + groovyscript
677 + "] executed successfully!");
680 String imageName = "unnamed.png";
681 while (aparser.getSize() > 1)
683 String outputFormat = aparser.nextValue();
684 file = aparser.nextValue();
686 if (outputFormat.equalsIgnoreCase("png"))
688 af.createPNG(new File(file));
689 imageName = (new File(file)).getName();
690 System.out.println("Creating PNG image: " + file);
693 else if (outputFormat.equalsIgnoreCase("svg"))
695 File imageFile = new File(file);
696 imageName = imageFile.getName();
697 af.createSVG(imageFile);
698 System.out.println("Creating SVG image: " + file);
701 else if (outputFormat.equalsIgnoreCase("html"))
703 File imageFile = new File(file);
704 imageName = imageFile.getName();
705 HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel);
706 htmlSVG.exportHTML(file);
708 System.out.println("Creating HTML image: " + file);
711 else if (outputFormat.equalsIgnoreCase("biojsmsa"))
715 System.err.println("The output html file must not be null");
720 BioJsHTMLOutput.refreshVersionInfo(
721 BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
722 } catch (URISyntaxException e)
726 BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel);
727 bjs.exportHTML(file);
729 .println("Creating BioJS MSA Viwer HTML file: " + file);
732 else if (outputFormat.equalsIgnoreCase("imgMap"))
734 af.createImageMap(new File(file), imageName);
735 System.out.println("Creating image map: " + file);
738 else if (outputFormat.equalsIgnoreCase("eps"))
740 File outputFile = new File(file);
742 "Creating EPS file: " + outputFile.getAbsolutePath());
743 af.createEPS(outputFile);
746 FileFormatI outFormat = null;
749 outFormat = FileFormats.getInstance().forName(outputFormat);
750 } catch (Exception formatP)
752 System.out.println("Couldn't parse " + outFormat
753 + " as a valid Jalview format string.");
755 if (outFormat != null)
757 if (!outFormat.isWritable())
760 "This version of Jalview does not support alignment export as "
765 af.saveAlignment(file, outFormat);
766 if (af.isSaveAlignmentSuccessful())
768 System.out.println("Written alignment in "
769 + outFormat.getName() + " format to " + file);
773 System.out.println("Error writing file " + file + " in "
774 + outFormat.getName() + " format!!");
781 while (aparser.getSize() > 0)
783 System.out.println("Unknown arg: " + aparser.nextValue());
787 AlignFrame startUpAlframe = null;
788 // We'll only open the default file if the desktop is visible.
790 // ////////////////////
792 if (!Platform.isJS() && !headless && file == null
793 && Cache.getDefault("SHOW_STARTUP_FILE", true))
800 file = Cache.getDefault("STARTUP_FILE",
801 Cache.getDefault("www.jalview.org", "https://www.jalview.org")
802 + "/examples/exampleFile_2_7.jvp");
803 if (file.equals("http://www.jalview.org/examples/exampleFile_2_3.jar")
805 "http://www.jalview.org/examples/exampleFile_2_7.jar"))
807 file.replace("http:", "https:");
808 // hardwire upgrade of the startup file
809 file.replace("_2_3", "_2_7");
810 file.replace("2_7.jar", "2_7.jvp");
811 // and remove the stale setting
812 Cache.removeProperty("STARTUP_FILE");
815 protocol = AppletFormatAdapter.checkProtocol(file);
817 if (file.endsWith(".jar"))
819 format = FileFormat.Jalview;
825 format = new IdentifyFile().identify(file, protocol);
826 } catch (FileFormatException e)
832 startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol,
834 // extract groovy arguments before anything else.
837 // Once all other stuff is done, execute any groovy scripts (in order)
838 if (groovyscript != null)
840 if (Cache.groovyJarsPresent())
842 System.out.println("Executing script " + groovyscript);
843 executeGroovyScript(groovyscript, startUpAlframe);
848 "Sorry. Groovy Support is not available, so ignoring the provided groovy script "
852 // and finally, turn off batch mode indicator - if the desktop still exists
857 desktop.setProgressBar(null, progress);
859 desktop.setInBatchMode(false);
863 private static void setLookAndFeel()
865 // property laf = "crossplatform", "system", "gtk", "metal", "nimbus" or
867 // If not set (or chosen laf fails), use the normal SystemLaF and if on Mac,
869 String lafProp = System.getProperty("laf");
870 String lafSetting = Cache.getDefault("PREFERRED_LAF", null);
876 else if (lafSetting != null)
880 boolean lafSet = false;
883 case "crossplatform":
884 lafSet = setCrossPlatformLookAndFeel();
887 Console.error("Could not set requested laf=" + laf);
891 lafSet = setSystemLookAndFeel();
894 Console.error("Could not set requested laf=" + laf);
898 lafSet = setGtkLookAndFeel();
901 Console.error("Could not set requested laf=" + laf);
905 lafSet = setMetalLookAndFeel();
908 Console.error("Could not set requested laf=" + laf);
912 lafSet = setNimbusLookAndFeel();
915 Console.error("Could not set requested laf=" + laf);
919 lafSet = setQuaquaLookAndFeel();
922 Console.error("Could not set requested laf=" + laf);
926 lafSet = setVaquaLookAndFeel();
929 Console.error("Could not set requested laf=" + laf);
933 lafSet = setMacLookAndFeel();
936 Console.error("Could not set requested laf=" + laf);
942 Console.error("Requested laf=" + laf + " not implemented");
946 setSystemLookAndFeel();
947 if (Platform.isLinux())
949 setMetalLookAndFeel();
951 if (Platform.isMac())
958 private static boolean setCrossPlatformLookAndFeel()
963 UIManager.setLookAndFeel(
964 UIManager.getCrossPlatformLookAndFeelClassName());
966 } catch (Exception ex)
968 Console.error("Unexpected Look and Feel Exception");
969 Console.error(ex.getMessage());
970 Console.debug(Cache.getStackTraceString(ex));
975 private static boolean setSystemLookAndFeel()
980 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
982 } catch (Exception ex)
984 Console.error("Unexpected Look and Feel Exception");
985 Console.error(ex.getMessage());
986 Console.debug(Cache.getStackTraceString(ex));
991 private static boolean setSpecificLookAndFeel(String name,
992 String className, boolean nameStartsWith)
997 for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels())
999 if (info.getName() != null && nameStartsWith
1000 ? info.getName().toLowerCase(Locale.ROOT)
1001 .startsWith(name.toLowerCase(Locale.ROOT))
1002 : info.getName().toLowerCase(Locale.ROOT)
1003 .equals(name.toLowerCase(Locale.ROOT)))
1005 className = info.getClassName();
1009 UIManager.setLookAndFeel(className);
1011 } catch (Exception ex)
1013 Console.error("Unexpected Look and Feel Exception");
1014 Console.error(ex.getMessage());
1015 Console.debug(Cache.getStackTraceString(ex));
1020 private static boolean setGtkLookAndFeel()
1022 return setSpecificLookAndFeel("gtk",
1023 "com.sun.java.swing.plaf.gtk.GTKLookAndFeel", true);
1026 private static boolean setMetalLookAndFeel()
1028 return setSpecificLookAndFeel("metal",
1029 "javax.swing.plaf.metal.MetalLookAndFeel", false);
1032 private static boolean setNimbusLookAndFeel()
1034 return setSpecificLookAndFeel("nimbus",
1035 "javax.swing.plaf.nimbus.NimbusLookAndFeel", false);
1038 private static boolean setQuaquaLookAndFeel()
1040 return setSpecificLookAndFeel("quaqua",
1041 ch.randelshofer.quaqua.QuaquaManager.getLookAndFeel().getClass()
1046 private static boolean setVaquaLookAndFeel()
1048 return setSpecificLookAndFeel("vaqua",
1049 "org.violetlib.aqua.AquaLookAndFeel", false);
1052 private static boolean setMacLookAndFeel()
1054 boolean set = false;
1055 System.setProperty("com.apple.mrj.application.apple.menu.about.name",
1056 ChannelProperties.getProperty("app_name"));
1057 System.setProperty("apple.laf.useScreenMenuBar", "true");
1058 set = setQuaquaLookAndFeel();
1059 if ((!set) || !UIManager.getLookAndFeel().getClass().toString()
1060 .toLowerCase(Locale.ROOT).contains("quaqua"))
1062 set = setVaquaLookAndFeel();
1067 private static void showUsage()
1070 "Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n"
1071 + "-nodisplay\tRun Jalview without User Interface.\n"
1072 + "-props FILE\tUse the given Jalview properties file instead of users default.\n"
1073 + "-colour COLOURSCHEME\tThe colourscheme to be applied to the alignment\n"
1074 + "-annotations FILE\tAdd precalculated annotations to the alignment.\n"
1075 + "-tree FILE\tLoad the given newick format tree file onto the alignment\n"
1076 + "-features FILE\tUse the given file to mark features on the alignment.\n"
1077 + "-fasta FILE\tCreate alignment file FILE in Fasta format.\n"
1078 + "-clustal FILE\tCreate alignment file FILE in Clustal format.\n"
1079 + "-pfam FILE\tCreate alignment file FILE in PFAM format.\n"
1080 + "-msf FILE\tCreate alignment file FILE in MSF format.\n"
1081 + "-pileup FILE\tCreate alignment file FILE in Pileup format\n"
1082 + "-pir FILE\tCreate alignment file FILE in PIR format.\n"
1083 + "-blc FILE\tCreate alignment file FILE in BLC format.\n"
1084 + "-json FILE\tCreate alignment file FILE in JSON format.\n"
1085 + "-jalview FILE\tCreate alignment file FILE in Jalview format.\n"
1086 + "-png FILE\tCreate PNG image FILE from alignment.\n"
1087 + "-svg FILE\tCreate SVG image FILE from alignment.\n"
1088 + "-html FILE\tCreate HTML file from alignment.\n"
1089 + "-biojsMSA FILE\tCreate BioJS MSA Viewer HTML file from alignment.\n"
1090 + "-imgMap FILE\tCreate HTML file FILE with image map of PNG image.\n"
1091 + "-eps FILE\tCreate EPS file FILE from alignment.\n"
1092 + "-questionnaire URL\tQueries the given URL for information about any Jalview user questionnaires.\n"
1093 + "-noquestionnaire\tTurn off questionnaire check.\n"
1094 + "-nonews\tTurn off check for Jalview news.\n"
1095 + "-nousagestats\tTurn off google analytics tracking for this session.\n"
1096 + "-sortbytree OR -nosortbytree\tEnable or disable sorting of the given alignment by the given tree\n"
1098 // "-setprop PROPERTY=VALUE\tSet the given Jalview property,
1099 // after all other properties files have been read\n\t
1100 // (quote the 'PROPERTY=VALUE' pair to ensure spaces are
1101 // passed in correctly)"
1102 + "-jabaws URL\tSpecify URL for Jabaws services (e.g. for a local installation).\n"
1103 + "-fetchfrom nickname\tQuery nickname for features for the alignments and display them.\n"
1104 + "-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"
1105 + "-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"
1106 + "-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"
1107 + "\n~Read documentation in Application or visit https://www.jalview.org for description of Features and Annotations file~\n\n");
1110 private static void startUsageStats(final Desktop desktop)
1113 * start a User Config prompt asking if we can log usage statistics.
1115 PromptUserConfig prompter = new PromptUserConfig(Desktop.desktop,
1116 "USAGESTATS", "Jalview Usage Statistics",
1117 "Do you want to help make Jalview better by enabling "
1118 + "the collection of usage statistics with Google Analytics ?"
1119 + "\n\n(you can enable or disable usage tracking in the preferences)",
1126 "Initialising googletracker for usage stats.");
1127 Cache.initGoogleTracker();
1128 Console.debug("Tracking enabled.");
1135 Console.debug("Not enabling Google Tracking.");
1138 desktop.addDialogThread(prompter);
1142 * Locate the given string as a file and pass it to the groovy interpreter.
1144 * @param groovyscript
1145 * the script to execute
1146 * @param jalviewContext
1147 * the Jalview Desktop object passed in to the groovy binding as the
1150 private void executeGroovyScript(String groovyscript, AlignFrame af)
1153 * for scripts contained in files
1160 if (groovyscript.trim().equals("STDIN"))
1162 // read from stdin into a tempfile and execute it
1165 tfile = File.createTempFile("jalview", "groovy");
1166 PrintWriter outfile = new PrintWriter(
1167 new OutputStreamWriter(new FileOutputStream(tfile)));
1168 BufferedReader br = new BufferedReader(
1169 new InputStreamReader(System.in));
1171 while ((line = br.readLine()) != null)
1173 outfile.write(line + "\n");
1179 } catch (Exception ex)
1181 System.err.println("Failed to read from STDIN into tempfile "
1182 + ((tfile == null) ? "(tempfile wasn't created)"
1183 : tfile.toString()));
1184 ex.printStackTrace();
1189 sfile = tfile.toURI().toURL();
1190 } catch (Exception x)
1193 "Unexpected Malformed URL Exception for temporary file created from STDIN: "
1195 x.printStackTrace();
1203 sfile = new URI(groovyscript).toURL();
1204 } catch (Exception x)
1206 tfile = new File(groovyscript);
1207 if (!tfile.exists())
1209 System.err.println("File '" + groovyscript + "' does not exist.");
1212 if (!tfile.canRead())
1214 System.err.println("File '" + groovyscript + "' cannot be read.");
1217 if (tfile.length() < 1)
1219 System.err.println("File '" + groovyscript + "' is empty.");
1224 sfile = tfile.getAbsoluteFile().toURI().toURL();
1225 } catch (Exception ex)
1227 System.err.println("Failed to create a file URL for "
1228 + tfile.getAbsoluteFile());
1235 Map<String, java.lang.Object> vbinding = new HashMap<>();
1236 vbinding.put("Jalview", this);
1239 vbinding.put("currentAlFrame", af);
1241 Binding gbinding = new Binding(vbinding);
1242 GroovyScriptEngine gse = new GroovyScriptEngine(new URL[] { sfile });
1243 gse.run(sfile.toString(), gbinding);
1244 if ("STDIN".equals(groovyscript))
1246 // delete temp file that we made -
1247 // only if it was successfully executed
1250 } catch (Exception e)
1252 System.err.println("Exception Whilst trying to execute file " + sfile
1253 + " as a groovy script.");
1254 e.printStackTrace(System.err);
1259 public static boolean isHeadlessMode()
1261 String isheadless = System.getProperty("java.awt.headless");
1262 if (isheadless != null && isheadless.equalsIgnoreCase("true"))
1269 public AlignFrame[] getAlignFrames()
1271 return desktop == null ? new AlignFrame[] { getCurrentAlignFrame() }
1272 : Desktop.getAlignFrames();
1277 * Quit method delegates to Desktop.quit - unless running in headless mode
1278 * when it just ends the JVM
1282 if (desktop != null)
1292 public static AlignFrame getCurrentAlignFrame()
1294 return Jalview.currentAlignFrame;
1297 public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)
1299 Jalview.currentAlignFrame = currentAlignFrame;