# Name of your program
package "RNAfold" # don't use package if you're using automake

purpose "Calculate minimum free energy secondary structures and partition function of RNAs"

usage "RNAfold [OPTIONS] [<input0.fa>] [<input1.fa>]..."

#version "2.0"   # don't use version if you're using automake

# command line options passed to gengetopt
args "--file-name=RNAfold_cmdl --include-getopt --default-optional --unamed-opts --func-name=RNAfold_cmdline_parser --arg-struct-name=RNAfold_args_info"


description "The program reads RNA sequences, calculates their minimum free energy (mfe) structure\
 and prints the mfe structure in bracket notation and its free energy. If not specified differently\
 using commandline arguments, input is accepted from stdin or read from an input file, and output\
 printed to stdout. If the -p option\
 was given it also computes the partition function (pf) and base pairing probability matrix, and\
 prints the free energy of the thermodynamic ensemble, the frequency of the mfe structure in the ensemble,\
 and the ensemble diversity to stdout.\n\nIt also produces PostScript files with plots of the resulting\
 secondary structure graph and a \"dot plot\" of the base pairing matrix.\nThe dot plot shows a matrix of\
 squares with area proportional to the pairing probability in the upper right half, and one square for each\
 pair in the minimum free energy structure in the lower left half. For each pair i-j with probability\
 p>10E-6 there is a line of the form\n\ni  j  sqrt(p)  ubox\n\nin the PostScript file, so that the pair\
 probabilities can be easily extracted.\n\nSequences may be provided in a simple text format where each sequence\
 occupies a single line. Output files are named \"rna.ps\" and \"dot.ps\". Existing files of the same name\
 will be overwritten.\n\nIt is also possible to provide sequence data in FASTA format. In this case, the\
 first word of the FASTA header will be used as prefix for output file names. PostScript files \"prefix_ss.ps\"\
 and \"prefix_dp.ps\" are produced for the structure and dot plot, respectively. Note, however, that once\
 FASTA input was provided all following sequences must be in FASTA format too.\n\nTo avoid problems with\
 certain operating systems and/or file systems the prefix will ALWAYS be sanitized!\
 This step substitutes any special character in the prefix by a filename delimiter. See the --filename-delim\
 option to change the delimiting character according to your requirements.\n\nThe program will continue to\
 read new sequences until a line consisting of the single character '@' or an end of file (EOF) condition is\
 encountered.\n\n"

# Options

option  "verbose" v
"Be verbose.\n\n"
flag
off


section "I/O Options"
sectiondesc="Command line options for input and output (pre-)processing\n\n"

option  "infile"  i
"Read a file instead of reading from stdin.\n"
details="The default behavior of RNAfold is to read input from stdin or the file(s) that follow(s)\
 the RNAfold command. Using this parameter the user can specify input file names where data\
 is read from. Note, that any additional files supplied to RNAfold are still processed as well.\n\n"
string
typestr="filename"
multiple
optional

option  "outfile" o
"Print output to file instead of stdout.\n"
details="This option may be used to write all output to output files rather than printing\
 to stdout. The default filename is \"RNAfold_output.fold\" if no FASTA header precedes\
 the input sequences and the --auto-id feature is inactive. Otherwise, output files with\
 the scheme \"prefix.fold\" are generated, where the \"prefix\" is taken from the sequence\
 id, e.g. the FASTA header. The user may specify a single output file name for all data\
 generated from the input by supplying a filename as argument following immediately\
 after this parameter.\nIn case a file with the same filename already exists, any output of\
 the program will be appended to it.\
 Note: Any special characters in the filename will be replaced by the filename delimiter,\
 hence there is no way to pass an entire directory path through this option (yet).\
 (See also the \"--filename-delim\" parameter)\n\n"
string
typestr="filename"
argoptional
optional

option  "jobs"  j
"Split batch input into jobs and start processing in parallel using multiple threads. A value of 0\
 indicates to use as many parallel threads as computation cores are available.\n"
