From b64d494eebb7f9cf14c61e50568f41887fca5c26 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Thu, 15 Dec 2022 14:25:40 +0000 Subject: [PATCH] JAL-629 move SubId to more logical place. Attempt removal of annotations in a better way (commented out). --- src/jalview/bin/ArgParser.java | 65 +++++++++++++++++++++ src/jalview/bin/Commands.java | 101 +++++++++++++++------------------ src/jalview/gui/StructureChooser.java | 1 + 3 files changed, 112 insertions(+), 55 deletions(-) diff --git a/src/jalview/bin/ArgParser.java b/src/jalview/bin/ArgParser.java index b02bfbc..b18b088 100644 --- a/src/jalview/bin/ArgParser.java +++ b/src/jalview/bin/ArgParser.java @@ -666,4 +666,69 @@ public class ArgParser } return sb.toString(); } + + public static SubId getSubId(String item) + { + return new SubId(item); + } + + /** + * A helper class to parse a string of the possible forms "content" + * "[index]content", "[keyName=keyValue]content" and return the integer index, + * the strings keyName and keyValue, and the content after the square brackets + * (if present). Values not set `will be -1 or null. + */ + public static class SubId + { + protected int index = 0; + + protected String keyName = null; + + protected String keyValue = null; + + protected String content = null; + + public SubId() + { + } + + public SubId(String item) + { + this.parseVal(item); + } + + public void parseVal(String item) + { + if (item.indexOf('[') == 0 && item.indexOf(']') > 1) + { + int openBracket = item.indexOf('['); + int closeBracket = item.indexOf(']'); + String indexString = item.substring(openBracket + 1, closeBracket); + this.content = item.substring(closeBracket + 1); + int equals = indexString.indexOf('='); + if (equals > -1) + { + this.keyName = indexString.substring(0, equals); + this.keyValue = indexString.substring(equals + 1); + this.index = -1; + } + else + { + try + { + this.index = Integer.parseInt(indexString); + } catch (NumberFormatException e) + { + Console.warn("Failed to obtain sequenced id or index from '" + + item + "'. Setting index=0 and using content='" + + content + "'."); + } + } + } + else + { + this.content = item; + } + } + } } \ No newline at end of file diff --git a/src/jalview/bin/Commands.java b/src/jalview/bin/Commands.java index 0cdc541..1f904cd 100644 --- a/src/jalview/bin/Commands.java +++ b/src/jalview/bin/Commands.java @@ -14,6 +14,7 @@ import jalview.analysis.AlignmentUtils; import jalview.api.AlignmentViewPanel; import jalview.bin.ArgParser.Arg; import jalview.bin.ArgParser.ArgValues; +import jalview.bin.ArgParser.SubId; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; @@ -148,6 +149,36 @@ public class Commands af = afMap.get(id); if (af == null) { + /* + * this approach isn't working yet + // get default annotations before opening AlignFrame + if (m.get(Arg.SSANNOTATION) != null) + { + Console.debug("***** SSANNOTATION=" + + m.get(Arg.SSANNOTATION).getBoolean()); + } + if (m.get(Arg.NOTEMPFAC) != null) + { + Console.debug( + "***** NOTEMPFAC=" + m.get(Arg.NOTEMPFAC).getBoolean()); + } + boolean showSecondaryStructure = (m.get(Arg.SSANNOTATION) != null) + ? m.get(Arg.SSANNOTATION).getBoolean() + : false; + boolean showTemperatureFactor = (m.get(Arg.NOTEMPFAC) != null) + ? !m.get(Arg.NOTEMPFAC).getBoolean() + : false; + Console.debug("***** tempfac=" + showTemperatureFactor + + ", showSS=" + showSecondaryStructure); + StructureSelectionManager ssm = StructureSelectionManager + .getStructureSelectionManager(Desktop.instance); + if (ssm != null) + { + ssm.setAddTempFacAnnot(showTemperatureFactor); + ssm.setProcessSecondaryStructure(showSecondaryStructure); + } + */ + // get kind of temperature factor annotation AlignmentAnnotation.TFType tempfacType = null; if ((m.get(Arg.NOTEMPFAC) == null @@ -196,10 +227,11 @@ public class Commands if (m.get(Arg.TITLE) != null) af.setTitle(m.get(Arg.TITLE).getValue()); + /* hacky approach to hiding the annotations */ // show secondary structure annotations? - if (m.get(Arg.SSANNOTATION) != null - && !m.get(Arg.SSANNOTATION).getBoolean()) + if (m.get(Arg.SSANNOTATION) != null) { + boolean showSS = m.get(Arg.SSANNOTATION).getBoolean(); // do this better (annotation types?) AlignmentUtils.showOrHideSequenceAnnotations( af.getCurrentView().getAlignment(), @@ -221,6 +253,9 @@ public class Commands false, false); } else + /* comment out hacky approach up to here and add this line: + if (showTemperatureFactor) + */ { if (m.get(Arg.TEMPFAC_LABEL) != null) { @@ -228,9 +263,16 @@ public class Commands .getFirstSequenceAnnotationOfType( af.getCurrentView().getAlignment(), AlignmentAnnotation.LINE_GRAPH); + String label = m.get(Arg.TEMPFAC_LABEL).getValue(); if (aa != null) { - aa.label = m.get(Arg.TEMPFAC_LABEL).getValue(); + aa.label = label; + } + else + { + Console.info( + "Could not find annotation to apply tempfac_label '" + + label); } } } @@ -274,7 +316,7 @@ public class Commands { for (String val : m.get(Arg.PAEMATRIX).getValues()) { - SubId subId = new SubId(val); + SubId subId = ArgParser.getSubId(val); File paeFile = new File(subId.content); EBIAlfaFold.addAlphaFoldPAE(af.getCurrentView().getAlignment(), paeFile, subId.index, @@ -370,55 +412,4 @@ public class Commands } return seq; } - - /** - * A helper class to parse a string of the possible forms "content" - * "[index]content", "[keyName=keyValue]content" and return the integer index, - * the strings keyName and keyValue, and the content after the square brackets - * (if present). Values not set will be -1 or null. - */ - protected class SubId - { - protected int index = 0; - - protected String keyName = null; - - protected String keyValue = null; - - protected String content = null; - - protected SubId(String item) - { - if (item.indexOf('[') == 0 && item.indexOf(']') > 1) - { - int openBracket = item.indexOf('['); - int closeBracket = item.indexOf(']'); - String indexString = item.substring(openBracket + 1, closeBracket); - this.content = item.substring(closeBracket + 1); - int equals = indexString.indexOf('='); - if (equals > -1) - { - this.keyName = indexString.substring(0, equals); - this.keyValue = indexString.substring(equals + 1); - this.index = -1; - } - else - { - try - { - this.index = Integer.parseInt(indexString); - } catch (NumberFormatException e) - { - Console.warn("Failed to obtain sequenced id or index from '" - + item + "'. Setting index=0 and using content='" - + content + "'."); - } - } - } - else - { - this.content = item; - } - } - } } diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index 89d5c6b..d38f39f 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -1614,5 +1614,6 @@ public class StructureChooser extends GStructureChooser { fileEntry }, ap, new SequenceI[] { seq }); sc.mainFrame.dispose(); + sc.noChooserGUI = false; } } -- 1.7.10.2