SeqNinja allows you to substitute the values of settings into single- and double quoted strings. You can substitute the value of any setting, including built-in settings, custom settings, and command-line arguments. When you run the script, SeqNinja will replace the name of the setting with its value. For example, a string (e.g., a file path) or a numeric setting (e.g., an integer) will be used in place of the setting name. This functionality allows the same script to be reused with different data and allows the script to be moved along with its data.

Substitution involves several steps, each of which is discussed below.

Step 1 – Enabling substitution:

Before substitution is used in a script, you must first enable “substitution” in that script. This is done by adding !setting:substitution = 'true' anywhere in the script above the substitution.

Step 2 – Defining a setting:

Settings can be defined…

  • in the script.
  • as an argument (e.g., !{1}).
  • implicitly (see the “Tip” below for an example).

The syntax for a user setting is !user:<optional text> = <value> … where:

!user: Recommended at the beginning of each custom setting, to avoid name clash with current and future built-in settings.
optional text Used to differentiate settings or to remind you of the purpose of a setting. For example, user:tags, user:fasta, user:genbank.
value The information you want to substitute for the setting when the script is run (e.g., a file path, integer, etc.). Substitution can occur in numeric expressions or in strings. Strings are sequences of characters (e.g., a file path) between pairs of single or double quotes.

Step 3 – Specifying substitution:

Curly braces are used to substitute the value of a setting in a string or numeric expression.

Arguments can be referenced in the script with !{1}, !{2}, etc. The path to the script file itself is !{0}. To refer to a ‘!’ in the script, use !!.

Examples using custom settings:

Example 1: Write and save a script called Then issue commands like the ones below:

C:\> seqninja.exe mg1655.fasta
C:\> seqninja.exe DH10B.fasta
C:\> seqninja.exe adh1_human.fap

Example 2: Write and save a script called Then issue commands like the ones below:

C:\> seqninja.exe ref_chr2L
C:\> seqninja.exe ref_chr3L
C:\> seqninja.exe ref_chr4L

Context-specific examples:

Context Example Comment
Paths “out.fap” = “!{program:dir}/”
Sequence literals “out.fasta” = “!{1}” + “in.fasta” In this example, the user passes a sequence of residues as the first command-line argument. For literals defined in the script, it’s easier just to use a sequence variable:

“out.fasta” = $INSERTION + “in.fasta”
Patterns “out.fasta” = collect( ‘!{program:dir}/genomes/Vibrio*.gbk’ )
Sequence index “out.fasta” = “454.fasta”#”$!{1}”
Settings !mydir=“C:\Users\norville”
Integers out.fasta = ( %!{1} > %!{2} ) This allows using integers passed on the command line in numeric expressions. For values defined in the script, it’s easier just to use variable integers:

%A = 42
%B = 111
out.fasta = %A > %B )
Single-quoted strings print( ‘File: !{1} )

Need more help with this?

Thanks for your feedback.