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 -classpath "$PATH_TO_LIB$/*:$PATH_TO_CLASSES$"
82 * singleton instance of this class
84 private static Jalview instance;
86 private Desktop desktop;
88 public static AlignFrame currentAlignFrame;
92 // grab all the rights we can the JVM
93 Policy.setPolicy(new Policy()
96 public PermissionCollection getPermissions(CodeSource codesource)
98 Permissions perms = new Permissions();
99 perms.add(new AllPermission());
104 public void refresh()
111 * keep track of feature fetching tasks.
119 * TODO: generalise to track all jalview events to orchestrate batch
123 private int queued = 0;
125 private int running = 0;
127 public FeatureFetcher()
132 public void addFetcher(final AlignFrame af,
133 final Vector<String> dasSources)
135 final long id = System.currentTimeMillis();
137 final FeatureFetcher us = this;
138 new Thread(new Runnable()
150 af.setProgressBar(MessageManager
151 .getString("status.das_features_being_retrived"), id);
152 af.featureSettings_actionPerformed(null);
153 af.featureSettings.fetchDasFeatures(dasSources, true);
154 af.setProgressBar(null, id);
163 public synchronized boolean allFinished()
165 return queued == 0 && running == 0;
170 public static Jalview getInstance()
176 * main class for Jalview application
179 * open <em>filename</em>
181 public static void main(String[] args)
183 instance = new Jalview();
184 instance.doMain(args);
190 void doMain(String[] args)
192 System.setSecurityManager(null);
194 .println("Java version: " + System.getProperty("java.version"));
195 System.out.println(System.getProperty("os.arch") + " "
196 + System.getProperty("os.name") + " "
197 + System.getProperty("os.version"));
199 ArgsParser aparser = new ArgsParser(args);
200 boolean headless = false;
202 if (aparser.contains("help") || aparser.contains("h"))
207 if (aparser.contains("nodisplay") || aparser.contains("nogui")
208 || aparser.contains("headless"))
210 System.setProperty("java.awt.headless", "true");
213 String usrPropsFile = aparser.getValue("props");
214 Cache.loadProperties(usrPropsFile); // must do this before
215 if (usrPropsFile != null)
218 "CMD [-props " + usrPropsFile + "] executed successfully!");
223 final String jabawsUrl = aparser.getValue("jabaws");
224 if (jabawsUrl != null)
228 Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl);
230 "CMD [-jabaws " + jabawsUrl + "] executed successfully!");
231 } catch (MalformedURLException e)
234 "Invalid jabaws parameter: " + jabawsUrl + " ignored");
238 String defs = aparser.getValue("setprop");
241 int p = defs.indexOf('=');
244 System.err.println("Ignoring invalid setprop argument : " + defs);
248 System.out.println("Executing setprop argument: " + defs);
249 // DISABLED FOR SECURITY REASONS
250 // TODO: add a property to allow properties to be overriden by cli args
251 // Cache.setProperty(defs.substring(0,p), defs.substring(p+1));
253 defs = aparser.getValue("setprop");
255 if (System.getProperty("java.awt.headless") != null
256 && System.getProperty("java.awt.headless").equals("true"))
260 System.setProperty("http.agent",
261 "Jalview Desktop/" + Cache.getDefault("VERSION", "Unknown"));
265 } catch (NoClassDefFoundError error)
267 error.printStackTrace();
268 System.out.println("\nEssential logging libraries not found."
269 + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview");
277 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
278 } catch (Exception ex)
280 System.err.println("Unexpected Look and Feel Exception");
281 ex.printStackTrace();
283 if (Platform.isAMac())
286 LookAndFeel lookAndFeel = ch.randelshofer.quaqua.QuaquaManager
288 System.setProperty("com.apple.mrj.application.apple.menu.about.name",
290 System.setProperty("apple.laf.useScreenMenuBar", "true");
291 if (lookAndFeel != null)
295 UIManager.setLookAndFeel(lookAndFeel);
296 } catch (Throwable e)
299 "Failed to set QuaQua look and feel: " + e.toString());
302 if (lookAndFeel == null || !(lookAndFeel.getClass()
303 .isAssignableFrom(UIManager.getLookAndFeel().getClass()))
304 || !UIManager.getLookAndFeel().getClass().toString()
305 .toLowerCase().contains("quaqua"))
310 "Quaqua LaF not available on this plaform. Using VAqua(4).\nSee https://issues.jalview.org/browse/JAL-2976");
311 UIManager.setLookAndFeel("org.violetlib.aqua.AquaLookAndFeel");
312 } catch (Throwable e)
315 "Failed to reset look and feel: " + e.toString());
321 * configure 'full' SO model if preferences say to,
322 * else use the default (SO Lite)
324 if (Cache.getDefault("USE_FULL_SO", false))
326 SequenceOntologyFactory.setInstance(new SequenceOntology());
331 desktop = new Desktop();
332 desktop.setInBatchMode(true); // indicate we are starting up
333 desktop.setVisible(true);
334 desktop.startServiceDiscovery();
335 if (!aparser.contains("nousagestats"))
337 startUsageStats(desktop);
341 System.err.println("CMD [-nousagestats] executed successfully!");
344 if (!aparser.contains("noquestionnaire"))
346 String url = aparser.getValue("questionnaire");
349 // Start the desktop questionnaire prompter with the specified
351 Cache.log.debug("Starting questionnaire url at " + url);
352 desktop.checkForQuestionnaire(url);
354 "CMD questionnaire[-" + url + "] executed successfully!");
358 if (Cache.getProperty("NOQUESTIONNAIRES") == null)
360 // Start the desktop questionnaire prompter with the specified
363 // "http://anaplog.compbio.dundee.ac.uk/cgi-bin/questionnaire.pl";
365 String defurl = "http://www.jalview.org/cgi-bin/questionnaire.pl";
367 "Starting questionnaire with default url: " + defurl);
368 desktop.checkForQuestionnaire(defurl);
374 System.err.println("CMD [-noquestionnaire] executed successfully!");
377 if (!aparser.contains("nonews"))
379 desktop.checkForNews();
382 BioJsHTMLOutput.updateBioJS();
385 String file = null, data = null;
386 FileFormatI format = null;
387 DataSourceType protocol = null;
388 FileLoader fileLoader = new FileLoader(!headless);
389 Vector<String> getFeatures = null; // vector of das source nicknames to
393 String groovyscript = null; // script to execute after all loading is
394 // completed one way or another
395 // extract groovy argument and execute if necessary
396 groovyscript = aparser.getValue("groovy", true);
397 file = aparser.getValue("open", true);
399 if (file == null && desktop == null)
401 System.out.println("No files to open!");
404 String vamsasImport = aparser.getValue("vdoc");
405 String vamsasSession = aparser.getValue("vsess");
406 if (vamsasImport != null || vamsasSession != null)
408 if (desktop == null || headless)
411 "Headless vamsas sessions not yet supported. Sorry.");
414 // if we have a file, start a new session and import it.
415 boolean inSession = false;
416 if (vamsasImport != null)
420 DataSourceType viprotocol = AppletFormatAdapter
421 .checkProtocol(vamsasImport);
422 if (viprotocol == DataSourceType.FILE)
424 inSession = desktop.vamsasImport(new File(vamsasImport));
426 else if (viprotocol == DataSourceType.URL)
428 inSession = desktop.vamsasImport(new URL(vamsasImport));
431 } catch (Exception e)
433 System.err.println("Exeption when importing " + vamsasImport
434 + " as a vamsas document.");
439 System.err.println("Failed to import " + vamsasImport
440 + " as a vamsas document.");
444 System.out.println("Imported Successfully into new session "
445 + desktop.getVamsasApplication().getCurrentSession());
448 if (vamsasSession != null)
450 if (vamsasImport != null)
452 // close the newly imported session and import the Jalview specific
453 // remnants into the new session later on.
454 desktop.vamsasStop_actionPerformed(null);
456 // now join the new session
459 if (desktop.joinVamsasSession(vamsasSession))
462 "Successfully joined vamsas session " + vamsasSession);
466 System.err.println("WARNING: Failed to join vamsas session "
469 } catch (Exception e)
472 "ERROR: Failed to join vamsas session " + vamsasSession);
475 if (vamsasImport != null)
477 // the Jalview specific remnants can now be imported into the new
478 // session at the user's leisure.
480 "Skipping Push for import of data into existing vamsas session."); // TODO:
485 // desktop.getVamsasApplication().push_update();
490 // Finally, deal with the remaining input data.
495 desktop.setProgressBar(
497 .getString("status.processing_commandline_args"),
498 progress = System.currentTimeMillis());
500 System.out.println("CMD [-open " + file + "] executed successfully!");
502 if (!file.startsWith("http://"))
504 if (!(new File(file)).exists())
506 System.out.println("Can't find " + file);
514 protocol = AppletFormatAdapter.checkProtocol(file);
518 format = new IdentifyFile().identify(file, protocol);
519 } catch (FileFormatException e1)
524 AlignFrame af = fileLoader.LoadFileWaitTillLoaded(file, protocol,
528 System.out.println("error");
532 setCurrentAlignFrame(af);
533 data = aparser.getValue("colour", true);
536 data.replaceAll("%20", " ");
538 ColourSchemeI cs = ColourSchemeProperty
539 .getColourScheme(af.getViewport().getAlignment(), data);
544 "CMD [-color " + data + "] executed successfully!");
549 // Must maintain ability to use the groups flag
550 data = aparser.getValue("groups", true);
553 af.parseFeaturesFile(data,
554 AppletFormatAdapter.checkProtocol(data));
555 // System.out.println("Added " + data);
557 "CMD groups[-" + data + "] executed successfully!");
559 data = aparser.getValue("features", true);
562 af.parseFeaturesFile(data,
563 AppletFormatAdapter.checkProtocol(data));
564 // System.out.println("Added " + data);
566 "CMD [-features " + data + "] executed successfully!");
569 data = aparser.getValue("annotations", true);
572 af.loadJalviewDataFile(data, null, null, null);
573 // System.out.println("Added " + data);
575 "CMD [-annotations " + data + "] executed successfully!");
577 // set or clear the sortbytree flag.
578 if (aparser.contains("sortbytree"))
580 af.getViewport().setSortByTree(true);
581 if (af.getViewport().getSortByTree())
583 System.out.println("CMD [-sortbytree] executed successfully!");
586 if (aparser.contains("no-annotation"))
588 af.getViewport().setShowAnnotation(false);
589 if (!af.getViewport().isShowAnnotation())
591 System.out.println("CMD no-annotation executed successfully!");
594 if (aparser.contains("nosortbytree"))
596 af.getViewport().setSortByTree(false);
597 if (!af.getViewport().getSortByTree())
600 .println("CMD [-nosortbytree] executed successfully!");
603 data = aparser.getValue("tree", true);
609 "CMD [-tree " + data + "] executed successfully!");
610 NewickFile nf = new NewickFile(data,
611 AppletFormatAdapter.checkProtocol(data));
613 .setCurrentTree(af.showNewickTree(nf, data).getTree());
614 } catch (IOException ex)
616 System.err.println("Couldn't add tree " + data);
617 ex.printStackTrace(System.err);
620 // TODO - load PDB structure(s) to alignment JAL-629
621 // (associate with identical sequence in alignment, or a specified
624 getFeatures = checkDasArguments(aparser);
625 if (af != null && getFeatures != null)
627 FeatureFetcher ff = startFeatureFetching(getFeatures);
630 while (!ff.allFinished() || af.operationInProgress())
632 // wait around until fetching is finished.
636 } catch (Exception e)
642 getFeatures = null; // have retrieved features - forget them now.
644 if (groovyscript != null)
646 // Execute the groovy script after we've done all the rendering stuff
647 // and before any images or figures are generated.
648 System.out.println("Executing script " + groovyscript);
649 executeGroovyScript(groovyscript, af);
650 System.out.println("CMD groovy[" + groovyscript
651 + "] executed successfully!");
654 String imageName = "unnamed.png";
655 while (aparser.getSize() > 1)
657 String outputFormat = aparser.nextValue();
658 file = aparser.nextValue();
660 if (outputFormat.equalsIgnoreCase("png"))
662 af.createPNG(new File(file));
663 imageName = (new File(file)).getName();
664 System.out.println("Creating PNG image: " + file);
667 else if (outputFormat.equalsIgnoreCase("svg"))
669 File imageFile = new File(file);
670 imageName = imageFile.getName();
671 af.createSVG(imageFile);
672 System.out.println("Creating SVG image: " + file);
675 else if (outputFormat.equalsIgnoreCase("html"))
677 File imageFile = new File(file);
678 imageName = imageFile.getName();
679 HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel);
680 htmlSVG.exportHTML(file);
682 System.out.println("Creating HTML image: " + file);
685 else if (outputFormat.equalsIgnoreCase("biojsmsa"))
689 System.err.println("The output html file must not be null");
694 BioJsHTMLOutput.refreshVersionInfo(
695 BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
696 } catch (URISyntaxException e)
700 BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel);
701 bjs.exportHTML(file);
703 .println("Creating BioJS MSA Viwer HTML file: " + file);
706 else if (outputFormat.equalsIgnoreCase("imgMap"))
708 af.createImageMap(new File(file), imageName);
709 System.out.println("Creating image map: " + file);
712 else if (outputFormat.equalsIgnoreCase("eps"))
714 File outputFile = new File(file);
716 "Creating EPS file: " + outputFile.getAbsolutePath());
717 af.createEPS(outputFile);
721 if (af.saveAlignment(file, format))
723 System.out.println("Written alignment in " + format
724 + " format to " + file);
728 System.out.println("Error writing file " + file + " in "
729 + format + " format!!");
734 while (aparser.getSize() > 0)
736 System.out.println("Unknown arg: " + aparser.nextValue());
740 AlignFrame startUpAlframe = null;
741 // We'll only open the default file if the desktop is visible.
743 // ////////////////////
745 if (!headless && file == null && vamsasImport == null
746 && jalview.bin.Cache.getDefault("SHOW_STARTUP_FILE", true))
748 file = jalview.bin.Cache.getDefault("STARTUP_FILE",
749 jalview.bin.Cache.getDefault("www.jalview.org",
750 "http://www.jalview.org")
751 + "/examples/exampleFile_2_7.jar");
753 "http://www.jalview.org/examples/exampleFile_2_3.jar"))
755 // hardwire upgrade of the startup file
756 file.replace("_2_3.jar", "_2_7.jar");
757 // and remove the stale setting
758 jalview.bin.Cache.removeProperty("STARTUP_FILE");
761 protocol = DataSourceType.FILE;
763 if (file.indexOf("http:") > -1)
765 protocol = DataSourceType.URL;
768 if (file.endsWith(".jar"))
770 format = FileFormat.Jalview;
776 format = new IdentifyFile().identify(file, protocol);
777 } catch (FileFormatException e)
783 startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol,
785 getFeatures = checkDasArguments(aparser);
786 // extract groovy arguments before anything else.
788 // If the user has specified features to be retrieved,
789 // or a groovy script to be executed, do them if they
790 // haven't been done already
791 // fetch features for the default alignment
792 if (getFeatures != null)
794 if (startUpAlframe != null)
796 startFeatureFetching(getFeatures);
799 // Once all other stuff is done, execute any groovy scripts (in order)
800 if (groovyscript != null)
802 if (Cache.groovyJarsPresent())
804 System.out.println("Executing script " + groovyscript);
805 executeGroovyScript(groovyscript, startUpAlframe);
810 "Sorry. Groovy Support is not available, so ignoring the provided groovy script "
814 // and finally, turn off batch mode indicator - if the desktop still exists
819 desktop.setProgressBar(null, progress);
821 desktop.setInBatchMode(false);
825 private static void showUsage()
828 "Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n"
829 + "-nodisplay\tRun Jalview without User Interface.\n"
830 + "-props FILE\tUse the given Jalview properties file instead of users default.\n"
831 + "-colour COLOURSCHEME\tThe colourscheme to be applied to the alignment\n"
832 + "-annotations FILE\tAdd precalculated annotations to the alignment.\n"
833 + "-tree FILE\tLoad the given newick format tree file onto the alignment\n"
834 + "-features FILE\tUse the given file to mark features on the alignment.\n"
835 + "-fasta FILE\tCreate alignment file FILE in Fasta format.\n"
836 + "-clustal FILE\tCreate alignment file FILE in Clustal format.\n"
837 + "-pfam FILE\tCreate alignment file FILE in PFAM format.\n"
838 + "-msf FILE\tCreate alignment file FILE in MSF format.\n"
839 + "-pileup FILE\tCreate alignment file FILE in Pileup format\n"
840 + "-pir FILE\tCreate alignment file FILE in PIR format.\n"
841 + "-blc FILE\tCreate alignment file FILE in BLC format.\n"
842 + "-json FILE\tCreate alignment file FILE in JSON format.\n"
843 + "-jalview FILE\tCreate alignment file FILE in Jalview format.\n"
844 + "-png FILE\tCreate PNG image FILE from alignment.\n"
845 + "-svg FILE\tCreate SVG image FILE from alignment.\n"
846 + "-html FILE\tCreate HTML file from alignment.\n"
847 + "-biojsMSA FILE\tCreate BioJS MSA Viewer HTML file from alignment.\n"
848 + "-imgMap FILE\tCreate HTML file FILE with image map of PNG image.\n"
849 + "-eps FILE\tCreate EPS file FILE from alignment.\n"
850 + "-questionnaire URL\tQueries the given URL for information about any Jalview user questionnaires.\n"
851 + "-noquestionnaire\tTurn off questionnaire check.\n"
852 + "-nonews\tTurn off check for Jalview news.\n"
853 + "-nousagestats\tTurn off google analytics tracking for this session.\n"
854 + "-sortbytree OR -nosortbytree\tEnable or disable sorting of the given alignment by the given tree\n"
856 // "-setprop PROPERTY=VALUE\tSet the given Jalview property,
857 // after all other properties files have been read\n\t
858 // (quote the 'PROPERTY=VALUE' pair to ensure spaces are
859 // passed in correctly)"
860 + "-jabaws URL\tSpecify URL for Jabaws services (e.g. for a local installation).\n"
861 + "-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"
862 + "\t\t\tSources that also support the sequence command may be specified by prepending the URL with sequence:\n"
863 + "\t\t\t e.g. sequence:http://localdas.somewhere.org/das/source)\n"
864 + "-fetchfrom nickname\tQuery nickname for features for the alignments and display them.\n"
866 // "-vdoc vamsas-document\tImport vamsas document into new
867 // session or join existing session with same URN\n"
868 // + "-vses vamsas-session\tJoin session with given URN\n"
869 + "-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"
870 + "\n~Read documentation in Application or visit http://www.jalview.org for description of Features and Annotations file~\n\n");
873 private static void startUsageStats(final Desktop desktop)
876 * start a User Config prompt asking if we can log usage statistics.
878 PromptUserConfig prompter = new PromptUserConfig(Desktop.desktop,
879 "USAGESTATS", "Jalview Usage Statistics",
880 "Do you want to help make Jalview better by enabling "
881 + "the collection of usage statistics with Google Analytics ?"
882 + "\n\n(you can enable or disable usage tracking in the preferences)",
889 "Initialising googletracker for usage stats.");
890 Cache.initGoogleTracker();
891 Cache.log.debug("Tracking enabled.");
898 Cache.log.debug("Not enabling Google Tracking.");
901 desktop.addDialogThread(prompter);
905 * Locate the given string as a file and pass it to the groovy interpreter.
907 * @param groovyscript
908 * the script to execute
909 * @param jalviewContext
910 * the Jalview Desktop object passed in to the groovy binding as the
913 private void executeGroovyScript(String groovyscript, AlignFrame af)
916 * for scripts contained in files
923 if (groovyscript.trim().equals("STDIN"))
925 // read from stdin into a tempfile and execute it
928 tfile = File.createTempFile("jalview", "groovy");
929 PrintWriter outfile = new PrintWriter(
930 new OutputStreamWriter(new FileOutputStream(tfile)));
931 BufferedReader br = new BufferedReader(
932 new InputStreamReader(System.in));
934 while ((line = br.readLine()) != null)
936 outfile.write(line + "\n");
942 } catch (Exception ex)
944 System.err.println("Failed to read from STDIN into tempfile "
945 + ((tfile == null) ? "(tempfile wasn't created)"
946 : tfile.toString()));
947 ex.printStackTrace();
952 sfile = tfile.toURI().toURL();
953 } catch (Exception x)
956 "Unexpected Malformed URL Exception for temporary file created from STDIN: "
966 sfile = new URI(groovyscript).toURL();
967 } catch (Exception x)
969 tfile = new File(groovyscript);
972 System.err.println("File '" + groovyscript + "' does not exist.");
975 if (!tfile.canRead())
977 System.err.println("File '" + groovyscript + "' cannot be read.");
980 if (tfile.length() < 1)
982 System.err.println("File '" + groovyscript + "' is empty.");
987 sfile = tfile.getAbsoluteFile().toURI().toURL();
988 } catch (Exception ex)
990 System.err.println("Failed to create a file URL for "
991 + tfile.getAbsoluteFile());
998 Map<String, Object> vbinding = new HashMap<>();
999 vbinding.put("Jalview", this);
1002 vbinding.put("currentAlFrame", af);
1004 Binding gbinding = new Binding(vbinding);
1005 GroovyScriptEngine gse = new GroovyScriptEngine(new URL[] { sfile });
1006 gse.run(sfile.toString(), gbinding);
1007 if ("STDIN".equals(groovyscript))
1009 // delete temp file that we made -
1010 // only if it was successfully executed
1013 } catch (Exception e)
1015 System.err.println("Exception Whilst trying to execute file " + sfile
1016 + " as a groovy script.");
1017 e.printStackTrace(System.err);
1023 * Check commandline for any das server definitions or any fetchfrom switches
1025 * @return vector of DAS source nicknames to retrieve from
1027 private static Vector<String> checkDasArguments(ArgsParser aparser)
1029 Vector<String> source = null;
1031 String locsources = Cache.getProperty(Cache.DAS_LOCAL_SOURCE);
1032 while ((data = aparser.getValue("dasserver", true)) != null)
1034 String nickname = null;
1036 int pos = data.indexOf('=');
1037 // determine capabilities
1040 nickname = data.substring(0, pos);
1042 url = data.substring(pos + 1);
1043 if (url != null && (url.startsWith("http:")
1044 || url.startsWith("sequence:http:")))
1046 if (nickname == null)
1050 if (locsources == null)
1058 locsources = locsources + nickname + "|" + url;
1060 "NOTE! dasserver parameter not yet really supported (got args of "
1061 + nickname + "|" + url);
1064 source = new Vector<>();
1066 source.addElement(nickname);
1069 "CMD [-dasserver " + data + "] executed successfully!");
1070 } // loop until no more server entries are found.
1071 if (locsources != null && locsources.indexOf('|') > -1)
1073 Cache.log.debug("Setting local source list in properties file to:\n"
1075 Cache.setProperty(Cache.DAS_LOCAL_SOURCE, locsources);
1077 while ((data = aparser.getValue("fetchfrom", true)) != null)
1079 System.out.println("adding source '" + data + "'");
1082 source = new Vector<>();
1084 source.addElement(data);
1090 * start a feature fetcher for every alignment frame
1094 private FeatureFetcher startFeatureFetching(
1095 final Vector<String> dasSources)
1097 FeatureFetcher ff = new FeatureFetcher();
1098 AlignFrame afs[] = Desktop.getAlignFrames();
1099 if (afs == null || afs.length == 0)
1103 for (int i = 0; i < afs.length; i++)
1105 ff.addFetcher(afs[i], dasSources);
1110 public static boolean isHeadlessMode()
1112 String isheadless = System.getProperty("java.awt.headless");
1113 if (isheadless != null && isheadless.equalsIgnoreCase("true"))
1120 public AlignFrame[] getAlignFrames()
1122 return desktop == null ? new AlignFrame[] { getCurrentAlignFrame() }
1123 : Desktop.getAlignFrames();
1128 * Quit method delegates to Desktop.quit - unless running in headless mode
1129 * when it just ends the JVM
1133 if (desktop != null)
1143 public static AlignFrame getCurrentAlignFrame()
1145 return Jalview.currentAlignFrame;
1148 public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)
1150 Jalview.currentAlignFrame = currentAlignFrame;