JAL-629 Added/corrected/tidied documentation
[jalview.git] / help / help / html / features / clarguments-basic.html
index 19406b4..9de0e08 100644 (file)
  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
  * The Jalview Authors are detailed in the 'AUTHORS' file.
  -->
-<title>Jalview Command Line Arguments: basic usage</title>
+<title>Command Line: basic usage</title>
 <body>
 
-  <h1>Jalview Command Line Arguments: basic usage</h1>
+  <h1>Command Line: basic usage</h1>
 
   <p>
-  <a href="clarguments.html">Jalview Command Line Arguments: summary</a>
+  <a href="clarguments.html">Command Line: introduction</a>
   <br/>
-  <a href="clarguments-intro.html">Jalview Command Line Arguments: introduction</a>
+  Command Line: basic usage
   <br/>
-  Jalview Command Line Arguments: basic usage
+  <a href="clarguments-advanced.html">Command Line: advanced usage</a>
   <br/>
-  <a href="clarguments-advanced.html">Jalview Command Line Arguments: advanced usage</a>
+  <a href="clarguments-argfiles.html">Command Line: argument files</a>
   <br/>
-  <a href="clarguments-argfiles.html">Jalview Command Line Arguments: argfiles</a>
+  <a href="clarguments-reference.html">Command Line: reference</a>
   </p>
 
   <hr/>
   <li><a href="#adding3dstructures">Adding 3D structures</a></li>
   <li><a href="#outputtingalignmentfiles">Outputting/converting alignment files and images</a></li>
   <li><a href="#filenamesubstitutionsandbatchprocessing">Filename substitutions and batch processing</a></li>
+  <li><a href="#alloutputwildcard">The all output wildcard</a></li>
   </ul>
 
   <h2><a name="openingalignments"></a>Opening alignments (<code>--open</code>, <code>--append</code>, <code>--new</code>)</h2>
 
   <p>
-  To simply open one or more alignment files in different windows just put the filenames as the first arguments:
+  To simply open one or more alignment files in different alignment windows just put the filenames as the first arguments:
   <pre>
   jalview filename1 filename2 ...
   </pre>
 
   <h2><a name="alignmentoptions"></a>Alignment options (<code>--colour</code>, <code>--wrap</code>, <code>--showannotations</code>, <code>--title</code>)</h2>
 
+  <p>
+  An opened alignment window (or set of opened alignment windows) can be modified in its appearance using the following arguments before the next <code>--open</code> argument.  These modifying arguments apply to the one or more files that were opened with the preceding <code>--open</code> argument.  E.g. <code>--open file.fa --colour gecos-flower</code> will colour the one alignment window with <code>file.fa</code>.  However, <code>--open *.fa --colour gecos-flower</code> will colour every alignment window matching <code>file*.fa</code>, and <code> --open file1.fa file2.fa --colour gecos-flower</code>
+  will colour both opened alignment windows.
+  </p>
+
   <h3><a name="colour"></a><code>--colour</code></h3>
 
   <p>
   </pre>
   </p>
 
-  <h2><a name="outputtingalignmentfiles"></a>Outputting/converting alignment files and images (<code>--output</code>, <code>--format</code>, <code>--image</code>, <code>--type</code>, <code>--textrenderer</code>, <code>--scale</code>, <code>--backups</code>, <code>--overwrite</code>)</h2>
+  <h2><a name="outputtingalignmentfiles"></a>Outputting/converting alignment files and images (<code>--output</code>, <code>--format</code>, <code>--image</code>, <code>--structureimage</code>, <code>--type</code>, <code>--scale</code>, <code>--width</code>, <code>--height</code>, <code>--imagecolour</code>, <code>--bgcolour</code>, <code>--textrenderer</code>, <code>--overwrite</code>, <code>--backups</code>, <code>--mkdirs</code>)</h2>
 
   <p>
   You can save an alignment as an alignment file, or exported as an image, in different formats.  Jalview's alignment output formats are:
   <code>phylip</code> (<code>phy</code>),
   <br/>
   <code>jalview</code> (<code>jvp, jar</code>).
+  </p>
   <p>
   For example, to open a FASTA file, append another FASTA file and then save the concatenation as a Stockholm file, do
   <pre>
   </pre>
   </p>
 
