import jalview.bin.ArgParser.ArgValues;
import jalview.bin.ArgParser.SubVal;
import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentI;
import jalview.datamodel.SequenceI;
+import jalview.datamodel.annotations.AlphaFoldAnnotationRowBuilder;
import jalview.gui.AlignFrame;
import jalview.gui.AlignmentPanel;
import jalview.gui.Desktop;
import jalview.io.FileLoader;
import jalview.io.HtmlSvgOutput;
import jalview.io.IdentifyFile;
+import jalview.structure.StructureImportSettings;
+import jalview.structure.StructureImportSettings.TFType;
+import jalview.structure.StructureSelectionManager;
import jalview.util.HttpUtils;
import jalview.util.MessageManager;
import jalview.util.Platform;
private Map<String, AlignFrame> afMap;
- public static void processArgs(ArgParser ap, boolean h)
+ public static boolean processArgs(ArgParser ap, boolean h)
{
argParser = ap;
headless = h;
+ boolean argsWereParsed = false;
+ if (headless)
+ {
+ System.setProperty("java.awt.headless", "true");
+ }
+
if (argParser != null && argParser.linkedIds() != null)
{
for (String id : argParser.linkedIds())
{
+ Console.debug("##### id=" + id);
Commands cmds = new Commands();
if (id == null)
{
cmds.processLinked(id);
}
cmds.processImages(id);
+ argsWereParsed |= cmds.wereParsed();
}
- if (argParser.getBool(Arg.QUIT))
- {
- Jalview.getInstance().quit();
- }
}
+ if (argParser.getBool(Arg.QUIT))
+ {
+ Jalview.getInstance().quit();
+ return true;
+ }
+ // carry on with jalview.bin.Jalview
+ return argsWereParsed;
+ }
+
+ boolean argsWereParsed = false;
+
+ private boolean wereParsed()
+ {
+ return argsWereParsed;
}
public Commands()
protected void processUnlinked(String id)
{
+ Map<Arg, ArgValues> m = argParser.linkedArgs(id);
+
processLinked(id);
}
FileFormatI format = null;
DataSourceType protocol = null;
*/
-
if (ArgParser.getArgValues(m, Arg.OPEN) != null)
{
long progress = -1;
boolean first = true;
AlignFrame af;
- OPEN: for (String openFile : ArgParser.getValues(m, Arg.OPEN))
+ for (String openFile : ArgParser.getValues(m, Arg.OPEN))
{
if (openFile == null)
- continue OPEN;
+ continue;
+ argsWereParsed = true;
if (first)
{
first = false;
if (!(new File(openFile)).exists())
{
Console.warn("Can't find file '" + openFile + "'");
- continue OPEN;
}
}
}
*/
// get kind of temperature factor annotation
- AlignmentAnnotation.TFType tempfacType = null;
+ StructureImportSettings.TFType tempfacType = TFType.DEFAULT;
if ((!ArgParser.getBoolean(m, Arg.NOTEMPFAC))
&& ArgParser.getArgValues(m, Arg.TEMPFAC) != null)
{
try
{
- tempfacType = AlignmentAnnotation.TFType.valueOf(ArgParser
+ tempfacType = StructureImportSettings.TFType.valueOf(ArgParser
.getValue(m, Arg.TEMPFAC).toUpperCase(Locale.ROOT));
Console.debug("Obtained Temperature Factor type of '"
+ tempfacType + "'");
.append(Arg.TEMPFAC.getName()).append(" to '")
.append(tempfacType)
.append("', ignoring. Valid values are: ");
- Iterator<AlignmentAnnotation.TFType> it = Arrays
- .stream(AlignmentAnnotation.TFType.values())
+ Iterator<StructureImportSettings.TFType> it = Arrays
+ .stream(StructureImportSettings.TFType.values())
.iterator();
while (it.hasNext())
{
Console.debug(
"Opening '" + openFile + "' in new alignment frame");
FileLoader fileLoader = new FileLoader(!headless);
- af = fileLoader.LoadFileWaitTillLoaded(openFile, protocol, format,
- tempfacType);
+
+ StructureImportSettings.setTemperatureFactorType(tempfacType);
+
+ af = fileLoader.LoadFileWaitTillLoaded(openFile, protocol,
+ format);
// wrap alignment?
if (ArgParser.getBoolean(m, Arg.WRAP))
// do this better (annotation types?)
List<String> hideThese = new ArrayList<>();
hideThese.add("Temperature Factor");
- hideThese.add(MessageManager
- .getString("label.alphafold_reliability"));
+ hideThese.add(AlphaFoldAnnotationRowBuilder.LABEL);
AlignmentUtils.showOrHideSequenceAnnotations(
af.getCurrentView().getAlignment(), hideThese, null,
false, false);
// store the AlignFrame for this id
afMap.put(id, af);
+
+ // is it its own structure file?
+ if (format.isStructureFile())
+ {
+ StructureSelectionManager ssm = StructureSelectionManager
+ .getStructureSelectionManager(Desktop.instance);
+ SequenceI seq = af.alignPanel.getAlignment().getSequenceAt(0);
+ ssm.computeMapping(false, new SequenceI[] { seq }, null,
+ openFile, DataSourceType.FILE, null);
+ }
}
else
{
Console.error("Could not open any files in headless mode");
System.exit(1);
}
- }
- else
- {
- Console.warn("No more files to open");
- if (desktop != null)
- desktop.setProgressBar(null, progress);
+ // TOREMOVE COMMENT
+ // @Ben assumed this was the GUI version of above, rather then the
+ // first==false state
+ else
+ {
+ Console.warn("No more files to open");
+ if (desktop != null)
+ desktop.setProgressBar(null, progress);
+ }
}
}
{
SubVal subVal = ArgParser.getSubVal(val);
File paeFile = new File(subVal.content);
- EBIAlfaFold.addAlphaFoldPAE(af.getCurrentView().getAlignment(),
- paeFile, subVal.index,
- "id".equals(subVal.keyName) ? subVal.keyValue : null);
- // required to readjust the height and position of the pAE
- // annotation
+ String structId = "structid".equals(subVal.keyName)
+ ? subVal.keyValue
+ : null;
+ if (subVal.notSet())
+ {
+ // take structid from pdbfilename
+ }
+ if ("structfile".equals(subVal.keyName))
+ {
+ EBIAlfaFold.addAlphaFoldPAEToStructure(
+ af.getCurrentView().getAlignment(), paeFile,
+ subVal.index, subVal.keyValue, false);
+ }
+ else if ("structid".equals(subVal.keyName))
+ {
+ EBIAlfaFold.addAlphaFoldPAEToStructure(
+ af.getCurrentView().getAlignment(), paeFile,
+ subVal.index, subVal.keyValue, true);
+ }
+ else
+ {
+ EBIAlfaFold.addAlphaFoldPAEToSequence(
+ af.getCurrentView().getAlignment(), paeFile,
+ subVal.index,
+ "seqid".equals(subVal.keyName) ? subVal.keyValue
+ : null);
+ // required to readjust the height and position of the pAE
+ // annotation
+ }
for (AlignmentViewPanel ap : af.getAlignPanels())
{
ap.adjustAnnotationHeight();
AlignFrame af = afMap.get(id);
if (ArgParser.getArgValues(m, Arg.STRUCTURE) != null)
{
- STRUCTURE: for (String val : ArgParser.getValues(m, Arg.STRUCTURE))
+ for (String val : ArgParser.getValues(m, Arg.STRUCTURE))
{
SubVal subId = new SubVal(val);
SequenceI seq = getSpecifiedSequence(af, subId);
if (structureFile == null)
{
Console.warn("Not provided structure file with '" + val + "'");
- continue STRUCTURE;
+ continue;
}
if (!structureFile.exists())
{
Console.warn("Structure file '"
+ structureFile.getAbsoluteFile() + "' not found.");
- continue STRUCTURE;
+ continue;
}
Console.debug("Using structure file "
}
}
}
+ // 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);
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);
break;
+ default:
+ Console.warn("--image type '" + type + "' not known. Ignoring");
+ break;
}
}
}
private SequenceI getSpecifiedSequence(AlignFrame af, SubVal subId)
{
- SequenceI seq = null;
- SequenceI[] sequences = af.getCurrentView().getAlignment()
- .getSequencesArray();
- if (-1 < subId.index && subId.index < sequences.length)
+ AlignmentI al = af.getCurrentView().getAlignment();
+ if (-1 < subId.index && subId.index < al.getSequences().size())
{
- seq = sequences[subId.index];
+ return al.getSequenceAt(subId.index);
}
else if ("id".equals(subId.keyName))
{
- for (SequenceI s : sequences)
- {
- if (s.getDisplayId(false).equals(subId.keyValue))
- {
- seq = s;
- break;
- }
- }
+ return al.findName(subId.keyValue);
}
- return seq;
+ return null;
}
}