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 processing
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 .println("Java version: " + System.getProperty("java.version"));
270 System.out.println("Java Home: " + System.getProperty("java.home"));
271 System.out.println(System.getProperty("os.arch") + " "
272 + System.getProperty("os.name") + " "
273 + System.getProperty("os.version"));
274 String val = System.getProperty("sys.install4jVersion");
277 System.out.println("Install4j version: " + val);
279 val = System.getProperty("installer_template_version");
282 System.out.println("Install4j template version: " + val);
284 val = System.getProperty("launcher_version");
287 System.out.println("Launcher version: " + val);
290 // report Jalview version
291 Cache.getInstance().loadBuildProperties(true);
293 ArgsParser aparser = new ArgsParser(args);
296 String usrPropsFile = aparser.getValue("props");
298 Cache.loadProperties(usrPropsFile); // must do this before
300 boolean allowServices = true;
304 j2sAppletID = Platform.getAppID(null);
305 Preferences.setAppletDefaults();
306 Cache.loadProperties(usrPropsFile); // again, because we
307 // might be changing defaults here?
308 appletResourcePath = (String) aparser.getAppletValue("resourcepath",
319 if (usrPropsFile != null)
322 "CMD [-props " + usrPropsFile + "] executed successfully!");
324 if (aparser.contains("help") || aparser.contains("h"))
329 // BH note: Only -nodisplay is official; others are deprecated?
330 if (aparser.contains("nodisplay") || aparser.contains("nogui")
331 || aparser.contains("headless")
332 || GraphicsEnvironment.isHeadless())
335 // BH Definitely not a good idea in JavaScript;
336 // probably should not be here for Java, either.
337 System.setProperty("java.awt.headless", "true");
342 final String jabawsUrl = aparser.getValue(ArgsParser.JABAWS);
343 allowServices = !("none".equals(jabawsUrl));
344 if (allowServices && jabawsUrl != null)
348 Jws2Discoverer.getInstance().setPreferredUrl(jabawsUrl);
350 "CMD [-jabaws " + jabawsUrl + "] executed successfully!");
351 } catch (MalformedURLException e)
354 "Invalid jabaws parameter: " + jabawsUrl + " ignored");
359 String defs = aparser.getValue(ArgsParser.SETPROP);
362 int p = defs.indexOf('=');
365 System.err.println("Ignoring invalid setprop argument : " + defs);
369 System.out.println("Executing setprop argument: " + defs);
372 Cache.setProperty(defs.substring(0, p), defs.substring(p + 1));
375 defs = aparser.getValue("setprop");
377 System.setProperty("http.agent",
378 "Jalview Desktop/" + Cache.getDefault("VERSION", "Unknown"));
382 } catch (NoClassDefFoundError error)
384 error.printStackTrace();
385 System.out.println("\nEssential logging libraries not found."
386 + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview");
395 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
396 } catch (Exception ex)
398 System.err.println("Unexpected Look and Feel Exception");
399 ex.printStackTrace();
401 if (Platform.isMac())
404 LookAndFeel lookAndFeel = ch.randelshofer.quaqua.QuaquaManager
407 "com.apple.mrj.application.apple.menu.about.name",
409 System.setProperty("apple.laf.useScreenMenuBar", "true");
410 if (lookAndFeel != null)
414 UIManager.setLookAndFeel(lookAndFeel);
415 } catch (Throwable e)
418 "Failed to set QuaQua look and feel: " + e.toString());
421 if (lookAndFeel == null
422 || !(lookAndFeel.getClass().isAssignableFrom(
423 UIManager.getLookAndFeel().getClass()))
424 || !UIManager.getLookAndFeel().getClass().toString()
425 .toLowerCase().contains("quaqua"))
430 "Quaqua LaF not available on this plaform. Using VAqua(4).\nSee https://issues.jalview.org/browse/JAL-2976");
431 UIManager.setLookAndFeel("org.violetlib.aqua.AquaLookAndFeel");
432 } catch (Throwable e)
435 "Failed to reset look and feel: " + e.toString());
441 * configure 'full' SO model if preferences say to, else use the default (full SO)
442 * - as JS currently doesn't have OBO parsing, it must use 'Lite' version
444 boolean soDefault = !isJS;
445 if (Cache.getDefault("USE_FULL_SO", soDefault))
447 SequenceOntologyFactory.setSequenceOntology(new SequenceOntology());
454 desktop = Desktop.getInstance();
455 desktop.setInBatchMode(true); // indicate we are starting up
458 JalviewTaskbar.setTaskbar(this);
459 } catch (Throwable t)
461 System.out.println("Error setting Taskbar: " + t.getMessage());
463 desktop.setVisible(true);
473 desktop.startServiceDiscovery();
474 if (!aparser.contains("nousagestats"))
476 startUsageStats(desktop);
480 System.err.println("CMD [-nousagestats] executed successfully!");
483 if (!aparser.contains("noquestionnaire"))
485 String url = aparser.getValue("questionnaire");
488 // Start the desktop questionnaire prompter with the specified
490 Cache.log.debug("Starting questionnaire url at " + url);
491 desktop.checkForQuestionnaire(url);
492 System.out.println("CMD questionnaire[-" + url
493 + "] executed successfully!");
497 if (Cache.getProperty("NOQUESTIONNAIRES") == null)
499 // Start the desktop questionnaire prompter with the specified
502 // "http://anaplog.compbio.dundee.ac.uk/cgi-bin/questionnaire.pl";
504 String defurl = "http://www.jalview.org/cgi-bin/questionnaire.pl";
506 "Starting questionnaire with default url: " + defurl);
507 desktop.checkForQuestionnaire(defurl);
514 .println("CMD [-noquestionnaire] executed successfully!");
517 if (!aparser.contains("nonews"))
519 desktop.checkForNews();
522 BioJsHTMLOutput.updateBioJS();
525 parseArguments(aparser, true);
529 * Parse all command-line String[] arguments as well as all JavaScript-derived
530 * parameters from Info.
532 * We allow for this method to be run from JavaScript. Basically allowing
538 public void parseArguments(ArgsParser aparser, boolean isStartup)
541 String groovyscript = null; // script to execute after all loading is
542 boolean isJS = Platform.isJS();
546 // Move any new getdown-launcher-new.jar into place over old
547 // getdown-launcher.jar
548 String appdirString = System.getProperty("getdownappdir");
549 if (appdirString != null && appdirString.length() > 0)
551 final File appdir = new File(appdirString);
557 LaunchUtil.upgradeGetdown(
558 new File(appdir, "getdown-launcher-old.jar"),
559 new File(appdir, "getdown-launcher.jar"),
560 new File(appdir, "getdown-launcher-new.jar"));
565 // completed one way or another
566 // extract groovy argument and execute if necessary
567 groovyscript = aparser.getValue("groovy", true);
571 String file = aparser.getValue("open", true);
573 if (!isJS && file == null && desktop == null)
575 System.out.println("No files to open!");
579 setDisplayParameters(aparser);
581 // time to open a file.
584 DataSourceType protocol = null;
585 FileLoader fileLoader = new FileLoader(!headless);
586 FileFormatI format = null;
587 // Finally, deal with the remaining input data.
588 AlignFrame af = null;
590 JalviewJSApp jsApp = (isJS ? new JalviewJSApp(this, aparser) : null);
596 // JalviewJS allows sequence1 sequence2 ....
599 else if (!headless && Cache.getDefault("SHOW_STARTUP_FILE", true))
607 // We'll only open the default file if the desktop is visible.
609 // ////////////////////
611 file = Cache.getDefault("STARTUP_FILE",
612 Cache.getDefault("www.jalview.org",
613 "http://www.jalview.org")
614 + "/examples/exampleFile_2_7.jar");
616 "http://www.jalview.org/examples/exampleFile_2_3.jar"))
618 // hardwire upgrade of the startup file
619 file.replace("_2_3.jar", "_2_7.jar");
620 // and remove the stale setting
621 Cache.removeProperty("STARTUP_FILE");
624 protocol = DataSourceType.FILE;
626 if (file.indexOf("http:") > -1)
628 protocol = DataSourceType.URL;
631 if (file.endsWith(".jar"))
633 format = FileFormat.Jalview;
639 format = new IdentifyFile().identify(file, protocol);
640 } catch (FileFormatException e)
645 af = fileLoader.LoadFileWaitTillLoaded(file, protocol, format);
652 desktop.setProgressBar(
654 .getString("status.processing_commandline_args"),
655 progress = System.currentTimeMillis());
657 System.out.println("CMD [-open " + file + "] executed successfully!");
659 if (!Platform.isJS())
661 * ignore in JavaScript -- can't just file existence - could load it?
666 if (!file.startsWith("http://") && !file.startsWith("https://"))
667 // BH 2019 added https check for Java
669 if (!(new File(file)).exists())
671 System.out.println("Can't find " + file);
680 String fileFormat = (isJS
681 ? (String) aparser.getAppletValue("format", null, true)
683 protocol = AppletFormatAdapter.checkProtocol(file);
686 format = (fileFormat != null
687 ? FileFormats.getInstance().forName(fileFormat)
691 format = new IdentifyFile().identify(file, protocol);
693 } catch (FileFormatException e1)
698 af = new FileLoader(!headless).LoadFileWaitTillLoaded(file, protocol,
702 System.out.println("jalview error - AlignFrame was not created");
707 // JalviewLite interface for JavaScript allows second file open
708 String file2 = aparser.getValue(ArgsParser.OPEN2, true);
711 protocol = AppletFormatAdapter.checkProtocol(file2);
714 format = new IdentifyFile().identify(file2, protocol);
715 } catch (FileFormatException e1)
719 AlignFrame af2 = new FileLoader(!headless)
720 .LoadFileWaitTillLoaded(file2, protocol, format);
723 System.out.println("error");
727 AlignViewport.openLinkedAlignmentAs(af,
728 af.getViewport().getAlignment(),
729 af2.getViewport().getAlignment(), "",
730 AlignViewport.SPLIT_FRAME);
732 "CMD [-open2 " + file2 + "] executed successfully!");
735 setCurrentAlignFrame(af);
737 setFrameDependentProperties(aparser, af);
741 jsApp.initFromParams(af);
750 if (groovyscript != null)
752 // Execute the groovy script after we've done all the rendering
754 // and before any images or figures are generated.
755 System.out.println("Executing script " + groovyscript);
756 executeGroovyScript(groovyscript, af);
757 System.out.println("CMD groovy[" + groovyscript
758 + "] executed successfully!");
762 if (!isJS || !isStartup) {
763 createOutputFiles(aparser, format);
767 // extract groovy arguments before anything else.
768 // Once all other stuff is done, execute any groovy scripts (in order)
769 if (!isJS && groovyscript != null)
771 if (Cache.groovyJarsPresent())
773 System.out.println("Executing script " + groovyscript);
774 executeGroovyScript(groovyscript, af);
779 "Sorry. Groovy Support is not available, so ignoring the provided groovy script "
784 // and finally, turn off batch mode indicator - if the desktop still exists
789 desktop.setProgressBar(null, progress);
791 desktop.setInBatchMode(false);
795 jsApp.callInitCallback();
800 * Set general display parameters irrespective of file loading or headlessness.
804 private void setDisplayParameters(ArgsParser aparser)
806 if (aparser.contains(ArgsParser.NOMENUBAR))
809 System.out.println("CMD [nomenu] executed successfully!");
812 if (aparser.contains(ArgsParser.NOSTATUS))
815 System.out.println("CMD [nostatus] executed successfully!");
818 if (aparser.contains(ArgsParser.NOANNOTATION)
819 || aparser.contains(ArgsParser.NOANNOTATION2))
822 System.out.println("CMD no-annotation executed successfully!");
824 if (aparser.contains(ArgsParser.NOCALCULATION))
826 noCalculation = true;
827 System.out.println("CMD [nocalculation] executed successfully!");
832 private void setFrameDependentProperties(ArgsParser aparser,
835 String data = aparser.getValue(ArgsParser.COLOUR, true);
838 data.replaceAll("%20", " ");
840 ColourSchemeI cs = ColourSchemeProperty.getColourScheme(
841 af.getViewport(), af.getViewport().getAlignment(), data);
846 "CMD [-color " + data + "] executed successfully!");
851 // Must maintain ability to use the groups flag
852 data = aparser.getValue(ArgsParser.GROUPS, true);
855 af.parseFeaturesFile(data,
856 AppletFormatAdapter.checkProtocol(data));
857 // System.out.println("Added " + data);
859 "CMD groups[-" + data + "] executed successfully!");
861 data = aparser.getValue(ArgsParser.FEATURES, true);
864 af.parseFeaturesFile(data,
865 AppletFormatAdapter.checkProtocol(data));
866 // System.out.println("Added " + data);
868 "CMD [-features " + data + "] executed successfully!");
870 data = aparser.getValue(ArgsParser.ANNOTATIONS, true);
873 af.loadJalviewDataFile(data, null, null, null);
874 // System.out.println("Added " + data);
876 "CMD [-annotations " + data + "] executed successfully!");
879 // JavaScript feature
881 if (aparser.contains(ArgsParser.SHOWOVERVIEW))
883 af.overviewMenuItem_actionPerformed(null);
884 System.out.println("CMD [showoverview] executed successfully!");
887 // set or clear the sortbytree flag.
888 if (aparser.contains(ArgsParser.SORTBYTREE))
890 af.getViewport().setSortByTree(true);
891 if (af.getViewport().getSortByTree())
893 System.out.println("CMD [-sortbytree] executed successfully!");
897 boolean doUpdateAnnotation = false;
899 * we do this earlier in JalviewJS because of a complication with
902 * For now, just fixing this in JalviewJS.
911 af.getViewport().setShowAnnotation(false);
912 if (!af.getViewport().isShowAnnotation())
914 doUpdateAnnotation = true;
919 if (aparser.contains(ArgsParser.NOSORTBYTREE))
921 af.getViewport().setSortByTree(false);
922 if (!af.getViewport().getSortByTree())
924 doUpdateAnnotation = true;
926 .println("CMD [-nosortbytree] executed successfully!");
929 if (doUpdateAnnotation)
931 af.setMenusForViewport();
932 af.alignPanel.updateLayout();
935 data = aparser.getValue(ArgsParser.TREE, true);
940 NewickFile nf = new NewickFile(data,
941 AppletFormatAdapter.checkProtocol(data));
943 .setCurrentTree(af.showNewickTree(nf, data).getTree());
945 "CMD [-tree " + data + "] executed successfully!");
946 } catch (IOException ex)
948 System.err.println("Couldn't add tree " + data);
949 ex.printStackTrace(System.err);
952 // TODO - load PDB structure(s) to alignment JAL-629
953 // (associate with identical sequence in alignment, or a specified
959 * Writes an output file for each format (if any) specified in the
960 * command-line arguments. Supported formats are currently
969 * A format parameter should be followed by a parameter specifying the output
970 * file name. {@code imgMap} parameters should follow those for the
971 * corresponding alignment image output.
976 private void createOutputFiles(ArgsParser aparser, FileFormatI format)
978 AlignFrame af = currentAlignFrame;
979 while (aparser.getSize() >= 2)
981 String outputFormat = aparser.nextValue();
984 switch (outputFormat.toLowerCase())
987 imageFile = new File(aparser.nextValue());
988 af.createPNG(imageFile);
990 "Creating PNG image: " + imageFile.getAbsolutePath());
993 imageFile = new File(aparser.nextValue());
994 af.createSVG(imageFile);
996 "Creating SVG image: " + imageFile.getAbsolutePath());
999 imageFile = new File(aparser.nextValue());
1001 "Creating EPS file: " + imageFile.getAbsolutePath());
1002 af.createEPS(imageFile);
1005 fname = new File(aparser.nextValue()).getAbsolutePath();
1008 BioJsHTMLOutput.refreshVersionInfo(
1009 BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
1010 } catch (URISyntaxException e)
1012 e.printStackTrace();
1014 BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel);
1015 bjs.exportHTML(fname);
1016 System.out.println("Creating BioJS MSA Viwer HTML file: " + fname);
1019 fname = new File(aparser.nextValue()).getAbsolutePath();
1020 HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel);
1021 htmlSVG.exportHTML(fname);
1022 System.out.println("Creating HTML image: " + fname);
1025 imageFile = new File(aparser.nextValue());
1026 af.alignPanel.makePNGImageMap(imageFile, "unnamed.png");
1028 "Creating image map: " + imageFile.getAbsolutePath());
1031 // fall through - try to parse as an alignment data export format
1032 FileFormatI outFormat = null;
1035 outFormat = FileFormats.getInstance().forName(outputFormat);
1036 } catch (Exception formatP)
1039 if (outFormat == null)
1041 System.out.println("Couldn't parse " + outputFormat
1042 + " as a valid Jalview format string.");
1045 if (!outFormat.isWritable())
1048 "This version of Jalview does not support alignment export as "
1052 // record file as it was passed to Jalview so it is recognisable to the CLI
1055 fname = new File(file = aparser.nextValue()).getAbsolutePath();
1056 // JBPNote - yuck - really wish we did have a bean returned from this which gave
1057 // success/fail like before !
1058 af.saveAlignment(fname, outFormat);
1059 if (!af.isSaveAlignmentSuccessful())
1061 System.out.println("Written alignment in " + outputFormat
1062 + " format to " + file);
1067 System.out.println("Error writing file " + file + " in "
1068 + outputFormat + " format!!");
1072 // ??? Should report - 'ignoring' extra args here...
1073 while (aparser.getSize() > 0)
1075 System.out.println("Ignoring extra argument: " + aparser.nextValue());
1079 private static void showUsage()
1082 "Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n"
1083 + "-nodisplay\tRun Jalview without User Interface.\n"
1084 + "-props FILE\tUse the given Jalview properties file instead of users default.\n"
1085 + "-colour COLOURSCHEME\tThe colourscheme to be applied to the alignment\n"
1086 + "-annotations FILE\tAdd precalculated annotations to the alignment.\n"
1087 + "-tree FILE\tLoad the given newick format tree file onto the alignment\n"
1088 + "-features FILE\tUse the given file to mark features on the alignment.\n"
1089 + "-fasta FILE\tCreate alignment file FILE in Fasta format.\n"
1090 + "-clustal FILE\tCreate alignment file FILE in Clustal format.\n"
1091 + "-pfam FILE\tCreate alignment file FILE in PFAM format.\n"
1092 + "-msf FILE\tCreate alignment file FILE in MSF format.\n"
1093 + "-pileup FILE\tCreate alignment file FILE in Pileup format\n"
1094 + "-pir FILE\tCreate alignment file FILE in PIR format.\n"
1095 + "-blc FILE\tCreate alignment file FILE in BLC format.\n"
1096 + "-json FILE\tCreate alignment file FILE in JSON format.\n"
1097 + "-jalview FILE\tCreate alignment file FILE in Jalview format.\n"
1098 + "-png FILE\tCreate PNG image FILE from alignment.\n"
1099 + "-svg FILE\tCreate SVG image FILE from alignment.\n"
1100 + "-html FILE\tCreate HTML file from alignment.\n"
1101 + "-biojsMSA FILE\tCreate BioJS MSA Viewer HTML file from alignment.\n"
1102 + "-imgMap FILE\tCreate HTML file FILE with image map of PNG image.\n"
1103 + "-eps FILE\tCreate EPS file FILE from alignment.\n"
1104 + "-questionnaire URL\tQueries the given URL for information about any Jalview user questionnaires.\n"
1105 + "-noquestionnaire\tTurn off questionnaire check.\n"
1106 + "-nonews\tTurn off check for Jalview news.\n"
1107 + "-nousagestats\tTurn off google analytics tracking for this session.\n"
1108 + "-sortbytree OR -nosortbytree\tEnable or disable sorting of the given alignment by the given tree\n"
1110 // "-setprop PROPERTY=VALUE\tSet the given Jalview property,
1111 // after all other properties files have been read\n\t
1112 // (quote the 'PROPERTY=VALUE' pair to ensure spaces are
1113 // passed in correctly)"
1114 + "-jabaws URL\tSpecify URL for Jabaws services (e.g. for a local installation).\n"
1115 + "-fetchfrom nickname\tQuery nickname for features for the alignments and display them.\n"
1116 + "-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"
1117 + "\n~Read documentation in Application or visit http://www.jalview.org for description of Features and Annotations file~\n\n");
1120 private static void startUsageStats(final Desktop desktop)
1123 * start a User Config prompt asking if we can log usage statistics.
1125 PromptUserConfig prompter = new PromptUserConfig(Desktop.getDesktopPane(),
1126 "USAGESTATS", "Jalview Usage Statistics",
1127 "Do you want to help make Jalview better by enabling "
1128 + "the collection of usage statistics with Google Analytics ?"
1129 + "\n\n(you can enable or disable usage tracking in the preferences)",
1136 "Initialising googletracker for usage stats.");
1137 Cache.initGoogleTracker();
1138 Cache.log.debug("Tracking enabled.");
1145 Cache.log.debug("Not enabling Google Tracking.");
1148 desktop.addDialogThread(prompter);
1152 * Locate the given string as a file and pass it to the groovy interpreter.
1154 * @param groovyscript
1155 * the script to execute
1156 * @param jalviewContext
1157 * the Jalview Desktop object passed in to the groovy binding as the
1160 private void executeGroovyScript(String groovyscript, AlignFrame af)
1163 * for scripts contained in files
1170 if (groovyscript.trim().equals("STDIN"))
1172 // read from stdin into a tempfile and execute it
1175 tfile = File.createTempFile("jalview", "groovy");
1176 PrintWriter outfile = new PrintWriter(
1177 new OutputStreamWriter(new FileOutputStream(tfile)));
1178 BufferedReader br = new BufferedReader(
1179 new InputStreamReader(System.in));
1181 while ((line = br.readLine()) != null)
1183 outfile.write(line + "\n");
1189 } catch (Exception ex)
1191 System.err.println("Failed to read from STDIN into tempfile "
1192 + ((tfile == null) ? "(tempfile wasn't created)"
1193 : tfile.toString()));
1194 ex.printStackTrace();
1199 sfile = tfile.toURI().toURL();
1200 } catch (Exception x)
1203 "Unexpected Malformed URL Exception for temporary file created from STDIN: "
1205 x.printStackTrace();
1213 sfile = new URI(groovyscript).toURL();
1214 } catch (Exception x)
1216 tfile = new File(groovyscript);
1217 if (!tfile.exists())
1219 System.err.println("File '" + groovyscript + "' does not exist.");
1222 if (!tfile.canRead())
1224 System.err.println("File '" + groovyscript + "' cannot be read.");
1227 if (tfile.length() < 1)
1229 System.err.println("File '" + groovyscript + "' is empty.");
1234 sfile = tfile.getAbsoluteFile().toURI().toURL();
1235 } catch (Exception ex)
1237 System.err.println("Failed to create a file URL for "
1238 + tfile.getAbsoluteFile());
1245 Map<String, java.lang.Object> vbinding = new HashMap<>();
1246 vbinding.put("Jalview", this);
1249 vbinding.put("currentAlFrame", af);
1251 Binding gbinding = new Binding(vbinding);
1252 GroovyScriptEngine gse = new GroovyScriptEngine(new URL[] { sfile });
1253 gse.run(sfile.toString(), gbinding);
1254 if ("STDIN".equals(groovyscript))
1256 // delete temp file that we made -
1257 // only if it was successfully executed
1260 } catch (Exception e)
1262 System.err.println("Exception Whilst trying to execute file " + sfile
1263 + " as a groovy script.");
1264 e.printStackTrace(System.err);
1269 public static boolean isHeadlessMode()
1271 String isheadless = System.getProperty("java.awt.headless");
1272 if (isheadless != null && isheadless.equalsIgnoreCase("true"))
1279 public AlignFrame[] getAlignFrames()
1281 return desktop == null ? new AlignFrame[] { getCurrentAlignFrame() }
1282 : Desktop.getAlignFrames();
1287 * Quit method delegates to Desktop.quit - unless running in headless mode
1288 * when it just ends the JVM
1292 if (desktop != null)
1302 public static AlignFrame getCurrentAlignFrame()
1304 return Jalview.getInstance().currentAlignFrame;
1307 public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)
1309 Jalview.getInstance().currentAlignFrame = currentAlignFrame;
1313 public void notifyWorker(AlignCalcWorkerI worker, String status)
1315 // System.out.println("Jalview worker " + worker.getClass().getSimpleName()
1320 private static boolean isInteractive = true;
1322 public static boolean isInteractive()
1324 return isInteractive;
1327 public static void setInteractive(boolean tf)