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 convert.star. Then issue commands like the ones below:

C:\> seqninja.exe convert.star mg1655.gb mg1655.fasta
C:\> seqninja.exe convert.star DH10B.fasta DH10B.gb
C:\> seqninja.exe convert.star adh1_human.pro adh1_human.fap

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

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

Context-specific examples:

Context Example Comment
Paths “out.fap” = “!{program:dir}/adh4_mouse.pro”
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:

$INSERTION = “NNNNNNNN”
“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”
!mydata=”!{mydir}/data”
!myresults=”!{mydir}/results”
Integers out.fasta = in.gb ( %!{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 = in.gb( %A > %B )
Single-quoted strings print( ‘File: !{1} )

Need more help with this?
Contact DNASTAR

Thanks for your feedback.