+ private boolean checkStartVamas(ArgsParser aparser)
+ {
+ String vamsasImport = aparser.getValue(ArgsParser.VDOC);
+ String vamsasSession = aparser.getValue(ArgsParser.VSESS);
+ if (vamsasImport == null && vamsasSession == null)
+ {
+ return false;
+ }
+ if (desktop == null || headless)
+ {
+ System.out.println(
+ "Headless vamsas sessions not yet supported. Sorry.");
+ System.exit(1);
+ }
+ boolean haveImport = (vamsasImport != null);
+ if (haveImport)
+ {
+ // if we have a file, start a new session and import it.
+ boolean inSession = false;
+ try
+ {
+ DataSourceType viprotocol = AppletFormatAdapter
+ .checkProtocol(vamsasImport);
+ if (viprotocol == DataSourceType.FILE)
+ {
+ inSession = desktop.vamsasImport(new File(vamsasImport));
+ }
+ else if (viprotocol == DataSourceType.URL)
+ {
+ inSession = desktop.vamsasImport(new URL(vamsasImport));
+ }
+
+ } catch (Exception e)
+ {
+ System.err.println("Exeption when importing " + vamsasImport
+ + " as a vamsas document.");
+ e.printStackTrace();
+ }
+ if (!inSession)
+ {
+ System.err.println("Failed to import " + vamsasImport
+ + " as a vamsas document.");
+ }
+ else
+ {
+ System.out.println("Imported Successfully into new session "
+ + desktop.getVamsasApplication().getCurrentSession());
+ }
+ }
+ if (vamsasSession != null)
+ {
+ if (vamsasImport != null)
+ {
+ // close the newly imported session and import the Jalview specific
+ // remnants into the new session later on.
+ desktop.vamsasStop_actionPerformed(null);
+ }
+ // now join the new session
+ try
+ {
+ if (desktop.joinVamsasSession(vamsasSession))
+ {
+ System.out.println(
+ "Successfully joined vamsas session " + vamsasSession);
+ }
+ else
+ {
+ System.err.println("WARNING: Failed to join vamsas session "
+ + vamsasSession);
+ }
+ } catch (Exception e)
+ {
+ System.err.println(
+ "ERROR: Failed to join vamsas session " + vamsasSession);
+ e.printStackTrace();
+ }
+ if (vamsasImport != null)
+ {
+ // the Jalview specific remnants can now be imported into the new
+ // session at the user's leisure.
+ Cache.log.info(
+ "Skipping Push for import of data into existing vamsas session."); // TODO:
+ // enable
+ // this
+ // when
+ // debugged
+ // desktop.getVamsasApplication().push_update();
+ }
+ }
+ return haveImport;
+ }
+
+ private void checkOutputFile(ArgsParser aparser, AlignFrame af,
+ FileFormatI format)
+ {
+ String imageName = "unnamed.png";
+ while (aparser.getSize() > 1)
+ {
+ // PNG filename
+ // SVG filename
+ // HTML filename
+ // biojsmsa filename
+ String outputFormat = aparser.nextValue();
+ String 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;
+ }
+
+ af.saveAlignment(file, format);
+ if (af.isSaveAlignmentSuccessful())
+ {
+ System.out.println(
+ "Written alignment in " + format + " format to " + file);
+ }
+ else
+ {
+ System.out.println("Error writing file " + file + " in " + format
+ + " format!!");
+ }
+
+ }
+ }
+