From: Ben Soares Date: Fri, 28 Apr 2023 16:39:54 +0000 (+0100) Subject: JAL-629 Change colour scheme shortnames to something consistent and command-line... X-Git-Tag: Release_2_11_4_0~360 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=94175f47370a77a29184067438d77f11baae759e;p=jalview.git JAL-629 Change colour scheme shortnames to something consistent and command-line friendly. Add more subval options. Change subval separator to ',' to be more command line friendly. --- diff --git a/help/help/html/colourSchemes/index.html b/help/help/html/colourSchemes/index.html index 9ba0578..6b77d91 100755 --- a/help/help/html/colourSchemes/index.html +++ b/help/help/html/colourSchemes/index.html @@ -94,7 +94,8 @@ td { - + + @@ -121,6 +122,7 @@ td { + @@ -147,6 +149,7 @@ td { + @@ -173,6 +176,7 @@ td { + @@ -199,7 +203,7 @@ td { - + @@ -226,6 +230,7 @@ td { + @@ -252,6 +257,7 @@ td { + @@ -278,6 +284,7 @@ td { + @@ -304,6 +311,7 @@ td { + @@ -330,6 +338,7 @@ td { + @@ -356,6 +365,7 @@ td { + @@ -382,6 +392,7 @@ td { + @@ -408,6 +419,7 @@ td { + @@ -445,7 +457,8 @@ td {
NameCLI name A R N
Clustalclustal
Zappozappo
Taylortaylor
gecos Flowergecos-flower
gecos Blossomgecos-blossom
gecos Sunsetgecos-sunset
gecos Oceangecos-ocean
Hydrophobicityhydrophobicity
Helix Propensityhelix-propensity
Strand Propensitystrand-propensity
Turn Propensityturn-propensity
Buried Indexburied-index - + + @@ -485,6 +498,7 @@ td { + @@ -506,6 +520,7 @@ td { + @@ -527,6 +542,7 @@ td { + diff --git a/help/help/html/features/clarguments-ng.html b/help/help/html/features/clarguments-ng.html index 687853d..9b1e88d 100644 --- a/help/help/html/features/clarguments-ng.html +++ b/help/help/html/features/clarguments-ng.html @@ -57,6 +57,10 @@

+ Not everything that can be done with the old arguments is currently implemented in the new arguments but functionality of the new command line arguments will increase over releases. Significant new functionality, particularly allowing batch processing of files, is available in the new arguments. +

+ +

To launch Jalview from the command line, see running Jalview from the command line.

@@ -141,6 +145,10 @@

+

+ Note that whilst you can include a Jalview Project File (.jvp) as an --append value, the items in the file will always open in their original frames and not append to another. +

+
--newframe

@@ -155,21 +163,152 @@

-

()

+

Alignment options (--colour, --wrap)

+ +
--colour

+ You can specify a residue/base colouring for the alignment using the --colour option (note spelling -- Jalview is made in Scotland!): +

+  jalview --open examples/uniref50.fa --colour gecos-flower
+  
+ There are several colour schemes that you can use. See the page on Colour Schemes for details. + The names to use on the command line for colour schemes are: +

+

+ clustal, +
+ blosum62, +
+ pc-identity, +
+ zappo, +
+ taylor, +
+ gecos-flower, +
+ gecos-blossom, +
+ gecos-sunset, +
+ gecos-ocean, +
+ hydrophobic, +
+ helix-propensity, +
+ strand-propensity, +
+ turn-propensity, +
+ buried-index, +
+ nucleotide, +
+ nucleotide-ambiguity, +
+ purine-pyrimidine, +
+ rna-helices, +
+ t-coffee-scores, +
+ sequence-id

-
--
+
--wrap
+

+ An alignment should open with your usual preferences stored in the .jalview_properties file. To open an alignment with the sequences (definitely) wrapped, following your --open (or first --append) argument use the argument --wrap: +

+  jalview --open examples/uniref50.fa --wrap
+  
+ To ensure an alignment is not wrapped use --nowrap: +
+  jalview --open examples/uniref50.fa --nowrap
+  
+

+ +
--annotations

+ You can specify whether the currently opened alignment frame should show alignment annotations (e.g. Conservation, Quality, Consensus...) or not with either --annotations or --noannotations. If you don't specify then your saved preference will be used.

+  jalview --open examples/uniref50.fa --noannotations
   

+
--title
+

+ If you would like to give the alignment frame a specific title you can do so with the --title option: +

+  jalview --open examples/uniref50.fa --title "My example alignment"
+  
+

-
NameCLI name A C
Nucleotidenucleotide
Nucleotide Ambiguitynucleotide-ambiguity
Purine/Pyrimidinepurine-pyrimidine
+
--structure
+ +

+ You can add a 3D structure file to a sequence in the current alignment frame with the --structure option: +

+  jalview --open examples/uniref50.fa --structure examples/AlphaFold/AF-P00221-F1-model_v4.pdb
+  
+

+ + +

+ seqid: + By default this attaches to the first sequence in the alignment but most likely you will want to attach it to another sequence. + To do this you can specify a sub-value with the sequence ID, by preceding the value with square brackets and seqid=SequenceId + like this: +

+  jalview --open examples/uniref50.fa --structure [seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.pdb
+  
+ + Remember that you might need to escape any spaces in the sequence ID or enclose the ID in quotation marks. +

+ +

+ index: + You can alternatively specify the (zero-indexed) index of the sequence within the alignment, although this is less precise. So to attach the structure to the 8th sequence use: +

+  jalview --open examples/uniref50.fa --structure [7]examples/AlphaFold/AF-P00221-F1-model_v4.pdb
+  
+

+ +

+ viewer: + You can specify which structure viewer (or not) to use to open the structure using the viewer sub-value. Multiple sub-values can be specified, separated by a comma ','. Possible values for the viewer sub-value are: +
+ none, +
+ jmol, +
+ chimera, +
+ chimerax, +
+ pymol. +
+ none and jmol will always be available, but to use the others you must have the appropriate software already set up on your computer and in Jalview. See the page Discovering and Viewing PDB and 3D-Beacons structures for more details. +

+  jalview --open examples/uniref50.fa --structure [seqid=FER1_SPIOL,viewer=none]examples/AlphaFold/AF-P00221-F1-model_v4.pdb
+  
+

+ + +

()

+ +

+

+ +
--
+ +

+

+  
+

diff --git a/help/help/html/menus/alignmentMenu.html b/help/help/html/menus/alignmentMenu.html index 6534d2d..fef5bb9 100755 --- a/help/help/html/menus/alignmentMenu.html +++ b/help/help/html/menus/alignmentMenu.html @@ -487,7 +487,7 @@ and the intensity threshold for transition between them.
  • Colour Scheme options: None, ClustalX, Blosum62 Score, Percentage Identity, Zappo, Taylor, - gecos:flower, gecos:blossom, gecos:sunset, gecos:ocean, + gecos-flower, gecos-blossom, gecos-sunset, gecos-ocean, Hydrophobicity, Helix Propensity, Strand Propensity, Turn Propensity, Buried Index, Nucleotide, Nucleotide Ambiguity, Purine/Pyrimidine, User Defined
    diff --git a/help/help/html/menus/alwcolour.html b/help/help/html/menus/alwcolour.html index 5b8d00b..33da749 100755 --- a/help/help/html/menus/alwcolour.html +++ b/help/help/html/menus/alwcolour.html @@ -38,7 +38,7 @@ the intensity threshold for transition between them.
  • Colour Scheme options: None, ClustalX, Blosum62 Score, Percentage Identity, Zappo, Taylor, - gecos:flower, gecos:blossom, gecos:sunset, gecos:ocean, + gecos-flower, gecos-blossom, gecos-sunset, gecos-ocean, Hydrophobicity, Helix Propensity, Strand Propensity, Turn Propensity, Buried Index, Nucleotide, Nucleotide Ambiguity, Purine/Pyrimidine, User Defined
    diff --git a/src/jalview/bin/Commands.java b/src/jalview/bin/Commands.java index 30e71b6..402024b 100644 --- a/src/jalview/bin/Commands.java +++ b/src/jalview/bin/Commands.java @@ -167,6 +167,7 @@ public class Commands for (ArgValue av : openAvList) { Arg a = av.getArg(); + SubVals sv = av.getSubVals(); String openFile = av.getValue(); if (openFile == null) continue; @@ -246,20 +247,24 @@ public class Commands af.setAnnotationsVisibility(showAnnotations, false, true); // wrap alignment? - if (avm.getBoolean(Arg.WRAP)) - { - af.getCurrentView().setWrapAlignment(true); - } + boolean wrap = ArgParser.getFromSubValArgOrPref(avm, Arg.WRAP, sv, + null, "WRAP_ALIGNMENT", false); + af.getCurrentView().setWrapAlignment(wrap); // colour aligment? - if (avm.containsArg(Arg.COLOUR)) + String colour = ArgParser.getFromSubValArgOrPref(avm, Arg.COLOUR, + sv, null, "DEFAULT_COLOUR_PROT", ""); + + if ("" != colour) { - af.changeColour_actionPerformed(avm.getValue(Arg.COLOUR)); + af.changeColour_actionPerformed(colour); } // change alignment frame title - if (avm.containsArg(Arg.TITLE)) - af.setTitle(avm.getValue(Arg.TITLE)); + String title = ArgParser.getFromSubValArgOrPref(avm, Arg.TITLE, + sv, null, null, null); + if (title != null) + af.setTitle(title); // show secondary structure annotations? boolean showSSAnnotations = ArgParser.getFromSubValArgOrPref(avm, diff --git a/src/jalview/bin/argparser/Arg.java b/src/jalview/bin/argparser/Arg.java index 9b5907f..8bb1dcb 100644 --- a/src/jalview/bin/argparser/Arg.java +++ b/src/jalview/bin/argparser/Arg.java @@ -20,8 +20,37 @@ public enum Arg protected static enum Opt { - BOOLEAN, STRING, UNARY, MULTI, LINKED, NODUPLICATEVALUES, BOOTSTRAP, - GLOB, NOACTION, ALLOWSUBSTITUTIONS, PRIVATE + BOOLEAN, // This Arg can be specified as --arg or --noarg to give true or + // false. A default can be given with setOptions(bool, Opt....). + // Use ArgParser.isSet(Arg) to see if this arg was not specified. + STRING, // This Arg can accept a value either through --arg=value or --arg + // value. + UNARY, // This Arg is a boolean value, true if present, false if not. Like + // BOOLEAN but without the --noarg option. + MULTI, // This Arg can be specified multiple times. Multiple values are + // stored in the ArgValuesMap (along with their positional index) for + // each linkedId. + LINKED, // This Arg can be linked to others through a --arg[linkedId] or + // --arg[linkedId]=value. If no linkedId is specified then the + // current default linkedId will be used. + NODUPLICATEVALUES, // This Arg can only have one value (per linkedId). The + // first value will be used and subsequent values ignored + // with a warning. + BOOTSTRAP, // This Arg value(s) can be determined at an earlier stage than + // non-BOOTSTRAP Args. Substitutions do not happen in BOOTSTRAP + // Args and they cannot be linked or contain SubVals. See + // jalview.bin.argparser.BootstrapArgs. + GLOB, // This Arg can expand wildcard filename "globs" (e.g. + // path/*/filename*). If the Arg value is given as --arg filename* + // then the shell will have expanded the glob already, but if + // specified as --arg=filename* then the Java glob expansion method + // will be used (see FileUtils.getFilenamesFromGlob()). Note that this + // might be different from the shell expansion rules. + NOACTION, // This Arg does not perform a data task, usually used to control + // flow in ArgParser.parse(args). + ALLOWSUBSTITUTIONS, // This Arg allows substitutions in its linkedId, + // SubVals and values. + PRIVATE // This Arg is used internally, and cannot be specified by the user. } static @@ -89,11 +118,6 @@ public enum Arg SETARGFILE.setOptions(Opt.STRING, Opt.MULTI, Opt.PRIVATE, Opt.NOACTION); UNSETARGFILE.setOptions(Opt.MULTI, Opt.PRIVATE, Opt.NOACTION); WEBSERVICEDISCOVERY.setOptions(Opt.BOOLEAN, Opt.BOOTSTRAP); - // Opt.BOOTSTRAP args are parsed (not linked with no SubVals so using a - // simplified parser, see jalview.bin.argparser.BootstrapArgs) - // before a full parse of arguments and so can be accessible at an earlier - // stage to (e.g.) set debug log level, provide a props file (that might set - // log level), run headlessly, read an argfile instead of other args. } private final String[] argNames; diff --git a/src/jalview/bin/argparser/SubVals.java b/src/jalview/bin/argparser/SubVals.java index 196cd24..a03ec15 100644 --- a/src/jalview/bin/argparser/SubVals.java +++ b/src/jalview/bin/argparser/SubVals.java @@ -21,7 +21,7 @@ public class SubVals private Map subValMap; - private static char SEPARATOR = ';'; + private static char SEPARATOR = ','; private static char EQUALS = '='; diff --git a/src/jalview/schemes/ColourSchemes.java b/src/jalview/schemes/ColourSchemes.java index 14daed6..698769c 100644 --- a/src/jalview/schemes/ColourSchemes.java +++ b/src/jalview/schemes/ColourSchemes.java @@ -20,16 +20,15 @@ */ package jalview.schemes; +import java.util.LinkedHashMap; import java.util.Locale; +import java.util.Map; import jalview.api.AlignViewportI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; -import java.util.LinkedHashMap; -import java.util.Map; - public class ColourSchemes { /* @@ -106,7 +105,7 @@ public class ColourSchemes * name is lower-case for non-case-sensitive lookup * (name in the colour keeps its true case) */ - String lower = name.toLowerCase(Locale.ROOT); + String lower = getColourSchemeShortName(cs); if (schemes.containsKey(lower)) { System.err @@ -115,6 +114,19 @@ public class ColourSchemes schemes.put(lower, cs); } + private String getColourSchemeShortName(ColourSchemeI cs) + { + return getColourSchemeShortName(cs.getSchemeName()); + } + + private String getColourSchemeShortName(String name) + { + if (name == null) + return null; + return name.toLowerCase(Locale.ROOT).replaceAll("%", "pc") + .replaceAll("[^a-z0-9]", "-").replaceAll("--+", "-"); + } + /** * Removes a colour scheme by name * @@ -124,7 +136,7 @@ public class ColourSchemes { if (name != null) { - schemes.remove(name.toLowerCase(Locale.ROOT)); + schemes.remove(getColourSchemeShortName(name)); } } @@ -150,7 +162,7 @@ public class ColourSchemes { return null; } - ColourSchemeI cs = schemes.get(name.toLowerCase(Locale.ROOT)); + ColourSchemeI cs = schemes.get(getColourSchemeShortName(name)); return cs == null ? null : cs.getInstance(viewport, forData); } @@ -194,6 +206,6 @@ public class ColourSchemes { return false; } - return schemes.containsKey(name.toLowerCase(Locale.ROOT)); + return schemes.containsKey(getColourSchemeShortName(name)); } } diff --git a/src/jalview/schemes/JalviewColourScheme.java b/src/jalview/schemes/JalviewColourScheme.java index accdc8a..da49fac 100644 --- a/src/jalview/schemes/JalviewColourScheme.java +++ b/src/jalview/schemes/JalviewColourScheme.java @@ -34,10 +34,10 @@ public enum JalviewColourScheme PID("% Identity", PIDColourScheme.class), Zappo("Zappo", ZappoColourScheme.class), Taylor("Taylor", TaylorColourScheme.class), - Flower("gecos:flower", FlowerColourScheme.class), - Blossom("gecos:blossom", BlossomColourScheme.class), - Sunset("gecos:sunset", SunsetColourScheme.class), - Ocean("gecos:ocean", OceanColourScheme.class), + Flower("gecos-flower", FlowerColourScheme.class), + Blossom("gecos-blossom", BlossomColourScheme.class), + Sunset("gecos-sunset", SunsetColourScheme.class), + Ocean("gecos-ocean", OceanColourScheme.class), Hydrophobic("Hydrophobic", HydrophobicColourScheme.class), Helix("Helix Propensity", HelixColourScheme.class), Strand("Strand Propensity", StrandColourScheme.class), diff --git a/test/jalview/bin/CommandsTest2.java b/test/jalview/bin/CommandsTest2.java index 5fa9ba0..dc7d061 100644 --- a/test/jalview/bin/CommandsTest2.java +++ b/test/jalview/bin/CommandsTest2.java @@ -139,40 +139,40 @@ public class CommandsTest2 /* */ { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa " - + "--colour=gecos:flower " + + "--colour=gecos-flower " + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif " + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json " + "--props=test/jalview/bin/commandsTest2.jvprops1 ", 15, 7, 1 }, { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa " - + "--colour=gecos:flower " + + "--colour=gecos-flower " + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif " + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json " + "--props=test/jalview/bin/commandsTest2.jvprops2 ", 15, 4, 1 }, { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa " - + "--colour=gecos:flower " + + "--colour=gecos-flower " + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif " + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json " + "--nossannotations " + "--props=test/jalview/bin/commandsTest2.jvprops1 ", 15, 4, 1 }, { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa " - + "--colour=gecos:flower " + + "--colour=gecos-flower " + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif " + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json " + "--noannotations " + "--props=test/jalview/bin/commandsTest2.jvprops1 ", 15, 3, 1 }, { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa " - + "--colour=gecos:flower " + + "--colour=gecos-flower " + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif " + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json " + "--noannotations " + "--nossannotations " + "--props=test/jalview/bin/commandsTest2.jvprops1 ", 15, 0, 1 }, { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa " - + "--colour=gecos:flower " + + "--colour=gecos-flower " + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif " + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json " + "--noannotations " + "--nossannotations " diff --git a/test/jalview/bin/argparser/testfiles/argfile.autocounter b/test/jalview/bin/argparser/testfiles/argfile.autocounter index e35a99e..58445a5 100644 --- a/test/jalview/bin/argparser/testfiles/argfile.autocounter +++ b/test/jalview/bin/argparser/testfiles/argfile.autocounter @@ -1,5 +1,5 @@ --open[{++n}]=test/jalview/bin/argparser/testfiles/test1.fa ---colour[{n}]=gecos:flower +--colour[{n}]=gecos-flower --open[{++n}]=test/jalview/bin/argparser/testfiles/test2.fa --colour[{n}]=zappo --open[{++n}]=test/jalview/bin/argparser/testfiles/test1.fa diff --git a/test/jalview/bin/argparser/testfiles/dir1/argfile.txt b/test/jalview/bin/argparser/testfiles/dir1/argfile.txt index 16d7fad..ec838ad 100644 --- a/test/jalview/bin/argparser/testfiles/dir1/argfile.txt +++ b/test/jalview/bin/argparser/testfiles/dir1/argfile.txt @@ -1,6 +1,6 @@ --substitutions --newframe --append={argfiledirname}/*.fa ---colour=gecos:flower +--colour=gecos-flower --image={argfiledirname}/{basename}.png --close diff --git a/test/jalview/bin/argparser/testfiles/dir2/argfile.txt b/test/jalview/bin/argparser/testfiles/dir2/argfile.txt index 16d7fad..ec838ad 100644 --- a/test/jalview/bin/argparser/testfiles/dir2/argfile.txt +++ b/test/jalview/bin/argparser/testfiles/dir2/argfile.txt @@ -1,6 +1,6 @@ --substitutions --newframe --append={argfiledirname}/*.fa ---colour=gecos:flower +--colour=gecos-flower --image={argfiledirname}/{basename}.png --close diff --git a/test/jalview/bin/argparser/testfiles/dir3/subdir/subdirfile.txt b/test/jalview/bin/argparser/testfiles/dir3/subdir/subdirfile.txt index 16d7fad..ec838ad 100644 --- a/test/jalview/bin/argparser/testfiles/dir3/subdir/subdirfile.txt +++ b/test/jalview/bin/argparser/testfiles/dir3/subdir/subdirfile.txt @@ -1,6 +1,6 @@ --substitutions --newframe --append={argfiledirname}/*.fa ---colour=gecos:flower +--colour=gecos-flower --image={argfiledirname}/{basename}.png --close diff --git a/test/jalview/bin/commandsTest2.argfile1 b/test/jalview/bin/commandsTest2.argfile1 index 1dc9e30..4cb5c86 100644 --- a/test/jalview/bin/commandsTest2.argfile1 +++ b/test/jalview/bin/commandsTest2.argfile1 @@ -2,7 +2,7 @@ --append=examples/test_fab41.result/sample.a2m --annotations --ssannotations ---colour=gecos:flower +--colour=gecos-flower --structure=[viewer=jmol;tempfac=plddt;paematrix={dirname}/test_fab41_unrelaxed_rank_1_model_3_scores.json]{dirname}/test_fab41_unrelaxed_rank_1_model_3.pdb --structure={dirname}/test_fab41_unrelaxed_rank_2_model_4.pdb --structureviewer=jmol diff --git a/test/jalview/bin/commandsTest2.argfile2 b/test/jalview/bin/commandsTest2.argfile2 index f8f1c65..6744b7e 100644 --- a/test/jalview/bin/commandsTest2.argfile2 +++ b/test/jalview/bin/commandsTest2.argfile2 @@ -5,7 +5,7 @@ --append=examples/test_fab41.result/sample.a2m --noannotations --nossannotations ---colour=gecos:flower +--colour=gecos-flower --structure=[tempfac=plddt;paematrix={dirname}/test_fab41_unrelaxed_rank_1_model_3_scores.json]{dirname}/test_fab41_unrelaxed_rank_1_model_3.pdb --structureviewer=none --structure={dirname}/test_fab41_unrelaxed_rank_2_model_4.pdb