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 jalview.ext.so.SequenceOntology;
24 import jalview.gui.AlignFrame;
25 import jalview.gui.Desktop;
26 import jalview.gui.PromptUserConfig;
27 import jalview.io.AppletFormatAdapter;
28 import jalview.io.BioJsHTMLOutput;
29 import jalview.io.DataSourceType;
30 import jalview.io.FileFormat;
31 import jalview.io.FileFormatException;
32 import jalview.io.FileFormatI;
33 import jalview.io.FileLoader;
34 import jalview.io.HtmlSvgOutput;
35 import jalview.io.IdentifyFile;
36 import jalview.io.NewickFile;
37 import jalview.io.gff.SequenceOntologyFactory;
38 import jalview.schemes.ColourSchemeI;
39 import jalview.schemes.ColourSchemeProperty;
40 import jalview.util.MessageManager;
41 import jalview.util.Platform;
42 import jalview.ws.jws2.Jws2Discoverer;
44 import java.io.BufferedReader;
46 import java.io.FileOutputStream;
47 import java.io.IOException;
48 import java.io.InputStreamReader;
49 import java.io.OutputStreamWriter;
50 import java.io.PrintWriter;
51 import java.net.MalformedURLException;
53 import java.net.URISyntaxException;
55 import java.security.AllPermission;
56 import java.security.CodeSource;
57 import java.security.PermissionCollection;
58 import java.security.Permissions;
59 import java.security.Policy;
60 import java.util.HashMap;
62 import java.util.Vector;
64 import javax.swing.LookAndFeel;
65 import javax.swing.UIManager;
67 import groovy.lang.Binding;
68 import groovy.util.GroovyScriptEngine;
71 * Main class for Jalview Application <br>
73 * start with java -Djava.ext.dirs=$PATH_TO_LIB$ jalview.bin.Jalview
81 // BH 6/19/2018 starting to work on JS version - just discovering issues
84 * singleton instance of this class
86 private static Jalview instance;
88 private Desktop desktop;
90 public static AlignFrame currentAlignFrame;
92 public static boolean isJS = /** @j2sNative true || */ // BH 2018
100 // grab all the rights we can the JVM
101 Policy.setPolicy(new Policy()
104 public PermissionCollection getPermissions(CodeSource codesource)
106 Permissions perms = new Permissions();
107 perms.add(new AllPermission());
112 public void refresh()
121 * keep track of feature fetching tasks.
129 * TODO: generalise to track all jalview events to orchestrate batch
133 private int queued = 0;
135 private int running = 0;
137 public FeatureFetcher()
142 public void addFetcher(final AlignFrame af,
143 final Vector<String> dasSources)
145 final long id = System.currentTimeMillis();
147 final FeatureFetcher us = this;
148 new Thread(new Runnable()
160 af.setProgressBar(MessageManager
161 .getString("status.das_features_being_retrived"), id);
162 af.featureSettings_actionPerformed(null);
163 af.featureSettings.fetchDasFeatures(dasSources, true);
164 af.setProgressBar(null, id);
173 public synchronized boolean allFinished()
175 return queued == 0 && running == 0;
180 public static Jalview getInstance()
186 * main class for Jalview application
189 * open <em>filename</em>
191 public static void main(String[] args)
193 instance = new Jalview();
194 instance.doMain(args);
200 void doMain(String[] args)
205 System.setSecurityManager(null);
209 .println("Java version: " + System.getProperty("java.version"));
210 System.out.println(System.getProperty("os.arch") + " "
211 + System.getProperty("os.name") + " "
212 + System.getProperty("os.version"));
214 ArgsParser aparser = new ArgsParser(args);
215 boolean headless = false;
217 if (aparser.contains("help") || aparser.contains("h"))
222 if (aparser.contains("nodisplay") || aparser.contains("nogui")
223 || aparser.contains("headless"))
225 System.setProperty("java.awt.headless", "true");
228 String usrPropsFile = aparser.getValue("props");
229 Cache.loadProperties(usrPropsFile); // must do this before
230 if (usrPropsFile != null)
233 "CMD [-props " + usrPropsFile + "] executed successfully!");
238 final String jabawsUrl = aparser.getValue("jabaws");
239 if (jabawsUrl != null)
243 Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl);
245 "CMD [-jabaws " + jabawsUrl + "] executed successfully!");
246 } catch (MalformedURLException e)
249 "Invalid jabaws parameter: " + jabawsUrl + " ignored");
253 String defs = aparser.getValue("setprop");
256 int p = defs.indexOf('=');
259 System.err.println("Ignoring invalid setprop argument : " + defs);
263 System.out.println("Executing setprop argument: " + defs);
264 // DISABLED FOR SECURITY REASONS
265 // TODO: add a property to allow properties to be overriden by cli args
266 // Cache.setProperty(defs.substring(0,p), defs.substring(p+1));
268 defs = aparser.getValue("setprop");
270 if (System.getProperty("java.awt.headless") != null
271 && System.getProperty("java.awt.headless").equals("true"))
275 System.setProperty("http.agent",
276 "Jalview Desktop/" + Cache.getDefault("VERSION", "Unknown"));
280 } catch (NoClassDefFoundError error)
282 error.printStackTrace();
283 System.out.println("\nEssential logging libraries not found."
284 + "\nUse: java -Djava.ext.dirs=$PATH_TO_LIB$ jalview.bin.Jalview");
292 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
293 } catch (Exception ex)
295 System.err.println("Unexpected Look and Feel Exception");
296 ex.printStackTrace();
298 if (Platform.isAMac())
301 LookAndFeel lookAndFeel = ch.randelshofer.quaqua.QuaquaManager
303 System.setProperty("com.apple.mrj.application.apple.menu.about.name",
305 System.setProperty("apple.laf.useScreenMenuBar", "true");
306 if (lookAndFeel != null)
310 UIManager.setLookAndFeel(lookAndFeel);
311 } catch (Throwable e)
314 "Failed to set QuaQua look and feel: " + e.toString());
317 if (lookAndFeel == null || !(lookAndFeel.getClass()
318 .isAssignableFrom(UIManager.getLookAndFeel().getClass()))
319 || !UIManager.getLookAndFeel().getClass().toString()
320 .toLowerCase().contains("quaqua"))
325 "Quaqua LaF not available on this plaform. Using VAqua(4).\nSee https://issues.jalview.org/browse/JAL-2976");
326 UIManager.setLookAndFeel("org.violetlib.aqua.AquaLookAndFeel");
327 } catch (Throwable e)
330 "Failed to reset look and feel: " + e.toString());
336 * configure 'full' SO model if preferences say to,
337 * else use the default (SO Lite)
339 if (Cache.getDefault("USE_FULL_SO", false))
341 SequenceOntologyFactory.setInstance(new SequenceOntology());
346 desktop = new Desktop();
347 desktop.setInBatchMode(true); // indicate we are starting up
348 desktop.setVisible(true);
349 desktop.startServiceDiscovery();
350 if (!aparser.contains("nousagestats"))
352 startUsageStats(desktop);
356 System.err.println("CMD [-nousagestats] executed successfully!");
359 if (!aparser.contains("noquestionnaire"))
361 String url = aparser.getValue("questionnaire");
364 // Start the desktop questionnaire prompter with the specified
366 Cache.log.debug("Starting questionnaire url at " + url);
367 desktop.checkForQuestionnaire(url);
369 "CMD questionnaire[-" + url + "] executed successfully!");
373 if (Cache.getProperty("NOQUESTIONNAIRES") == null)
375 // Start the desktop questionnaire prompter with the specified
378 // "http://anaplog.compbio.dundee.ac.uk/cgi-bin/questionnaire.pl";
380 String defurl = "http://www.jalview.org/cgi-bin/questionnaire.pl";
382 "Starting questionnaire with default url: " + defurl);
383 desktop.checkForQuestionnaire(defurl);
389 System.err.println("CMD [-noquestionnaire] executed successfully!");
392 if (!aparser.contains("nonews"))
394 desktop.checkForNews();
397 BioJsHTMLOutput.updateBioJS();
400 String file = null, data = null;
401 FileFormatI format = null;
402 DataSourceType protocol = null;
403 FileLoader fileLoader = new FileLoader(!headless);
404 Vector<String> getFeatures = null; // vector of das source nicknames to
408 String groovyscript = null; // script to execute after all loading is
409 // completed one way or another
410 // extract groovy argument and execute if necessary
411 groovyscript = aparser.getValue("groovy", true);
412 file = aparser.getValue("open", true);
414 if (file == null && desktop == null)
416 System.out.println("No files to open!");
419 String vamsasImport = aparser.getValue("vdoc");
420 String vamsasSession = aparser.getValue("vsess");
421 if (vamsasImport != null || vamsasSession != null)
423 if (desktop == null || headless)
426 "Headless vamsas sessions not yet supported. Sorry.");
429 // if we have a file, start a new session and import it.
430 boolean inSession = false;
431 if (vamsasImport != null)
435 DataSourceType viprotocol = AppletFormatAdapter
436 .checkProtocol(vamsasImport);
437 if (viprotocol == DataSourceType.FILE)
439 inSession = desktop.vamsasImport(new File(vamsasImport));
441 else if (viprotocol == DataSourceType.URL)
443 inSession = desktop.vamsasImport(new URL(vamsasImport));
446 } catch (Exception e)
448 System.err.println("Exeption when importing " + vamsasImport
449 + " as a vamsas document.");
454 System.err.println("Failed to import " + vamsasImport
455 + " as a vamsas document.");
459 System.out.println("Imported Successfully into new session "
460 + desktop.getVamsasApplication().getCurrentSession());
463 if (vamsasSession != null)
465 if (vamsasImport != null)
467 // close the newly imported session and import the Jalview specific
468 // remnants into the new session later on.
469 desktop.vamsasStop_actionPerformed(null);
471 // now join the new session
474 if (desktop.joinVamsasSession(vamsasSession))
477 "Successfully joined vamsas session " + vamsasSession);
481 System.err.println("WARNING: Failed to join vamsas session "
484 } catch (Exception e)
487 "ERROR: Failed to join vamsas session " + vamsasSession);
490 if (vamsasImport != null)
492 // the Jalview specific remnants can now be imported into the new
493 // session at the user's leisure.
495 "Skipping Push for import of data into existing vamsas session."); // TODO:
500 // desktop.getVamsasApplication().push_update();
505 // Finally, deal with the remaining input data.
510 desktop.setProgressBar(
512 .getString("status.processing_commandline_args"),
513 progress = System.currentTimeMillis());
515 System.out.println("CMD [-open " + file + "] executed successfully!");
517 if (!file.startsWith("http://"))
519 if (!(new File(file)).exists())
521 System.out.println("Can't find " + file);
529 protocol = AppletFormatAdapter.checkProtocol(file);
533 format = new IdentifyFile().identify(file, protocol);
534 } catch (FileFormatException e1)
539 AlignFrame af = fileLoader.LoadFileWaitTillLoaded(file, protocol,
543 System.out.println("error");
547 setCurrentAlignFrame(af);
548 data = aparser.getValue("colour", true);
551 data.replaceAll("%20", " ");
553 ColourSchemeI cs = ColourSchemeProperty
554 .getColourScheme(af.getViewport().getAlignment(), data);
559 "CMD [-color " + data + "] executed successfully!");
564 // Must maintain ability to use the groups flag
565 data = aparser.getValue("groups", true);
568 af.parseFeaturesFile(data,
569 AppletFormatAdapter.checkProtocol(data));
570 // System.out.println("Added " + data);
572 "CMD groups[-" + data + "] executed successfully!");
574 data = aparser.getValue("features", true);
577 af.parseFeaturesFile(data,
578 AppletFormatAdapter.checkProtocol(data));
579 // System.out.println("Added " + data);
581 "CMD [-features " + data + "] executed successfully!");
584 data = aparser.getValue("annotations", true);
587 af.loadJalviewDataFile(data, null, null, null);
588 // System.out.println("Added " + data);
590 "CMD [-annotations " + data + "] executed successfully!");
592 // set or clear the sortbytree flag.
593 if (aparser.contains("sortbytree"))
595 af.getViewport().setSortByTree(true);
596 if (af.getViewport().getSortByTree())
598 System.out.println("CMD [-sortbytree] executed successfully!");
601 if (aparser.contains("no-annotation"))
603 af.getViewport().setShowAnnotation(false);
604 if (!af.getViewport().isShowAnnotation())
606 System.out.println("CMD no-annotation executed successfully!");
609 if (aparser.contains("nosortbytree"))
611 af.getViewport().setSortByTree(false);
612 if (!af.getViewport().getSortByTree())
615 .println("CMD [-nosortbytree] executed successfully!");
618 data = aparser.getValue("tree", true);
624 "CMD [-tree " + data + "] executed successfully!");
625 NewickFile nf = new NewickFile(data,
626 AppletFormatAdapter.checkProtocol(data));
628 .setCurrentTree(af.showNewickTree(nf, data).getTree());
629 } catch (IOException ex)
631 System.err.println("Couldn't add tree " + data);
632 ex.printStackTrace(System.err);
635 // TODO - load PDB structure(s) to alignment JAL-629
636 // (associate with identical sequence in alignment, or a specified
639 getFeatures = checkDasArguments(aparser);
640 if (af != null && getFeatures != null)
642 FeatureFetcher ff = startFeatureFetching(getFeatures);
645 while (!ff.allFinished() || af.operationInProgress())
647 // wait around until fetching is finished.
651 } catch (Exception e)
657 getFeatures = null; // have retrieved features - forget them now.
659 if (groovyscript != null)
661 // Execute the groovy script after we've done all the rendering stuff
662 // and before any images or figures are generated.
663 System.out.println("Executing script " + groovyscript);
664 executeGroovyScript(groovyscript, af);
665 System.out.println("CMD groovy[" + groovyscript
666 + "] executed successfully!");
669 String imageName = "unnamed.png";
670 while (aparser.getSize() > 1)
672 String outputFormat = aparser.nextValue();
673 file = aparser.nextValue();
675 if (outputFormat.equalsIgnoreCase("png"))
677 af.createPNG(new File(file));
678 imageName = (new File(file)).getName();
679 System.out.println("Creating PNG image: " + file);
682 else if (outputFormat.equalsIgnoreCase("svg"))
684 File imageFile = new File(file);
685 imageName = imageFile.getName();
686 af.createSVG(imageFile);
687 System.out.println("Creating SVG image: " + file);
690 else if (outputFormat.equalsIgnoreCase("html"))
692 File imageFile = new File(file);
693 imageName = imageFile.getName();
694 HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel);
695 htmlSVG.exportHTML(file);
697 System.out.println("Creating HTML image: " + file);
700 else if (outputFormat.equalsIgnoreCase("biojsmsa"))
704 System.err.println("The output html file must not be null");
709 BioJsHTMLOutput.refreshVersionInfo(
710 BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
711 } catch (URISyntaxException e)
715 BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel);
716 bjs.exportHTML(file);
718 .println("Creating BioJS MSA Viwer HTML file: " + file);
721 else if (outputFormat.equalsIgnoreCase("imgMap"))
723 af.createImageMap(new File(file), imageName);
724 System.out.println("Creating image map: " + file);
727 else if (outputFormat.equalsIgnoreCase("eps"))
729 File outputFile = new File(file);
731 "Creating EPS file: " + outputFile.getAbsolutePath());
732 af.createEPS(outputFile);
736 if (af.saveAlignment(file, format))
738 System.out.println("Written alignment in " + format
739 + " format to " + file);
743 System.out.println("Error writing file " + file + " in "
744 + format + " format!!");
749 while (aparser.getSize() > 0)
751 System.out.println("Unknown arg: " + aparser.nextValue());
755 AlignFrame startUpAlframe = null;
756 // We'll only open the default file if the desktop is visible.
758 // ////////////////////
760 if (!headless && file == null && vamsasImport == null
761 && jalview.bin.Cache.getDefault("SHOW_STARTUP_FILE", true))
763 file = jalview.bin.Cache.getDefault("STARTUP_FILE",
764 jalview.bin.Cache.getDefault("www.jalview.org",
765 "http://www.jalview.org")
766 + "/examples/exampleFile_2_7.jar");
768 "http://www.jalview.org/examples/exampleFile_2_3.jar"))
770 // hardwire upgrade of the startup file
771 file.replace("_2_3.jar", "_2_7.jar");
772 // and remove the stale setting
773 jalview.bin.Cache.removeProperty("STARTUP_FILE");
776 protocol = DataSourceType.FILE;
778 if (file.indexOf("http:") > -1)
780 protocol = DataSourceType.URL;
783 if (file.endsWith(".jar"))
785 format = FileFormat.Jalview;
791 format = new IdentifyFile().identify(file, protocol);
792 } catch (FileFormatException e)
798 startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol,
800 getFeatures = checkDasArguments(aparser);
801 // extract groovy arguments before anything else.
803 // If the user has specified features to be retrieved,
804 // or a groovy script to be executed, do them if they
805 // haven't been done already
806 // fetch features for the default alignment
807 if (getFeatures != null)
809 if (startUpAlframe != null)
811 startFeatureFetching(getFeatures);
814 // Once all other stuff is done, execute any groovy scripts (in order)
815 if (groovyscript != null)
817 if (Cache.groovyJarsPresent())
819 System.out.println("Executing script " + groovyscript);
820 executeGroovyScript(groovyscript, startUpAlframe);
825 "Sorry. Groovy Support is not available, so ignoring the provided groovy script "
829 // and finally, turn off batch mode indicator - if the desktop still exists
834 desktop.setProgressBar(null, progress);
836 desktop.setInBatchMode(false);
840 private static void showUsage()
843 "Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n"
844 + "-nodisplay\tRun Jalview without User Interface.\n"
845 + "-props FILE\tUse the given Jalview properties file instead of users default.\n"
846 + "-colour COLOURSCHEME\tThe colourscheme to be applied to the alignment\n"
847 + "-annotations FILE\tAdd precalculated annotations to the alignment.\n"
848 + "-tree FILE\tLoad the given newick format tree file onto the alignment\n"
849 + "-features FILE\tUse the given file to mark features on the alignment.\n"
850 + "-fasta FILE\tCreate alignment file FILE in Fasta format.\n"
851 + "-clustal FILE\tCreate alignment file FILE in Clustal format.\n"
852 + "-pfam FILE\tCreate alignment file FILE in PFAM format.\n"
853 + "-msf FILE\tCreate alignment file FILE in MSF format.\n"
854 + "-pileup FILE\tCreate alignment file FILE in Pileup format\n"
855 + "-pir FILE\tCreate alignment file FILE in PIR format.\n"
856 + "-blc FILE\tCreate alignment file FILE in BLC format.\n"
857 + "-json FILE\tCreate alignment file FILE in JSON format.\n"
858 + "-jalview FILE\tCreate alignment file FILE in Jalview format.\n"
859 + "-png FILE\tCreate PNG image FILE from alignment.\n"
860 + "-svg FILE\tCreate SVG image FILE from alignment.\n"
861 + "-html FILE\tCreate HTML file from alignment.\n"
862 + "-biojsMSA FILE\tCreate BioJS MSA Viewer HTML file from alignment.\n"
863 + "-imgMap FILE\tCreate HTML file FILE with image map of PNG image.\n"
864 + "-eps FILE\tCreate EPS file FILE from alignment.\n"
865 + "-questionnaire URL\tQueries the given URL for information about any Jalview user questionnaires.\n"
866 + "-noquestionnaire\tTurn off questionnaire check.\n"
867 + "-nonews\tTurn off check for Jalview news.\n"
868 + "-nousagestats\tTurn off google analytics tracking for this session.\n"
869 + "-sortbytree OR -nosortbytree\tEnable or disable sorting of the given alignment by the given tree\n"
871 // "-setprop PROPERTY=VALUE\tSet the given Jalview property,
872 // after all other properties files have been read\n\t
873 // (quote the 'PROPERTY=VALUE' pair to ensure spaces are
874 // passed in correctly)"
875 + "-jabaws URL\tSpecify URL for Jabaws services (e.g. for a local installation).\n"
876 + "-dasserver nickname=URL\tAdd and enable a das server with given nickname\n\t\t\t(alphanumeric or underscores only) for retrieval of features for all alignments.\n"
877 + "\t\t\tSources that also support the sequence command may be specified by prepending the URL with sequence:\n"
878 + "\t\t\t e.g. sequence:http://localdas.somewhere.org/das/source)\n"
879 + "-fetchfrom nickname\tQuery nickname for features for the alignments and display them.\n"
881 // "-vdoc vamsas-document\tImport vamsas document into new
882 // session or join existing session with same URN\n"
883 // + "-vses vamsas-session\tJoin session with given URN\n"
884 + "-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"
885 + "\n~Read documentation in Application or visit http://www.jalview.org for description of Features and Annotations file~\n\n");
888 private static void startUsageStats(final Desktop desktop)
891 * start a User Config prompt asking if we can log usage statistics.
893 PromptUserConfig prompter = new PromptUserConfig(Desktop.desktop,
894 "USAGESTATS", "Jalview Usage Statistics",
895 "Do you want to help make Jalview better by enabling "
896 + "the collection of usage statistics with Google Analytics ?"
897 + "\n\n(you can enable or disable usage tracking in the preferences)",
904 "Initialising googletracker for usage stats.");
905 Cache.initGoogleTracker();
906 Cache.log.debug("Tracking enabled.");
913 Cache.log.debug("Not enabling Google Tracking.");
916 desktop.addDialogThread(prompter);
920 * Locate the given string as a file and pass it to the groovy interpreter.
922 * @param groovyscript
923 * the script to execute
924 * @param jalviewContext
925 * the Jalview Desktop object passed in to the groovy binding as the
928 private void executeGroovyScript(String groovyscript, AlignFrame af)
931 * for scripts contained in files
938 if (groovyscript.trim().equals("STDIN"))
940 // read from stdin into a tempfile and execute it
943 tfile = File.createTempFile("jalview", "groovy");
944 PrintWriter outfile = new PrintWriter(
945 new OutputStreamWriter(new FileOutputStream(tfile)));
946 BufferedReader br = new BufferedReader(
947 new InputStreamReader(System.in));
949 while ((line = br.readLine()) != null)
951 outfile.write(line + "\n");
957 } catch (Exception ex)
959 System.err.println("Failed to read from STDIN into tempfile "
960 + ((tfile == null) ? "(tempfile wasn't created)"
961 : tfile.toString()));
962 ex.printStackTrace();
967 sfile = tfile.toURI().toURL();
968 } catch (Exception x)
971 "Unexpected Malformed URL Exception for temporary file created from STDIN: "
981 sfile = new URI(groovyscript).toURL();
982 } catch (Exception x)
984 tfile = new File(groovyscript);
987 System.err.println("File '" + groovyscript + "' does not exist.");
990 if (!tfile.canRead())
992 System.err.println("File '" + groovyscript + "' cannot be read.");
995 if (tfile.length() < 1)
997 System.err.println("File '" + groovyscript + "' is empty.");
1002 sfile = tfile.getAbsoluteFile().toURI().toURL();
1003 } catch (Exception ex)
1005 System.err.println("Failed to create a file URL for "
1006 + tfile.getAbsoluteFile());
1013 Map<String, Object> vbinding = new HashMap<>();
1014 vbinding.put("Jalview", this);
1017 vbinding.put("currentAlFrame", af);
1019 Binding gbinding = new Binding(vbinding);
1020 GroovyScriptEngine gse = new GroovyScriptEngine(new URL[] { sfile });
1021 gse.run(sfile.toString(), gbinding);
1022 if ("STDIN".equals(groovyscript))
1024 // delete temp file that we made -
1025 // only if it was successfully executed
1028 } catch (Exception e)
1030 System.err.println("Exception Whilst trying to execute file " + sfile
1031 + " as a groovy script.");
1032 e.printStackTrace(System.err);
1038 * Check commandline for any das server definitions or any fetchfrom switches
1040 * @return vector of DAS source nicknames to retrieve from
1042 private static Vector<String> checkDasArguments(ArgsParser aparser)
1044 Vector<String> source = null;
1046 String locsources = Cache.getProperty(Cache.DAS_LOCAL_SOURCE);
1047 while ((data = aparser.getValue("dasserver", true)) != null)
1049 String nickname = null;
1051 int pos = data.indexOf('=');
1052 // determine capabilities
1055 nickname = data.substring(0, pos);
1057 url = data.substring(pos + 1);
1058 if (url != null && (url.startsWith("http:")
1059 || url.startsWith("sequence:http:")))
1061 if (nickname == null)
1065 if (locsources == null)
1073 locsources = locsources + nickname + "|" + url;
1075 "NOTE! dasserver parameter not yet really supported (got args of "
1076 + nickname + "|" + url);
1079 source = new Vector<>();
1081 source.addElement(nickname);
1084 "CMD [-dasserver " + data + "] executed successfully!");
1085 } // loop until no more server entries are found.
1086 if (locsources != null && locsources.indexOf('|') > -1)
1088 Cache.log.debug("Setting local source list in properties file to:\n"
1090 Cache.setProperty(Cache.DAS_LOCAL_SOURCE, locsources);
1092 while ((data = aparser.getValue("fetchfrom", true)) != null)
1094 System.out.println("adding source '" + data + "'");
1097 source = new Vector<>();
1099 source.addElement(data);
1105 * start a feature fetcher for every alignment frame
1109 private FeatureFetcher startFeatureFetching(
1110 final Vector<String> dasSources)
1112 FeatureFetcher ff = new FeatureFetcher();
1113 AlignFrame afs[] = Desktop.getAlignFrames();
1114 if (afs == null || afs.length == 0)
1118 for (int i = 0; i < afs.length; i++)
1120 ff.addFetcher(afs[i], dasSources);
1125 public static boolean isHeadlessMode()
1127 String isheadless = System.getProperty("java.awt.headless");
1128 if (isheadless != null && isheadless.equalsIgnoreCase("true"))
1135 public AlignFrame[] getAlignFrames()
1137 return desktop == null ? new AlignFrame[] { getCurrentAlignFrame() }
1138 : Desktop.getAlignFrames();
1143 * Quit method delegates to Desktop.quit - unless running in headless mode
1144 * when it just ends the JVM
1148 if (desktop != null)
1158 public static AlignFrame getCurrentAlignFrame()
1160 return Jalview.currentAlignFrame;
1163 public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)
1165 Jalview.currentAlignFrame = currentAlignFrame;