details="Default processing of input data is performed in a serial fashion, i.e. one sequence at\
 a time. Using this switch, a user can instead start the computation for many sequences in the\
 input in parallel. RNAfold will create as many parallel computation slots as specified and\
 assigns input sequences of the input file(s) to the available slots. Note, that this increases\
 memory consumption since input alignments have to be kept in memory until an empty compute slot\
 is available and each running job requires its own dynamic programming matrices.\n\n"
int
default="0"
typestr="number"
argoptional
optional

option  "unordered"  -
"Do not try to keep output in order with input while parallel processing is in place.\n"
details="When parallel input processing (--jobs flag) is enabled, the order in which input\
 is processed depends on the host machines job scheduler. Therefore, any output to stdout\
 or files generated by this program will most likely not follow the order of the corresponding\
 input data set. The default of RNAfold is to use a specialized data structure to still keep\
 the results output in order with the input data. However, this comes with a trade-off in terms\
 of memory consumption, since all output must be kept in memory for as long as no chunks\
 of consecutive, ordered output are available. By setting this flag, RNAfold will not buffer\
 individual results but print them as soon as they have been computated.\n\n"
flag
off
dependon="jobs"
hidden

option  "noconv"  -
"Do not automatically substitute nucleotide \"T\" with \"U\".\n\n"
flag
off

option  "auto-id"  -
"Automatically generate an ID for each sequence.\n"
details="The default mode of RNAfold is to automatically determine an ID from the input sequence\
 data if the input file format allows to do that. Sequence IDs are usually given in the FASTA\
 header of input sequences. If this flag is active, RNAfold ignores any IDs retrieved from the\
 input and automatically generates an ID for each sequence. This ID consists of a prefix and an\
 increasing number. This flag can also be used to add a FASTA header to the output even if\
 the input has none.\n\n"
flag
off

option  "id-prefix" -
"Prefix for automatically generated IDs (as used in output file names).\n"
details="If this parameter is set, each sequence will be prefixed with the\
 provided string. Hence, the output files will obey the following naming\
 scheme: \"prefix_xxxx_ss.ps\" (secondary structure plot), \"prefix_xxxx_dp.ps\"\
 (dot-plot), \"prefix_xxxx_dp2.ps\" (stack probabilities), etc. where xxxx\
 is the sequence number. Note: Setting this parameter implies --auto-id.\n\n"
string
typestr="STRING"
default="sequence"
optional

option  "id-delim" -
"Change the delimiter between prefix and increasing number for automatically generated IDs (as used in output file names).\n"
details="This parameter can be used to change the default delimiter \"_\" between\
 the prefix string and the increasing number for automatically generated ID.\n\n"
string
typestr="CHAR"
default="_"
optional
hidden

option  "id-digits"  -
"Specify the number of digits of the counter in automatically generated alignment IDs.\n"
details="When alignments IDs are automatically generated, they receive an increasing number, starting\
 with 1. This number will always be left-padded by leading zeros, such that the number takes up a\
 certain width. Using this parameter, the width can be specified to the users need. We allow\
 numbers in the range [1:18]. This option implies --auto-id.\n\n"
int
default="4"
optional
hidden

option  "id-start"  -
"Specify the first number in automatically generated IDs.\n"
details="When sequence IDs are automatically generated, they receive an increasing number,\
 usually starting with 1. Using this parameter, the first number can be specified to the users\
 requirements. Note: negative numbers are not allowed.\nNote: Setting this parameter implies\
 to ignore any IDs retrieved from the input data, i.e. it activates the --auto-id flag.\n\n"
long
default="1"
optional
hidden

option  "filename-delim" -
"Change the delimiting character used in sanitized filenames.\n"
details="This parameter can be used to change the delimiting character used while\
 sanitizing filenames, i.e. replacing invalid characters. Note, that the default\
 delimiter ALWAYS is the first character of the \"ID delimiter\" as supplied through\
 the --id-delim option. If the delimiter is a whitespace character or empty, invalid\
 characters will be simply removed rather than substituted.\
 Currently, we regard the following characters as illegal for use in filenames:\
 backslash '\', slash '/', question mark '?', percent sign '%', asterisk '*', colon ':',\
 pipe symbol '|', double quote '\"', triangular brackets '<' and '>'.\n\n"
