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 * singleton instance of this class
83 private static Jalview instance;
85 private Desktop desktop;
87 public static AlignFrame currentAlignFrame;
91 // grab all the rights we can the JVM
92 Policy.setPolicy(new Policy()
95 public PermissionCollection getPermissions(CodeSource codesource)
97 Permissions perms = new Permissions();
98 perms.add(new AllPermission());
103 public void refresh()
110 * keep track of feature fetching tasks.
118 * TODO: generalise to track all jalview events to orchestrate batch
122 private int queued = 0;
124 private int running = 0;
126 public FeatureFetcher()
131 public void addFetcher(final AlignFrame af,
132 final Vector<String> dasSources)
134 final long id = System.currentTimeMillis();
136 final FeatureFetcher us = this;
137 new Thread(new Runnable()
149 af.setProgressBar(MessageManager
150 .getString("status.das_features_being_retrived"), id);
151 af.featureSettings_actionPerformed(null);
152 af.setProgressBar(null, id);
161 public synchronized boolean allFinished()
163 return queued == 0 && running == 0;
168 public static Jalview getInstance()
174 * main class for Jalview application
177 * open <em>filename</em>
178 * @throws InterruptedException
179 * @throws IOException
181 public static void main(String[] args)
183 instance = new Jalview();
184 instance.doMain(args);
189 * @throws InterruptedException
190 * @throws IOException
192 void doMain(String[] args)
194 System.setSecurityManager(null);
196 .println("Java version: " + System.getProperty("java.version"));
197 System.out.println(System.getProperty("os.arch") + " "
198 + System.getProperty("os.name") + " "
199 + System.getProperty("os.version"));
201 ArgsParser aparser = new ArgsParser(args);
202 boolean headless = false;
204 if (aparser.contains("help") || aparser.contains("h"))
209 if (aparser.contains("nodisplay") || aparser.contains("nogui")
210 || aparser.contains("headless"))
212 System.setProperty("java.awt.headless", "true");
215 String usrPropsFile = aparser.getValue("props");
216 Cache.loadProperties(usrPropsFile); // must do this before
217 if (usrPropsFile != null)
220 "CMD [-props " + usrPropsFile + "] executed successfully!");
225 final String jabawsUrl = aparser.getValue("jabaws");
226 if (jabawsUrl != null)
230 Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl);
232 "CMD [-jabaws " + jabawsUrl + "] executed successfully!");
233 } catch (MalformedURLException e)
236 "Invalid jabaws parameter: " + jabawsUrl + " ignored");
240 String defs = aparser.getValue("setprop");
243 int p = defs.indexOf('=');
246 System.err.println("Ignoring invalid setprop argument : " + defs);
250 System.out.println("Executing setprop argument: " + defs);
251 // DISABLED FOR SECURITY REASONS
252 // TODO: add a property to allow properties to be overriden by cli args
253 // Cache.setProperty(defs.substring(0,p), defs.substring(p+1));
255 defs = aparser.getValue("setprop");
257 if (System.getProperty("java.awt.headless") != null
258 && System.getProperty("java.awt.headless").equals("true"))
262 System.setProperty("http.agent",
263 "Jalview Desktop/" + Cache.getDefault("VERSION", "Unknown"));
267 } catch (NoClassDefFoundError error)
269 error.printStackTrace();
270 System.out.println("\nEssential logging libraries not found."
271 + "\nUse: java -Djava.ext.dirs=$PATH_TO_LIB$ jalview.bin.Jalview");
279 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
280 } catch (Exception ex)
282 System.err.println("Unexpected Look and Feel Exception");
283 ex.printStackTrace();
285 if (Platform.isAMac())
288 LookAndFeel lookAndFeel = ch.randelshofer.quaqua.QuaquaManager
290 System.setProperty("com.apple.mrj.application.apple.menu.about.name",
292 System.setProperty("apple.laf.useScreenMenuBar", "true");
293 if (lookAndFeel != null)
297 UIManager.setLookAndFeel(lookAndFeel);
298 } catch (Throwable e)
301 "Failed to set QuaQua look and feel: " + e.toString());
304 if (lookAndFeel == null || !(lookAndFeel.getClass()
305 .isAssignableFrom(UIManager.getLookAndFeel().getClass()))
306 || !UIManager.getLookAndFeel().getClass().toString()
307 .toLowerCase().contains("quaqua"))
312 "Quaqua LaF not available on this plaform. Using VAqua(4).\nSee https://issues.jalview.org/browse/JAL-2976");
313 UIManager.setLookAndFeel("org.violetlib.aqua.AquaLookAndFeel");
314 } catch (Throwable e)
317 "Failed to reset look and feel: " + e.toString());
323 * configure 'full' SO model if preferences say to,
324 * else use the default (SO Lite)
326 if (Cache.getDefault("USE_FULL_SO", false))
328 SequenceOntologyFactory.setInstance(new SequenceOntology());
333 desktop = new Desktop();
334 desktop.setInBatchMode(true); // indicate we are starting up
335 desktop.setVisible(true);
336 desktop.startServiceDiscovery();
337 if (!aparser.contains("nousagestats"))
339 startUsageStats(desktop);
343 System.err.println("CMD [-nousagestats] executed successfully!");
346 if (!aparser.contains("noquestionnaire"))
348 String url = aparser.getValue("questionnaire");
351 // Start the desktop questionnaire prompter with the specified
353 Cache.log.debug("Starting questionnaire url at " + url);
354 desktop.checkForQuestionnaire(url);
356 "CMD questionnaire[-" + url + "] executed successfully!");
360 if (Cache.getProperty("NOQUESTIONNAIRES") == null)
362 // Start the desktop questionnaire prompter with the specified
365 // "http://anaplog.compbio.dundee.ac.uk/cgi-bin/questionnaire.pl";
367 String defurl = "http://www.jalview.org/cgi-bin/questionnaire.pl";
369 "Starting questionnaire with default url: " + defurl);
370 desktop.checkForQuestionnaire(defurl);
376 System.err.println("CMD [-noquestionnaire] executed successfully!");
379 if (!aparser.contains("nonews"))
381 desktop.checkForNews();
384 BioJsHTMLOutput.updateBioJS();
387 String file = null, data = null;
388 FileFormatI format = null;
389 DataSourceType protocol = null;
390 FileLoader fileLoader = new FileLoader(!headless);
391 Vector<String> getFeatures = null; // vector of das source nicknames to
395 String groovyscript = null; // script to execute after all loading is
396 // completed one way or another
397 // extract groovy argument and execute if necessary
398 groovyscript = aparser.getValue("groovy", true);
399 file = aparser.getValue("open", true);
401 if (file == null && desktop == null)
403 System.out.println("No files to open!");
406 String vamsasImport = aparser.getValue("vdoc");
407 String vamsasSession = aparser.getValue("vsess");
408 if (vamsasImport != null || vamsasSession != null)
410 if (desktop == null || headless)
413 "Headless vamsas sessions not yet supported. Sorry.");
416 // if we have a file, start a new session and import it.
417 boolean inSession = false;
418 if (vamsasImport != null)
422 DataSourceType viprotocol = AppletFormatAdapter
423 .checkProtocol(vamsasImport);
424 if (viprotocol == DataSourceType.FILE)
426 inSession = desktop.vamsasImport(new File(vamsasImport));
428 else if (viprotocol == DataSourceType.URL)
430 inSession = desktop.vamsasImport(new URL(vamsasImport));
433 } catch (Exception e)
435 System.err.println("Exeption when importing " + vamsasImport
436 + " as a vamsas document.");
441 System.err.println("Failed to import " + vamsasImport
442 + " as a vamsas document.");
446 System.out.println("Imported Successfully into new session "
447 + desktop.getVamsasApplication().getCurrentSession());
450 if (vamsasSession != null)
452 if (vamsasImport != null)
454 // close the newly imported session and import the Jalview specific
455 // remnants into the new session later on.
456 desktop.vamsasStop_actionPerformed(null);
458 // now join the new session
461 if (desktop.joinVamsasSession(vamsasSession))
464 "Successfully joined vamsas session " + vamsasSession);
468 System.err.println("WARNING: Failed to join vamsas session "
471 } catch (Exception e)
474 "ERROR: Failed to join vamsas session " + vamsasSession);
477 if (vamsasImport != null)
479 // the Jalview specific remnants can now be imported into the new
480 // session at the user's leisure.
482 "Skipping Push for import of data into existing vamsas session."); // TODO:
487 // desktop.getVamsasApplication().push_update();
492 // Finally, deal with the remaining input data.
497 desktop.setProgressBar(
499 .getString("status.processing_commandline_args"),
500 progress = System.currentTimeMillis());
502 System.out.println("CMD [-open " + file + "] executed successfully!");
504 if (!file.startsWith("http://"))
506 if (!(new File(file)).exists())
508 System.out.println("Can't find " + file);
516 protocol = AppletFormatAdapter.checkProtocol(file);
520 format = new IdentifyFile().identify(file, protocol);
521 } catch (FileFormatException e1)
526 AlignFrame af = fileLoader.LoadFileWaitTillLoaded(file, protocol,
530 System.out.println("error");
534 setCurrentAlignFrame(af);
535 data = aparser.getValue("colour", true);
538 data.replaceAll("%20", " ");
540 ColourSchemeI cs = ColourSchemeProperty
541 .getColourScheme(af.getViewport().getAlignment(), data);
546 "CMD [-color " + data + "] executed successfully!");
551 // Must maintain ability to use the groups flag
552 data = aparser.getValue("groups", true);
555 af.parseFeaturesFile(data,
556 AppletFormatAdapter.checkProtocol(data));
557 // System.out.println("Added " + data);
559 "CMD groups[-" + data + "] executed successfully!");
561 data = aparser.getValue("features", true);
564 af.parseFeaturesFile(data,
565 AppletFormatAdapter.checkProtocol(data));
566 // System.out.println("Added " + data);
568 "CMD [-features " + data + "] executed successfully!");
571 data = aparser.getValue("annotations", true);
574 af.loadJalviewDataFile(data, null, null, null);
575 // System.out.println("Added " + data);
577 "CMD [-annotations " + data + "] executed successfully!");
579 // set or clear the sortbytree flag.
580 if (aparser.contains("sortbytree"))
582 af.getViewport().setSortByTree(true);
583 if (af.getViewport().getSortByTree())
585 System.out.println("CMD [-sortbytree] executed successfully!");
588 if (aparser.contains("no-annotation"))
590 af.getViewport().setShowAnnotation(false);
591 if (!af.getViewport().isShowAnnotation())
593 System.out.println("CMD no-annotation executed successfully!");
596 if (aparser.contains("nosortbytree"))
598 af.getViewport().setSortByTree(false);
599 if (!af.getViewport().getSortByTree())
602 .println("CMD [-nosortbytree] executed successfully!");
605 data = aparser.getValue("tree", true);
611 "CMD [-tree " + data + "] executed successfully!");
612 NewickFile nf = new NewickFile(data,
613 AppletFormatAdapter.checkProtocol(data));
615 .setCurrentTree(af.showNewickTree(nf, data).getTree());
616 } catch (IOException ex)
618 System.err.println("Couldn't add tree " + data);
619 ex.printStackTrace(System.err);
622 // TODO - load PDB structure(s) to alignment JAL-629
623 // (associate with identical sequence in alignment, or a specified
626 getFeatures = checkDasArguments(aparser);
627 if (af != null && getFeatures != null)
629 FeatureFetcher ff = startFeatureFetching(getFeatures);
632 while (!ff.allFinished() || af.operationInProgress())
634 // wait around until fetching is finished.
638 } catch (Exception e)
644 getFeatures = null; // have retrieved features - forget them now.
646 if (groovyscript != null)
648 // Execute the groovy script after we've done all the rendering stuff
649 // and before any images or figures are generated.
650 System.out.println("Executing script " + groovyscript);
651 executeGroovyScript(groovyscript, af);
652 System.out.println("CMD groovy[" + groovyscript
653 + "] executed successfully!");
656 String imageName = "unnamed.png";
657 while (aparser.getSize() > 1)
659 String outputFormat = aparser.nextValue();
660 file = aparser.nextValue();
662 if (outputFormat.equalsIgnoreCase("png"))
664 af.createPNG(new File(file));
665 imageName = (new File(file)).getName();
666 System.out.println("Creating PNG image: " + file);
669 else if (outputFormat.equalsIgnoreCase("svg"))
671 File imageFile = new File(file);
672 imageName = imageFile.getName();
673 af.createSVG(imageFile);
674 System.out.println("Creating SVG image: " + file);
677 else if (outputFormat.equalsIgnoreCase("html"))
679 File imageFile = new File(file);
680 imageName = imageFile.getName();
681 HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel);
682 htmlSVG.exportHTML(file);
684 System.out.println("Creating HTML image: " + file);
687 else if (outputFormat.equalsIgnoreCase("biojsmsa"))
691 System.err.println("The output html file must not be null");
696 BioJsHTMLOutput.refreshVersionInfo(
697 BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
698 } catch (URISyntaxException e)
702 BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel);
703 bjs.exportHTML(file);
705 .println("Creating BioJS MSA Viwer HTML file: " + file);
708 else if (outputFormat.equalsIgnoreCase("imgMap"))
710 af.createImageMap(new File(file), imageName);
711 System.out.println("Creating image map: " + file);
714 else if (outputFormat.equalsIgnoreCase("eps"))
716 File outputFile = new File(file);
718 "Creating EPS file: " + outputFile.getAbsolutePath());
719 af.createEPS(outputFile);
723 if (af.saveAlignment(file, format))
725 System.out.println("Written alignment in " + format
726 + " format to " + file);
730 System.out.println("Error writing file " + file + " in "
731 + format + " format!!");
736 while (aparser.getSize() > 0)
738 System.out.println("Unknown arg: " + aparser.nextValue());
742 AlignFrame startUpAlframe = null;
743 // We'll only open the default file if the desktop is visible.
745 // ////////////////////
747 if (!headless && file == null && vamsasImport == null
748 && jalview.bin.Cache.getDefault("SHOW_STARTUP_FILE", true))
750 file = jalview.bin.Cache.getDefault("STARTUP_FILE",
751 jalview.bin.Cache.getDefault("www.jalview.org",
752 "http://www.jalview.org")
753 + "/examples/exampleFile_2_7.jar");
755 "http://www.jalview.org/examples/exampleFile_2_3.jar"))
757 // hardwire upgrade of the startup file
758 file.replace("_2_3.jar", "_2_7.jar");
759 // and remove the stale setting
760 jalview.bin.Cache.removeProperty("STARTUP_FILE");
763 protocol = DataSourceType.FILE;
765 if (file.indexOf("http:") > -1)
767 protocol = DataSourceType.URL;
770 if (file.endsWith(".jar"))
772 format = FileFormat.Jalview;
778 format = new IdentifyFile().identify(file, protocol);
779 } catch (FileFormatException e)
785 startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol,
787 getFeatures = checkDasArguments(aparser);
788 // extract groovy arguments before anything else.
790 // If the user has specified features to be retrieved,
791 // or a groovy script to be executed, do them if they
792 // haven't been done already
793 // fetch features for the default alignment
794 if (getFeatures != null)
796 if (startUpAlframe != null)
798 startFeatureFetching(getFeatures);
801 // Once all other stuff is done, execute any groovy scripts (in order)
802 if (groovyscript != null)
804 if (Cache.groovyJarsPresent())
806 System.out.println("Executing script " + groovyscript);
807 executeGroovyScript(groovyscript, startUpAlframe);
812 "Sorry. Groovy Support is not available, so ignoring the provided groovy script "
816 // and finally, turn off batch mode indicator - if the desktop still exists
821 desktop.setProgressBar(null, progress);
823 desktop.setInBatchMode(false);
827 private static void showUsage()
830 "Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n"
831 + "-nodisplay\tRun Jalview without User Interface.\n"
832 + "-props FILE\tUse the given Jalview properties file instead of users default.\n"
833 + "-colour COLOURSCHEME\tThe colourscheme to be applied to the alignment\n"
834 + "-annotations FILE\tAdd precalculated annotations to the alignment.\n"
835 + "-tree FILE\tLoad the given newick format tree file onto the alignment\n"
836 + "-features FILE\tUse the given file to mark features on the alignment.\n"
837 + "-fasta FILE\tCreate alignment file FILE in Fasta format.\n"
838 + "-clustal FILE\tCreate alignment file FILE in Clustal format.\n"
839 + "-pfam FILE\tCreate alignment file FILE in PFAM format.\n"
840 + "-msf FILE\tCreate alignment file FILE in MSF format.\n"
841 + "-pileup FILE\tCreate alignment file FILE in Pileup format\n"
842 + "-pir FILE\tCreate alignment file FILE in PIR format.\n"
843 + "-blc FILE\tCreate alignment file FILE in BLC format.\n"
844 + "-json FILE\tCreate alignment file FILE in JSON format.\n"
845 + "-jalview FILE\tCreate alignment file FILE in Jalview format.\n"
846 + "-png FILE\tCreate PNG image FILE from alignment.\n"
847 + "-svg FILE\tCreate SVG image FILE from alignment.\n"
848 + "-html FILE\tCreate HTML file from alignment.\n"
849 + "-biojsMSA FILE\tCreate BioJS MSA Viewer HTML file from alignment.\n"
850 + "-imgMap FILE\tCreate HTML file FILE with image map of PNG image.\n"
851 + "-eps FILE\tCreate EPS file FILE from alignment.\n"
852 + "-questionnaire URL\tQueries the given URL for information about any Jalview user questionnaires.\n"
853 + "-noquestionnaire\tTurn off questionnaire check.\n"
854 + "-nonews\tTurn off check for Jalview news.\n"
855 + "-nousagestats\tTurn off google analytics tracking for this session.\n"
856 + "-sortbytree OR -nosortbytree\tEnable or disable sorting of the given alignment by the given tree\n"
858 // "-setprop PROPERTY=VALUE\tSet the given Jalview property,
859 // after all other properties files have been read\n\t
860 // (quote the 'PROPERTY=VALUE' pair to ensure spaces are
861 // passed in correctly)"
862 + "-jabaws URL\tSpecify URL for Jabaws services (e.g. for a local installation).\n"
863 + "-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"
864 + "\t\t\tSources that also support the sequence command may be specified by prepending the URL with sequence:\n"
865 + "\t\t\t e.g. sequence:http://localdas.somewhere.org/das/source)\n"
866 + "-fetchfrom nickname\tQuery nickname for features for the alignments and display them.\n"
868 // "-vdoc vamsas-document\tImport vamsas document into new
869 // session or join existing session with same URN\n"
870 // + "-vses vamsas-session\tJoin session with given URN\n"
871 + "-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"
872 + "\n~Read documentation in Application or visit http://www.jalview.org for description of Features and Annotations file~\n\n");
875 private static void startUsageStats(final Desktop desktop)
878 * start a User Config prompt asking if we can log usage statistics.
880 PromptUserConfig prompter = new PromptUserConfig(Desktop.desktop,
881 "USAGESTATS", "Jalview Usage Statistics",
882 "Do you want to help make Jalview better by enabling "
883 + "the collection of usage statistics with Google Analytics ?"
884 + "\n\n(you can enable or disable usage tracking in the preferences)",
891 "Initialising googletracker for usage stats.");
892 Cache.initGoogleTracker();
893 Cache.log.debug("Tracking enabled.");
900 Cache.log.debug("Not enabling Google Tracking.");
903 desktop.addDialogThread(prompter);
907 * Locate the given string as a file and pass it to the groovy interpreter.
909 * @param groovyscript
910 * the script to execute
911 * @param jalviewContext
912 * the Jalview Desktop object passed in to the groovy binding as the
915 private void executeGroovyScript(String groovyscript, AlignFrame af)
918 * for scripts contained in files
925 if (groovyscript.trim().equals("STDIN"))
927 // read from stdin into a tempfile and execute it
930 tfile = File.createTempFile("jalview", "groovy");
931 PrintWriter outfile = new PrintWriter(
932 new OutputStreamWriter(new FileOutputStream(tfile)));
933 BufferedReader br = new BufferedReader(
934 new InputStreamReader(System.in));
936 while ((line = br.readLine()) != null)
938 outfile.write(line + "\n");
944 } catch (Exception ex)
946 System.err.println("Failed to read from STDIN into tempfile "
947 + ((tfile == null) ? "(tempfile wasn't created)"
948 : tfile.toString()));
949 ex.printStackTrace();
954 sfile = tfile.toURI().toURL();
955 } catch (Exception x)
958 "Unexpected Malformed URL Exception for temporary file created from STDIN: "
968 sfile = new URI(groovyscript).toURL();
969 } catch (Exception x)
971 tfile = new File(groovyscript);
974 System.err.println("File '" + groovyscript + "' does not exist.");
977 if (!tfile.canRead())
979 System.err.println("File '" + groovyscript + "' cannot be read.");
982 if (tfile.length() < 1)
984 System.err.println("File '" + groovyscript + "' is empty.");
989 sfile = tfile.getAbsoluteFile().toURI().toURL();
990 } catch (Exception ex)
992 System.err.println("Failed to create a file URL for "
993 + tfile.getAbsoluteFile());
1000 Map<String, Object> vbinding = new HashMap<>();
1001 vbinding.put("Jalview", this);
1004 vbinding.put("currentAlFrame", af);
1006 Binding gbinding = new Binding(vbinding);
1007 GroovyScriptEngine gse = new GroovyScriptEngine(new URL[] { sfile });
1008 gse.run(sfile.toString(), gbinding);
1009 if ("STDIN".equals(groovyscript))
1011 // delete temp file that we made -
1012 // only if it was successfully executed
1015 } catch (Exception e)
1017 System.err.println("Exception Whilst trying to execute file " + sfile
1018 + " as a groovy script.");
1019 e.printStackTrace(System.err);
1025 * Check commandline for any das server definitions or any fetchfrom switches
1027 * @return vector of DAS source nicknames to retrieve from
1029 private static Vector<String> checkDasArguments(ArgsParser aparser)
1031 Vector<String> source = null;
1033 String locsources = Cache.getProperty(Cache.DAS_LOCAL_SOURCE);
1034 while ((data = aparser.getValue("dasserver", true)) != null)
1036 String nickname = null;
1038 int pos = data.indexOf('=');
1039 // determine capabilities
1042 nickname = data.substring(0, pos);
1044 url = data.substring(pos + 1);
1045 if (url != null && (url.startsWith("http:")
1046 || url.startsWith("sequence:http:")))
1048 if (nickname == null)
1052 if (locsources == null)
1060 locsources = locsources + nickname + "|" + url;
1062 "NOTE! dasserver parameter not yet really supported (got args of "
1063 + nickname + "|" + url);
1066 source = new Vector<>();
1068 source.addElement(nickname);
1071 "CMD [-dasserver " + data + "] executed successfully!");
1072 } // loop until no more server entries are found.
1073 if (locsources != null && locsources.indexOf('|') > -1)
1075 Cache.log.debug("Setting local source list in properties file to:\n"
1077 Cache.setProperty(Cache.DAS_LOCAL_SOURCE, locsources);
1079 while ((data = aparser.getValue("fetchfrom", true)) != null)
1081 System.out.println("adding source '" + data + "'");
1084 source = new Vector<>();
1086 source.addElement(data);
1092 * start a feature fetcher for every alignment frame
1096 private FeatureFetcher startFeatureFetching(
1097 final Vector<String> dasSources)
1099 FeatureFetcher ff = new FeatureFetcher();
1100 AlignFrame afs[] = Desktop.getAlignFrames();
1101 if (afs == null || afs.length == 0)
1105 for (int i = 0; i < afs.length; i++)
1107 ff.addFetcher(afs[i], dasSources);
1112 public static boolean isHeadlessMode()
1114 String isheadless = System.getProperty("java.awt.headless");
1115 if (isheadless != null && isheadless.equalsIgnoreCase("true"))
1122 public AlignFrame[] getAlignFrames()
1124 return desktop == null ? new AlignFrame[] { getCurrentAlignFrame() }
1125 : Desktop.getAlignFrames();
1130 * Quit method delegates to Desktop.quit - unless running in headless mode
1131 * when it just ends the JVM
1135 if (desktop != null)
1145 public static AlignFrame getCurrentAlignFrame()
1147 return Jalview.currentAlignFrame;
1150 public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)
1152 Jalview.currentAlignFrame = currentAlignFrame;