+ SequenceOntologyFactory.setInstance(new SequenceOntology());
+ }
+
+ if (!(headless || headlessArg))
+ {
+ Desktop.nosplash = "false".equals(bootstrapArgs.get(Arg.SPLASH))
+ || aparser.contains("nosplash")
+ || Cache.getDefault("SPLASH", "true").equals("false");
+ desktop = new Desktop();
+ desktop.setInBatchMode(true); // indicate we are starting up
+
+ try
+ {
+ JalviewTaskbar.setTaskbar(this);
+ } catch (Exception e)
+ {
+ Console.info("Cannot set Taskbar");
+ Console.error(e.getMessage());
+ // e.printStackTrace();
+ } catch (Throwable t)
+ {
+ Console.info("Cannot set Taskbar");
+ Console.error(t.getMessage());
+ // t.printStackTrace();
+ }
+
+ // set Proxy settings before all the internet calls
+ Cache.setProxyPropertiesFromPreferences();
+
+ desktop.setVisible(true);
+
+ if (!Platform.isJS())
+ /**
+ * Java only
+ *
+ * @j2sIgnore
+ */
+ {
+
+ /**
+ * Check to see that the JVM version being run is suitable for the Java
+ * version this Jalview was compiled for. Popup a warning if not.
+ */
+ if (!LaunchUtils.checkJavaVersion())
+ {
+ Console.warn("The Java version being used (Java "
+ + LaunchUtils.getJavaVersion()
+ + ") may lead to problems. This installation of Jalview should be used with Java "
+ + LaunchUtils.getJavaCompileVersion() + ".");
+
+ if (!LaunchUtils
+ .getBooleanUserPreference("IGNORE_JVM_WARNING_POPUP"))
+ {
+ Object[] options = {
+ MessageManager.getString("label.continue") };
+ JOptionPane.showOptionDialog(null,
+ MessageManager.formatMessage(
+ "warning.wrong_jvm_version_message",
+ LaunchUtils.getJavaVersion(),
+ LaunchUtils.getJavaCompileVersion()),
+ MessageManager
+ .getString("warning.wrong_jvm_version_title"),
+ JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
+ null, options, options[0]);
+ }
+ }
+
+ boolean webservicediscovery = bootstrapArgs
+ .getBoolean(Arg.WEBSERVICEDISCOVERY);
+ if (aparser.contains("nowebservicediscovery"))
+ webservicediscovery = false;
+ if (webservicediscovery)
+ {
+ desktop.startServiceDiscovery();
+ }
+ else
+ {
+ testoutput(argparser, Arg.WEBSERVICEDISCOVERY);
+ }
+
+ boolean usagestats = bootstrapArgs.getBoolean(Arg.USAGESTATS);
+ if (aparser.contains("nousagestats"))
+ usagestats = false;
+ if (usagestats)
+ {
+ startUsageStats(desktop);
+ testoutput(argparser, Arg.USAGESTATS);
+ }
+ else
+ {
+ System.out.println("CMD [-nousagestats] executed successfully!");
+ testoutput(argparser, Arg.USAGESTATS);
+ }
+
+ boolean questionnaire = bootstrapArgs.getBoolean(Arg.QUESTIONNAIRE);
+ if (aparser.contains("noquestionnaire"))
+ questionnaire = false;
+ if (questionnaire)
+ {
+ String url = aparser.getValue("questionnaire");
+ if (url != null)
+ {
+ // Start the desktop questionnaire prompter with the specified
+ // questionnaire
+ Console.debug("Starting questionnaire url at " + url);
+ desktop.checkForQuestionnaire(url);
+ System.out.println("CMD questionnaire[-" + url
+ + "] executed successfully!");
+ }
+ else
+ {
+ if (Cache.getProperty("NOQUESTIONNAIRES") == null)
+ {
+ // Start the desktop questionnaire prompter with the specified
+ // questionnaire
+ // String defurl =
+ // "http://anaplog.compbio.dundee.ac.uk/cgi-bin/questionnaire.pl";
+ // //
+ String defurl = "https://www.jalview.org/cgi-bin/questionnaire.pl";
+ Console.debug(
+ "Starting questionnaire with default url: " + defurl);
+ desktop.checkForQuestionnaire(defurl);
+ }
+ }
+ }
+ else
+ {
+ System.out
+ .println("CMD [-noquestionnaire] executed successfully!");
+ testoutput(argparser, Arg.QUESTIONNAIRE);
+ }
+
+ if ((!aparser.contains("nonews")
+ && Cache.getProperty("NONEWS") == null
+ && !"false".equals(bootstrapArgs.get(Arg.NEWS)))
+ || "true".equals(bootstrapArgs.get(Arg.NEWS)))
+ {
+ desktop.checkForNews();
+ }
+
+ if (!aparser.contains("nohtmltemplates")
+ && Cache.getProperty("NOHTMLTEMPLATES") == null)
+ {
+ BioJsHTMLOutput.updateBioJS();
+ }
+ }
+ }
+ // Run Commands from cli
+ cmds = new Commands(argparser, headlessArg);
+ boolean commandsSuccess = cmds.argsWereParsed();
+ if (commandsSuccess)
+ {
+ if (headlessArg)
+ {
+ Jalview.exit("Successfully completed commands in headless mode", 0);
+ }
+ Console.info("Successfully completed commands");
+ }
+ else
+ {
+ if (headlessArg)
+ {
+ Jalview.exit("Error when running Commands in headless mode", 1);
+ }
+ Console.warn("Error when running commands");
+ }
+
+ // Check if JVM and compile version might cause problems and log if it
+ // might.
+ if (headless && !Platform.isJS() && !LaunchUtils.checkJavaVersion())
+ {
+ Console.warn("The Java version being used (Java "
+ + LaunchUtils.getJavaVersion()
+ + ") may lead to problems. This installation of Jalview should be used with Java "
+ + LaunchUtils.getJavaCompileVersion() + ".");
+ }
+
+ String file = null, data = null;
+
+ FileFormatI format = null;
+
+ DataSourceType protocol = null;
+
+ FileLoader fileLoader = new FileLoader(!headless);
+
+ String groovyscript = null; // script to execute after all loading is
+ // completed one way or another
+ // extract groovy argument and execute if necessary
+ groovyscript = aparser.getValue("groovy", true);
+ file = aparser.getValue("open", true);
+
+ if (file == null && desktop == null && !commandsSuccess)
+ {
+ Jalview.exit("No files to open!", 1);
+ }
+
+ long progress = -1;
+ // Finally, deal with the remaining input data.
+ if (file != null)
+ {
+ if (!headless)
+ {
+ desktop.setProgressBar(
+ MessageManager
+ .getString("status.processing_commandline_args"),
+ progress = System.currentTimeMillis());
+ }
+ System.out.println("CMD [-open " + file + "] executed successfully!");
+
+ if (!Platform.isJS())
+ /**
+ * ignore in JavaScript -- can't just file existence - could load it?
+ *
+ * @j2sIgnore
+ */
+ {
+ if (!HttpUtils.startsWithHttpOrHttps(file))
+ {
+ if (!(new File(file)).exists())
+ {
+ if (headless)
+ {
+ Jalview.exit(
+ "Can't find file '" + file + "' in headless mode", 1);
+ }
+ Console.warn("Can't find file'" + file + "'");
+ }
+ }
+ }
+
+ protocol = AppletFormatAdapter.checkProtocol(file);
+
+ try
+ {
+ format = new IdentifyFile().identify(file, protocol);
+ } catch (FileFormatException e1)
+ {
+ // TODO ?
+ }
+
+ AlignFrame af = fileLoader.LoadFileWaitTillLoaded(file, protocol,
+ format);
+ if (af == null)
+ {
+ System.out.println("error");
+ }
+ else
+ {
+ setCurrentAlignFrame(af);
+ data = aparser.getValue("colour", true);
+ if (data != null)
+ {
+ data.replaceAll("%20", " ");
+
+ ColourSchemeI cs = ColourSchemeProperty.getColourScheme(
+ af.getViewport(), af.getViewport().getAlignment(), data);
+
+ if (cs != null)
+ {
+ System.out.println(
+ "CMD [-colour " + data + "] executed successfully!");
+ }
+ af.changeColour(cs);
+ }
+
+ // Must maintain ability to use the groups flag
+ data = aparser.getValue("groups", true);
+ if (data != null)
+ {
+ af.parseFeaturesFile(data,
+ AppletFormatAdapter.checkProtocol(data));
+ // System.out.println("Added " + data);
+ System.out.println(
+ "CMD groups[-" + data + "] executed successfully!");
+ }
+ data = aparser.getValue("features", true);
+ if (data != null)
+ {
+ af.parseFeaturesFile(data,
+ AppletFormatAdapter.checkProtocol(data));
+ // System.out.println("Added " + data);
+ System.out.println(
+ "CMD [-features " + data + "] executed successfully!");
+ }
+
+ data = aparser.getValue("annotations", true);
+ if (data != null)
+ {
+ af.loadJalviewDataFile(data, null, null, null);
+ // System.out.println("Added " + data);
+ System.out.println(
+ "CMD [-annotations " + data + "] executed successfully!");
+ }
+ // set or clear the sortbytree flag.
+ if (aparser.contains("sortbytree"))
+ {
+ af.getViewport().setSortByTree(true);
+ if (af.getViewport().getSortByTree())
+ {
+ System.out.println("CMD [-sortbytree] executed successfully!");
+ }
+ }
+ if (aparser.contains("no-annotation"))
+ {
+ af.getViewport().setShowAnnotation(false);
+ if (!af.getViewport().isShowAnnotation())
+ {
+ System.out.println("CMD no-annotation executed successfully!");
+ }
+ }
+ if (aparser.contains("nosortbytree"))
+ {
+ af.getViewport().setSortByTree(false);
+ if (!af.getViewport().getSortByTree())
+ {
+ System.out
+ .println("CMD [-nosortbytree] executed successfully!");
+ }
+ }
+ data = aparser.getValue("tree", true);
+ if (data != null)
+ {
+ try
+ {
+ System.out.println(
+ "CMD [-tree " + data + "] executed successfully!");
+ NewickFile nf = new NewickFile(data,
+ AppletFormatAdapter.checkProtocol(data));
+ af.getViewport()
+ .setCurrentTree(af.showNewickTree(nf, data).getTree());
+ } catch (IOException ex)
+ {
+ System.err.println("Couldn't add tree " + data);
+ ex.printStackTrace(System.err);
+ }
+ }
+ // TODO - load PDB structure(s) to alignment JAL-629
+ // (associate with identical sequence in alignment, or a specified
+ // sequence)
+ if (groovyscript != null)
+ {
+ // Execute the groovy script after we've done all the rendering stuff
+ // and before any images or figures are generated.
+ System.out.println("Executing script " + groovyscript);
+ executeGroovyScript(groovyscript, af);
+ System.out.println("CMD groovy[" + groovyscript
+ + "] executed successfully!");
+ groovyscript = null;
+ }
+ String imageName = "unnamed.png";
+ while (aparser.getSize() > 1)
+ {
+ String outputFormat = aparser.nextValue();
+ file = aparser.nextValue();
+
+ if (outputFormat.equalsIgnoreCase("png"))
+ {
+ af.createPNG(new File(file));
+ imageName = (new File(file)).getName();
+ System.out.println("Creating PNG image: " + file);
+ continue;
+ }
+ else if (outputFormat.equalsIgnoreCase("svg"))
+ {
+ File imageFile = new File(file);
+ imageName = imageFile.getName();
+ af.createSVG(imageFile);
+ System.out.println("Creating SVG image: " + file);
+ continue;
+ }
+ else if (outputFormat.equalsIgnoreCase("html"))
+ {
+ File imageFile = new File(file);
+ imageName = imageFile.getName();
+ HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel);
+ htmlSVG.exportHTML(file);
+
+ System.out.println("Creating HTML image: " + file);
+ continue;
+ }
+ else if (outputFormat.equalsIgnoreCase("biojsmsa"))
+ {
+ if (file == null)
+ {
+ System.err.println("The output html file must not be null");
+ return;
+ }
+ try
+ {
+ BioJsHTMLOutput.refreshVersionInfo(
+ BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
+ } catch (URISyntaxException e)
+ {
+ e.printStackTrace();
+ }
+ BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel);
+ bjs.exportHTML(file);
+ System.out
+ .println("Creating BioJS MSA Viwer HTML file: " + file);
+ continue;
+ }
+ else if (outputFormat.equalsIgnoreCase("imgMap"))
+ {
+ af.createImageMap(new File(file), imageName);
+ System.out.println("Creating image map: " + file);
+ continue;
+ }
+ else if (outputFormat.equalsIgnoreCase("eps"))
+ {
+ File outputFile = new File(file);
+ System.out.println(
+ "Creating EPS file: " + outputFile.getAbsolutePath());
+ af.createEPS(outputFile);
+ continue;
+ }
+ FileFormatI outFormat = null;
+ try
+ {
+ outFormat = FileFormats.getInstance().forName(outputFormat);
+ } catch (Exception formatP)
+ {
+ System.out.println("Couldn't parse " + outFormat
+ + " as a valid Jalview format string.");
+ }
+ if (outFormat != null)
+ {
+ if (!outFormat.isWritable())
+ {
+ System.out.println(
+ "This version of Jalview does not support alignment export as "
+ + outputFormat);
+ }
+ else
+ {
+ af.saveAlignment(file, outFormat);
+ if (af.isSaveAlignmentSuccessful())
+ {
+ System.out.println("Written alignment in "
+ + outFormat.getName() + " format to " + file);
+ }
+ else
+ {
+ System.out.println("Error writing file " + file + " in "
+ + outFormat.getName() + " format!!");
+ }
+ }
+ }
+
+ }
+
+ while (aparser.getSize() > 0)
+ {
+ System.out.println("Unknown arg: " + aparser.nextValue());
+ }