4 import java.io.IOException;
5 import java.net.URISyntaxException;
6 import java.util.ArrayList;
7 import java.util.Arrays;
8 import java.util.Collections;
9 import java.util.EnumSet;
10 import java.util.HashMap;
11 import java.util.Iterator;
12 import java.util.List;
13 import java.util.Locale;
16 import jalview.analysis.AlignmentUtils;
17 import jalview.api.structures.JalviewStructureDisplayI;
18 import jalview.bin.argparser.Arg;
19 import jalview.bin.argparser.ArgParser;
20 import jalview.bin.argparser.ArgParser.Position;
21 import jalview.bin.argparser.ArgValue;
22 import jalview.bin.argparser.ArgValuesMap;
23 import jalview.bin.argparser.SubVals;
24 import jalview.datamodel.AlignmentI;
25 import jalview.datamodel.SequenceI;
26 import jalview.datamodel.annotations.AlphaFoldAnnotationRowBuilder;
27 import jalview.gui.AlignFrame;
28 import jalview.gui.AlignmentPanel;
29 import jalview.gui.AppJmol;
30 import jalview.gui.Desktop;
31 import jalview.gui.Preferences;
32 import jalview.gui.StructureChooser;
33 import jalview.gui.StructureViewer;
34 import jalview.gui.StructureViewer.ViewerType;
35 import jalview.io.AppletFormatAdapter;
36 import jalview.io.BackupFiles;
37 import jalview.io.BioJsHTMLOutput;
38 import jalview.io.DataSourceType;
39 import jalview.io.FileFormat;
40 import jalview.io.FileFormatException;
41 import jalview.io.FileFormatI;
42 import jalview.io.FileFormats;
43 import jalview.io.FileLoader;
44 import jalview.io.HtmlSvgOutput;
45 import jalview.io.IdentifyFile;
46 import jalview.io.NewickFile;
47 import jalview.structure.StructureImportSettings.TFType;
48 import jalview.structure.StructureSelectionManager;
49 import jalview.util.FileUtils;
50 import jalview.util.HttpUtils;
51 import jalview.util.ImageMaker;
52 import jalview.util.ImageMaker.TYPE;
53 import jalview.util.MessageManager;
54 import jalview.util.Platform;
55 import jalview.util.imagemaker.BitmapImageSizing;
61 private boolean headless;
63 private ArgParser argParser;
65 private Map<String, AlignFrame> afMap;
67 private boolean commandArgsProvided = false;
69 private boolean argsWereParsed = false;
71 public Commands(ArgParser argparser, boolean headless)
73 this(Desktop.instance, argparser, headless);
76 public Commands(Desktop d, ArgParser argparser, boolean h)
78 argParser = argparser;
81 afMap = new HashMap<>();
82 if (argparser != null)
84 processArgs(argparser, headless);
88 private boolean processArgs(ArgParser argparser, boolean h)
90 argParser = argparser;
92 boolean theseArgsWereParsed = false;
94 if (argParser != null && argParser.getLinkedIds() != null)
96 for (String id : argParser.getLinkedIds())
98 ArgValuesMap avm = argParser.getLinkedArgs(id);
99 theseArgsWereParsed = true;
100 theseArgsWereParsed &= processLinked(id);
101 processGroovyScript(id);
102 boolean processLinkedOkay = theseArgsWereParsed;
103 theseArgsWereParsed &= processImages(id);
104 if (processLinkedOkay)
105 theseArgsWereParsed &= processOutput(id);
108 if (avm.getBoolean(Arg.CLOSE))
110 AlignFrame af = afMap.get(id);
113 af.closeMenuItem_actionPerformed(true);
120 if (argParser.getBoolean(Arg.QUIT))
122 Jalview.getInstance().quit();
125 // carry on with jalview.bin.Jalview
126 argsWereParsed = theseArgsWereParsed;
127 return argsWereParsed;
130 public boolean commandArgsProvided()
132 return commandArgsProvided;
135 public boolean argsWereParsed()
137 return argsWereParsed;
140 protected boolean processUnlinked(String id)
142 return processLinked(id);
145 protected boolean processLinked(String id)
147 boolean theseArgsWereParsed = false;
148 ArgValuesMap avm = argParser.getLinkedArgs(id);
153 * // script to execute after all loading is completed one way or another String
154 * groovyscript = m.get(Arg.GROOVY) == null ? null :
155 * m.get(Arg.GROOVY).getValue(); String file = m.get(Arg.OPEN) == null ? null :
156 * m.get(Arg.OPEN).getValue(); String data = null; FileFormatI format = null;
157 * DataSourceType protocol = null;
159 if (avm.containsArg(Arg.APPEND) || avm.containsArg(Arg.OPEN))
161 commandArgsProvided = true;
164 boolean first = true;
165 boolean progressBarSet = false;
167 // Combine the APPEND and OPEN files into one list, along with whether it
168 // was APPEND or OPEN
169 List<ArgValue> openAvList = new ArrayList<>();
170 openAvList.addAll(avm.getArgValueList(Arg.OPEN));
171 openAvList.addAll(avm.getArgValueList(Arg.APPEND));
172 // sort avlist based on av.getArgIndex()
173 Collections.sort(openAvList);
174 for (ArgValue av : openAvList)
177 SubVals sv = av.getSubVals();
178 String openFile = av.getValue();
179 if (openFile == null)
182 theseArgsWereParsed = true;
186 if (!headless && desktop != null)
188 desktop.setProgressBar(
189 MessageManager.getString(
190 "status.processing_commandline_args"),
191 progress = System.currentTimeMillis());
192 progressBarSet = true;
196 if (!Platform.isJS())
198 * ignore in JavaScript -- can't just file existence - could load it?
203 if (!HttpUtils.startsWithHttpOrHttps(openFile))
205 if (!(new File(openFile)).exists())
207 Console.warn("Can't find file '" + openFile + "'");
212 DataSourceType protocol = AppletFormatAdapter
213 .checkProtocol(openFile);
215 FileFormatI format = null;
218 format = new IdentifyFile().identify(openFile, protocol);
219 } catch (FileFormatException e1)
221 Console.error("Unknown file format for '" + openFile + "'");
225 // When to open a new AlignFrame
226 if (af == null || "true".equals(av.getSubVal("new"))
227 || a == Arg.OPEN || format == FileFormat.Jalview)
231 Jalview.testoutput(argParser, Arg.OPEN, "examples/uniref50.fa",
236 "Opening '" + openFile + "' in new alignment frame");
237 FileLoader fileLoader = new FileLoader(!headless);
239 af = fileLoader.LoadFileWaitTillLoaded(openFile, protocol,
243 boolean wrap = ArgParser.getFromSubValArgOrPref(avm, Arg.WRAP, sv,
244 null, "WRAP_ALIGNMENT", false);
245 af.getCurrentView().setWrapAlignment(wrap);
248 String colour = ArgParser.getFromSubValArgOrPref(avm, av,
249 Arg.COLOUR, sv, null, "DEFAULT_COLOUR_PROT", "");
252 af.changeColour_actionPerformed(colour);
253 Jalview.testoutput(argParser, Arg.COLOUR, "zappo", colour);
256 // Change alignment frame title
257 String title = ArgParser.getFromSubValArgOrPref(avm, av,
258 Arg.TITLE, sv, null, null, null);
262 Jalview.testoutput(argParser, Arg.TITLE, "test title", title);
266 String featuresfile = ArgParser.getValueFromSubValOrArg(avm, av,
268 if (featuresfile != null)
270 af.parseFeaturesFile(featuresfile,
271 AppletFormatAdapter.checkProtocol(featuresfile));
272 Jalview.testoutput(argParser, Arg.FEATURES,
273 "examples/testdata/plantfdx.features", featuresfile);
276 // Add annotations from file
277 String annotationsfile = ArgParser.getValueFromSubValOrArg(avm,
278 av, Arg.ANNOTATIONS, sv);
279 if (annotationsfile != null)
281 af.loadJalviewDataFile(annotationsfile, null, null, null);
282 Jalview.testoutput(argParser, Arg.ANNOTATIONS,
283 "examples/testdata/plantfdx.annotations",
287 // Set or clear the sortbytree flag
288 boolean sortbytree = ArgParser.getBoolFromSubValOrArg(avm,
292 af.getViewport().setSortByTree(true);
293 Jalview.testoutput(argParser, Arg.SORTBYTREE);
296 // Load tree from file
297 String treefile = ArgParser.getValueFromSubValOrArg(avm, av,
299 if (treefile != null)
303 NewickFile nf = new NewickFile(treefile,
304 AppletFormatAdapter.checkProtocol(treefile));
305 af.getViewport().setCurrentTree(
306 af.showNewickTree(nf, treefile).getTree());
307 Jalview.testoutput(argParser, Arg.TREE,
308 "examples/testdata/uniref50_test_tree", treefile);
309 } catch (IOException e)
311 Console.warn("Couldn't add tree " + treefile, e);
315 // Show secondary structure annotations?
316 boolean showSSAnnotations = ArgParser.getFromSubValArgOrPref(avm,
317 Arg.SHOWSSANNOTATIONS, av.getSubVals(), null,
318 "STRUCT_FROM_PDB", true);
319 af.setAnnotationsVisibility(showSSAnnotations, true, false);
321 // Show sequence annotations?
322 boolean showAnnotations = ArgParser.getFromSubValArgOrPref(avm,
323 Arg.SHOWANNOTATIONS, av.getSubVals(), null,
324 "SHOW_ANNOTATIONS", true);
325 af.setAnnotationsVisibility(showAnnotations, false, true);
327 // show temperature factor annotations?
328 if (avm.getBoolean(Arg.NOTEMPFAC))
330 // do this better (annotation types?)
331 List<String> hideThese = new ArrayList<>();
332 hideThese.add("Temperature Factor");
333 hideThese.add(AlphaFoldAnnotationRowBuilder.LABEL);
334 AlignmentUtils.showOrHideSequenceAnnotations(
335 af.getCurrentView().getAlignment(), hideThese, null,
339 // store the AlignFrame for this id
342 // is it its own structure file?
343 if (format.isStructureFile())
345 StructureSelectionManager ssm = StructureSelectionManager
346 .getStructureSelectionManager(Desktop.instance);
347 SequenceI seq = af.alignPanel.getAlignment().getSequenceAt(0);
348 ssm.computeMapping(false, new SequenceI[] { seq }, null,
349 openFile, DataSourceType.FILE, null, null, null, false);
355 "Opening '" + openFile + "' in existing alignment frame");
356 DataSourceType dst = HttpUtils.startsWithHttpOrHttps(openFile)
358 : DataSourceType.FILE;
359 FileLoader fileLoader = new FileLoader(!headless);
360 fileLoader.LoadFile(af.getCurrentView(), openFile, dst, null,
364 Console.debug("Command " + Arg.APPEND + " executed successfully!");
367 if (first) // first=true means nothing opened
371 Jalview.exit("Could not open any files in headless mode", 1);
375 Console.warn("No more files to open");
378 if (progressBarSet && desktop != null)
379 desktop.setProgressBar(null, progress);
383 // open the structure (from same PDB file or given PDBfile)
384 if (!avm.getBoolean(Arg.NOSTRUCTURE))
386 AlignFrame af = afMap.get(id);
387 if (avm.containsArg(Arg.STRUCTURE))
389 commandArgsProvided = true;
390 for (ArgValue av : avm.getArgValueList(Arg.STRUCTURE))
392 String val = av.getValue();
393 SubVals subVals = av.getSubVals();
394 SequenceI seq = getSpecifiedSequence(af, avm, av);
397 // Could not find sequence from subId, let's assume the first
398 // sequence in the alignframe
399 AlignmentI al = af.getCurrentView().getAlignment();
400 seq = al.getSequenceAt(0);
405 Console.warn("Could not find sequence for argument "
406 + Arg.STRUCTURE.argString() + "=" + val);
407 // you probably want to continue here, not break
411 File structureFile = null;
412 if (subVals.getContent() != null
413 && subVals.getContent().length() != 0)
415 structureFile = new File(subVals.getContent());
416 Console.debug("Using structure file (from argument) '"
417 + structureFile.getAbsolutePath() + "'");
421 * PDBEntry fileEntry = new AssociatePdbFileWithSeq()
422 * .associatePdbWithSeq(selectedPdbFileName, DataSourceType.FILE,
423 * selectedSequence, true, Desktop.instance);
425 * sViewer = launchStructureViewer(ssm, new PDBEntry[] { fileEntry }, ap, new
426 * SequenceI[] { selectedSequence });
429 /* THIS DOESN'T WORK */
430 else if (seq.getAllPDBEntries() != null
431 && seq.getAllPDBEntries().size() > 0)
433 structureFile = new File(
434 seq.getAllPDBEntries().elementAt(0).getFile());
435 Console.debug("Using structure file (from sequence) '"
436 + structureFile.getAbsolutePath() + "'");
439 if (structureFile == null)
441 Console.warn("Not provided structure file with '" + val + "'");
445 if (!structureFile.exists())
447 Console.warn("Structure file '"
448 + structureFile.getAbsoluteFile() + "' not found.");
452 Console.debug("Using structure file "
453 + structureFile.getAbsolutePath());
455 // ##### Does this need to happen? Follow
456 // openStructureFileForSequence() below
458 PDBEntry fileEntry = new AssociatePdbFileWithSeq()
459 .associatePdbWithSeq(structureFile.getAbsolutePath(),
460 DataSourceType.FILE, seq, true, Desktop.instance);
463 // open structure view
464 AlignmentPanel ap = af.alignPanel;
467 Cache.setProperty(Preferences.STRUCTURE_DISPLAY,
468 StructureViewer.ViewerType.JMOL.toString());
471 String structureFilepath = structureFile.getAbsolutePath();
473 // get PAEMATRIX file and label from subvals or Arg.PAEMATRIX
474 String paeFilepath = ArgParser
475 .getFromSubValArgOrPrefWithSubstitutions(argParser, avm,
476 Arg.PAEMATRIX, Position.AFTER, av, subVals, null,
478 if (paeFilepath != null)
480 File paeFile = new File(paeFilepath);
484 paeFilepath = paeFile.getCanonicalPath();
485 } catch (IOException e)
487 paeFilepath = paeFile.getAbsolutePath();
488 Console.warn("Problem with the PAE file path: '"
489 + paeFile.getPath() + "'");
493 // showing annotations from structure file or not
494 boolean ssFromStructure = ArgParser.getFromSubValArgOrPref(avm,
495 Arg.SHOWSSANNOTATIONS, subVals, null, "STRUCT_FROM_PDB",
498 // get TEMPFAC type from subvals or Arg.TEMPFAC in case user Adds
499 // reference annotations
500 String tftString = ArgParser
501 .getFromSubValArgOrPrefWithSubstitutions(argParser, avm,
502 Arg.TEMPFAC, Position.AFTER, av, subVals, null,
504 boolean notempfac = ArgParser.getFromSubValArgOrPref(avm,
505 Arg.NOTEMPFAC, subVals, null, "ADD_TEMPFACT_ANN", false,
507 TFType tft = notempfac ? null : TFType.DEFAULT;
509 String tftString = subVals.get("tempfac");
510 ArgValue tftAv = getArgAssociatedWithStructure(Arg.TEMPFAC, avm,
511 af, structureFilepath);
512 if (tftString == null && tftAv != null)
514 tftString = tftAv.getSubVals().getContent();
517 if (tftString != null && !notempfac)
519 // get kind of temperature factor annotation
522 tft = TFType.valueOf(tftString.toUpperCase(Locale.ROOT));
523 Console.debug("Obtained Temperature Factor type of '" + tft
524 + "' for structure '" + structureFilepath + "'");
525 } catch (IllegalArgumentException e)
527 // Just an error message!
528 StringBuilder sb = new StringBuilder().append("Cannot set ")
529 .append(Arg.TEMPFAC.argString()).append(" to '")
531 .append("', ignoring. Valid values are: ");
532 Iterator<TFType> it = Arrays.stream(TFType.values())
536 sb.append(it.next().toString().toLowerCase(Locale.ROOT));
540 Console.warn(sb.toString());
544 String sViewer = ArgParser.getFromSubValArgOrPref(avm,
545 Arg.STRUCTUREVIEWER, Position.AFTER, av, subVals, null,
547 ViewerType viewerType = null;
548 if (!"none".equals(sViewer))
550 for (ViewerType v : EnumSet.allOf(ViewerType.class))
552 String name = v.name().toLowerCase(Locale.ROOT)
553 .replaceAll(" ", "");
554 if (sViewer.equals(name))
562 // TODO use ssFromStructure
563 StructureViewer sv = StructureChooser
564 .openStructureFileForSequence(null, null, ap, seq, false,
565 structureFilepath, tft, paeFilepath, false,
566 ssFromStructure, false, viewerType);
573 String structureImageFilename = ArgParser.getValueFromSubValOrArg(
574 avm, av, Arg.STRUCTUREIMAGE, subVals);
575 if (sv != null && structureImageFilename != null)
577 ArgValue siAv = avm.getClosestNextArgValueOfArg(av,
580 if (structureImageFilename.equals(siAv.getValue()))
582 sisv = siAv.getSubVals();
584 File structureImageFile = new File(structureImageFilename);
585 String width = ArgParser.getValueFromSubValOrArg(avm, av,
586 Arg.STRUCTUREIMAGEWIDTH, sisv);
587 String height = ArgParser.getValueFromSubValOrArg(avm, av,
588 Arg.STRUCTUREIMAGEHEIGHT, sisv);
589 String scale = ArgParser.getValueFromSubValOrArg(avm, av,
590 Arg.STRUCTUREIMAGESCALE, sisv);
591 String renderer = ArgParser.getValueFromSubValOrArg(avm, av,
592 Arg.STRUCTUREIMAGETEXTRENDERER, sisv);
593 String typeS = ArgParser.getValueFromSubValOrArg(avm, av,
594 Arg.STRUCTUREIMAGETYPE, sisv);
595 if (typeS == null || typeS.length() == 0)
597 typeS = FileUtils.getExtension(structureImageFile);
602 imageType = Enum.valueOf(TYPE.class,
603 typeS.toUpperCase(Locale.ROOT));
604 } catch (IllegalArgumentException e)
606 Console.warn("Do not know image format '" + typeS
608 imageType = TYPE.PNG;
610 BitmapImageSizing userBis = ImageMaker
611 .parseScaleWidthHeightStrings(scale, width, height);
612 switch (StructureViewer.getViewerType())
618 } catch (InterruptedException e)
620 // TODO Auto-generated catch block
623 JalviewStructureDisplayI sview = sv
624 .getJalviewStructureDisplay();
625 if (sview instanceof AppJmol)
627 AppJmol jmol = (AppJmol) sview;
628 jmol.makePDBImage(structureImageFile, imageType, renderer,
633 Console.warn("Cannot export image for structure viewer "
634 + sv.getViewerType() + " yet");
643 boolean doShading = avm.getBoolean(Arg.TEMPFAC_SHADING);
646 AlignFrame af = afMap.get(id);
647 for (AlignmentAnnotation aa : af.alignPanel.getAlignment()
648 .findAnnotation(PDBChain.class.getName().toString()))
650 AnnotationColourGradient acg = new AnnotationColourGradient(aa,
651 af.alignPanel.av.getGlobalColourScheme(), 0);
652 acg.setSeqAssociated(true);
653 af.changeColour(acg);
654 Console.info("Changed colour " + acg.toString());
659 return theseArgsWereParsed;
662 protected void processGroovyScript(String id)
664 ArgValuesMap avm = argParser.getLinkedArgs(id);
665 AlignFrame af = afMap.get(id);
669 Console.warn("Did not have an alignment window for id=" + id);
673 if (avm.containsArg(Arg.GROOVY))
675 String groovyscript = avm.getValue(Arg.GROOVY);
676 if (groovyscript != null)
678 // Execute the groovy script after we've done all the rendering stuff
679 // and before any images or figures are generated.
680 Console.info("Executing script " + groovyscript);
681 Jalview.getInstance().executeGroovyScript(groovyscript, af);
686 protected boolean processImages(String id)
688 ArgValuesMap avm = argParser.getLinkedArgs(id);
689 AlignFrame af = afMap.get(id);
693 Console.warn("Did not have an alignment window for id=" + id);
697 if (avm.containsArg(Arg.IMAGE))
699 for (ArgValue av : avm.getArgValueList(Arg.IMAGE))
701 String val = av.getValue();
702 SubVals subVal = av.getSubVals();
703 String fileName = subVal.getContent();
704 File file = new File(fileName);
705 String name = af.getName();
706 String renderer = ArgParser.getValueFromSubValOrArg(avm, av,
707 Arg.TEXTRENDERER, subVal);
708 if (renderer == null)
710 String type = "png"; // default
712 String scale = ArgParser.getValueFromSubValOrArg(avm, av, Arg.SCALE,
714 String width = ArgParser.getValueFromSubValOrArg(avm, av, Arg.WIDTH,
716 String height = ArgParser.getValueFromSubValOrArg(avm, av,
718 BitmapImageSizing userBis = ImageMaker
719 .parseScaleWidthHeightStrings(scale, width, height);
721 type = ArgParser.getValueFromSubValOrArg(avm, av, Arg.TYPE, subVal);
722 if (type == null && fileName != null)
724 for (String ext : new String[] { "svg", "png", "html", "eps" })
726 if (fileName.toLowerCase(Locale.ROOT).endsWith("." + ext))
732 // for moment we disable JSON export
733 Cache.setPropsAreReadOnly(true);
734 Cache.setProperty("EXPORT_EMBBED_BIOJSON", "false");
736 Console.info("Writing " + file);
742 Console.debug("Outputting type '" + type + "' to " + fileName);
743 af.createSVG(file, renderer);
747 Console.debug("Outputting type '" + type + "' to " + fileName);
748 af.createPNG(file, null, userBis);
752 Console.debug("Outputting type '" + type + "' to " + fileName);
753 HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel);
754 htmlSVG.exportHTML(fileName, renderer);
760 BioJsHTMLOutput.refreshVersionInfo(
761 BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
762 } catch (URISyntaxException e)
766 BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel);
767 bjs.exportHTML(fileName);
768 Console.debug("Creating BioJS MSA Viwer HTML file: " + fileName);
772 af.createEPS(file, name);
773 Console.debug("Creating EPS file: " + fileName);
777 af.createImageMap(file, name);
778 Console.debug("Creating ImageMap file: " + fileName);
782 Console.warn(Arg.IMAGE.argString() + " type '" + type
783 + "' not known. Ignoring");
791 protected boolean processOutput(String id)
793 ArgValuesMap avm = argParser.getLinkedArgs(id);
794 AlignFrame af = afMap.get(id);
798 Console.warn("Did not have an alignment window for id=" + id);
802 if (avm.containsArg(Arg.OUTPUT))
804 for (ArgValue av : avm.getArgValueList(Arg.OUTPUT))
806 String val = av.getValue();
807 SubVals subVals = av.getSubVals();
808 String fileName = subVals.getContent();
809 File file = new File(fileName);
810 boolean overwrite = ArgParser.getFromSubValArgOrPref(avm,
811 Arg.OVERWRITE, subVals, null, "OVERWRITE_OUTPUT", false);
812 // backups. Use the Arg.BACKUPS or subval "backups" setting first,
813 // otherwise if headless assume false, if not headless use the user
814 // preference with default true.
815 boolean backups = ArgParser.getFromSubValArgOrPref(avm, Arg.BACKUPS,
817 Platform.isHeadless() ? null : BackupFiles.ENABLED,
818 !Platform.isHeadless());
820 // if backups is not true then --overwrite must be specified
821 if (file.exists() && !(overwrite || backups))
823 Console.error("Won't overwrite file '" + fileName + "' without "
824 + Arg.OVERWRITE.argString() + " or "
825 + Arg.BACKUPS.argString() + " set");
829 String name = af.getName();
830 String format = ArgParser.getValueFromSubValOrArg(avm, av,
831 Arg.FORMAT, subVals);
832 FileFormats ffs = FileFormats.getInstance();
833 List<String> validFormats = ffs.getWritableFormats(false);
835 FileFormatI ff = null;
836 if (format == null && fileName != null)
838 FORMAT: for (String fname : validFormats)
840 FileFormatI tff = ffs.forName(fname);
841 String[] extensions = tff.getExtensions().split(",");
842 for (String ext : extensions)
844 if (fileName.toLowerCase(Locale.ROOT).endsWith("." + ext))
847 format = ff.getName();
853 if (ff == null && format != null)
855 ff = ffs.forName(format);
859 StringBuilder validSB = new StringBuilder();
860 for (String f : validFormats)
862 if (validSB.length() > 0)
863 validSB.append(", ");
865 FileFormatI tff = ffs.forName(f);
866 validSB.append(" (");
867 validSB.append(tff.getExtensions());
871 Jalview.exit("No valid format specified for "
872 + Arg.OUTPUT.argString() + ". Valid formats are "
873 + validSB.toString() + ".", 1);
874 // this return really shouldn't happen
878 String savedBackupsPreference = Cache
879 .getDefault(BackupFiles.ENABLED, null);
880 Console.debug("Setting backups to " + backups);
881 Cache.applicationProperties.put(BackupFiles.ENABLED,
882 Boolean.toString(backups));
884 Console.info("Writing " + fileName);
886 af.saveAlignment(fileName, ff);
887 Console.debug("Returning backups to " + savedBackupsPreference);
888 if (savedBackupsPreference != null)
889 Cache.applicationProperties.put(BackupFiles.ENABLED,
890 savedBackupsPreference);
891 if (af.isSaveAlignmentSuccessful())
893 Console.debug("Written alignment '" + name + "' in "
894 + ff.getName() + " format to " + file);
898 Console.warn("Error writing file " + file + " in " + ff.getName()
907 private SequenceI getSpecifiedSequence(AlignFrame af, ArgValuesMap avm,
910 SubVals subVals = av.getSubVals();
911 ArgValue idAv = avm.getClosestNextArgValueOfArg(av, Arg.SEQID);
912 SequenceI seq = null;
913 if (subVals == null && idAv == null)
915 if (af == null || af.getCurrentView() == null)
919 AlignmentI al = af.getCurrentView().getAlignment();
926 if (subVals.has(Arg.SEQID.getName()))
928 seq = al.findName(subVals.get(Arg.SEQID.getName()));
930 else if (-1 < subVals.getIndex()
931 && subVals.getIndex() < al.getSequences().size())
933 seq = al.getSequenceAt(subVals.getIndex());
936 else if (idAv != null)
938 seq = al.findName(idAv.getValue());