string
typestr="CHAR"
default="ID-delimiter"
optional
hidden

option  "filename-full" -
"Use full FASTA header to create filenames.\n"
details="This parameter can be used to deactivate the default behavior of limiting\
 output filenames to the first word of the sequence ID. Consider the following example:\
 An input with FASTA header '>NM_0001 Homo Sapiens some gene' usually produces output\
 files with the prefix \"NM_0001\" without the additional data available in the FASTA\
 header, e.g. \"NM_0001_ss.ps\" for secondary structure plots. With this flag set, no\
 truncation of the output filenames is done, i.e. output filenames receive the full\
 FASTA header data as prefixes. Note, however, that invalid characters (such as whitespace)\
 will be substituted by a delimiting character or simply removed, (see also the parameter\
 option --filename-delim).\n\n"
flag
off
hidden


section "Algorithms"
sectiondesc="Select additional algorithms which should be included in the calculations.\nThe Minimum free energy\
 (MFE) and a structure representative are calculated in any case.\n\n"

option  "partfunc"  p
"Calculate the partition function and base pairing probability matrix.\n"
details="In addition to the MFE structure\
 we print a coarse representation of the pair probabilities in form of a pseudo bracket notation followed by\
 the ensemble free energy. This notation makes use of the letters '.', ',', '|', '{', '}', '(', and ')' denoting bases that are\
 essentially unpaired, weakly paired, strongly paired without preference, weakly upstream (downstream) paired,\
 or strongly up- (down-)stream paired bases, respectively. On the next line the centroid structure as derived\
 from the pair probabilities together with its free energy and distance to the ensemble is shown. Finally it\
 prints the frequency of the mfe structure, and the\
 structural diversity (mean distance between the structures in the ensemble).\nSee the description of 'vrna_pf()'\
 and 'mean_bp_dist()' and 'vrna_centroid()' in the RNAlib documentation for details.\nNote that unless you also specify\
 -d2 or -d0, the partition function and mfe calculations will use a slightly different energy model. See the\
 discussion of dangling end options below.\n\nAn additionally passed value to this option changes the behavior\
 of partition function calculation:\n-p0 Calculate the partition function but not the pair probabilities,\
 saving about 50% in runtime. This prints the ensemble free energy 'dG=-kT ln(Z)'.\n-p2 Compute stack probabilities,\
 i.e. the probability that a pair '(i,j)' and the immediately interior pair '(i+1,j-1)' are formed simultaneously in\
 addition to pair probabilities. A second postscript dot plot named \"name_dp2.ps\", or \"dot2.ps\" (if the\
 sequence does not have a name), is produced that contains pair probabilities in the upper right half and stack\
 probabilities in the lower left.\n\n"
int
default="1"
argoptional
optional

option  "betaScale" -
"Set the scaling of the Boltzmann factors.\n"
details="The argument provided with this option is used to scale the thermodynamic temperature\
 in the Boltzmann factors independently from the temperature of the individual loop energy contributions.\
 The Boltzmann factors then become 'exp(- dG/(kT*betaScale))' where 'k' is the Boltzmann constant, 'dG'\
 the free energy contribution of the state and 'T' the absolute temperature.\n\n"
double
default="1."
optional
dependon="partfunc"
hidden

option  "pfScale" S
"In the calculation of the pf use scale*mfe as an estimate for the ensemble free energy (used to avoid\
 overflows).\n"
details="The default is 1.07, useful values are 1.0 to 1.2. Occasionally needed for long sequences.\n\n"
double
default="1.07"
optional
hidden

option  "MEA"   -
"Compute MEA (maximum expected accuracy) structure.\n"
details="The expected accuracy is computed from the pair probabilities: each base pair '(i,j)' receives\
 a score '2*gamma*p_ij' and the score of an unpaired base is given by the probability of not forming\
 a pair. The parameter gamma tunes the importance of correctly predicted pairs versus unpaired bases.\
 Thus, for small values of gamma the MEA structure will contain only pairs with very high probability.\
 Using --MEA implies -p for computing the pair probabilities.\n\n"
