+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.bin;
import java.awt.Color;
Boolean isError = Boolean.valueOf(false);
- // set wrap scope here so it can be applied after structures are opened
+ // set wrap, showSSAnnotations, showAnnotations and hideTFrows scope here so
+ // it can be applied after structures are opened
boolean wrap = false;
+ boolean showSSAnnotations = false;
+ boolean showAnnotations = false;
+ boolean hideTFrows = false;
+ AlignFrame af = null;
if (avm.containsArg(Arg.APPEND) || avm.containsArg(Arg.OPEN))
{
boolean first = true;
boolean progressBarSet = false;
- AlignFrame af;
// Combine the APPEND and OPEN files into one list, along with whether it
// was APPEND or OPEN
List<ArgValue> openAvList = new ArrayList<>();
}
// Show secondary structure annotations?
- boolean showSSAnnotations = avm.getFromSubValArgOrPref(
+ showSSAnnotations = avm.getFromSubValArgOrPref(
Arg.SHOWSSANNOTATIONS, av.getSubVals(), null,
"STRUCT_FROM_PDB", true);
-
// Show sequence annotations?
- boolean showAnnotations = avm.getFromSubValArgOrPref(
- Arg.SHOWANNOTATIONS, av.getSubVals(), null,
- "SHOW_ANNOTATIONS", true);
-
- boolean hideTFrows = (avm.getBoolean(Arg.NOTEMPFAC));
- final AlignFrame _af = af;
- // many of jalview's format/layout methods are only thread safe on the
- // swingworker thread.
- // all these methods should be on the alignViewController so it can
- // coordinate such details
- try
- {
- SwingUtilities.invokeAndWait(new Runnable()
- {
-
- @Override
- public void run()
- {
- _af.setAnnotationsVisibility(showSSAnnotations, true,
- false);
+ showAnnotations = avm.getFromSubValArgOrPref(Arg.SHOWANNOTATIONS,
+ av.getSubVals(), null, "SHOW_ANNOTATIONS", true);
+ // hide the Temperature Factor row?
+ hideTFrows = (avm.getBoolean(Arg.NOTEMPFAC));
- _af.setAnnotationsVisibility(showAnnotations, false, true);
-
- // show temperature factor annotations?
- if (hideTFrows)
- {
- // do this better (annotation types?)
- List<String> hideThese = new ArrayList<>();
- hideThese.add("Temperature Factor");
- hideThese.add(AlphaFoldAnnotationRowBuilder.LABEL);
- AlignmentUtils.showOrHideSequenceAnnotations(
- _af.getCurrentView().getAlignment(), hideThese,
- null, false, false);
- }
- }
- });
- } catch (Exception x)
- {
- Console.warn(
- "Unexpected exception adjusting annotation row visibility.",
- x);
- }
+ // showSSAnnotations, showAnnotations, hideTFrows used after opening
+ // structure
// wrap alignment? do this last for formatting reasons
wrap = avm.getFromSubValArgOrPref(Arg.WRAP, sv, null,
// open the structure (from same PDB file or given PDBfile)
if (!avm.getBoolean(Arg.NOSTRUCTURE))
{
-
- AlignFrame af = afMap.get(id);
+ if (af == null)
+ {
+ af = afMap.get(id);
+ }
if (avm.containsArg(Arg.STRUCTURE))
{
commandArgsProvided = true;
- for (
-
- ArgValue av : avm.getArgValueList(Arg.STRUCTURE))
+ for (ArgValue structureAv : avm.getArgValueList(Arg.STRUCTURE))
{
argParser.setStructureFilename(null);
- String val = av.getValue();
- SubVals subVals = av.getSubVals();
- int argIndex = av.getArgIndex();
- SequenceI seq = getSpecifiedSequence(af, avm, av);
+ String val = structureAv.getValue();
+ SubVals subVals = structureAv.getSubVals();
+ int argIndex = structureAv.getArgIndex();
+ SequenceI seq = getSpecifiedSequence(af, avm, structureAv);
if (seq == null)
{
// Could not find sequence from subId, let's assume the first
// get PAEMATRIX file and label from subvals or Arg.PAEMATRIX
String paeFilepath = avm.getFromSubValArgOrPrefWithSubstitutions(
- argParser, Arg.PAEMATRIX, ArgValuesMap.Position.AFTER, av,
- subVals, null, null, null);
+ argParser, Arg.PAEMATRIX, ArgValuesMap.Position.AFTER,
+ structureAv, subVals, null, null, null);
if (paeFilepath != null)
{
File paeFile = new File(paeFilepath);
// get TEMPFAC type from subvals or Arg.TEMPFAC in case user Adds
// reference annotations
String tftString = avm.getFromSubValArgOrPrefWithSubstitutions(
- argParser, Arg.TEMPFAC, ArgValuesMap.Position.AFTER, av,
- subVals, null, null, null);
+ argParser, Arg.TEMPFAC, ArgValuesMap.Position.AFTER,
+ structureAv, subVals, null, null, null);
boolean notempfac = avm.getFromSubValArgOrPref(Arg.NOTEMPFAC,
subVals, null, "ADD_TEMPFACT_ANN", false, true);
TFType tft = notempfac ? null : TFType.DEFAULT;
}
String sViewerName = avm.getFromSubValArgOrPref(
- Arg.STRUCTUREVIEWER, ArgValuesMap.Position.AFTER, av,
- subVals, null, null, "jmol");
+ Arg.STRUCTUREVIEWER, ArgValuesMap.Position.AFTER,
+ structureAv, subVals, null, null, "jmol");
ViewerType viewerType = ViewerType.getFromString(sViewerName);
// TODO use ssFromStructure
if (avm.containsArg(Arg.STRUCTUREIMAGE))
{
for (ArgValue structureImageArgValue : avm
- .getArgValueList(Arg.STRUCTUREIMAGE))
+ .getArgValueListFromSubValOrArg(structureAv,
+ Arg.STRUCTUREIMAGE, subVals))
{
String structureImageFilename = argParser.makeSubstitutions(
structureImageArgValue.getValue(), id, true);
}
}
- if (wrap)
+ if (af == null)
{
+ af = afMap.get(id);
+ }
+ // many of jalview's format/layout methods are only thread safe on the
+ // swingworker thread.
+ // all these methods should be on the alignViewController so it can
+ // coordinate such details
+ if (headless)
+ {
+ showOrHideAnnotations(af, showSSAnnotations, showAnnotations,
+ hideTFrows);
+ }
+ else
+ {
+ try
+ {
+ AlignFrame _af = af;
+ final boolean _showSSAnnotations = showSSAnnotations;
+ final boolean _showAnnotations = showAnnotations;
+ final boolean _hideTFrows = hideTFrows;
+ SwingUtilities.invokeAndWait(() -> {
+ showOrHideAnnotations(_af, _showSSAnnotations, _showAnnotations,
+ _hideTFrows);
+ }
- AlignFrame af = afMap.get(id);
+ );
+ } catch (Exception x)
+ {
+ Console.warn(
+ "Unexpected exception adjusting annotation row visibility.",
+ x);
+ }
+ }
+
+ if (wrap)
+ {
+ if (af == null)
+ {
+ af = afMap.get(id);
+ }
if (af != null)
{
af.setWrapFormat(wrap, true);
return theseArgsWereParsed && !isError;
}
+ private static void showOrHideAnnotations(AlignFrame af,
+ boolean showSSAnnotations, boolean showAnnotations,
+ boolean hideTFrows)
+ {
+ Console.debug(
+ "##### Setting showSSAnnotations to " + showSSAnnotations);
+ Console.debug("##### Setting showAnnotations to " + showAnnotations);
+ Console.debug("##### Setting hideTFrows to " + hideTFrows);
+ af.setAnnotationsVisibility(showSSAnnotations, true, false);
+
+ af.setAnnotationsVisibility(showAnnotations, false, true);
+
+ // show temperature factor annotations?
+ if (hideTFrows)
+ {
+ // do this better (annotation types?)
+ List<String> hideThese = new ArrayList<>();
+ hideThese.add("Temperature Factor");
+ hideThese.add(AlphaFoldAnnotationRowBuilder.LABEL);
+ AlignmentUtils.showOrHideSequenceAnnotations(
+ af.getCurrentView().getAlignment(), hideThese, null, false,
+ false);
+ }
+ }
+
protected void processGroovyScript(String id)
{
ArgValuesMap avm = argParser.getLinkedArgs(id);