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.schemes.UserColourScheme;
44 import jalview.util.MessageManager;
45 import jalview.util.Platform;
46 import jalview.ws.jws2.Jws2Discoverer;
48 import java.io.BufferedReader;
50 import java.io.FileOutputStream;
51 import java.io.IOException;
52 import java.io.InputStreamReader;
53 import java.io.OutputStreamWriter;
54 import java.io.PrintWriter;
55 import java.net.MalformedURLException;
57 import java.net.URISyntaxException;
59 import java.security.AllPermission;
60 import java.security.CodeSource;
61 import java.security.PermissionCollection;
62 import java.security.Permissions;
63 import java.security.Policy;
64 import java.util.HashMap;
66 import java.util.Vector;
68 import javax.swing.UIManager;
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.featureSettings.fetchDasFeatures(dasSources, true);
153 af.setProgressBar(null, id);
162 public synchronized boolean allFinished()
164 return queued == 0 && running == 0;
169 public static Jalview getInstance()
175 * main class for Jalview application
178 * open <em>filename</em>
180 public static void main(String[] args)
182 instance = new Jalview();
183 instance.doMain(args);
189 void doMain(String[] args)
191 System.setSecurityManager(null);
192 System.out.println("Java version: "
193 + System.getProperty("java.version"));
194 System.out.println(System.getProperty("os.arch") + " "
195 + System.getProperty("os.name") + " "
196 + System.getProperty("os.version"));
198 ArgsParser aparser = new ArgsParser(args);
199 boolean headless = false;
201 if (aparser.contains("help") || aparser.contains("h"))
206 if (aparser.contains("nodisplay") || aparser.contains("nogui")
207 || aparser.contains("headless"))
209 System.setProperty("java.awt.headless", "true");
212 String usrPropsFile = aparser.getValue("props");
213 Cache.loadProperties(usrPropsFile); // must do this before
214 if (usrPropsFile != null)
216 System.out.println("CMD [-props " + usrPropsFile
217 + "] executed successfully!");
222 final String jabawsUrl = aparser.getValue("jabaws");
223 if (jabawsUrl != null)
227 Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl);
228 System.out.println("CMD [-jabaws " + jabawsUrl
229 + "] executed successfully!");
230 } catch (MalformedURLException e)
232 System.err.println("Invalid jabaws parameter: " + jabawsUrl
237 String defs = aparser.getValue("setprop");
240 int p = defs.indexOf('=');
243 System.err.println("Ignoring invalid setprop argument : " + defs);
247 System.out.println("Executing setprop argument: " + defs);
248 // DISABLED FOR SECURITY REASONS
249 // TODO: add a property to allow properties to be overriden by cli args
250 // Cache.setProperty(defs.substring(0,p), defs.substring(p+1));
252 defs = aparser.getValue("setprop");
254 if (System.getProperty("java.awt.headless") != null
255 && System.getProperty("java.awt.headless").equals("true"))
259 System.setProperty("http.agent",
260 "Jalview Desktop/" + Cache.getDefault("VERSION", "Unknown"));
264 } catch (NoClassDefFoundError error)
266 error.printStackTrace();
268 .println("\nEssential logging libraries not found."
269 + "\nUse: java -Djava.ext.dirs=$PATH_TO_LIB$ jalview.bin.Jalview");
277 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
278 } catch (Exception ex)
281 if (Platform.isAMac())
283 System.setProperty("com.apple.mrj.application.apple.menu.about.name",
285 System.setProperty("apple.laf.useScreenMenuBar", "true");
288 UIManager.setLookAndFeel(ch.randelshofer.quaqua.QuaquaManager
290 } catch (Throwable e)
292 System.err.println("Failed to set QuaQua look and feel: "
298 * configure 'full' SO model if preferences say to,
299 * else use the default (SO Lite)
301 if (Cache.getDefault("USE_FULL_SO", false))
303 SequenceOntologyFactory.setInstance(new SequenceOntology());
308 desktop = new Desktop();
309 desktop.setInBatchMode(true); // indicate we are starting up
310 desktop.setVisible(true);
311 desktop.startServiceDiscovery();
312 if (!aparser.contains("nousagestats"))
314 startUsageStats(desktop);
318 System.err.println("CMD [-nousagestats] executed successfully!");
321 if (!aparser.contains("noquestionnaire"))
323 String url = aparser.getValue("questionnaire");
326 // Start the desktop questionnaire prompter with the specified
328 Cache.log.debug("Starting questionnaire url at " + url);
329 desktop.checkForQuestionnaire(url);
330 System.out.println("CMD questionnaire[-" + url
331 + "] executed successfully!");
335 if (Cache.getProperty("NOQUESTIONNAIRES") == null)
337 // Start the desktop questionnaire prompter with the specified
340 // "http://anaplog.compbio.dundee.ac.uk/cgi-bin/questionnaire.pl";
342 String defurl = "http://www.jalview.org/cgi-bin/questionnaire.pl";
343 Cache.log.debug("Starting questionnaire with default url: "
345 desktop.checkForQuestionnaire(defurl);
351 System.err.println("CMD [-noquestionnaire] executed successfully!");
354 if (!aparser.contains("nonews"))
356 desktop.checkForNews();
359 BioJsHTMLOutput.updateBioJS();
362 String file = null, data = null;
363 FileFormatI format = null;
364 DataSourceType protocol = null;
365 FileLoader fileLoader = new FileLoader(!headless);
366 Vector<String> getFeatures = null; // vector of das source nicknames to
370 String groovyscript = null; // script to execute after all loading is
371 // completed one way or another
372 // extract groovy argument and execute if necessary
373 groovyscript = aparser.getValue("groovy", true);
374 file = aparser.getValue("open", true);
376 if (file == null && desktop == null)
378 System.out.println("No files to open!");
381 String vamsasImport = aparser.getValue("vdoc");
382 String vamsasSession = aparser.getValue("vsess");
383 if (vamsasImport != null || vamsasSession != null)
385 if (desktop == null || headless)
388 .println("Headless vamsas sessions not yet supported. Sorry.");
391 // if we have a file, start a new session and import it.
392 boolean inSession = false;
393 if (vamsasImport != null)
397 DataSourceType viprotocol = AppletFormatAdapter
398 .checkProtocol(vamsasImport);
399 if (viprotocol == DataSourceType.FILE)
401 inSession = desktop.vamsasImport(new File(vamsasImport));
403 else if (viprotocol == DataSourceType.URL)
405 inSession = desktop.vamsasImport(new URL(vamsasImport));
408 } catch (Exception e)
410 System.err.println("Exeption when importing " + vamsasImport
411 + " as a vamsas document.");
416 System.err.println("Failed to import " + vamsasImport
417 + " as a vamsas document.");
421 System.out.println("Imported Successfully into new session "
422 + desktop.getVamsasApplication().getCurrentSession());
425 if (vamsasSession != null)
427 if (vamsasImport != null)
429 // close the newly imported session and import the Jalview specific
430 // remnants into the new session later on.
431 desktop.vamsasStop_actionPerformed(null);
433 // now join the new session
436 if (desktop.joinVamsasSession(vamsasSession))
438 System.out.println("Successfully joined vamsas session "
443 System.err.println("WARNING: Failed to join vamsas session "
446 } catch (Exception e)
448 System.err.println("ERROR: Failed to join vamsas session "
452 if (vamsasImport != null)
454 // the Jalview specific remnants can now be imported into the new
455 // session at the user's leisure.
457 .info("Skipping Push for import of data into existing vamsas session."); // TODO:
462 // desktop.getVamsasApplication().push_update();
467 // Finally, deal with the remaining input data.
472 desktop.setProgressBar(MessageManager
473 .getString("status.processing_commandline_args"),
474 progress = System.currentTimeMillis());
476 System.out.println("CMD [-open " + file + "] executed successfully!");
478 if (!file.startsWith("http://"))
480 if (!(new File(file)).exists())
482 System.out.println("Can't find " + file);
490 protocol = AppletFormatAdapter.checkProtocol(file);
494 format = new IdentifyFile().identify(file, protocol);
495 } catch (FileFormatException e1)
500 AlignFrame af = fileLoader.LoadFileWaitTillLoaded(file, protocol,
504 System.out.println("error");
508 setCurrentAlignFrame(af);
509 data = aparser.getValue("colour", true);
512 data.replaceAll("%20", " ");
514 ColourSchemeI cs = ColourSchemeProperty.getColour(af
515 .getViewport().getAlignment(), data);
519 UserColourScheme ucs = new UserColourScheme("white");
520 ucs.parseAppletParameter(data);
525 System.out.println("CMD [-color " + data
526 + "] executed successfully!");
531 // Must maintain ability to use the groups flag
532 data = aparser.getValue("groups", true);
535 af.parseFeaturesFile(data,
536 AppletFormatAdapter.checkProtocol(data));
537 // System.out.println("Added " + data);
538 System.out.println("CMD groups[-" + data
539 + "] executed successfully!");
541 data = aparser.getValue("features", true);
544 af.parseFeaturesFile(data,
545 AppletFormatAdapter.checkProtocol(data));
546 // System.out.println("Added " + data);
547 System.out.println("CMD [-features " + data
548 + "] executed successfully!");
551 data = aparser.getValue("annotations", true);
554 af.loadJalviewDataFile(data, null, null, null);
555 // System.out.println("Added " + data);
556 System.out.println("CMD [-annotations " + data
557 + "] executed successfully!");
559 // set or clear the sortbytree flag.
560 if (aparser.contains("sortbytree"))
562 af.getViewport().setSortByTree(true);
563 if (af.getViewport().getSortByTree())
565 System.out.println("CMD [-sortbytree] executed successfully!");
568 if (aparser.contains("no-annotation"))
570 af.getViewport().setShowAnnotation(false);
571 if (!af.getViewport().isShowAnnotation())
573 System.out.println("CMD no-annotation executed successfully!");
576 if (aparser.contains("nosortbytree"))
578 af.getViewport().setSortByTree(false);
579 if (!af.getViewport().getSortByTree())
582 .println("CMD [-nosortbytree] executed successfully!");
585 data = aparser.getValue("tree", true);
588 jalview.io.NewickFile fin = null;
591 System.out.println("CMD [-tree " + data
592 + "] executed successfully!");
593 fin = new NewickFile(data,
594 AppletFormatAdapter.checkProtocol(data));
597 af.getViewport().setCurrentTree(
598 af.ShowNewickTree(fin, data).getTree());
600 } catch (IOException ex)
602 System.err.println("Couldn't add tree " + data);
603 ex.printStackTrace(System.err);
606 // TODO - load PDB structure(s) to alignment JAL-629
607 // (associate with identical sequence in alignment, or a specified
610 getFeatures = checkDasArguments(aparser);
611 if (af != null && getFeatures != null)
613 FeatureFetcher ff = startFeatureFetching(getFeatures);
616 while (!ff.allFinished() || af.operationInProgress())
618 // wait around until fetching is finished.
622 } catch (Exception e)
628 getFeatures = null; // have retrieved features - forget them now.
630 if (groovyscript != null)
632 // Execute the groovy script after we've done all the rendering stuff
633 // and before any images or figures are generated.
634 System.out.println("Executing script " + groovyscript);
635 executeGroovyScript(groovyscript, af);
636 System.out.println("CMD groovy[" + groovyscript
637 + "] executed successfully!");
640 String imageName = "unnamed.png";
641 while (aparser.getSize() > 1)
643 String outputFormat = aparser.nextValue();
644 file = aparser.nextValue();
646 if (outputFormat.equalsIgnoreCase("png"))
648 af.createPNG(new File(file));
649 imageName = (new File(file)).getName();
650 System.out.println("Creating PNG image: " + file);
653 else if (outputFormat.equalsIgnoreCase("svg"))
655 File imageFile = new File(file);
656 imageName = imageFile.getName();
657 af.createSVG(imageFile);
658 System.out.println("Creating SVG image: " + file);
661 else if (outputFormat.equalsIgnoreCase("html"))
663 File imageFile = new File(file);
664 imageName = imageFile.getName();
665 HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel);
666 htmlSVG.exportHTML(file);
668 System.out.println("Creating HTML image: " + file);
671 else if (outputFormat.equalsIgnoreCase("biojsmsa"))
675 System.err.println("The output html file must not be null");
681 .refreshVersionInfo(BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
682 } catch (URISyntaxException e)
686 BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel);
687 bjs.exportHTML(file);
688 System.out.println("Creating BioJS MSA Viwer HTML file: "
692 else if (outputFormat.equalsIgnoreCase("imgMap"))
694 af.createImageMap(new File(file), imageName);
695 System.out.println("Creating image map: " + file);
698 else if (outputFormat.equalsIgnoreCase("eps"))
700 File outputFile = new File(file);
701 System.out.println("Creating EPS file: "
702 + outputFile.getAbsolutePath());
703 af.createEPS(outputFile);
707 if (af.saveAlignment(file, format))
709 System.out.println("Written alignment in " + format
710 + " format to " + file);
714 System.out.println("Error writing file " + file + " in "
715 + format + " format!!");
720 while (aparser.getSize() > 0)
722 System.out.println("Unknown arg: " + aparser.nextValue());
726 AlignFrame startUpAlframe = null;
727 // We'll only open the default file if the desktop is visible.
729 // ////////////////////
731 if (!headless && file == null && vamsasImport == null
732 && jalview.bin.Cache.getDefault("SHOW_STARTUP_FILE", true))
734 file = jalview.bin.Cache.getDefault(
736 jalview.bin.Cache.getDefault("www.jalview.org",
737 "http://www.jalview.org")
738 + "/examples/exampleFile_2_7.jar");
739 if (file.equals("http://www.jalview.org/examples/exampleFile_2_3.jar"))
741 // hardwire upgrade of the startup file
742 file.replace("_2_3.jar", "_2_7.jar");
743 // and remove the stale setting
744 jalview.bin.Cache.removeProperty("STARTUP_FILE");
747 protocol = DataSourceType.FILE;
749 if (file.indexOf("http:") > -1)
751 protocol = DataSourceType.URL;
754 if (file.endsWith(".jar"))
756 format = FileFormat.Jalview;
762 format = new IdentifyFile().identify(file, protocol);
763 } catch (FileFormatException e)
769 startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol,
771 getFeatures = checkDasArguments(aparser);
772 // extract groovy arguments before anything else.
774 // If the user has specified features to be retrieved,
775 // or a groovy script to be executed, do them if they
776 // haven't been done already
777 // fetch features for the default alignment
778 if (getFeatures != null)
780 if (startUpAlframe != null)
782 startFeatureFetching(getFeatures);
785 // Once all other stuff is done, execute any groovy scripts (in order)
786 if (groovyscript != null)
788 if (Cache.groovyJarsPresent())
790 System.out.println("Executing script " + groovyscript);
791 executeGroovyScript(groovyscript, startUpAlframe);
796 .println("Sorry. Groovy Support is not available, so ignoring the provided groovy script "
800 // and finally, turn off batch mode indicator - if the desktop still exists
805 desktop.setProgressBar(null, progress);
807 desktop.setInBatchMode(false);
811 private static void showUsage()
814 .println("Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n"
815 + "-nodisplay\tRun Jalview without User Interface.\n"
816 + "-props FILE\tUse the given Jalview properties file instead of users default.\n"
817 + "-colour COLOURSCHEME\tThe colourscheme to be applied to the alignment\n"
818 + "-annotations FILE\tAdd precalculated annotations to the alignment.\n"
819 + "-tree FILE\tLoad the given newick format tree file onto the alignment\n"
820 + "-features FILE\tUse the given file to mark features on the alignment.\n"
821 + "-fasta FILE\tCreate alignment file FILE in Fasta format.\n"
822 + "-clustal FILE\tCreate alignment file FILE in Clustal format.\n"
823 + "-pfam FILE\tCreate alignment file FILE in PFAM format.\n"
824 + "-msf FILE\tCreate alignment file FILE in MSF format.\n"
825 + "-pileup FILE\tCreate alignment file FILE in Pileup format\n"
826 + "-pir FILE\tCreate alignment file FILE in PIR format.\n"
827 + "-blc FILE\tCreate alignment file FILE in BLC format.\n"
828 + "-json FILE\tCreate alignment file FILE in JSON format.\n"
829 + "-jalview FILE\tCreate alignment file FILE in Jalview format.\n"
830 + "-png FILE\tCreate PNG image FILE from alignment.\n"
831 + "-svg FILE\tCreate SVG image FILE from alignment.\n"
832 + "-html FILE\tCreate HTML file from alignment.\n"
833 + "-biojsMSA FILE\tCreate BioJS MSA Viewer HTML file from alignment.\n"
834 + "-imgMap FILE\tCreate HTML file FILE with image map of PNG image.\n"
835 + "-eps FILE\tCreate EPS file FILE from alignment.\n"
836 + "-questionnaire URL\tQueries the given URL for information about any Jalview user questionnaires.\n"
837 + "-noquestionnaire\tTurn off questionnaire check.\n"
838 + "-nonews\tTurn off check for Jalview news.\n"
839 + "-nousagestats\tTurn off google analytics tracking for this session.\n"
840 + "-sortbytree OR -nosortbytree\tEnable or disable sorting of the given alignment by the given tree\n"
842 // "-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)"
843 + "-jabaws URL\tSpecify URL for Jabaws services (e.g. for a local installation).\n"
844 + "-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"
845 + "\t\t\tSources that also support the sequence command may be specified by prepending the URL with sequence:\n"
846 + "\t\t\t e.g. sequence:http://localdas.somewhere.org/das/source)\n"
847 + "-fetchfrom nickname\tQuery nickname for features for the alignments and display them.\n"
849 // "-vdoc vamsas-document\tImport vamsas document into new session or join existing session with same URN\n"
850 // + "-vses vamsas-session\tJoin session with given URN\n"
851 + "-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"
852 + "\n~Read documentation in Application or visit http://www.jalview.org for description of Features and Annotations file~\n\n");
855 private static void startUsageStats(final Desktop desktop)
858 * start a User Config prompt asking if we can log usage statistics.
860 PromptUserConfig prompter = new PromptUserConfig(
863 "Jalview Usage Statistics",
864 "Do you want to help make Jalview better by enabling "
865 + "the collection of usage statistics with Google Analytics ?"
866 + "\n\n(you can enable or disable usage tracking in the preferences)",
873 .debug("Initialising googletracker for usage stats.");
874 Cache.initGoogleTracker();
875 Cache.log.debug("Tracking enabled.");
882 Cache.log.debug("Not enabling Google Tracking.");
885 desktop.addDialogThread(prompter);
889 * Locate the given string as a file and pass it to the groovy interpreter.
891 * @param groovyscript
892 * the script to execute
893 * @param jalviewContext
894 * the Jalview Desktop object passed in to the groovy binding as the
897 private void executeGroovyScript(String groovyscript, AlignFrame af)
900 * for scripts contained in files
907 if (groovyscript.trim().equals("STDIN"))
909 // read from stdin into a tempfile and execute it
912 tfile = File.createTempFile("jalview", "groovy");
913 PrintWriter outfile = new PrintWriter(new OutputStreamWriter(
914 new FileOutputStream(tfile)));
915 BufferedReader br = new BufferedReader(new InputStreamReader(
918 while ((line = br.readLine()) != null)
920 outfile.write(line + "\n");
926 } catch (Exception ex)
928 System.err.println("Failed to read from STDIN into tempfile "
929 + ((tfile == null) ? "(tempfile wasn't created)" : tfile
931 ex.printStackTrace();
936 sfile = tfile.toURI().toURL();
937 } catch (Exception x)
940 .println("Unexpected Malformed URL Exception for temporary file created from STDIN: "
950 sfile = new URI(groovyscript).toURL();
951 } catch (Exception x)
953 tfile = new File(groovyscript);
956 System.err.println("File '" + groovyscript + "' does not exist.");
959 if (!tfile.canRead())
961 System.err.println("File '" + groovyscript + "' cannot be read.");
964 if (tfile.length() < 1)
966 System.err.println("File '" + groovyscript + "' is empty.");
971 sfile = tfile.getAbsoluteFile().toURI().toURL();
972 } catch (Exception ex)
974 System.err.println("Failed to create a file URL for "
975 + tfile.getAbsoluteFile());
982 Map<String, Object> vbinding = new HashMap<String, Object>();
983 vbinding.put("Jalview", this);
986 vbinding.put("currentAlFrame", af);
988 Binding gbinding = new Binding(vbinding);
989 GroovyScriptEngine gse = new GroovyScriptEngine(new URL[] { sfile });
990 gse.run(sfile.toString(), gbinding);
991 if ("STDIN".equals(groovyscript))
993 // delete temp file that we made -
994 // only if it was successfully executed
997 } catch (Exception e)
999 System.err.println("Exception Whilst trying to execute file " + sfile
1000 + " as a groovy script.");
1001 e.printStackTrace(System.err);
1007 * Check commandline for any das server definitions or any fetchfrom switches
1009 * @return vector of DAS source nicknames to retrieve from
1011 private static Vector<String> checkDasArguments(ArgsParser aparser)
1013 Vector<String> source = null;
1015 String locsources = Cache.getProperty(Cache.DAS_LOCAL_SOURCE);
1016 while ((data = aparser.getValue("dasserver", true)) != null)
1018 String nickname = null;
1020 int pos = data.indexOf('=');
1021 // determine capabilities
1024 nickname = data.substring(0, pos);
1026 url = data.substring(pos + 1);
1028 && (url.startsWith("http:") || url
1029 .startsWith("sequence:http:")))
1031 if (nickname == null)
1035 if (locsources == null)
1043 locsources = locsources + nickname + "|" + url;
1045 .println("NOTE! dasserver parameter not yet really supported (got args of "
1046 + nickname + "|" + url);
1049 source = new Vector<String>();
1051 source.addElement(nickname);
1053 System.out.println("CMD [-dasserver " + data
1054 + "] executed successfully!");
1055 } // loop until no more server entries are found.
1056 if (locsources != null && locsources.indexOf('|') > -1)
1058 Cache.log.debug("Setting local source list in properties file to:\n"
1060 Cache.setProperty(Cache.DAS_LOCAL_SOURCE, locsources);
1062 while ((data = aparser.getValue("fetchfrom", true)) != null)
1064 System.out.println("adding source '" + data + "'");
1067 source = new Vector<String>();
1069 source.addElement(data);
1075 * start a feature fetcher for every alignment frame
1079 private FeatureFetcher startFeatureFetching(
1080 final Vector<String> dasSources)
1082 FeatureFetcher ff = new FeatureFetcher();
1083 AlignFrame afs[] = Desktop.getAlignFrames();
1084 if (afs == null || afs.length == 0)
1088 for (int i = 0; i < afs.length; i++)
1090 ff.addFetcher(afs[i], dasSources);
1095 public static boolean isHeadlessMode()
1097 String isheadless = System.getProperty("java.awt.headless");
1098 if (isheadless != null && isheadless.equalsIgnoreCase("true"))
1105 public AlignFrame[] getAlignFrames()
1107 return desktop == null ? new AlignFrame[] { getCurrentAlignFrame() }
1108 : Desktop.getAlignFrames();
1113 * Quit method delegates to Desktop.quit - unless running in headless mode
1114 * when it just ends the JVM
1118 if (desktop != null)
1128 public static AlignFrame getCurrentAlignFrame()
1130 return Jalview.currentAlignFrame;
1133 public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)
1135 Jalview.currentAlignFrame = currentAlignFrame;