private Map<String, AlignFrame> afMap;
+ private Map<String, List<StructureViewer>> svMap;
+
private boolean commandArgsProvided = false;
private boolean argsWereParsed = false;
headless = h;
desktop = d;
afMap = new HashMap<>();
- if (argparser != null)
- {
- processArgs(argparser, headless);
- }
}
- private boolean processArgs(ArgParser argparser, boolean h)
+ protected boolean processArgs()
{
- argParser = argparser;
- headless = h;
+ if (argParser == null)
+ {
+ return true;
+ }
+
boolean theseArgsWereParsed = false;
if (argParser != null && argParser.getLinkedIds() != null)
{
ArgValuesMap avm = argParser.getLinkedArgs(id);
theseArgsWereParsed = true;
- theseArgsWereParsed &= processLinked(id);
+ boolean processLinkedOkay = processLinked(id);
+ theseArgsWereParsed &= processLinkedOkay;
+
processGroovyScript(id);
- boolean processLinkedOkay = theseArgsWereParsed;
// wait around until alignFrame isn't busy
AlignFrame af = afMap.get(id);
}
theseArgsWereParsed &= processImages(id);
+
if (processLinkedOkay)
+ {
theseArgsWereParsed &= processOutput(id);
+ }
// close ap
if (avm.getBoolean(Arg.CLOSE))
return argsWereParsed;
}
- protected boolean processUnlinked(String id)
- {
- return processLinked(id);
- }
-
protected boolean processLinked(String id)
{
boolean theseArgsWereParsed = false;
if (!(new File(openFile)).exists())
{
Console.warn("Can't find file '" + openFile + "'");
+ continue;
}
}
}
} catch (FileFormatException e1)
{
Console.error("Unknown file format for '" + openFile + "'");
+ continue;
}
af = afMap.get(id);
Console.debug(
"Opening '" + openFile + "' in new alignment frame");
FileLoader fileLoader = new FileLoader(!headless);
-
- af = fileLoader.LoadFileWaitTillLoaded(openFile, protocol,
- format);
+ boolean xception=false;
+ try {
+ af = fileLoader.LoadFileWaitTillLoaded(openFile, protocol,
+ format);
+ } catch (Throwable thr)
+ {
+ xception=true;
+ Console.error("Couldn't open '"+openFile+"' as "+format+" "+thr.getLocalizedMessage()+ " (Enable debug for full stack trace)");
+ Console.debug("Exception when opening '"+openFile+"'",thr);
+ }
+ finally
+ {
+ if (af==null && !xception)
+ {
+ Console.info("Ignoring '"+openFile+"' - no alignment data found.");
+ continue;
+ }
+ }
// colour alignment?
String colour = ArgParser.getFromSubValArgOrPref(avm, av,
Console.warn("Exception whilst waiting for structure viewer "
+ structureFilepath, x);
}
+
+ // add StructureViewer to svMap list
+ if (svMap == null)
+ {
+ svMap = new HashMap<>();
+ }
+ if (svMap.get(id) == null)
+ {
+ svMap.put(id, new ArrayList<>());
+ }
+ svMap.get(id).add(sv);
+
Console.debug(
"Successfully opened viewer for " + structureFilepath);
String structureImageFilename = ArgParser.getValueFromSubValOrArg(
switch (StructureViewer.getViewerType())
{
case JMOL:
- try
- {
- Thread.sleep(1000); // WHY ???
- } catch (InterruptedException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
JalviewStructureDisplayI sview = sv
.getJalviewStructureDisplay();
if (sview instanceof AppJmol)
case "biojs":
Console.debug(
- "Creating BioJS MSA Viwer HTML file: " + fileName);
+ "Outputting BioJS MSA Viwer HTML file: " + fileName);
try
{
BioJsHTMLOutput.refreshVersionInfo(
break;
case "eps":
- Console.debug("Creating EPS file: " + fileName);
- af.createEPS(file, name);
+ Console.debug("Outputting EPS file: " + fileName);
+ af.createEPS(file, renderer);
break;
case "imagemap":
- Console.debug("Creating ImageMap file: " + fileName);
+ Console.debug("Outputting ImageMap file: " + fileName);
af.createImageMap(file, name);
break;
seq = al.getSequenceAt(subVals.getIndex());
}
}
- else if (idAv != null)
+ if (seq == null && idAv != null)
{
seq = al.findName(idAv.getValue());
}
return seq;
}
+
+ public AlignFrame[] getAlignFrames()
+ {
+ AlignFrame[] afs = null;
+ if (afMap != null)
+ {
+ afs = (AlignFrame[]) afMap.values().toArray();
+ }
+
+ return afs;
+ }
+
+ public List<StructureViewer> getStructureViewers()
+ {
+ List<StructureViewer> svs = null;
+ if (svMap != null)
+ {
+ for (List<StructureViewer> svList : svMap.values())
+ {
+ if (svs == null)
+ {
+ svs = new ArrayList<>();
+ }
+ svs.addAll(svList);
+ }
+ }
+ return svs;
+ }
}