+ protocol = jalview.io.AppletFormatAdapter.checkProtocol(file);
+
+ format = new jalview.io.IdentifyFile().Identify(file, protocol);
+
+ AlignFrame af = fileLoader.LoadFileWaitTillLoaded(file, protocol,
+ format);
+ if (af == null)
+ {
+ System.out.println("error");
+ }
+ else
+ {
+ Desktop.setCurrentAlignFrame(af);
+ data = aparser.getValue("colour", true);
+ if (data != null)
+ {
+ data.replaceAll("%20", " ");
+
+ jalview.schemes.ColourSchemeI cs = jalview.schemes.ColourSchemeProperty
+ .getColour(af.getViewport().getAlignment(), data);
+
+ if (cs == null)
+ {
+ jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme(
+ "white");
+ ucs.parseAppletParameter(data);
+ cs = ucs;
+ }
+ else
+ {
+ System.out.println("CMD [-color " + 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,
+ jalview.io.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,
+ jalview.io.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)
+ {
+ jalview.io.NewickFile fin = null;
+ try
+ {
+ System.out.println("CMD [-tree " + data
+ + "] executed successfully!");
+ fin = new jalview.io.NewickFile(data,
+ jalview.io.AppletFormatAdapter.checkProtocol(data));
+ if (fin != null)
+ {
+ af.getViewport().setCurrentTree(
+ af.ShowNewickTree(fin, 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)
+
+ getFeatures = checkDasArguments(aparser);
+ if (af != null && getFeatures != null)
+ {
+ FeatureFetcher ff = startFeatureFetching(getFeatures);
+ if (ff != null)
+ {
+ while (!ff.allFinished() || af.operationInProgress())
+ {
+ // wait around until fetching is finished.
+ try
+ {
+ Thread.sleep(100);
+ } catch (Exception e)
+ {
+
+ }
+ }
+ }
+ getFeatures = null; // have retrieved features - forget them now.
+ }
+ if (groovyscript != null)
+ {
+ // Execute the groovy script after we've done all the rendering stuff
+ // and before any images or figures are generated.
+ if (jalview.bin.Cache.groovyJarsPresent())
+ {
+ System.out.println("Executing script " + groovyscript);
+ executeGroovyScript(groovyscript, new Object[] { desktop, af });
+
+ System.out.println("CMD groovy[" + groovyscript
+ + "] executed successfully!");
+ }
+ else
+ {
+ System.err
+ .println("Sorry. Groovy Support is not available, so ignoring the provided groovy script "
+ + groovyscript);
+ }
+ groovyscript = null;
+ }
+ String imageName = "unnamed.png";
+ while (aparser.getSize() > 1)
+ {
+ format = aparser.nextValue();
+ file = aparser.nextValue();
+
+ if (format.equalsIgnoreCase("png"))
+ {
+ af.createPNG(new java.io.File(file));
+ imageName = (new java.io.File(file)).getName();
+ System.out.println("Creating PNG image: " + file);
+ continue;
+ }
+ else if (format.equalsIgnoreCase("svg"))
+ {
+ File imageFile = new java.io.File(file);
+ imageName = imageFile.getName();
+ af.createSVG(imageFile);
+ System.out.println("Creating SVG image: " + file);
+ continue;
+ }
+ else if (format.equalsIgnoreCase("html"))
+ {
+ File imageFile = new java.io.File(file);
+ imageName = imageFile.getName();
+ new HtmlSvgOutput(new java.io.File(file), af.alignPanel);
+ System.out.println("Creating HTML image: " + file);
+ continue;
+ }
+ else if (format.equalsIgnoreCase("imgMap"))
+ {
+ af.createImageMap(new java.io.File(file), imageName);
+ System.out.println("Creating image map: " + file);
+ continue;
+ }
+ else if (format.equalsIgnoreCase("eps"))
+ {
+ File outputFile = new java.io.File(file);
+ System.out.println("Creating EPS file: "
+ + outputFile.getAbsolutePath());
+ af.createEPS(outputFile);
+ continue;
+ }
+
+ if (af.saveAlignment(file, format))
+ {
+ System.out.println("Written alignment in " + format
+ + " format to " + file);
+ }
+ else
+ {
+ System.out.println("Error writing file " + file + " in "
+ + format + " format!!");
+ }
+
+ }
+
+ while (aparser.getSize() > 0)
+ {
+ System.out.println("Unknown arg: " + aparser.nextValue());
+ }
+ }
+ }
+ AlignFrame startUpAlframe = null;
+ // We'll only open the default file if the desktop is visible.
+ // And the user
+ // ////////////////////
+
+ if (!headless && file == null && vamsasImport == null
+ && jalview.bin.Cache.getDefault("SHOW_STARTUP_FILE", true))
+ {
+ file = jalview.bin.Cache.getDefault(
+ "STARTUP_FILE",
+ jalview.bin.Cache.getDefault("www.jalview.org",
+ "http://www.jalview.org")
+ + "/examples/exampleFile_2_7.jar");
+ if (file.equals("http://www.jalview.org/examples/exampleFile_2_3.jar"))
+ {
+ // hardwire upgrade of the startup file
+ file.replace("_2_3.jar", "_2_7.jar");
+ // and remove the stale setting
+ jalview.bin.Cache.removeProperty("STARTUP_FILE");
+ }
+