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.awt.GraphicsEnvironment;
24 import java.io.BufferedReader;
26 import java.io.FileOutputStream;
27 import java.io.IOException;
28 import java.io.InputStreamReader;
29 import java.io.OutputStreamWriter;
30 import java.io.PrintWriter;
31 import java.net.MalformedURLException;
33 import java.net.URISyntaxException;
35 import java.security.AllPermission;
36 import java.security.CodeSource;
37 import java.security.PermissionCollection;
38 import java.security.Permissions;
39 import java.security.Policy;
40 import java.util.HashMap;
42 import java.util.Vector;
44 import javax.swing.LookAndFeel;
45 import javax.swing.UIManager;
47 import com.threerings.getdown.util.LaunchUtil;
49 import groovy.lang.Binding;
50 import groovy.util.GroovyScriptEngine;
51 import jalview.api.AlignCalcWorkerI;
52 import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
53 import jalview.ext.so.SequenceOntology;
54 import jalview.gui.AlignFrame;
55 import jalview.gui.AlignViewport;
56 import jalview.gui.Desktop;
57 import jalview.gui.Preferences;
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.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')
92 public class Jalview implements ApplicationSingletonI
95 // for testing those nasty messages you cannot ever find.
98 // System.setOut(new PrintStream(new ByteArrayOutputStream())
101 // public void println(Object o)
105 // System.err.println(o);
111 public static Jalview getInstance()
113 return (Jalview) ApplicationSingletonProvider
114 .getInstance(Jalview.class);
121 private boolean headless;
123 private Desktop desktop;
125 public AlignFrame currentAlignFrame;
127 public String appletResourcePath;
129 public String j2sAppletID;
131 private boolean noCalculation, noMenuBar, noStatus;
133 private boolean noAnnotation;
135 public boolean getStartCalculations()
137 return !noCalculation;
140 public boolean getAllowMenuBar()
145 public boolean getShowStatus()
150 public boolean getShowAnnotation()
152 return !noAnnotation;
157 if (Platform.isJS()) {
158 Platform.getURLCommandArguments();
159 } else /** @j2sIgnore */
161 // grab all the rights we can for the JVM
162 Policy.setPolicy(new Policy()
165 public PermissionCollection getPermissions(CodeSource codesource)
167 Permissions perms = new Permissions();
168 perms.add(new AllPermission());
173 public void refresh()
181 * keep track of feature fetching tasks.
189 * TODO: generalise to track all jalview events to orchestrate batch
193 private int queued = 0;
195 private int running = 0;
197 public FeatureFetcher()
202 public void addFetcher(final AlignFrame af,
203 final Vector<String> dasSources)
205 final long id = System.currentTimeMillis();
207 final FeatureFetcher us = this;
208 new Thread(new Runnable()
220 af.setProgressBar(MessageManager
221 .getString("status.das_features_being_retrived"), id);
222 af.featureSettings_actionPerformed(null);
223 af.setProgressBar(null, id);
232 public synchronized boolean allFinished()
234 return queued == 0 && running == 0;
239 private final static boolean doPlatformLogging = false;
242 * main class for Jalview application
245 * open <em>filename</em>
247 public static void main(String[] args)
249 if (doPlatformLogging)
251 Platform.startJavaLogging();
253 getInstance().doMain(args);
259 void doMain(String[] args)
262 boolean isJS = Platform.isJS();
265 System.setSecurityManager(null);
269 * @j2sNative J2S.db._DirectDatabaseCalls["compbio.dundee.ac.uk"]=null;
270 * @j2sNative J2S.db._DirectDatabaseCalls["jalview.org"]=null;
274 .println("Java version: " + System.getProperty("java.version"));
275 System.out.println("Java Home: " + System.getProperty("java.home"));
276 System.out.println(System.getProperty("os.arch") + " "
277 + System.getProperty("os.name") + " "
278 + System.getProperty("os.version"));
279 String val = System.getProperty("sys.install4jVersion");
282 System.out.println("Install4j version: " + val);
284 val = System.getProperty("installer_template_version");
287 System.out.println("Install4j template version: " + val);
289 val = System.getProperty("launcher_version");
292 System.out.println("Launcher version: " + val);
295 // report Jalview version
296 Cache.getInstance().loadBuildProperties(true);
298 ArgsParser aparser = new ArgsParser(args);
301 String usrPropsFile = aparser.getValue("props");
303 Cache.loadProperties(usrPropsFile); // must do this before
305 boolean allowServices = true;
309 j2sAppletID = Platform.getAppID(null);
310 Preferences.setAppletDefaults();
311 Cache.loadProperties(usrPropsFile); // again, because we
312 // might be changing defaults here?
313 appletResourcePath = (String) aparser.getAppletValue("resourcepath",
324 if (usrPropsFile != null)
327 "CMD [-props " + usrPropsFile + "] executed successfully!");
329 if (aparser.contains("help") || aparser.contains("h"))
334 // BH note: Only -nodisplay is official; others are deprecated?
335 if (aparser.contains("nodisplay") || aparser.contains("nogui")
336 || aparser.contains("headless")
337 || GraphicsEnvironment.isHeadless())
340 // BH Definitely not a good idea in JavaScript;
341 // probably should not be here for Java, either.
342 System.setProperty("java.awt.headless", "true");
347 final String jabawsUrl = aparser.getValue(ArgsParser.JABAWS);
348 allowServices = !("none".equals(jabawsUrl));
349 if (allowServices && jabawsUrl != null)
353 Jws2Discoverer.getInstance().setPreferredUrl(jabawsUrl);
355 "CMD [-jabaws " + jabawsUrl + "] executed successfully!");
356 } catch (MalformedURLException e)
359 "Invalid jabaws parameter: " + jabawsUrl + " ignored");
364 String defs = aparser.getValue(ArgsParser.SETPROP);
367 int p = defs.indexOf('=');
370 System.err.println("Ignoring invalid setprop argument : " + defs);
374 System.out.println("Executing setprop argument: " + defs);
377 Cache.setProperty(defs.substring(0, p), defs.substring(p + 1));
380 defs = aparser.getValue("setprop");
382 System.setProperty("http.agent",
383 "Jalview Desktop/" + Cache.getDefault("VERSION", "Unknown"));
387 } catch (NoClassDefFoundError error)
389 error.printStackTrace();
390 System.out.println("\nEssential logging libraries not found."
391 + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview");
400 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
401 } catch (Exception ex)
403 System.err.println("Unexpected Look and Feel Exception");
404 ex.printStackTrace();
406 if (Platform.isMac())
409 LookAndFeel lookAndFeel = ch.randelshofer.quaqua.QuaquaManager
412 "com.apple.mrj.application.apple.menu.about.name",
414 System.setProperty("apple.laf.useScreenMenuBar", "true");
415 if (lookAndFeel != null)
419 UIManager.setLookAndFeel(lookAndFeel);
420 } catch (Throwable e)
423 "Failed to set QuaQua look and feel: " + e.toString());
426 if (lookAndFeel == null
427 || !(lookAndFeel.getClass().isAssignableFrom(
428 UIManager.getLookAndFeel().getClass()))
429 || !UIManager.getLookAndFeel().getClass().toString()
430 .toLowerCase().contains("quaqua"))
435 "Quaqua LaF not available on this plaform. Using VAqua(4).\nSee https://issues.jalview.org/browse/JAL-2976");
436 UIManager.setLookAndFeel("org.violetlib.aqua.AquaLookAndFeel");
437 } catch (Throwable e)
440 "Failed to reset look and feel: " + e.toString());
446 * configure 'full' SO model if preferences say to, else use the default (full SO)
447 * - as JS currently doesn't have OBO parsing, it must use 'Lite' version
449 boolean soDefault = !isJS;
450 if (Cache.getDefault("USE_FULL_SO", soDefault))
452 SequenceOntologyFactory.setSequenceOntology(new SequenceOntology());
459 desktop = Desktop.getInstance();
460 desktop.setInBatchMode(true); // indicate we are starting up
463 JalviewTaskbar.setTaskbar(this);
464 } catch (Throwable t)
466 System.out.println("Error setting Taskbar: " + t.getMessage());
468 desktop.setVisible(true);
470 Cache.setProperty("SHOW_JWS2_SERVICES", "false");
473 desktop.startServiceDiscovery();
482 if (!aparser.contains("nousagestats"))
484 startUsageStats(desktop);
488 System.err.println("CMD [-nousagestats] executed successfully!");
491 if (!aparser.contains("noquestionnaire"))
493 String url = aparser.getValue("questionnaire");
496 // Start the desktop questionnaire prompter with the specified
498 Cache.log.debug("Starting questionnaire url at " + url);
499 desktop.checkForQuestionnaire(url);
500 System.out.println("CMD questionnaire[-" + url
501 + "] executed successfully!");
505 if (Cache.getProperty("NOQUESTIONNAIRES") == null)
507 // Start the desktop questionnaire prompter with the specified
510 // "http://anaplog.compbio.dundee.ac.uk/cgi-bin/questionnaire.pl";
512 String defurl = "http://www.jalview.org/cgi-bin/questionnaire.pl";
514 "Starting questionnaire with default url: " + defurl);
515 desktop.checkForQuestionnaire(defurl);
522 .println("CMD [-noquestionnaire] executed successfully!");
525 if (!aparser.contains("nonews"))
527 desktop.checkForNews();
530 BioJsHTMLOutput.updateBioJS();
533 parseArguments(aparser, true);
537 * Parse all command-line String[] arguments as well as all JavaScript-derived
538 * parameters from Info.
540 * We allow for this method to be run from JavaScript. Basically allowing
546 public void parseArguments(ArgsParser aparser, boolean isStartup)
549 String groovyscript = null; // script to execute after all loading is
550 boolean isJS = Platform.isJS();
554 // Move any new getdown-launcher-new.jar into place over old
555 // getdown-launcher.jar
556 String appdirString = System.getProperty("getdownappdir");
557 if (appdirString != null && appdirString.length() > 0)
559 final File appdir = new File(appdirString);
565 LaunchUtil.upgradeGetdown(
566 new File(appdir, "getdown-launcher-old.jar"),
567 new File(appdir, "getdown-launcher.jar"),
568 new File(appdir, "getdown-launcher-new.jar"));
573 // completed one way or another
574 // extract groovy argument and execute if necessary
575 groovyscript = aparser.getValue("groovy", true);
579 String file = aparser.getValue("open", true);
581 if (!isJS && file == null && desktop == null)
583 System.out.println("No files to open!");
587 setDisplayParameters(aparser);
589 // time to open a file.
592 DataSourceType protocol = null;
593 FileLoader fileLoader = new FileLoader(!headless);
594 FileFormatI format = null;
595 // Finally, deal with the remaining input data.
596 AlignFrame af = null;
598 JalviewJSApp jsApp = (isJS ? new JalviewJSApp(this, aparser) : null);
604 // JalviewJS allows sequence1 sequence2 ....
607 else if (!headless && Cache.getDefault("SHOW_STARTUP_FILE", true))
615 // We'll only open the default file if the desktop is visible.
617 // ////////////////////
619 file = Cache.getDefault("STARTUP_FILE",
620 Cache.getDefault("www.jalview.org",
621 "http://www.jalview.org")
622 + "/examples/exampleFile_2_7.jar");
624 "http://www.jalview.org/examples/exampleFile_2_3.jar"))
626 // hardwire upgrade of the startup file
627 file.replace("_2_3.jar", "_2_7.jar");
628 // and remove the stale setting
629 Cache.removeProperty("STARTUP_FILE");
632 protocol = DataSourceType.FILE;
634 if (file.indexOf("http:") > -1)
636 protocol = DataSourceType.URL;
639 if (file.endsWith(".jar"))
641 format = FileFormat.Jalview;
647 format = new IdentifyFile().identify(file, protocol);
648 } catch (FileFormatException e)
653 af = fileLoader.LoadFileWaitTillLoaded(file, protocol, format);
660 desktop.setProgressBar(
662 .getString("status.processing_commandline_args"),
663 progress = System.currentTimeMillis());
665 System.out.println("CMD [-open " + file + "] executed successfully!");
667 if (!Platform.isJS())
669 * ignore in JavaScript -- can't just file existence - could load it?
674 if (!file.startsWith("http://") && !file.startsWith("https://"))
675 // BH 2019 added https check for Java
677 if (!(new File(file)).exists())
679 System.out.println("Can't find " + file);
688 String fileFormat = (isJS
689 ? (String) aparser.getAppletValue("format", null, true)
691 protocol = AppletFormatAdapter.checkProtocol(file);
694 format = (fileFormat != null
695 ? FileFormats.getInstance().forName(fileFormat)
699 format = new IdentifyFile().identify(file, protocol);
701 } catch (FileFormatException e1)
706 af = new FileLoader(!headless).LoadFileWaitTillLoaded(file, protocol,
710 System.out.println("jalview error - AlignFrame was not created");
715 // JalviewLite interface for JavaScript allows second file open
716 String file2 = aparser.getValue(ArgsParser.OPEN2, true);
719 protocol = AppletFormatAdapter.checkProtocol(file2);
722 format = new IdentifyFile().identify(file2, protocol);
723 } catch (FileFormatException e1)
727 AlignFrame af2 = new FileLoader(!headless)
728 .LoadFileWaitTillLoaded(file2, protocol, format);
731 System.out.println("error");
735 AlignViewport.openLinkedAlignmentAs(af,
736 af.getViewport().getAlignment(),
737 af2.getViewport().getAlignment(), "",
738 AlignViewport.SPLIT_FRAME);
740 "CMD [-open2 " + file2 + "] executed successfully!");
743 setCurrentAlignFrame(af);
745 setFrameDependentProperties(aparser, af);
749 jsApp.initFromParams(af);
758 if (groovyscript != null)
760 // Execute the groovy script after we've done all the rendering
762 // and before any images or figures are generated.
763 System.out.println("Executing script " + groovyscript);
764 executeGroovyScript(groovyscript, af);
765 System.out.println("CMD groovy[" + groovyscript
766 + "] executed successfully!");
770 if (!isJS || !isStartup) {
771 createOutputFiles(aparser, format);
776 af.getViewport().getCalcManager().shutdown();
779 // extract groovy arguments before anything else.
780 // Once all other stuff is done, execute any groovy scripts (in order)
781 if (!isJS && groovyscript != null)
783 if (Cache.groovyJarsPresent())
785 System.out.println("Executing script " + groovyscript);
786 executeGroovyScript(groovyscript, af);
791 "Sorry. Groovy Support is not available, so ignoring the provided groovy script "
796 // and finally, turn off batch mode indicator - if the desktop still exists
801 desktop.setProgressBar(null, progress);
803 desktop.setInBatchMode(false);
807 jsApp.callInitCallback();
812 * Set general display parameters irrespective of file loading or headlessness.
816 private void setDisplayParameters(ArgsParser aparser)
818 if (aparser.contains(ArgsParser.NOMENUBAR))
821 System.out.println("CMD [nomenu] executed successfully!");
824 if (aparser.contains(ArgsParser.NOSTATUS))
827 System.out.println("CMD [nostatus] executed successfully!");
830 if (aparser.contains(ArgsParser.NOANNOTATION)
831 || aparser.contains(ArgsParser.NOANNOTATION2))
834 System.out.println("CMD no-annotation executed successfully!");
836 if (aparser.contains(ArgsParser.NOCALCULATION))
838 noCalculation = true;
839 System.out.println("CMD [nocalculation] executed successfully!");
844 private void setFrameDependentProperties(ArgsParser aparser,
847 String data = aparser.getValue(ArgsParser.COLOUR, true);
850 data.replaceAll("%20", " ");
852 ColourSchemeI cs = ColourSchemeProperty.getColourScheme(
853 af.getViewport(), af.getViewport().getAlignment(), data);
858 "CMD [-color " + data + "] executed successfully!");
863 // Must maintain ability to use the groups flag
864 data = aparser.getValue(ArgsParser.GROUPS, true);
867 af.parseFeaturesFile(data,
868 AppletFormatAdapter.checkProtocol(data));
869 // System.out.println("Added " + data);
871 "CMD groups[-" + data + "] executed successfully!");
873 data = aparser.getValue(ArgsParser.FEATURES, true);
876 af.parseFeaturesFile(data,
877 AppletFormatAdapter.checkProtocol(data));
878 // System.out.println("Added " + data);
880 "CMD [-features " + data + "] executed successfully!");
882 data = aparser.getValue(ArgsParser.ANNOTATIONS, true);
885 af.loadJalviewDataFile(data, null, null, null);
886 // System.out.println("Added " + data);
888 "CMD [-annotations " + data + "] executed successfully!");
891 // JavaScript feature
893 if (aparser.contains(ArgsParser.SHOWOVERVIEW))
895 af.overviewMenuItem_actionPerformed(null);
896 System.out.println("CMD [showoverview] executed successfully!");
899 // set or clear the sortbytree flag.
900 if (aparser.contains(ArgsParser.SORTBYTREE))
902 af.getViewport().setSortByTree(true);
903 if (af.getViewport().getSortByTree())
905 System.out.println("CMD [-sortbytree] executed successfully!");
909 boolean doUpdateAnnotation = false;
911 * we do this earlier in JalviewJS because of a complication with
914 * For now, just fixing this in JalviewJS.
923 af.getViewport().setShowAnnotation(false);
924 if (!af.getViewport().isShowAnnotation())
926 doUpdateAnnotation = true;
931 if (aparser.contains(ArgsParser.NOSORTBYTREE))
933 af.getViewport().setSortByTree(false);
934 if (!af.getViewport().getSortByTree())
936 doUpdateAnnotation = true;
938 .println("CMD [-nosortbytree] executed successfully!");
941 if (doUpdateAnnotation)
943 af.setMenusForViewport();
944 af.alignPanel.updateLayout();
947 data = aparser.getValue(ArgsParser.TREE, true);
952 NewickFile nf = new NewickFile(data,
953 AppletFormatAdapter.checkProtocol(data));
955 .setCurrentTree(af.showNewickTree(nf, data).getTree());
957 "CMD [-tree " + data + "] executed successfully!");
958 } catch (IOException ex)
960 System.err.println("Couldn't add tree " + data);
961 ex.printStackTrace(System.err);
964 // TODO - load PDB structure(s) to alignment JAL-629
965 // (associate with identical sequence in alignment, or a specified
971 * Writes an output file for each format (if any) specified in the
972 * command-line arguments. Supported formats are currently
981 * A format parameter should be followed by a parameter specifying the output
982 * file name. {@code imgMap} parameters should follow those for the
983 * corresponding alignment image output.
988 private void createOutputFiles(ArgsParser aparser, FileFormatI format)
990 AlignFrame af = currentAlignFrame;
991 while (aparser.getSize() >= 2)
993 String outputFormat = aparser.nextValue();
996 switch (outputFormat.toLowerCase())
999 imageFile = new File(aparser.nextValue());
1000 af.createPNG(imageFile);
1002 "Creating PNG image: " + imageFile.getAbsolutePath());
1005 imageFile = new File(aparser.nextValue());
1006 af.createSVG(imageFile);
1008 "Creating SVG image: " + imageFile.getAbsolutePath());
1011 imageFile = new File(aparser.nextValue());
1013 "Creating EPS file: " + imageFile.getAbsolutePath());
1014 af.createEPS(imageFile);
1017 fname = new File(aparser.nextValue()).getAbsolutePath();
1020 BioJsHTMLOutput.refreshVersionInfo(
1021 BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
1022 } catch (URISyntaxException e)
1024 e.printStackTrace();
1026 BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel);
1027 bjs.exportHTML(fname);
1028 System.out.println("Creating BioJS MSA Viwer HTML file: " + fname);
1031 fname = new File(aparser.nextValue()).getAbsolutePath();
1032 HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel);
1033 htmlSVG.exportHTML(fname);
1034 System.out.println("Creating HTML image: " + fname);
1037 imageFile = new File(aparser.nextValue());
1038 af.alignPanel.makePNGImageMap(imageFile, "unnamed.png");
1040 "Creating image map: " + imageFile.getAbsolutePath());
1043 // fall through - try to parse as an alignment data export format
1044 FileFormatI outFormat = null;
1047 outFormat = FileFormats.getInstance().forName(outputFormat);
1048 } catch (Exception formatP)
1051 if (outFormat == null)
1053 System.out.println("Couldn't parse " + outputFormat
1054 + " as a valid Jalview format string.");
1057 if (!outFormat.isWritable())
1060 "This version of Jalview does not support alignment export as "
1064 // record file as it was passed to Jalview so it is recognisable to the CLI
1067 fname = new File(file = aparser.nextValue()).getAbsolutePath();
1068 // JBPNote - yuck - really wish we did have a bean returned from this which gave
1069 // success/fail like before !
1070 af.saveAlignment(fname, outFormat);
1071 if (!af.isSaveAlignmentSuccessful())
1073 System.out.println("Written alignment in " + outputFormat
1074 + " format to " + file);
1079 System.out.println("Error writing file " + file + " in "
1080 + outputFormat + " format!!");
1084 // ??? Should report - 'ignoring' extra args here...
1085 while (aparser.getSize() > 0)
1087 System.out.println("Ignoring extra argument: " + aparser.nextValue());
1091 private static void showUsage()
1094 "Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n"
1095 + "-nodisplay\tRun Jalview without User Interface.\n"
1096 + "-props FILE\tUse the given Jalview properties file instead of users default.\n"
1097 + "-colour COLOURSCHEME\tThe colourscheme to be applied to the alignment\n"
1098 + "-annotations FILE\tAdd precalculated annotations to the alignment.\n"
1099 + "-tree FILE\tLoad the given newick format tree file onto the alignment\n"
1100 + "-features FILE\tUse the given file to mark features on the alignment.\n"
1101 + "-fasta FILE\tCreate alignment file FILE in Fasta format.\n"
1102 + "-clustal FILE\tCreate alignment file FILE in Clustal format.\n"
1103 + "-pfam FILE\tCreate alignment file FILE in PFAM format.\n"
1104 + "-msf FILE\tCreate alignment file FILE in MSF format.\n"
1105 + "-pileup FILE\tCreate alignment file FILE in Pileup format\n"
1106 + "-pir FILE\tCreate alignment file FILE in PIR format.\n"
1107 + "-blc FILE\tCreate alignment file FILE in BLC format.\n"
1108 + "-json FILE\tCreate alignment file FILE in JSON format.\n"
1109 + "-jalview FILE\tCreate alignment file FILE in Jalview format.\n"
1110 + "-png FILE\tCreate PNG image FILE from alignment.\n"
1111 + "-svg FILE\tCreate SVG image FILE from alignment.\n"
1112 + "-html FILE\tCreate HTML file from alignment.\n"
1113 + "-biojsMSA FILE\tCreate BioJS MSA Viewer HTML file from alignment.\n"
1114 + "-imgMap FILE\tCreate HTML file FILE with image map of PNG image.\n"
1115 + "-eps FILE\tCreate EPS file FILE from alignment.\n"
1116 + "-questionnaire URL\tQueries the given URL for information about any Jalview user questionnaires.\n"
1117 + "-noquestionnaire\tTurn off questionnaire check.\n"
1118 + "-nonews\tTurn off check for Jalview news.\n"
1119 + "-nousagestats\tTurn off google analytics tracking for this session.\n"
1120 + "-sortbytree OR -nosortbytree\tEnable or disable sorting of the given alignment by the given tree\n"
1122 // "-setprop PROPERTY=VALUE\tSet the given Jalview property,
1123 // after all other properties files have been read\n\t
1124 // (quote the 'PROPERTY=VALUE' pair to ensure spaces are
1125 // passed in correctly)"
1126 + "-jabaws URL\tSpecify URL for Jabaws services (e.g. for a local installation).\n"
1127 + "-fetchfrom nickname\tQuery nickname for features for the alignments and display them.\n"
1128 + "-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"
1129 + "\n~Read documentation in Application or visit http://www.jalview.org for description of Features and Annotations file~\n\n");
1132 private static void startUsageStats(final Desktop desktop)
1135 * start a User Config prompt asking if we can log usage statistics.
1137 PromptUserConfig prompter = new PromptUserConfig(Desktop.getDesktopPane(),
1138 "USAGESTATS", "Jalview Usage Statistics",
1139 "Do you want to help make Jalview better by enabling "
1140 + "the collection of usage statistics with Google Analytics ?"
1141 + "\n\n(you can enable or disable usage tracking in the preferences)",
1148 "Initialising googletracker for usage stats.");
1149 Cache.initGoogleTracker();
1150 Cache.log.debug("Tracking enabled.");
1157 Cache.log.debug("Not enabling Google Tracking.");
1160 desktop.addDialogThread(prompter);
1164 * Locate the given string as a file and pass it to the groovy interpreter.
1166 * @param groovyscript
1167 * the script to execute
1168 * @param jalviewContext
1169 * the Jalview Desktop object passed in to the groovy binding as the
1172 private void executeGroovyScript(String groovyscript, AlignFrame af)
1175 * for scripts contained in files
1182 if (groovyscript.trim().equals("STDIN"))
1184 // read from stdin into a tempfile and execute it
1187 tfile = File.createTempFile("jalview", "groovy");
1188 PrintWriter outfile = new PrintWriter(
1189 new OutputStreamWriter(new FileOutputStream(tfile)));
1190 BufferedReader br = new BufferedReader(
1191 new InputStreamReader(System.in));
1193 while ((line = br.readLine()) != null)
1195 outfile.write(line + "\n");
1201 } catch (Exception ex)
1203 System.err.println("Failed to read from STDIN into tempfile "
1204 + ((tfile == null) ? "(tempfile wasn't created)"
1205 : tfile.toString()));
1206 ex.printStackTrace();
1211 sfile = tfile.toURI().toURL();
1212 } catch (Exception x)
1215 "Unexpected Malformed URL Exception for temporary file created from STDIN: "
1217 x.printStackTrace();
1225 sfile = new URI(groovyscript).toURL();
1226 } catch (Exception x)
1228 tfile = new File(groovyscript);
1229 if (!tfile.exists())
1231 System.err.println("File '" + groovyscript + "' does not exist.");
1234 if (!tfile.canRead())
1236 System.err.println("File '" + groovyscript + "' cannot be read.");
1239 if (tfile.length() < 1)
1241 System.err.println("File '" + groovyscript + "' is empty.");
1246 sfile = tfile.getAbsoluteFile().toURI().toURL();
1247 } catch (Exception ex)
1249 System.err.println("Failed to create a file URL for "
1250 + tfile.getAbsoluteFile());
1257 Map<String, java.lang.Object> vbinding = new HashMap<>();
1258 vbinding.put("Jalview", this);
1261 vbinding.put("currentAlFrame", af);
1263 Binding gbinding = new Binding(vbinding);
1264 GroovyScriptEngine gse = new GroovyScriptEngine(new URL[] { sfile });
1265 gse.run(sfile.toString(), gbinding);
1266 if ("STDIN".equals(groovyscript))
1268 // delete temp file that we made -
1269 // only if it was successfully executed
1272 } catch (Exception e)
1274 System.err.println("Exception Whilst trying to execute file " + sfile
1275 + " as a groovy script.");
1276 e.printStackTrace(System.err);
1281 public static boolean isHeadlessMode()
1283 String isheadless = System.getProperty("java.awt.headless");
1284 if (isheadless != null && isheadless.equalsIgnoreCase("true"))
1291 public AlignFrame[] getAlignFrames()
1293 return desktop == null ? new AlignFrame[] { getCurrentAlignFrame() }
1294 : Desktop.getAlignFrames();
1299 * Quit method delegates to Desktop.quit - unless running in headless mode
1300 * when it just ends the JVM
1304 if (desktop != null)
1314 public static AlignFrame getCurrentAlignFrame()
1316 return Jalview.getInstance().currentAlignFrame;
1319 public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)
1321 Jalview.getInstance().currentAlignFrame = currentAlignFrame;
1325 public void notifyWorker(AlignCalcWorkerI worker, String status)
1327 // System.out.println("Jalview worker " + worker.getClass().getSimpleName()
1332 private static boolean isInteractive = true;
1334 public static boolean isInteractive()
1336 return isInteractive;
1339 public static void setInteractive(boolean tf)