biotite.application.viennarna.RNAfoldApp

class biotite.application.viennarna.RNAfoldApp(sequence, temperature=37, bin_path='RNAfold')[source]

Bases: LocalApp

Compute the minimum free energy secondary structure of a ribonucleic acid sequence using ViennaRNA’s RNAfold software.

Internally this creates a Popen instance, which handles the execution.

Parameters
sequenceNucleotideSequence

The RNA sequence.

temperatureint, optional

The temperature (°C) to be assumed for the energy parameters.

bin_pathstr, optional

Path of the RNAfold binary.

Examples

>>> sequence = NucleotideSequence("CGACGTAGATGCTAGCTGACTCGATGC")
>>> app = RNAfoldApp(sequence)
>>> app.start()
>>> app.join()
>>> print(app.get_free_energy())
-1.3
>>> print(app.get_dot_bracket())
(((.((((.......)).)))))....
add_additional_options(options)

Add additional options for the command line program. These options are put before the arguments automatically determined by the respective LocalApp subclass.

This method is focused on advanced users, who have knowledge on the available options of the command line program and the options already used by the LocalApp subclasses. Ignoring the already used options may result in conflicting CLI arguments and potential unexpected results. It is recommended to use this method only, when the respective LocalApp subclass does not provide a method to set the desired option.

Parameters
optionslist of str

A list of strings representing the command line options.

Notes

In order to see which options the command line execution used, try the get_command() method.

Examples

>>> seq1 = ProteinSequence("BIQTITE")
>>> seq2 = ProteinSequence("TITANITE")
>>> seq3 = ProteinSequence("BISMITE")
>>> seq4 = ProteinSequence("IQLITE")
>>> # Run application without additional arguments
>>> app = ClustalOmegaApp([seq1, seq2, seq3, seq4])
>>> app.start()
>>> app.join()
>>> print(app.get_command())
clustalo --in ...fa --out ...fa --force --output-order=tree-order --seqtype Protein --guidetree-out ...tree
>>> # Run application with additional argument
>>> app = ClustalOmegaApp([seq1, seq2, seq3, seq4])
>>> app.add_additional_options(["--full"])
>>> app.start()
>>> app.join()
>>> print(app.get_command())
clustalo --full --in ...fa --out ...fa --force --output-order=tree-order --seqtype Protein --guidetree-out ...tree
cancel()

Cancel the application when in RUNNING or FINISHED state.

clean_up()

Do clean up work after the application terminates.

PROTECTED: Optionally override when inheriting.

static compute_secondary_structure(sequence, bin_path='RNAfold')

Compute the minimum free energy secondary structure of a ribonucleic acid sequence using ViennaRNA’s RNAfold software.

This is a convenience function, that wraps the RNAfoldApp execution.

Parameters
sequenceNucleotideSequence

The RNA sequence.

bin_pathstr, optional

Path of the RNAfold binary.

Returns
dotbracketstr

The secondary structure in dot bracket notation.

free_energyfloat

The free energy.

evaluate()

Evaluate application results. Called in join().

PROTECTED: Override when inheriting.

get_app_state()

Get the current app state.

Returns
app_stateAppState

The current app state.

get_base_pairs()

Get the base pairs from the minimum free energy secondary structure of the input sequence.

Returns
base_pairsndarray, shape=(n,2)

Each row corresponds to the positions of the bases in the sequence.

Examples

>>> sequence = NucleotideSequence("CGACGTAGATGCTAGCTGACTCGATGC")
>>> app = RNAfoldApp(sequence)
>>> app.start()
>>> app.join()
>>> print(app.get_base_pairs())
    [[ 0 22]
     [ 1 21]
     [ 2 20]
     [ 4 19]
     [ 5 18]
     [ 6 16]
     [ 7 15]]

For reference, the corresponding dot bracket notation can be displayed as below.

>>> print(app.get_dot_bracket())
(((.((((.......)).)))))....
get_command()

Get the executed command.

Cannot be called until the application has been started.

Returns
commandstr

The executed command.

Examples

>>> seq1 = ProteinSequence("BIQTITE")
>>> seq2 = ProteinSequence("TITANITE")
>>> seq3 = ProteinSequence("BISMITE")
>>> seq4 = ProteinSequence("IQLITE")
>>> app = ClustalOmegaApp([seq1, seq2, seq3, seq4])
>>> app.start()
>>> print(app.get_command())
clustalo --in ...fa --out ...fa --force --output-order=tree-order --seqtype Protein --guidetree-out ...tree
get_dot_bracket()

