import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.EnumSet;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import jalview.analysis.AlignmentUtils;
import jalview.api.structures.JalviewStructureDisplayI;
+import jalview.bin.Jalview.ExitCode;
import jalview.bin.argparser.Arg;
import jalview.bin.argparser.ArgParser;
import jalview.bin.argparser.ArgParser.Position;
}
if (argParser.getBoolean(Arg.QUIT))
{
- Jalview.getInstance().quit();
+ Jalview.getInstance().exit(
+ "Exiting due to " + Arg.QUIT.argString() + " argument.",
+ ExitCode.OK);
return true;
}
// carry on with jalview.bin.Jalview
if (avm == null)
return true;
- /*
- * // script to execute after all loading is completed one way or another String
- * groovyscript = m.get(Arg.GROOVY) == null ? null :
- * m.get(Arg.GROOVY).getValue(); String file = m.get(Arg.OPEN) == null ? null :
- * m.get(Arg.OPEN).getValue(); String data = null; FileFormatI format = null;
- * DataSourceType protocol = null;
- */
+ // set wrap scope here so it can be applied after structures are opened
+ boolean wrap = false;
+
if (avm.containsArg(Arg.APPEND) || avm.containsArg(Arg.OPEN))
{
commandArgsProvided = true;
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);
-
- // wrap alignment?
- boolean wrap = ArgParser.getFromSubValArgOrPref(avm, Arg.WRAP, sv,
- null, "WRAP_ALIGNMENT", false);
- af.getCurrentView().setWrapAlignment(wrap);
+ 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,
false, false);
}
+ // wrap alignment? do this last for formatting reasons
+ wrap = ArgParser.getFromSubValArgOrPref(avm, Arg.WRAP, sv, null,
+ "WRAP_ALIGNMENT", false);
+ // af.setWrapFormat(wrap) is applied after structures are opened for
+ // annotation reasons
+
// store the AlignFrame for this id
afMap.put(id, af);
{
if (headless)
{
- Jalview.exit("Could not open any files in headless mode", 1);
+ Jalview.exit("Could not open any files in headless mode",
+ ExitCode.NO_FILES);
}
else
{
String sViewer = ArgParser.getFromSubValArgOrPref(avm,
Arg.STRUCTUREVIEWER, Position.AFTER, av, subVals, null,
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;
- }
- }
- }
+ ViewerType viewerType = ViewerType.getFromString(sViewer);
// TODO use ssFromStructure
StructureViewer sv = StructureChooser
}
}
+ if (wrap)
+ {
+ AlignFrame af = afMap.get(id);
+ if (af != null)
+ {
+ af.setWrapFormat(wrap, true);
+ }
+ }
+
/*
boolean doShading = avm.getBoolean(Arg.TEMPFAC_SHADING);
if (doShading)
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;
Jalview.exit("No valid format specified for "
+ Arg.OUTPUT.argString() + ". Valid formats are "
- + validSB.toString() + ".", 1);
+ + validSB.toString() + ".", ExitCode.INVALID_FORMAT);
// this return really shouldn't happen
return false;
}
seq = al.getSequenceAt(subVals.getIndex());
}
}
- else if (idAv != null)
+ if (seq == null && idAv != null)
{
seq = al.findName(idAv.getValue());
}