Module content

RNAsketch.py: A small module containing all the important helpers and functions for all major RNAdesign operations.

RNAsketch.adaptive_walk_fixed(dg, design, objective_function=<function calculate_objective>, number=1000, mode='sample_clocal', avoid_motifs=None, white_positions=None, progress=False)[source]

Takes a Design object and does a adaptive walk optimization with a fixed amount of move steps.

Parameters:
  • dg – RNAdesign DependencyGraph object
  • design – Design object containing the sequence and structures
  • objective_functions – array of functions which takes a design object and returns a score for evaluation
  • number – Number of sampling new sequences before stoping the optimization
  • mode – String defining the sampling mode: sample, sample_clocal, sample_plocal
  • avoid_motifs – list of regex pattern specifiying sequence motifs to avoid
  • white_positions – list of [start, end] positions in the sequence where the avoid_motifs pattern should be ignored
  • progress – Whether or not to print the progress to the console
Returns:

Optimization score reached for the final sequence

Returns:

Number of samples neccessary to reach this result

RNAsketch.adaptive_walk_optimization(dg, design, objective_function=<function calculate_objective>, stop=1000, mode='sample', avoid_motifs=None, white_positions=None, progress=False)[source]

Takes a Design object and does a adaptive walk optimization of this sequence.

Parameters:
  • dg – RNAdesign DependencyGraph object
  • design – Design object containing the sequence and structures
  • objective_functions – array of functions which takes a design object and returns a score for evaluation
  • stop – Number of unsuccessful new sequences before stoping the optimization
  • mode – String defining the sampling mode: sample, sample_clocal, sample_plocal
  • avoid_motifs – list of regex pattern specifiying sequence motifs to avoid
  • white_positions – list of [start, end] positions in the sequence where the avoid_motifs pattern should be ignored
  • progress – Whether or not to print the progress to the console
Returns:

Optimization score reached for the final sequence

Returns:

Number of samples neccessary to reach this result

RNAsketch.calculate_objective(design, weight=0.5)[source]

Calculates the objective function given a Design object containing the designed sequence and input structures. objective function (3 seqs): (eos(1)+eos(2)+eos(3) - 3 * gibbs) / number_of_structures + weight * (eos(1)-eos(2))^2 + (eos(1)-eos(3))^2 + (eos(2)-eos(3))^2) * 2 / (number_of_structures * (number_of_structures-1))

Parameters:
  • design (Object of type Design) – Design object containing the sequence and structures
  • weight (float) – To wheight the influence of the eos diffences
Returns:

score calculated by the objective function

RNAsketch.calculate_objective_1(design)[source]

Calculates the objective function given a Design object containing the designed sequence and input structures. objective function (3 seqs): (eos(1)+eos(2)+eos(3) - 3 * gibbs) / number_of_structures

Parameters:design (Object of type Design) – Design object containing the sequence and structures
Returns:score calculated by the objective function
RNAsketch.calculate_objective_2(design)[source]

Calculates the objective function given a Design object containing the designed sequence and input structures. objective function (3 seqs): abs(eos(1)-eos(2)) + abs(eos(1)-eos(3)) + abs(eos(2)-eos(3))) * 2 / (number_of_structures * (number_of_structures-1))

Parameters:design – Design object containing the sequence and structures
Returns:score calculated by the objective function
RNAsketch.calculate_objective_2_squared(design)[source]

Calculates the objective function given a Design object containing the designed sequence and input structures. objective function (3 seqs): (eos(1)-eos(2))^2 + (eos(1)-eos(3))^2 + (eos(2)-eos(3))^2) * 2 / (number_of_structures * (number_of_structures-1))

Parameters:design – Design object containing the sequence and structures
Returns:score calculated by the objective function
RNAsketch.constraint_generation_optimization(dg, design, objective_function=<function calculate_objective>, stop=1000, mode='sample', num_neg_constraints=100, max_eos_diff=0, avoid_motifs=None, white_positions=None, progress=False)[source]

Takes a Design object and does a constraint generation optimization of this sequence.

