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 groovy.lang.Binding;
24 import groovy.util.GroovyScriptEngine;
26 import jalview.ext.so.SequenceOntology;
27 import jalview.gui.AlignFrame;
28 import jalview.gui.Desktop;
29 import jalview.gui.PromptUserConfig;
30 import jalview.io.AppletFormatAdapter;
31 import jalview.io.BioJsHTMLOutput;
32 import jalview.io.DataSourceType;
33 import jalview.io.FileFormat;
34 import jalview.io.FileFormatException;
35 import jalview.io.FileFormatI;
36 import jalview.io.FileLoader;
37 import jalview.io.HtmlSvgOutput;
38 import jalview.io.IdentifyFile;
39 import jalview.io.NewickFile;
40 import jalview.io.gff.SequenceOntologyFactory;
41 import jalview.schemes.ColourSchemeI;
42 import jalview.schemes.ColourSchemeProperty;
43 import jalview.util.MessageManager;
44 import jalview.util.Platform;
45 import jalview.ws.jws2.Jws2Discoverer;
47 import java.io.BufferedReader;
49 import java.io.FileOutputStream;
50 import java.io.IOException;
51 import java.io.InputStreamReader;
52 import java.io.OutputStreamWriter;
53 import java.io.PrintWriter;
54 import java.net.MalformedURLException;
56 import java.net.URISyntaxException;
58 import java.security.AllPermission;
59 import java.security.CodeSource;
60 import java.security.PermissionCollection;
61 import java.security.Permissions;
62 import java.security.Policy;
63 import java.util.HashMap;
65 import java.util.Vector;
67 import javax.swing.UIManager;
70 * Main class for Jalview Application <br>
72 * start with java -Djava.ext.dirs=$PATH_TO_LIB$ jalview.bin.Jalview
80 * singleton instance of this class
82 private static Jalview instance;
84 private Desktop desktop;
86 public static AlignFrame currentAlignFrame;
90 // grab all the rights we can the JVM
91 Policy.setPolicy(new Policy()
94 public PermissionCollection getPermissions(CodeSource codesource)
96 Permissions perms = new Permissions();
97 perms.add(new AllPermission());
102 public void refresh()
109 * keep track of feature fetching tasks.
117 * TODO: generalise to track all jalview events to orchestrate batch
121 private int queued = 0;
123 private int running = 0;
125 public FeatureFetcher()
130 public void addFetcher(final AlignFrame af,
131 final Vector<String> dasSources)
133 final long id = System.currentTimeMillis();
135 final FeatureFetcher us = this;
136 new Thread(new Runnable()
148 af.setProgressBar(MessageManager
149 .getString("status.das_features_being_retrived"), id);
150 af.featureSettings_actionPerformed(null);
151 af.featureSettings.fetchDasFeatures(dasSources, true);
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>
179 public static void main(String[] args)
181 instance = new Jalview();
182 instance.doMain(args);
188 void doMain(String[] args)
190 System.setSecurityManager(null);
191 System.out.println("Java version: "
192 + System.getProperty("java.version"));
193 System.out.println(System.getProperty("os.arch") + " "
194 + System.getProperty("os.name") + " "
195 + System.getProperty("os.version"));
197 ArgsParser aparser = new ArgsParser(args);
198 boolean headless = false;
200 if (aparser.contains("help") || aparser.contains("h"))
205 if (aparser.contains("nodisplay") || aparser.contains("nogui")
206 || aparser.contains("headless"))
208 System.setProperty("java.awt.headless", "true");
211 String usrPropsFile = aparser.getValue("props");
212 Cache.loadProperties(usrPropsFile); // must do this before
213 if (usrPropsFile != null)
215 System.out.println("CMD [-props " + usrPropsFile
216 + "] executed successfully!");
221 final String jabawsUrl = aparser.getValue("jabaws");
222 if (jabawsUrl != null)
226 Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl);
227 System.out.println("CMD [-jabaws " + jabawsUrl
228 + "] executed successfully!");
229 } catch (MalformedURLException e)
231 System.err.println("Invalid jabaws parameter: " + jabawsUrl
236 String defs = aparser.getValue("setprop");
239 int p = defs.indexOf('=');
242 System.err.println("Ignoring invalid setprop argument : " + defs);
246 System.out.println("Executing setprop argument: " + defs);
247 // DISABLED FOR SECURITY REASONS
248 // TODO: add a property to allow properties to be overriden by cli args
249 // Cache.setProperty(defs.substring(0,p), defs.substring(p+1));
251 defs = aparser.getValue("setprop");
253 if (System.getProperty("java.awt.headless") != null
254 && System.getProperty("java.awt.headless").equals("true"))
258 System.setProperty("http.agent",
259 "Jalview Desktop/" + Cache.getDefault("VERSION", "Unknown"));
263 } catch (NoClassDefFoundError error)
265 error.printStackTrace();
267 .println("\nEssential logging libraries not found."
268 + "\nUse: java -Djava.ext.dirs=$PATH_TO_LIB$ jalview.bin.Jalview");
276 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
277 } catch (Exception ex)
280 if (Platform.isAMac())
282 System.setProperty("com.apple.mrj.application.apple.menu.about.name",
284 System.setProperty("apple.laf.useScreenMenuBar", "true");
287 UIManager.setLookAndFeel(ch.randelshofer.quaqua.QuaquaManager
289 } catch (Throwable e)
291 System.err.println("Failed to set QuaQua look and feel: "
297 * configure 'full' SO model if preferences say to,
298 * else use the default (SO Lite)
300 if (Cache.getDefault("USE_FULL_SO", false))
302 SequenceOntologyFactory.setInstance(new SequenceOntology());
307 desktop = new Desktop();
308 desktop.setInBatchMode(true); // indicate we are starting up
309 desktop.setVisible(true);
310 desktop.startServiceDiscovery();
311 if (!aparser.contains("nousagestats"))
313 startUsageStats(desktop);
317 System.err.println("CMD [-nousagestats] executed successfully!");
320 if (!aparser.contains("noquestionnaire"))
322 String url = aparser.getValue("questionnaire");
325 // Start the desktop questionnaire prompter with the specified
327 Cache.log.debug("Starting questionnaire url at " + url);
328 desktop.checkForQuestionnaire(url);
329 System.out.println("CMD questionnaire[-" + url
330 + "] executed successfully!");
334 if (Cache.getProperty("NOQUESTIONNAIRES") == null)
336 // Start the desktop questionnaire prompter with the specified
339 // "http://anaplog.compbio.dundee.ac.uk/cgi-bin/questionnaire.pl";
341 String defurl = "http://www.jalview.org/cgi-bin/questionnaire.pl";
342 Cache.log.debug("Starting questionnaire with default url: "
344 desktop.checkForQuestionnaire(defurl);
350 System.err.println("CMD [-noquestionnaire] executed successfully!");
353 if (!aparser.contains("nonews"))
355 desktop.checkForNews();
358 BioJsHTMLOutput.updateBioJS();
361 String file = null, data = null;
362 FileFormatI format = null;
363 DataSourceType protocol = null;
364 FileLoader fileLoader = new FileLoader(!headless);
365 Vector<String> getFeatures = null; // vector of das source nicknames to
369 String groovyscript = null; // script to execute after all loading is
370 // completed one way or another
371 // extract groovy argument and execute if necessary
372 groovyscript = aparser.getValue("groovy", true);
373 file = aparser.getValue("open", true);
375 if (file == null && desktop == null)
377 System.out.println("No files to open!");
380 String vamsasImport = aparser.getValue("vdoc");
381 String vamsasSession = aparser.getValue("vsess");
382 if (vamsasImport != null || vamsasSession != null)
384 if (desktop == null || headless)
387 .println("Headless vamsas sessions not yet supported. Sorry.");
390 // if we have a file, start a new session and import it.
391 boolean inSession = false;
392 if (vamsasImport != null)
396 DataSourceType viprotocol = AppletFormatAdapter
397 .checkProtocol(vamsasImport);
398 if (viprotocol == DataSourceType.FILE)
400 inSession = desktop.vamsasImport(new File(vamsasImport));
402 else if (viprotocol == DataSourceType.URL)
404 inSession = desktop.vamsasImport(new URL(vamsasImport));
407 } catch (Exception e)
409 System.err.println("Exeption when importing " + vamsasImport
410 + " as a vamsas document.");
415 System.err.println("Failed to import " + vamsasImport
416 + " as a vamsas document.");
420 System.out.println("Imported Successfully into new session "
421 + desktop.getVamsasApplication().getCurrentSession());
424 if (vamsasSession != null)
426 if (vamsasImport != null)
428 // close the newly imported session and import the Jalview specific
429 // remnants into the new session later on.
430 desktop.vamsasStop_actionPerformed(null);
432 // now join the new session
435 if (desktop.joinVamsasSession(vamsasSession))
437 System.out.println("Successfully joined vamsas session "
442 System.err.println("WARNING: Failed to join vamsas session "
445 } catch (Exception e)
447 System.err.println("ERROR: Failed to join vamsas session "
451 if (vamsasImport != null)
453 // the Jalview specific remnants can now be imported into the new
454 // session at the user's leisure.
456 .info("Skipping Push for import of data into existing vamsas session."); // TODO:
461 // desktop.getVamsasApplication().push_update();
466 // Finally, deal with the remaining input data.
471 desktop.setProgressBar(MessageManager
472 .getString("status.processing_commandline_args"),
473 progress = System.currentTimeMillis());
475 System.out.println("CMD [-open " + file + "] executed successfully!");
477 if (!file.startsWith("http://"))
479 if (!(new File(file)).exists())
481 System.out.println("Can't find " + file);
489 protocol = AppletFormatAdapter.checkProtocol(file);
493 format = new IdentifyFile().identify(file, protocol);
494 } catch (FileFormatException e1)
499 AlignFrame af = fileLoader.LoadFileWaitTillLoaded(file, protocol,
503 System.out.println("error");
507 setCurrentAlignFrame(af);
508 data = aparser.getValue("colour", true);
511 data.replaceAll("%20", " ");
513 ColourSchemeI cs = ColourSchemeProperty.getColourScheme(af
514 .getViewport().getAlignment(), data);
518 System.out.println("CMD [-color " + data
519 + "] executed successfully!");
524 // Must maintain ability to use the groups flag
525 data = aparser.getValue("groups", true);
528 af.parseFeaturesFile(data,
529 AppletFormatAdapter.checkProtocol(data));
530 // System.out.println("Added " + data);
531 System.out.println("CMD groups[-" + data
532 + "] executed successfully!");
534 data = aparser.getValue("features", true);
537 af.parseFeaturesFile(data,
538 AppletFormatAdapter.checkProtocol(data));
539 // System.out.println("Added " + data);
540 System.out.println("CMD [-features " + data
541 + "] executed successfully!");
544 data = aparser.getValue("annotations", true);
547 af.loadJalviewDataFile(data, null, null, null);
548 // System.out.println("Added " + data);
549 System.out.println("CMD [-annotations " + data
550 + "] executed successfully!");
552 // set or clear the sortbytree flag.
553 if (aparser.contains("sortbytree"))
555 af.getViewport().setSortByTree(true);
556 if (af.getViewport().getSortByTree())
558 System.out.println("CMD [-sortbytree] executed successfully!");
561 if (aparser.contains("no-annotation"))
563 af.getViewport().setShowAnnotation(false);
564 if (!af.getViewport().isShowAnnotation())
566 System.out.println("CMD no-annotation executed successfully!");
569 if (aparser.contains("nosortbytree"))
571 af.getViewport().setSortByTree(false);
572 if (!af.getViewport().getSortByTree())
575 .println("CMD [-nosortbytree] executed successfully!");
578 data = aparser.getValue("tree", true);
581 jalview.io.NewickFile fin = null;
584 System.out.println("CMD [-tree " + data
585 + "] executed successfully!");
586 fin = new NewickFile(data,
587 AppletFormatAdapter.checkProtocol(data));
590 af.getViewport().setCurrentTree(
591 af.ShowNewickTree(fin, data).getTree());
593 } catch (IOException ex)
595 System.err.println("Couldn't add tree " + data);
596 ex.printStackTrace(System.err);
599 // TODO - load PDB structure(s) to alignment JAL-629
600 // (associate with identical sequence in alignment, or a specified
603 getFeatures = checkDasArguments(aparser);
604 if (af != null && getFeatures != null)
606 FeatureFetcher ff = startFeatureFetching(getFeatures);
609 while (!ff.allFinished() || af.operationInProgress())
611 // wait around until fetching is finished.
615 } catch (Exception e)
621 getFeatures = null; // have retrieved features - forget them now.
623 if (groovyscript != null)
625 // Execute the groovy script after we've done all the rendering stuff
626 // and before any images or figures are generated.
627 System.out.println("Executing script " + groovyscript);
628 executeGroovyScript(groovyscript, af);
629 System.out.println("CMD groovy[" + groovyscript
630 + "] executed successfully!");
633 String imageName = "unnamed.png";
634 while (aparser.getSize() > 1)
636 String outputFormat = aparser.nextValue();
637 file = aparser.nextValue();
639 if (outputFormat.equalsIgnoreCase("png"))
641 af.createPNG(new File(file));
642 imageName = (new File(file)).getName();
643 System.out.println("Creating PNG image: " + file);
646 else if (outputFormat.equalsIgnoreCase("svg"))
648 File imageFile = new File(file);
649 imageName = imageFile.getName();
650 af.createSVG(imageFile);
651 System.out.println("Creating SVG image: " + file);
654 else if (outputFormat.equalsIgnoreCase("html"))
656 File imageFile = new File(file);
657 imageName = imageFile.getName();
658 HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel);
659 htmlSVG.exportHTML(file);
661 System.out.println("Creating HTML image: " + file);
664 else if (outputFormat.equalsIgnoreCase("biojsmsa"))
668 System.err.println("The output html file must not be null");
674 .refreshVersionInfo(BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
675 } catch (URISyntaxException e)
679 BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel);
680 bjs.exportHTML(file);
681 System.out.println("Creating BioJS MSA Viwer HTML file: "
685 else if (outputFormat.equalsIgnoreCase("imgMap"))
687 af.createImageMap(new File(file), imageName);
688 System.out.println("Creating image map: " + file);
691 else if (outputFormat.equalsIgnoreCase("eps"))
693 File outputFile = new File(file);
694 System.out.println("Creating EPS file: "
695 + outputFile.getAbsolutePath());
696 af.createEPS(outputFile);
700 if (af.saveAlignment(file, format))
702 System.out.println("Written alignment in " + format
703 + " format to " + file);
707 System.out.println("Error writing file " + file + " in "
708 + format + " format!!");
713 while (aparser.getSize() > 0)
715 System.out.println("Unknown arg: " + aparser.nextValue());
719 AlignFrame startUpAlframe = null;
720 // We'll only open the default file if the desktop is visible.
722 // ////////////////////
724 if (!headless && file == null && vamsasImport == null
725 && jalview.bin.Cache.getDefault("SHOW_STARTUP_FILE", true))
727 file = jalview.bin.Cache.getDefault(
729 jalview.bin.Cache.getDefault("www.jalview.org",
730 "http://www.jalview.org")
731 + "/examples/exampleFile_2_7.jar");
732 if (file.equals("http://www.jalview.org/examples/exampleFile_2_3.jar"))
734 // hardwire upgrade of the startup file
735 file.replace("_2_3.jar", "_2_7.jar");
736 // and remove the stale setting
737 jalview.bin.Cache.removeProperty("STARTUP_FILE");
740 protocol = DataSourceType.FILE;
742 if (file.indexOf("http:") > -1)
744 protocol = DataSourceType.URL;
747 if (file.endsWith(".jar"))
749 format = FileFormat.Jalview;
755 format = new IdentifyFile().identify(file, protocol);
756 } catch (FileFormatException e)
762 startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol,
764 getFeatures = checkDasArguments(aparser);
765 // extract groovy arguments before anything else.
767 // If the user has specified features to be retrieved,
768 // or a groovy script to be executed, do them if they
769 // haven't been done already
770 // fetch features for the default alignment
771 if (getFeatures != null)
773 if (startUpAlframe != null)
775 startFeatureFetching(getFeatures);
778 // Once all other stuff is done, execute any groovy scripts (in order)
779 if (groovyscript != null)
781 if (Cache.groovyJarsPresent())
783 System.out.println("Executing script " + groovyscript);
784 executeGroovyScript(groovyscript, startUpAlframe);
789 .println("Sorry. Groovy Support is not available, so ignoring the provided groovy script "
793 // and finally, turn off batch mode indicator - if the desktop still exists
798 desktop.setProgressBar(null, progress);
800 desktop.setInBatchMode(false);
804 private static void showUsage()
807 .println("Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n"
808 + "-nodisplay\tRun Jalview without User Interface.\n"
809 + "-props FILE\tUse the given Jalview properties file instead of users default.\n"
810 + "-colour COLOURSCHEME\tThe colourscheme to be applied to the alignment\n"
811 + "-annotations FILE\tAdd precalculated annotations to the alignment.\n"
812 + "-tree FILE\tLoad the given newick format tree file onto the alignment\n"
813 + "-features FILE\tUse the given file to mark features on the alignment.\n"
814 + "-fasta FILE\tCreate alignment file FILE in Fasta format.\n"
815 + "-clustal FILE\tCreate alignment file FILE in Clustal format.\n"
816 + "-pfam FILE\tCreate alignment file FILE in PFAM format.\n"
817 + "-msf FILE\tCreate alignment file FILE in MSF format.\n"
818 + "-pileup FILE\tCreate alignment file FILE in Pileup format\n"
819 + "-pir FILE\tCreate alignment file FILE in PIR format.\n"
820 + "-blc FILE\tCreate alignment file FILE in BLC format.\n"
821 + "-json FILE\tCreate alignment file FILE in JSON format.\n"
822 + "-jalview FILE\tCreate alignment file FILE in Jalview format.\n"
823 + "-png FILE\tCreate PNG image FILE from alignment.\n"
824 + "-svg FILE\tCreate SVG image FILE from alignment.\n"
825 + "-html FILE\tCreate HTML file from alignment.\n"
826 + "-biojsMSA FILE\tCreate BioJS MSA Viewer HTML file from alignment.\n"
827 + "-imgMap FILE\tCreate HTML file FILE with image map of PNG image.\n"
828 + "-eps FILE\tCreate EPS file FILE from alignment.\n"
829 + "-questionnaire URL\tQueries the given URL for information about any Jalview user questionnaires.\n"
830 + "-noquestionnaire\tTurn off questionnaire check.\n"
831 + "-nonews\tTurn off check for Jalview news.\n"
832 + "-nousagestats\tTurn off google analytics tracking for this session.\n"
833 + "-sortbytree OR -nosortbytree\tEnable or disable sorting of the given alignment by the given tree\n"
835 // "-setprop PROPERTY=VALUE\tSet the given Jalview property, after all other properties files have been read\n\t (quote the 'PROPERTY=VALUE' pair to ensure spaces are passed in correctly)"
836 + "-jabaws URL\tSpecify URL for Jabaws services (e.g. for a local installation).\n"
837 + "-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"
838 + "\t\t\tSources that also support the sequence command may be specified by prepending the URL with sequence:\n"
839 + "\t\t\t e.g. sequence:http://localdas.somewhere.org/das/source)\n"
840 + "-fetchfrom nickname\tQuery nickname for features for the alignments and display them.\n"
842 // "-vdoc vamsas-document\tImport vamsas document into new session or join existing session with same URN\n"
843 // + "-vses vamsas-session\tJoin session with given URN\n"
844 + "-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"
845 + "\n~Read documentation in Application or visit http://www.jalview.org for description of Features and Annotations file~\n\n");
848 private static void startUsageStats(final Desktop desktop)
851 * start a User Config prompt asking if we can log usage statistics.
853 PromptUserConfig prompter = new PromptUserConfig(
856 "Jalview Usage Statistics",
857 "Do you want to help make Jalview better by enabling "
858 + "the collection of usage statistics with Google Analytics ?"
859 + "\n\n(you can enable or disable usage tracking in the preferences)",
866 .debug("Initialising googletracker for usage stats.");
867 Cache.initGoogleTracker();
868 Cache.log.debug("Tracking enabled.");
875 Cache.log.debug("Not enabling Google Tracking.");
878 desktop.addDialogThread(prompter);
882 * Locate the given string as a file and pass it to the groovy interpreter.
884 * @param groovyscript
885 * the script to execute
886 * @param jalviewContext
887 * the Jalview Desktop object passed in to the groovy binding as the
890 private void executeGroovyScript(String groovyscript, AlignFrame af)
893 * for scripts contained in files
900 if (groovyscript.trim().equals("STDIN"))
902 // read from stdin into a tempfile and execute it
905 tfile = File.createTempFile("jalview", "groovy");
906 PrintWriter outfile = new PrintWriter(new OutputStreamWriter(
907 new FileOutputStream(tfile)));
908 BufferedReader br = new BufferedReader(new InputStreamReader(
911 while ((line = br.readLine()) != null)
913 outfile.write(line + "\n");
919 } catch (Exception ex)
921 System.err.println("Failed to read from STDIN into tempfile "
922 + ((tfile == null) ? "(tempfile wasn't created)" : tfile
924 ex.printStackTrace();
929 sfile = tfile.toURI().toURL();
930 } catch (Exception x)
933 .println("Unexpected Malformed URL Exception for temporary file created from STDIN: "
943 sfile = new URI(groovyscript).toURL();
944 } catch (Exception x)
946 tfile = new File(groovyscript);
949 System.err.println("File '" + groovyscript + "' does not exist.");
952 if (!tfile.canRead())
954 System.err.println("File '" + groovyscript + "' cannot be read.");
957 if (tfile.length() < 1)
959 System.err.println("File '" + groovyscript + "' is empty.");
964 sfile = tfile.getAbsoluteFile().toURI().toURL();
965 } catch (Exception ex)
967 System.err.println("Failed to create a file URL for "
968 + tfile.getAbsoluteFile());
975 Map<String, Object> vbinding = new HashMap<String, Object>();
976 vbinding.put("Jalview", this);
979 vbinding.put("currentAlFrame", af);
981 Binding gbinding = new Binding(vbinding);
982 GroovyScriptEngine gse = new GroovyScriptEngine(new URL[] { sfile });
983 gse.run(sfile.toString(), gbinding);
984 if ("STDIN".equals(groovyscript))
986 // delete temp file that we made -
987 // only if it was successfully executed
990 } catch (Exception e)
992 System.err.println("Exception Whilst trying to execute file " + sfile
993 + " as a groovy script.");
994 e.printStackTrace(System.err);
1000 * Check commandline for any das server definitions or any fetchfrom switches
1002 * @return vector of DAS source nicknames to retrieve from
1004 private static Vector<String> checkDasArguments(ArgsParser aparser)
1006 Vector<String> source = null;
1008 String locsources = Cache.getProperty(Cache.DAS_LOCAL_SOURCE);
1009 while ((data = aparser.getValue("dasserver", true)) != null)
1011 String nickname = null;
1013 int pos = data.indexOf('=');
1014 // determine capabilities
1017 nickname = data.substring(0, pos);
1019 url = data.substring(pos + 1);
1021 && (url.startsWith("http:") || url
1022 .startsWith("sequence:http:")))
1024 if (nickname == null)
1028 if (locsources == null)
1036 locsources = locsources + nickname + "|" + url;
1038 .println("NOTE! dasserver parameter not yet really supported (got args of "
1039 + nickname + "|" + url);
1042 source = new Vector<String>();
1044 source.addElement(nickname);
1046 System.out.println("CMD [-dasserver " + data
1047 + "] executed successfully!");
1048 } // loop until no more server entries are found.
1049 if (locsources != null && locsources.indexOf('|') > -1)
1051 Cache.log.debug("Setting local source list in properties file to:\n"
1053 Cache.setProperty(Cache.DAS_LOCAL_SOURCE, locsources);
1055 while ((data = aparser.getValue("fetchfrom", true)) != null)
1057 System.out.println("adding source '" + data + "'");
1060 source = new Vector<String>();
1062 source.addElement(data);
1068 * start a feature fetcher for every alignment frame
1072 private FeatureFetcher startFeatureFetching(
1073 final Vector<String> dasSources)
1075 FeatureFetcher ff = new FeatureFetcher();
1076 AlignFrame afs[] = Desktop.getAlignFrames();
1077 if (afs == null || afs.length == 0)
1081 for (int i = 0; i < afs.length; i++)
1083 ff.addFetcher(afs[i], dasSources);
1088 public static boolean isHeadlessMode()
1090 String isheadless = System.getProperty("java.awt.headless");
1091 if (isheadless != null && isheadless.equalsIgnoreCase("true"))
1098 public AlignFrame[] getAlignFrames()
1100 return desktop == null ? new AlignFrame[] { getCurrentAlignFrame() }
1101 : Desktop.getAlignFrames();
1106 * Quit method delegates to Desktop.quit - unless running in headless mode
1107 * when it just ends the JVM
1111 if (desktop != null)
1121 public static AlignFrame getCurrentAlignFrame()
1123 return Jalview.currentAlignFrame;
1126 public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)
1128 Jalview.currentAlignFrame = currentAlignFrame;