float
typestr="gamma"
default="1."
argoptional
optional

option  "circ"    c
"Assume a circular (instead of linear) RNA molecule.\n\n"
flag
off

option  "ImFeelingLucky"  -
"Return exactly one stochastically backtracked structure.\n"
details="This function computes the partition function and returns exactly one secondary structure\
 stochastically sampled from the Boltzmann equilibrium according to its probability in the ensemble\n\n"
flag
off
hidden

option  "bppmThreshold" -
"Set the threshold/cutoff for base pair probabilities included in the postscript output.\n\n"
details="By setting the threshold the base pair probabilities that are included in the\
 output can be varied. By default only those exceeding '1e-5' in probability will be shown as squares\
 in the dot plot. Changing the threshold to any other value allows for increase or decrease of data.\n\n"
double
typestr="cutoff"
optional
default="1e-5"
hidden

option  "gquad" g
"Incoorporate G-Quadruplex formation into the structure prediction algorithm.\n\n"
flag
off


section "Structure Constraints"
sectiondesc="Command line options to interact with the structure constraints feature of this program\n\n"

option  "maxBPspan" -
"Set the maximum base pair span.\n\n"
int
default="-1"
optional

option  "constraint"  C
"Calculate structures subject to constraints.\n"
details="The program reads first the\
 sequence, then a string containing constraints on the structure encoded with the symbols:\n\n'.' (no constraint\
 for this base)\n\n'|' (the corresponding base has to be paired\n\n'x' (the base is unpaired)\n\n'<' (base i is paired with\
 a base j>i)\n\n'>' (base i is paired with a base j<i)\n\nand matching brackets '(' ')' (base i pairs base j)\n\nWith the\
 exception of '|', constraints will disallow all pairs conflicting with the constraint. This is usually\
 sufficient to enforce the constraint, but occasionally a base may stay unpaired in spite of constraints. PF\
 folding ignores constraints of type '|'.\n\n"
string
typestr="filename"
default = ""
argoptional

option  "batch"   -
"Use constraints for multiple sequences.\n"
details="Usually, constraints provided from input file only apply to a single input sequence. Therefore,\
 RNAfold will stop its computation and quit after the first input sequence was processed. Using this\
 switch, RNAfold processes multiple input sequences and applies the same provided constraints to each of them.\n\n"
flag
off
dependon="constraint"
hidden

option  "canonicalBPonly" -
"Remove non-canonical base pairs from the structure constraint.\n\n"
flag
off
dependon="constraint"
hidden

option  "enforceConstraint" -
"Enforce base pairs given by round brackets '(' ')' in structure constraint.\n\n"
flag
off
dependon="constraint"

option  "shape" -
"Use SHAPE reactivity data to guide structure predictions.\n\n"
string
typestr="filename"
optional

option  "shapeMethod" -
"Select SHAPE reactivity data incorporation strategy.\n\n"
details="The following methods can be used to convert SHAPE reactivities into pseudo energy contributions.\n\n\
 'D': Convert by using the linear equation according to Deigan et al 2009. Derived pseudo energy terms\
 will be applied for every nucleotide involved in a stacked pair. This method is recognized by a capital\
 'D' in the provided parameter, i.e.: --shapeMethod=\"D\" is the default setting. The slope 'm' and the\
 intercept 'b' can be set to a non-default value if necessary, otherwise m=1.8 and b=-0.6. To alter these\
 parameters, e.g. m=1.9 and b=-0.7, use a parameter string like this: --shapeMethod=\"Dm1.9b-0.7\". You\
 may also provide only one of the two parameters like: --shapeMethod=\"Dm1.9\" or --shapeMethod=\"Db-0.7\".\n\n\
 'Z': Convert SHAPE reactivities to pseudo energies according to Zarringhalam et al 2012.\
 SHAPE reactivities will be converted to pairing probabilities by using linear mapping.\
 Aberration from the observed pairing probabilities will be penalized during the folding recursion.\
 The magnitude of the penalties can affected by adjusting the factor beta\
 (e.g. --shapeMethod=\"Zb0.8\").\n\n\
 'W': Apply a given vector of perturbation energies to unpaired nucleotides according to Washietl et al 2012.\
 Perturbation vectors can be calculated by using RNApvmin.\n\n"
