From: James Procter Date: Tue, 23 Jan 2024 14:21:59 +0000 (+0000) Subject: Merge branch 'develop' into bug/JAL-4290_headless_alignment_export_with_structure_ann... X-Git-Tag: Release_2_11_3_3~7^2~2^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=d1d89672d38fb328eca3495177d651c396970fd1;hp=-c;p=jalview.git Merge branch 'develop' into bug/JAL-4290_headless_alignment_export_with_structure_annotations_doesnt_include_secondary_structure_and_temperature_factor --- d1d89672d38fb328eca3495177d651c396970fd1 diff --combined src/jalview/bin/Commands.java index a72da0d,8ba4194..b6a5a25 --- a/src/jalview/bin/Commands.java +++ b/src/jalview/bin/Commands.java @@@ -179,7 -179,8 +179,7 @@@ public class Command if (argParser.getBoolean(Arg.QUIT)) { - Jalview.getInstance().exit( - "Exiting due to " + Arg.QUIT.argString() + " argument.", + Jalview.exit("Exiting due to " + Arg.QUIT.argString() + " argument.", ExitCode.OK); return true; } @@@ -209,13 -210,8 +209,13 @@@ 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)) { @@@ -224,6 -220,7 +224,6 @@@ 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 openAvList = new ArrayList<>(); @@@ -331,9 -328,17 +331,17 @@@ } // colour alignment - String colour = avm.getFromSubValArgOrPref(av, Arg.COLOUR, sv, - null, "DEFAULT_COLOUR_PROT", ""); - this.colourAlignFrame(af, colour); + String colour = null; + if (avm.containsArg(Arg.COLOUR) + || !(format == FileFormat.Jalview)) + { + colour = avm.getFromSubValArgOrPref(av, Arg.COLOUR, sv, null, + "DEFAULT_COLOUR_PROT", null); + } + if (colour != null) + { + this.colourAlignFrame(af, colour); + } // Change alignment frame title String title = avm.getFromSubValArgOrPref(av, Arg.TITLE, sv, null, @@@ -395,17 -400,53 +403,17 @@@ } // 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() - { + showAnnotations = avm.getFromSubValArgOrPref(Arg.SHOWANNOTATIONS, + av.getSubVals(), null, "SHOW_ANNOTATIONS", true); + // hide the Temperature Factor row? + hideTFrows = (avm.getBoolean(Arg.NOTEMPFAC)); - @Override - public void run() - { - _af.setAnnotationsVisibility(showSSAnnotations, true, - false); - - _af.setAnnotationsVisibility(showAnnotations, false, true); - - // show temperature factor annotations? - if (hideTFrows) - { - // do this better (annotation types?) - List 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, @@@ -463,10 -504,8 +471,10 @@@ // 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; @@@ -836,47 -875,10 +844,47 @@@ } } - 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); @@@ -903,26 -905,6 +911,26 @@@ return theseArgsWereParsed && !isError; } + private static void showOrHideAnnotations(AlignFrame af, + boolean showSSAnnotations, boolean showAnnotations, + boolean hideTFrows) + { + af.setAnnotationsVisibility(showSSAnnotations, true, false); + af.setAnnotationsVisibility(showAnnotations, false, true); + + // show temperature factor annotations? + if (hideTFrows) + { + // do this better (annotation types?) + List 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); @@@ -1293,8 -1275,19 +1301,19 @@@ private void colourAlignFrame(AlignFrame af, ColourSchemeI cs) { - // Note that cs == null removes colour scheme from af - af.changeColour(cs); + try { + SwingUtilities.invokeAndWait(new Runnable() + { + @Override + public void run() + { + // Note that cs == null removes colour scheme from af + af.changeColour(cs); + } + }); } catch (Exception x) { + Console.trace("Interrupted whilst waiting for colorAlignFrame action",x); + + } } private ColourSchemeI getColourScheme(AlignFrame af)