Command Line: advanced usage

Command Line: introduction
Command Line: basic usage
Command Line: advanced usage
Command Line: argument files
Command Line: reference


Alignment linked IDs

Jalview's alignment related arguments are linked together using a linked ID. In all of the basic usage examples this linked ID is assigned using a default formula of JALVIEW:n where n starts at 0 and increments every time there is an ‑‑opened file (or a first use of ‑‑append) or the ‑‑new argument is used.

When another alignment related argument is used (without a specified linked ID), it is assigned this default linked ID. When the ‑‑all argument is used, following alignment related arguments are applied to all of the linked IDs (made so far).

You can assign your own linked IDs to alignments that are opened from the command-line. To do this put the linked ID in square brackets ('[', ']') immediately following the argument (i.e. before any space or equals sign) like this:

  jalview --open[myId1] file1.fa --open[myId2] file2.fa --open[myId3] file3.fa --colour[myId1] gecos-flower --colour[myId2] gecos-blossom --colour[myId3] zappo --image "*.png" --headless
  

As you can see, if you specify your own linked IDs, the arguments for one alignment do not need to be adjacent as they are when using the default assigned linked ID.

A specified linked ID will also take precedence over a wildcard or ‑‑all set linked ID. e.g.

  jalview --open[myID] examples/uniref50.fa --all --colour taylor --colour[myID] gecos-blossom
  
will open the alignment using the gecos-blossom colour scheme (thank goodness).

More substitutions ({n}, {++n}, [*], {m}, {++m})

In the basic usage document we have a list of special strings that get replaced in output filename values with parts of input filename values.

There is also an incrementor integer value {n} that can be put into both linked IDs and filenames and works across different linked IDs. Whenever you use {n} in a linked ID or filename value it is replaced with the current value of n. The initial value is 0, and it can be incremented by using the argument ‑‑npp or ‑‑n++, or using a another special substitution {++n} in either a linked ID or filename value which increments the value and is replaced with the new incremented value of n.

In the same way that the ‑‑all argument enables (some) following arguments to apply to all opened alignments so far, the special linked ID * will also apply an individual argument to all opened linked IDs (in fact when you use the ‑‑all argument it simply changes the default linked ID to *).

  jalview --open[myId1] fileA.fa --open[myId2] fileB.fa --open[myId3] fileC.fa --colour[*] taylor --all --image tmp/image-{++n}.png --headless
  
The above will produce an image image-0.png for the alignment in fileA.fa, an image image-1.png for the alignment in fileB.fa, etc. If you suddenly decide to colour the last alignment differently you could add to the command:
  jalview --open[myId1] fileA.fa --open[myId2] fileB.fa --open[myId3] fileC.fa --colour[*] taylor --all --image tmp/image-{++n}.png --headless --colour[myId3] gecos-blossom
  
because all of the command line arguments are read and sorted into their linked IDs before starting to be processed, and the [myId3] specified linked ID takes precedence over the [*] wildcard linked ID.

All of the substitutions talked about so far are evaluated in the argument parsing process. If in some cases (almost certainly involving structure images!) you find {n} is not incrementing when you think it should, when specifying ‑‑structureimage filenames you can also use {m} and {++m}, along with {structuredirname}, {structurebasename} and {structureextension} which are substituted at the point of use. {m} is just a plain counter starting at 0.

Equals separator and Java file globs

When a Command-line argument requires one (or more) values, you can use the usual space separation, which allows the shell to expand any file "globs" (that is, filenames with wildcard characters allowing it to represent multiple files). The shell "expands" this file glob and to Jalview it appears like a list of filenames supplied to the argument.

There is a limitation to shell expansion of file globs, as the length of a single command, or number of files the shell is willing to expand a file glob to, is limited (to different amounts depending on your shell and its configuration).

Jalview will also recognise values supplied to arguments (that expect one or more value) that are separated by an equals sign ("="). There should be no spaces around the equals sign, e.g.

  jalview --open=examples/uniref50*.fa --colour=clustal --all --image=*.png --scale=2.5 --headless
  

One benefit of this is seen above in the ‑‑image argument, the special "alloutput" wildcard filename *.png will not be expanded by the shell, so does not need to be escaped or surrounded with quotation marks.

A bigger benefit is that the input filename is not expanded by the shell but can instead be expanded by Jalview. There is no limit to the number of files that this kind of file glob can match since it is expanded by Jalview, not the shell.

Jalview uses the Java PathMatcher "glob" scheme to match filenames, which is quite similar, though in some ways more powerful, to most shell glob rules. The usual '*' and '?' characters act the same, but other combinations can be used too. For the full rules see java.nio.file.PathMatcher.getPathMatcher javadocs at https://devdocs.io/openjdk~11/java.base/java/nio/file/filesystem#getPathMatcher(java.lang.String).

One such PathMatcher addition to shell file globs is the use of ** to match any number of directories and sub-directories (matching across file separator). So to convert every Fasta file under the current working directory to BLC format you can do:

  jalview --open=./**/*.fa --output=*.blc --close --headless
  
or to find every Stockholm and Pfam file under /tmp and convert to Fasta and save in your own folder, do
  jalview --open=/tmp/**/*.{stk,pfam} --all --output=~/rescued/{basenamedir}.fa --close --headless
  

Sub-value modifiers

Sub-value modifiers are given in square brackets ('[', ']') immediately before the value (i.e. after any space or equals sign, and with no space between it and the value) like this:

  jalview --open=examples/uniref50.fa --image=[scale=1.414]picture.png
  

Some arguments (such as ‑‑scale=n) are used to modify the behaviour of other "primary" arguments (such as ‑‑image=filename). These arguments can alternatively be specifed as sub-value modifiers of the values given to the primary argument. If specified as a sub-value modifier, this modifier takes precedence over any following linked argument if given. e.g

  jalview --open=[colour=zappo]examples/*.fa
  
Notice also that if a sub-value modifier is used for a value that is expanded by the application (i.e. using an equals sign ('=') to separate argument and value) then that modifier is applied to all of the values.

For shell expanded globs this is more problematic since the presence of a sub-value modifier will almost certainly prevent the shell from recognising the file glob, so

  jalview --open [colour=zappo]examples/*.fa
  
will NOT work the same as above. If you need to use sub-value modifiers on a file glob you should use an equals sign ('=') to separate it from the argument.

You can specify multiple sub-value modifiers separating them with a comma (','). If you wish to specify a "boolean" argument, such as ‑‑wrap or ‑‑nowrap then simply use the argument name without a value, like this:

  jalview --open=[colour=gecos-flower,wrap,noannotations,features=examples/plantfdx.features]examples/plantfdx.fa
  


Continue to Command Line: argument files.
Command Line: reference