Parameters:
  • dg – RNAdesign DependencyGraph object
  • design – Design object containing the sequence and structures
  • objective_functions – array of functions which takes a design object and returns a score for evaluation
  • stop – Number of unsuccessful new sequences before stoping the optimization
  • mode – String defining the sampling mode: sample, sample_clocal, sample_plocal
  • num_neg_constraints – Maximal number of negative constraints to accumulate during the optimization process
  • max_eos_diff – Maximal difference between eos of the negative and positive constraints
  • avoid_motifs – list of regex pattern specifiying sequence motifs to avoid
  • white_positions – list of [start, end] positions in the sequence where the avoid_motifs pattern should be ignored
  • progress – Whether or not to print the progress to the console
Returns:

Optimization score reached for the final sequence

Returns:

Number of samples neccessary to reach this result

RNAsketch.get_graph_properties(dg)[source]

Takes a RNAdesign DependencyGraph Object and constructs a dicionary with all the calculated properties.

Parameters:dg – RNAdesign DependencyGraph object
Returns:properties - Dictionary containing all the graph properties
RNAsketch.read_inp_file(filename)[source]

Reads a file in .inp format and returns all neccessary information

Parameters:filename – Filename of the file to read
Returns:structures - List of structures in dot-bracket notation
Returns:constraint - Sequence constraint
Returns:sequence - Start sequence
RNAsketch.read_input(content)[source]

Reads some input and returns all neccessary information in the right container. Input is a string, lines separated by linebreaks. Content might be structures, a sequence constraint and a start sequence

Parameters:filename – Filename of the file to read
Returns:structures - List of structures in dot-bracket notation
Returns:constraint - Sequence constraint
Returns:sequence - Start sequence
RNAsketch.read_input_additions(content)[source]

Reads some input and returns all neccessary information in the right container. Input is a string, lines separated by linebreaks. Content might be structures, a sequence constraint and a start sequence. Additional information for the structural states can be provided with any separator ;,: or whitespaces after the structure.

Parameters:filename – Filename of the file to read
Returns:structures - List of structures in dot-bracket notation
Returns:constraint - Sequence constraint
Returns:sequence - Start sequence
Returns:additions - List of additional information after the structures
RNAsketch.sample_count_unique_solutions(solution_space_size, sample_size)[source]

Calculates the expectancy value of how many time it is necessary to draw a solution to gain a unique set of solutions with the given sample size

Parameters:
  • solution_space_size – The size of the complete solutions space to draw from
  • sample_size – The size of the requested unique set
Returns:

Expectancy value of how many times to draw from the solution space to gain this unique set

RNAsketch.sample_sequence(dg, design, mode, sample_steps=1, avoid_motifs=None, white_positions=None)[source]

This function samples a sequence with the given mode from the dependency graph object and writes it into the design object

Parameters:
  • dg – RNAdesign dependency graph object
  • design – design object
  • mode – mode how to sample, this is a string
  • sample_steps – count how many times to do the sample operation
  • avoid_motifs – list of regex pattern specifiying sequence motifs to avoid
  • white_positions – list of [start, end] positions in the sequence where the avoid_motifs pattern should be ignored
Returns:

mut_nos is the solution space we drew from

Returns:

sample_count is how many times we sampled a solution from the dependency graph object (important for revert later)

RNAsketch.simulated_annealing_optimization(dg, design, objective_function=<function calculate_objective>, temperature_gradient=None, cooling_step=50, mode='sample', avoid_motifs=None, white_positions=None, progress=False)[source]

Takes a Design object and does a simulated annealing optimization of this sequence.

Parameters:
  • dg – RNAdesign DependencyGraph object
  • design – Design object containing the sequence and structures
  • objective_functions – array of functions which takes a design object and returns a score for evaluation
  • temperature_gradient – Iterable containing the temperatures in descend order
  • cooling_steps – Use the current temperature that many times before cooling down
  • mode – String defining the sampling mode: sample, sample_clocal, sample_plocal
  • avoid_motifs – list of regex pattern specifiying sequence motifs to avoid
  • white_positions – list of [start, end] positions in the sequence where the avoid_motifs pattern should be ignored
  • progress – Whether or not to print the progress to the console
Returns:

Optimization score reached for the final sequence

Returns:

Number of samples neccessary to reach this result