string
typestr="method"
dependon="shape"
default="D"
optional
hidden

option  "shapeConversion" -
"Select method for SHAPE reactivity conversion.\n\n"
details="This parameter is useful when dealing with the SHAPE incorporation according to Zarringhalam et al. \
The following methods can be used to convert SHAPE reactivities into the probability for a certain nucleotide to be unpaired.\n
'M': Use linear mapping according to Zarringhalam et al.
'C': Use a cutoff-approach to divide into paired and unpaired nucleotides (e.g. \"C0.25\")
'S': Skip the normalizing step since the input data already represents probabilities for being unpaired rather than raw reactivity values
'L': Use a linear model to convert the reactivity into a probability for being unpaired (e.g. \"Ls0.68i0.2\" to use a slope of 0.68 and an intercept of 0.2)
'O': Use a linear model to convert the log of the reactivity into a probability for being unpaired (e.g. \"Os1.6i-2.29\" to use a slope of 1.6 and an intercept of -2.29)\n\n"
string
typestr="method"
default="O"
optional

option  "motif"   -
"Specify stabilizing energy of a ligand binding to a particular sequence/structure motif.\n"
details="Some ligands binding to RNAs require and/or induce particular sequence and structure motifs. For\
 instance they bind to an interior loop, or small hairpin loop. If for such cases a binding free energy is\
 known, the binding and therefore stabilizing effect of the ligand can be included in the folding recursions.\
 Interior loop motifs are specified as concatenations of 5' and 3' motif, separated by an '&' character.\n\
 Energy contributions must be specified in kcal/mol.\nSee the manpage for an example usage of this option.\n\n"
string
typestr="SEQUENCE,STRUCTURE,ENERGY"
optional
hidden

option  "commands"   -
"Read additional commands from file\n"
details="Commands include hard and soft constraints, but also structure motifs in hairpin and interior\
 loops that need to be treeted differently. Furthermore, commands can be set for unstructured and structured\
 domains.\n\n"
string
typestr="filename"
optional
hidden


section "Energy Parameters"
sectiondesc="Energy parameter sets can be adapted or loaded from user-provided input files\n\n"

option  "temp"  T
"Rescale energy parameters to a temperature of temp C. Default is 37C.\n\n"
double
default="37.0"
optional

option  "paramFile" P
"Read energy parameters from paramfile, instead of using the default parameter set.\n"
details="Different sets of energy parameters for RNA and DNA should accompany your distribution.\nSee the\
 RNAlib documentation for details on the file format. The placeholder file name 'DNA' can be used\
 to load DNA parameters without the need to actually specify any input file.\n\n"
string
typestr="paramfile"
optional

option  "noTetra" 4
"Do not include special tabulated stabilizing energies for tri-, tetra- and hexaloop hairpins.\n"
details="Mostly for testing.\n\n"
flag
off
hidden

option  "salt" -
"Set salt concentration in molar (M). Default is 1.021M.\n\n"
double
optional

option  "modifications" m
"Allow for modified bases within the RNA sequence string.\n"
details="Treat modified bases within the RNA sequence differently, i.e. use corresponding\
 energy corrections and/or pairing partner rules if available. For that, the modified bases\
 in the input sequence must be marked by their corresponding one-letter code. If no additional\
 arguments are supplied, all available corrections are performed. Otherwise, the user may\
 limit the modifications to a particular subset of modifications, resp. one-letter codes,\
 e.g. -mP6 will only correct for pseudouridine and m6A bases.\n\
 Currently supported one-letter codes and energy corrections are:\n\n\
 '7': 7-deaza-adenonsine (7DA)\n\n\
 'I': Inosine\n\n\
 '6': N6-methyladenosine (m6A)\n\n\
 'P': Pseudouridine\n\n\
 '9': Purine (a.k.a. nebularine)\n\n\
 'D': Dihydrouridine\n\n"
string
argoptional
default="7I6P9D"

option  "mod-file"  -
"Use additional modified base data from JSON file.\n\n"
string
multiple
optional


section "Model Details"
sectiondesc="Tweak the energy model and pairing rules additionally using the following parameters\n\n"

option  "dangles" d
"How to treat \"dangling end\" energies for bases adjacent to helices in free ends and multi-loops.\n"
details="\nWith -d1 only unpaired bases can participate in at most one dangling end. With -d2 this\
 check is ignored, dangling energies will be added for the bases adjacent to a helix on both sides in\
 any case; this is the default for mfe and partition function folding (-p).\nThe option -d0 ignores\
 dangling ends altogether (mostly for debugging).\nWith -d3 mfe folding will allow coaxial stacking\
 of adjacent helices in multi-loops. At the moment the implementation will not allow coaxial stacking\
 of the two interior pairs in a loop of degree 3 and works only for mfe folding.\n\nNote that with\
 -d1 and -d3 only the MFE computations will be using this setting while partition function uses\
 -d2 setting, i.e. dangling ends will be treated differently.\n\n"
int
default="2"
optional

option  "noLP"  -
"Produce structures without lonely pairs (helices of length 1).\n"
details="For partition function folding this only disallows pairs that can only occur isolated. Other\
 pairs may still occasionally occur as helices of length 1.\n\n"
flag
off

option  "noGU"  -
"Do not allow GU pairs.\n\n"
flag
off
hidden

option  "noClosingGU" -
"Do not allow GU pairs at the end of helices.\n\n"
flag
off
hidden

option  "nsp" -
"Allow other pairs in addition to the usual AU,GC,and GU pairs.\n"
details="Its argument is a comma separated list of additionally allowed pairs. If the\
 first character is a \"-\" then AB will imply that AB and BA are allowed pairs, e.g.\
 --nsp=\"-GA\"  will allow GA and AG pairs. Nonstandard pairs are given 0 stacking\
 energy.\n\n"
string
optional
hidden

option  "energyModel" e
"Set energy model.\n"
details="Rarely used option to fold sequences from the artificial ABCD... alphabet, where\
 A pairs B, C-D etc.  Use the energy parameters for GC (-e 1) or AU (-e 2) pairs.\n\n"
int
optional
hidden

option  "helical-rise"  -
"Set the helical rise of the helix in units of Angstrom.\n"
details="Use with caution! This value will be re-set automatically to 3.4 in case DNA\
 parameters are loaded via -P DNA and no further value is provided.\n\n"
float
optional
default="2.8"
hidden

option  "backbone-length"  -
"Set the average backbone length for looped regions in units of Angstrom.\n"
details="Use with caution! This value will be re-set automatically to 6.76 in case DNA\
 parameters are loaded via -P DNA and no further value is provided.\n\n"
float
optional
default="6.0"
hidden


section "Plotting"
sectiondesc="Command line options for changing the default behavior of structure layout and pairing probability plots\n\n"

option  "noPS"  -
"Do not produce postscript drawing of the mfe structure.\n\n"
flag
off

option  "noDP"  -
"Do not produce dot-plot postscript file containing base pair or stack probabilitities.\n"
details="In combination with the -p option, this flag turns-off creation of individual\
 dot-plot files. Consequently, computed base pair probability output is omitted but centroid\
 and MEA structure prediction is still performed.\n\n"
flag
dependon="partfunc"
off

option  "layout-type"  t
"Choose the layout algorithm.\n"
details="Select the layout algorithm that computes the nucleotide coordinates.\
 Currently, the following algorithms are available:\n\
 '0': simple radial layout\n\n\
 '1': Naview layout (Bruccoleri et al. 1988)\n\n\
 '2': circular layout\n\n\
 '3': RNAturtle (Wiegreffe et al. 2018)\n\n\
 '4': RNApuzzler (Wiegreffe et al. 2018)\n\n"
int
default="1"
optional
hidden


text    "\nIf in doubt our program is right, nature is at fault.\nComments should be sent to\
 rna@tbi.univie.ac.at.\n\n"
