+ Jalview.exit("Could not open any files in headless mode", 1);
+ }
+ else
+ {
+ Console.warn("No more files to open");
+ }
+ }
+ if (progressBarSet && desktop != null)
+ desktop.setProgressBar(null, progress);
+
+ }
+
+ // open the structure (from same PDB file or given PDBfile)
+ if (!avm.getBoolean(Arg.NOSTRUCTURE))
+ {
+ AlignFrame af = afMap.get(id);
+ if (avm.containsArg(Arg.STRUCTURE))
+ {
+ commandArgsProvided = true;
+ for (ArgValue av : avm.getArgValueList(Arg.STRUCTURE))
+ {
+ String val = av.getValue();
+ SubVals subVals = av.getSubVals();
+ SequenceI seq = getSpecifiedSequence(af, subVals);
+ if (seq == null)
+ {
+ // Could not find sequence from subId, let's assume the first
+ // sequence in the alignframe
+ AlignmentI al = af.getCurrentView().getAlignment();
+ seq = al.getSequenceAt(0);
+ }
+
+ if (seq == null)
+ {
+ Console.warn("Could not find sequence for argument "
+ + Arg.STRUCTURE.argString() + "=" + val);
+ // you probably want to continue here, not break
+ // break;
+ continue;
+ }
+ File structureFile = null;
+ if (subVals.getContent() != null
+ && subVals.getContent().length() != 0)
+ {
+ structureFile = new File(subVals.getContent());
+ Console.debug("Using structure file (from argument) '"
+ + structureFile.getAbsolutePath() + "'");
+ }
+ // TRY THIS
+ /*
+ * PDBEntry fileEntry = new AssociatePdbFileWithSeq()
+ * .associatePdbWithSeq(selectedPdbFileName, DataSourceType.FILE,
+ * selectedSequence, true, Desktop.instance);
+ *
+ * sViewer = launchStructureViewer(ssm, new PDBEntry[] { fileEntry }, ap, new
+ * SequenceI[] { selectedSequence });
+ *
+ */
+ /* THIS DOESN'T WORK */
+ else if (seq.getAllPDBEntries() != null
+ && seq.getAllPDBEntries().size() > 0)
+ {
+ structureFile = new File(
+ seq.getAllPDBEntries().elementAt(0).getFile());
+ Console.debug("Using structure file (from sequence) '"
+ + structureFile.getAbsolutePath() + "'");
+ }
+
+ if (structureFile == null)
+ {
+ Console.warn("Not provided structure file with '" + val + "'");
+ continue;
+ }
+
+ if (!structureFile.exists())
+ {
+ Console.warn("Structure file '"
+ + structureFile.getAbsoluteFile() + "' not found.");
+ continue;
+ }
+
+ Console.debug("Using structure file "
+ + structureFile.getAbsolutePath());
+
+ // ##### Does this need to happen? Follow
+ // openStructureFileForSequence() below
+ /*
+ PDBEntry fileEntry = new AssociatePdbFileWithSeq()
+ .associatePdbWithSeq(structureFile.getAbsolutePath(),
+ DataSourceType.FILE, seq, true, Desktop.instance);
+ */
+
+ // open structure view
+ AlignmentPanel ap = af.alignPanel;
+ if (headless)
+ {
+ Cache.setProperty(Preferences.STRUCTURE_DISPLAY,
+ StructureViewer.ViewerType.JMOL.toString());
+ }
+
+ String structureFilepath = structureFile.getAbsolutePath();
+
+ // get PAEMATRIX file and label from subvals or Arg.PAEMATRIX
+ String paeFilepath = subVals.getWithSubstitutions(argParser, id,
+ "paematrix");
+ String paeLabel = subVals.get("paelabel");
+ ArgValue paeAv = getArgAssociatedWithStructure(Arg.PAEMATRIX, avm,
+ af, structureFilepath);
+ if (paeFilepath == null && paeAv != null)
+ {
+ SubVals sv = paeAv.getSubVals();
+ File paeFile = new File(sv.getContent());
+
+ paeLabel = sv.get("label");
+ try
+ {
+ paeFilepath = paeFile.getCanonicalPath();
+ } catch (IOException e)
+ {
+ paeFilepath = paeFile.getAbsolutePath();
+ Console.warn("Problem with the PAE file path: '"
+ + paeFile.getPath() + "'");
+ }
+ }
+
+ // showing annotations from structure file or not
+ boolean ssFromStructure = ArgParser.getFromSubValArgOrPref(avm,
+ Arg.SSANNOTATIONS, subVals, null, "STRUCT_FROM_PDB",
+ true);
+
+ // get TEMPFAC type from subvals or Arg.TEMPFAC in case user Adds
+ // reference annotations
+ String tftString = subVals.get("tempfac");
+ TFType tft = avm.getBoolean(Arg.NOTEMPFAC) ? null
+ : TFType.DEFAULT;
+ ArgValue tftAv = getArgAssociatedWithStructure(Arg.TEMPFAC, avm,
+ af, structureFilepath);
+ if (tftString == null && tftAv != null)
+ {
+ tftString = tftAv.getSubVals().getContent();
+ }
+ if (tftString != null)
+ {
+ // get kind of temperature factor annotation
+ try
+ {
+ tft = TFType.valueOf(tftString.toUpperCase(Locale.ROOT));
+ Console.debug("Obtained Temperature Factor type of '" + tft
+ + "' for structure '" + structureFilepath + "'");
+ } catch (IllegalArgumentException e)
+ {
+ // Just an error message!
+ StringBuilder sb = new StringBuilder().append("Cannot set ")
+ .append(Arg.TEMPFAC.argString()).append(" to '")
+ .append(tft)
+ .append("', ignoring. Valid values are: ");
+ Iterator<TFType> it = Arrays.stream(TFType.values())
+ .iterator();
+ while (it.hasNext())
+ {
+ sb.append(it.next().toString().toLowerCase(Locale.ROOT));
+ if (it.hasNext())
+ sb.append(", ");
+ }
+ Console.warn(sb.toString());
+ }
+ }
+
+ String sViewer = ArgParser.getFromSubValArgOrPref(avm,
+ Arg.STRUCTUREVIEWER, Position.AFTER, av, subVals,
+ "viewer", null, "jmol");
+ ViewerType viewerType = null;
+ if (!"none".equals(sViewer))
+ {
+ for (ViewerType v : EnumSet.allOf(ViewerType.class))
+ {
+ String name = v.name().toLowerCase(Locale.ROOT)
+ .replaceAll(" ", "");
+ if (sViewer.equals(name))
+ {
+ viewerType = v;
+ break;
+ }
+ }
+ }
+
+ boolean addTempFac = tft != null
+ || Cache.getDefault("ADD_TEMPFACT_ANN", false);
+
+ // TODO use ssFromStructure
+ StructureChooser.openStructureFileForSequence(null, null, ap, seq,
+ false, structureFilepath, tft, paeFilepath, false,
+ ssFromStructure, false, viewerType);
+ }
+ }
+ }
+
+ /*
+ boolean doShading = avm.getBoolean(Arg.TEMPFAC_SHADING);
+ if (doShading)
+ {
+ AlignFrame af = afMap.get(id);
+ for (AlignmentAnnotation aa : af.alignPanel.getAlignment()
+ .findAnnotation(PDBChain.class.getName().toString()))
+ {
+ AnnotationColourGradient acg = new AnnotationColourGradient(aa,
+ af.alignPanel.av.getGlobalColourScheme(), 0);
+ acg.setSeqAssociated(true);
+ af.changeColour(acg);
+ Console.info("Changed colour " + acg.toString());
+ }
+ }
+ */
+
+ return theseArgsWereParsed;
+ }
+
+ protected boolean processImages(String id)
+ {
+ ArgValuesMap avm = argParser.getLinkedArgs(id);
+ AlignFrame af = afMap.get(id);
+
+ if (af == null)
+ {
+ Console.warn("Did not have an alignment window for id=" + id);
+ return false;
+ }
+
+ if (avm.containsArg(Arg.IMAGE))
+ {
+ for (ArgValue av : avm.getArgValueList(Arg.IMAGE))
+ {
+ String val = av.getValue();
+ SubVals subVal = av.getSubVals();
+ String fileName = subVal.getContent();
+ File file = new File(fileName);
+ String name = af.getName();
+ String renderer = ArgParser.getValueFromSubValOrArg(avm, av,
+ Arg.RENDERER, subVal);
+ if (renderer == null)
+ renderer = "text";
+ String type = "png"; // default
+ type = ArgParser.getValueFromSubValOrArg(avm, av, Arg.TYPE, subVal);
+ if (type == null && fileName != null)
+ {
+ for (String ext : new String[] { "svg", "png", "html", "eps" })
+ {
+ if (fileName.toLowerCase(Locale.ROOT).endsWith("." + ext))
+ {
+ type = ext;
+ }
+ }
+ }
+ // for moment we disable JSON export
+ Cache.setPropsAreReadOnly(true);
+ Cache.setProperty("EXPORT_EMBBED_BIOJSON", "false");
+
+ switch (type)
+ {
+
+ case "svg":
+ Console.debug("Outputting type '" + type + "' to " + fileName);
+ af.createSVG(file, renderer);
+ break;
+
+ case "png":
+ Console.debug("Outputting type '" + type + "' to " + fileName);
+ af.createPNG(file);
+ break;
+
+ case "html":
+ Console.debug("Outputting type '" + type + "' to " + fileName);
+ HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel);
+ htmlSVG.exportHTML(fileName, renderer);
+ break;
+
+ case "biojs":
+ try
+ {
+ BioJsHTMLOutput.refreshVersionInfo(
+ BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
+ } catch (URISyntaxException e)
+ {
+ e.printStackTrace();
+ }
+ BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel);
+ bjs.exportHTML(fileName);
+ Console.debug("Creating BioJS MSA Viwer HTML file: " + fileName);
+ break;
+
+ case "eps":
+ af.createEPS(file, name);
+ Console.debug("Creating EPS file: " + fileName);
+ break;
+
+ case "imagemap":
+ af.createImageMap(file, name);
+ Console.debug("Creating ImageMap file: " + fileName);
+ break;
+
+ default:
+ Console.warn(Arg.IMAGE.argString() + " type '" + type
+ + "' not known. Ignoring");
+ break;