Get the minimum free energy secondary structure of the input sequence in dot bracket notation.

Returns
dotbracketstr

The secondary structure in dot bracket notation.

Examples

>>> sequence = NucleotideSequence("CGACGTAGATGCTAGCTGACTCGATGC")
>>> app = RNAfoldApp(sequence)
>>> app.start()
>>> app.join()
>>> print(app.get_dot_bracket())
(((.((((.......)).)))))....
get_exit_code()

Get the exit code of the process.

PROTECTED: Do not call from outside.

Returns
codeint

The exit code.

get_free_energy()

Get the free energy (kcal/mol) of the suggested secondary structure.

Returns
free_energyfloat

The free energy.

Examples

>>> sequence = NucleotideSequence("CGACGTAGATGCTAGCTGACTCGATGC")
>>> app = RNAfoldApp(sequence)
>>> app.start()
>>> app.join()
>>> print(app.get_free_energy())
-1.3
get_mfe()

Get the free energy (kcal/mol) of the suggested secondary structure.

DEPRECATED: Use get_free_energy() instead.

Returns
mfefloat

The minimum free energy.

get_process()

Get the Popen instance.

PROTECTED: Do not call from outside.

Returns
processPopen

The Popen instance

get_stderr()

Get the STDERR pipe content of the process.

PROTECTED: Do not call from outside.

Returns
stdoutstr

The standard error.

get_stdout()

Get the STDOUT pipe content of the process.

PROTECTED: Do not call from outside.

Returns
stdoutstr

The standard output.

is_finished()

Check if the application has finished.

PROTECTED: Override when inheriting.

Returns
finishedbool

True of the application has finished, false otherwise

join(timeout=None)

Conclude the application run and set its state to JOINED. This can only be done from the RUNNING or FINISHED state.

If the application is FINISHED the joining process happens immediately, if otherwise the application is RUNNING, this method waits until the application is FINISHED.

Parameters
timeoutfloat, optional

If this parameter is specified, the Application only waits for finishing until this value (in seconds) runs out. After this time is exceeded a TimeoutError is raised and the application is cancelled.

Raises
TimeoutError

If the joining process exceeds the timeout value.

run()

Commence the application run. Called in start().

PROTECTED: Override when inheriting.

set_arguments(arguments)

Set command line arguments for the application run.

PROTECTED: Do not call from outside.

Parameters
argumentslist of str

A list of strings representing the command line options.

set_constraints(pairs=None, paired=None, unpaired=None, downstream=None, upstream=None, enforce=False)

Add constraints of known paired or unpaired bases to the folding algorithm.

Constraints forbid pairs conflicting with the respective constraint.

Parameters
pairsndarray, shape=(n,2), dtype=int, optional

Positions of constrained base pairs.

pairedndarray, shape=(n,), dtype=int or dtype=bool, optional

Positions of bases that are paired with any other base.

unpairedndarray, shape=(n,), dtype=int or dtype=bool, optional

Positions of bases that are unpaired.

downstreamndarray, shape=(n,), dtype=int or dtype=bool, optional

Positions of bases that are paired with any downstream base.

upstreamndarray, shape=(n,), dtype=int or dtype=bool, optional

Positions of bases that are paired with any upstream base.

enforcebool, optional

If set to true, the given constraints are enforced, i.e. a the respective base pairs must form. By default (false), a constraint does only forbid formation of a pair that would conflict with this constraint.

set_exec_dir(exec_dir)

Set the directory where the application should be executed. If not set, it will be executed in the working directory at the time the application was created.

PROTECTED: Do not call from outside.

Parameters
exec_dirstr

The execution directory.

set_stdin(file)

Set a file as standard input for the application run.

PROTECTED: Do not call from outside.

Parameters
filefile object

The file for the standard input. Must have a valid file descriptor, e.g. file-like objects such as StringIO are invalid.

set_temperature(temperature)

Adjust the energy parameters according to a temperature in degrees Celsius.

Parameters
temperatureint

The temperature.

start()

Start the application run and set its state to RUNNING. This can only be done from the CREATED state.

wait_interval()

The time interval of is_finished() calls in the joining process.

PROTECTED: Override when inheriting.

Returns
intervalfloat

Time (in seconds) between calls of is_finished() in join()