+  <p>
+  <em>Important!</em> If you use <code>--output</code> or any other argument that outputs a file, then it will be assumed you want to run Jalview in headless mode (as if you had specified <code>--headless</code>).  To use Jalview with <code>--output</code> and not assume headless mode, use the <code>--gui</code> argument (the order doesn't matter).
+  </p>
+
+  <p>
+  If you would like to output an alignment file directly to standard output (often referred to as STDOUT), then use the filename <code>-</code> (a single hyphen).  In this case any messages that would normally appear on STDOUT will be diverted to STDERR to avoid invalidating the output file.
+  </p>
+  <p>
+  For example, to open a Stockholm file and pipe it to another command as a Block file, do
+  <pre>
+  jalview --open alignment1.stk --output - --format blc | another_command
+  </pre>
+  or equivalently
+  <pre>
+  jalview alignment1.stk --output=[format=blc]- | another_command
+  </pre>
+  </p>
+
   <h3><a name="format"></a><code>--format</code></h3>
 
   <p>
   </p>
 
   <h3><a name="image"></a><code>--image</code></h3>
-  To export the open alignment window as an image, use the <code>--image</code> argument, which will give an image of the alignment and annotations as it appears (or would appear if not in <code>--headless</code> mode) in the alignment window if it was large enough for the whole alignment, including colour choice and features.
+  <p>
+  To export the open alignment window as an image, use the <code>--image</code> argument, which will give an image of the alignment and annotations as it appears (or would appear if not in <code>--headless</code> mode) in the alignment window if it was large enough for the whole alignment, including colour scheme and features.
+  </p>
+  <p>
+  <pre>
+  jalview --open examples/plantfdx.fa --colour gecos-blossom --features examples/plantfdx.features --annotations examples/plantfdx.annotations --image plantfdx.png --headless
+  </pre>
+  </p>
+
+  <h3><a name="structureimage"></a><code>--structureimage</code></h3>
+  <p>
+  To export an open structure as an image, use the <code>--structureimage</code> argument, which will give an image of the structure as it appears (or would appear if not in <code>--headless</code> mode) in a Jmol window including colour scheme. <code>--structureimage</code> can currently only be used with structures opened with the <code>jmol</code> structureviewer (the default viewer).
+  </p>
   <p>
   <pre>
   jalview --open examples/plantfdx.fa --colour gecos-blossom --features examples/plantfdx.features --annotations examples/plantfdx.annotations --image plantfdx.png --headless
   </p>
 
   <p>
-  This by default produces a PNG image of screen or webpage resolution, which you may want to improve upon.  There are two ways of doing this with Jalview: increasing the scale of the PNG image, or using a vector based image format (EPS, SVG, HTML).
+  These by default produce a PNG image of screen or webpage resolution, which you will probably want to improve upon.  There are two ways of doing this with Jalview: increasing the scale of the PNG image, or using a vector based image format (EPS, SVG, HTML).
   <p>
 
+  <h3><a name="type"></a><code>--type</code></h3>
+
+  <p>
+  To specify the type of image file to write (if using an unrecognised file extension) use the <code>--type</code> argument to specify a value (see above).  A sub-value modifier on the <code>--image</code> and <code>--structureimage</code> value can also be used.  Valid values are:
+  <br/>
+  <code>png</code> - A Portable Network Graphics image (bitmap, default),
+  <br/>
+  <code>svg</code> - A Scalable Vector Graphics image (vector),
+  <br/>
+  <code>eps</code> - An Encapsulated PostScript file (vector),
+  <br/>
+  <code>html</code> - An HTML rendition of the alignment with embedded source data (vector/web browser),
+  <br/>
+  <code>biojs</code> - An HTML rendition of the alignment with interactive MSA viewer <a href="biojsmsa.html">BioJS-MSA</a> (vector).
+  </p>
+
   <h3><a name="bitmap"></a>Bitmap image types (<code>png</code>)</h3>
 
   <p>
   <h3><a name="scale"></a><code>--scale</code></h3>
 
   <p>
-  We can increase the size of the PNG image by a factor of <em>S</em> by following the <code>--image</code> argument with a <code>--scale <em>S</em></code> argument and value.  The value doesn't have to be an integer and should be given as an integer or floating point formatted number, e.g.
+  We can increase the size of the PNG image by a factor of <em>S</em> by following the <code>--image</code> or <code>--structureimage</code> argument with a <code>--scale <em>S</em></code> argument and value.  The value doesn't have to be an integer and should be given as an integer or floating point formatted number, e.g.
   <pre>
   jalview --open examples/uniref50.fa --colour gecos-ocean --image mypic.png --scale 5.5 --headless
   </pre>
   </p>
 
   <p>
-  You can specify two or all of <code>--scale</code>, <code>--width</code> and <code>--height</code> as limits to the size of the image (think of one or two bounding boxes) and the one which produces the smallest scale of image is used.  You can also specify each of these as sub-value modifiers to the <code>--image</code> value:
+  You can specify two or all of <code>--scale</code>, <code>--width</code> and <code>--height</code> as limits to the size of the image (think of one or two bounding boxes) and the one which produces the smallest scale of image is used.  You can also specify each of these as sub-value modifiers to the <code>--image</code> or <code>--structureimage</code> value:
   <pre>
   jalview --headless --open https://www.ebi.ac.uk/interpro/api/entry/pfam/PF03760/?annotation=alignment%3Aseed --noshowannotations --colour gecos-flower --image [scale=0.25,width=320,height=240]thumbnail.png
   </pre>
   </p>
 
+  <h3><a name="imagecolour"></a><code>--imagecolour</code></h3>
+
+  <p>
+  Specify a colour scheme to use just for this image using the <code>--imagecolour</code> argument:
+  <pre>
+  jalview --open examples/uniref50.fa --colour gecos-flower --image uniref50-residues.png --height 2160 --image uniref50-helix.png --imagecolour helix-propensity --width 800 --image uniref50-turn.png --imagecolour turn-propensity --width 800
+  </pre>
+  </p>
+
+  <h3><a name="bgcolour"></a><code>--bgcolour</code></h3>
+
+  <p>
+  <strong>Only applies to <code>--structureimage</code>.</strong> Specify a background colour for a structure image.  The colour can be specified as a named colour recognised by Java (e.g. <code>"white"</code>, <code>"cyan"</code>) or as a #RRGGBB hash-6-digit-hex-string as used in web pages (e.g. <code>"#ffffff"</code>, <code>"#00ffff"</code>).  Note that if you're using a hash in a bash-like shell then you should quote the string to avoid problems with it being interpreted as a comment character.
+  </p>
+  <p>
+  E.g.
+  <pre>
+  jalview --open examples/uniref50.fa --colour gecos-sunset --structure examples/AF-P00221-F1-model_v4.pdb --seqid FER1_SPIOL --structureimage temp.png  --bgcolour magenta
+  </pre>
+  </p>
+
   <p>
   Next we look at vector image formats, which maintain detail at all resolutions.
   </p>
 
-  <h3><a name="vector"></a>Vector image export</h3>
+  <h3><a name="vector"></a>Vector image export (<code>svg</code>, <code>eps</code>, <code>html</code>, <code>biojs</code>)</h3>
 
   <p>
   Jalview can export an alignment in Encapsulated PostScript (<code>eps</code>), Scalable Vector Graphics (<code>svg</code>), HTML (<code>html</code>) or BioJSON -- another HTML format (<code>biojs</code>), by using, e.g.
   </pre>
   </p>
 
+  <h3><a name="outputbehaviour"></a>Output behaviour</h3>
 
-  <h2><a name="filenamesubstitutionsandbatchprocessing"></a>Filename substitutions and batch processing (<code>--substitutions</code>, <code>--new</code>, <code>--close</code>, <code>--all</code>)</h2>
+  <h3><a name="overwrite"></a><code>--overwrite</code></h3>
 
-  <h3><a name=""></a><code>--</code></h3>
+  <p>
+  By default, Jalview will refuse to overwrite an output file (alignment or image) unless backups are in operation (alignment files only).  To force overwriting files, use the <code>--overwrite</code> argument.
+  </p>
+
+  <h3><a name="backups"></a><code>--backups / --nobackups</code></h3>
+
+  <p>
+  Jalview should honour your preferences for backup files of output alignment files.  Using <code>--backups</code> or <code>--nobackups</code> forces the behaviour.  With no backups set, you will need to use <code>--overwrite</code> to overwrite an existing file.  Note that Jalview does not make backup files of exported images.
+  </p>
+
+  <h3><a name="mkdirs"></a><code>--mkdirs</code></h3>
+
+  <p>
+  If you want to output a file into a folder that doesn't yet exist (this might happen particularly when using <code>{dirname}</code> substitutions -- see below), then Jalview will fail to write the file since the parent directory doesn't exist.  You can use <code>--mkdirs</code> to tell Jalview to make the new directory (or directories, it will create several nested directories if necessary) before writing the file.  <code>--mkdirs</code> is cautious and will generally refuse to make a new directory using a relative path with <code>..</code> in.
+  </p>
+
+  <h2><a name="filenamesubstitutionsandbatchprocessing"></a>Filename substitutions and batch processing (<code>--substitutions</code>, <code>--close</code>, <code>--all</code>)</h2>
+
+  <p>
+  One of the more powerful aspects of Jalview's command line operations is that stores all of the different opened alignment arguments (before opening them) and can apply some arguments to <em>all</em> of the alignments as they are opened.  This includes display and output arguments.
+  </p>
 
   <p>
+  When outputting a file you will obviously want to use a different filename for each of the alignments that are opened.  There are several ways you can specify how that filename differs, but the easiest way is to refer to the input filename and change the extension.  In the case of an alignment where multiple files are appended, the filename of the first file to be appended or opened is used.
+  </p>
+
+  <p>
+  To refer to different parts of the opening filename, you can use the strings
+  <ul>
+  <li><code>{dirname}</code> -- is replaced by the directory path to the opened file.</li>
+  <li><code>{basename}</code> -- is replaced by the base of the filename of the opened file. This is without the path or file extension (if there is one).</li>
+  <li><code>{extension}</code> -- is replaced by the extension of the filename of the opened file.</li>
+  </ul>
+  The braces (curly brackets '{', '}') are important!
+  </p>
+
+  <p>
+  Specifically for <code>--structureimage</code> output, you can also use substitutions using parts of the structure filename:
+  <ul>
+  <li><code>{structuredirname}</code> -- is replaced by the directory path to the opened structure file.</li>
+  <li><code>{structurebasename}</code> -- is replaced by the base of the filename of the opened structure file. This is without the path or file extension (if there is one).</li>
+  <li><code>{structureextension}</code> -- is replaced by the extension of the filename of the opened structure file.</li>
+  </ul>
+  </p>
+
+  <p>
+  These filename substitutions are on by default, but if for whatever reason you wish to disable the substitutions, they can be turned off (or back on again) through the list of arguments with:
+  </p>
+
+  <h3><a name="substitutions"></a><code>--substitutions / --nosubstitutions</code></h3>
+
+  <p>
+  Enable (or disable) filename substitutions in the following argument values and sub-value modifier values.
   <pre>
+  jalview --open exampes/uniref50.fa --nosubstitutions --output I_Want_A_Weird_Output_Filname_With_{basename}_Curly_Brackets_In_And_A_Sensible_One_Next.stk --substitutions --output tmp/{basename}.stk --headless
   </pre>
   </p>
 
-  <h3><a name=""></a><code>--</code></h3>
+  <p>
+  For opening single files this is less useful, since you could obviously just type the output filename, but for multiple opened alignments you can also use these substituted values and they will be replaced by the relevant part of the filename given for each opened alignment window.  Normally an <code>--output</code> or <code>--image</code> argument will only be applied to the latest opened alignment window, but you can tell Jalview to apply some arguments to all alignments that have been opened (so far) by using the <code>--all</code> argument.
+  </p>
+
+  <h3><a name="all"></a><code>--all / -noall</code></h3>
+
+  <p>
+  When using the <code>--all</code> argument, following arguments will apply to all of the previously opened alignment windows.  You can turn this behaviour off again for following arguments using the <code>--noall</code> argument.  The arguments that can apply to all previously opened alignments are:
+  <br/>
+  <code>--colour</code>
+  <br/>
+  <code>--sortbytree</code>
+  <br/>
+  <code>--showannotations</code>
+  <br/>
+  <code>--wrap</code>
+  <br/>
+  <code>--nostructure</code>
+  <br/>
+  <code>--notempfac</code>
+  <br/>
+  <code>--showssannotations</code>
+  <br/>
+  <code>--image</code>
+  <br/>
+  <code>--type</code>
+  <br/>
+  <code>--textrenderer</code>
+  <br/>
+  <code>--scale</code>
+  <br/>
+  <code>--width</code>
+  <br/>
+  <code>--height</code>
+  <br/>
+  <code>--output</code>
+  <br/>
+  <code>--format</code>
+  <br/>
+  <code>--groovy</code>
+  <br/>
+  <code>--backups</code>
+  <br/>
+  <code>--overwrite</code>
+  <br/>
+  <code>--close</code>
+  </p>
+  <p>
+  In particular, for our example above, we can use <code>-all</code> and <code>--output</code> like this (<code>--close</code> will be explained in a moment):
+  <pre>
+  jalview --open all_my_fasta_files/*.fa --all --output all_my_converted_stockholm_files/{basename}.stk --close --headless
+  </pre>
+  </p>
 
   <p>
+  Another example would be to create a print quality coloured postscript image for every Fasta file in several directories and place the image next to the alignment:
   <pre>
+  jalview --open */*.fa --all --colour gecos-flower --image {dirname}/{basename}.eps --textrenderer text --close --headless
+  </pre>
+  or thumbnails for every Fasta file with
+  <pre>
+  jalview --open */*.fa --all --colour gecos-flower --image {dirname}/{basename}.png --width 256 --height 256 --close --headless
   </pre>
   </p>
 
-  <h3><a name=""></a><code>--</code></h3>
+  <h3><a name="close"></a><code>--close</code></h3>
 
   <p>
+  The <code>--close</code> tag is used to close an alignment window after all output files or image exports are performed.  This reduces memory use, especially if an <code>--open</code> value is set to open many files.  These will be opened, formatted and output sequentially so since they are closed before the next one is opened memory use will not build up over a large number of alignments.
   <pre>
   </pre>
   </p>
 
-  <h3><a name=""></a><code>--</code></h3>
+
+  <h2><a name="alloutputwildcard"></a>The all output wildcard: <code>--output "*/*.ext"</code>,  <code>--image "*/*.ext"</code></h2>
+
+  <p>
+  Purely as an intuitive syntactic sweetener, you can use the <code>--output</code> wildcard <code>*</code> in two places as part of an output path and filename.
+  </p>
 
   <p>
+  Using an asterisk (<code>*</code>) as a filename before an extension, e.g. <code>--image "tmp/*.png"</code> will result in that asterisk being treated as a <code>{basename}</code> substitution.
+  </p>
+
+  <p>
+  Using an asterisk (<code>*</code>) before a file separator (usually </code>/</code>), e.g. <code>--image "tmp/*/file1.png"</code> will result in that asterisk being treated as a <code>{dirname}</code> substitution.
+  </p>
+
+  <p>
+  You can combine these, using an asterisk (<code>*</code>) before and after the last file separator, e.g. <code>--image "tmp/*/*.png"</code> will result in being substituted like <code>tmp/{dirname}/{basename}.png</code>.
+  </p>
+
+  <p>
+  For example, to achieve the same as the thumbnails example above, you could use
   <pre>
+  jalview --open */*.fa --image "*/*.png" --colour gecos-flower --width 256 --height 256 --close --headless
   </pre>
+  Here we move the <code>--colour</code> argument after the <code>--output</code> argument (it will still be applied before the image export or file output) so that it is included after the implied <code>--all</code> argument.  The thumbnails will be placed in the same directory as the alignment file with the same filename except for a different extension of <code>.png</code>.
   </p>
 
-  <h3><a name=""></a><code>--</code></h3>
-
   <p>
+  For a simple conversion of many fasta files into Stockholm format, simply use
   <pre>
+  jalview --open all_my_fasta_files/*.fa --output "*.stk" --close --headless
   </pre>
   </p>
 
-  Continue to <a href="clarguments-advanced.html">Jalview Command Line Arguments: advanced usage</a>.
+  <p>
+  <strong>Important!</strong>  Please note that using a bareword <code>*.ext</code> (i.e. without an escape or quotation marks) in a shell command line will potentially be expanded by the shell to a list of all the files in the current directory ending with <code>.ext</code> <em>before</em> this value is passed to Jalview.  This will result in the first of these files being overwritten (multiple times)!  If you shell-escape the <code>*</code> (usually with a backslash '\') or enclose the value in quotation marks (<code>"*.ext"</code> - that's including the quotation marks) then the shell will not expand the wildcard.
+  </p>
 
+  <p>
+  An alternative is to use an equals sign ('=') with no spaces between the argument and the value, <code>--output=*.ext</code>, which Jalview will interpret the same, but the shell will not automatically expand before it is sent to Jalview, e.g.
+  <pre>
+  jalview --open all_my_fasta_files/*.fa --output=*.stk --close --headless
+  </pre>
+  </p>
 
+  <hr/>
+  Continue to <a href="clarguments-advanced.html">Command Line: advanced usage</a>.
+  <br/>
+  <a href="clarguments-reference.html">Command Line: reference</a>
 
 </body>
 </html>