Python API Reference

What’s the idea?

PyFuRNAce is inspired by the ROAD RNA origami software (Geary et al., Nat. Chem., 2021), which uses text-based RNA diagrams for RNA nanostructures design.

To facilitate the design of RNA nanostructures, pyFuRNAce aims to provide a simple and flexible Python package for creating, manipulating, and visualizing RNA with text-based diagrams.

The approach of pyFuRNAce is to hierarchically build RNA nanostructures from simple building blocks: strands and motifs.

Therefore, there are three main classes:

  1. Strand A strand is simply a string of ASCII characters, which contains nucleotides (e.g., AUCG) and/or characters to route the strands on the page (e.g., -/\|). If we imagine drawing a strand on a page, each symbol has an (x, y) position. In pyFuRNAce, each character position is calculated automatically, as the strand is defined by:

    • strand characters (e.g., A-UCG|CC—)

    • start position (e.g., (0, 0))

    • start direction (e.g., pf.RIGHT)

    • directionality of the sequence (e.g., '53'; optional)

    A Strand can also have 3D coordinates associated with the sequence, allowing the assembly of 3D models in real time.

  2. Motif The motif is the building block of the RNA origami, exploiting the vast library of RNA aptamers. In pyFuRNAce, a Motif is simply a collection of strands which can have base pairs. The base pairs define the secondary structure of the motifs. Internally, base pairs are represented as strand–position pairs in a dictionary. In the Python API, the secondary structure can be set and obtained in the more common dot-bracket notation. In summary, a motif is made of:

    • strands (e.g., [Strand('CCAGG'), Strand('CCGGG', start=(4, 0), direction=pf.LEFT)])

    • structure (e.g., "((.((&)).))")

    A large library of pre-defined motifs and aptamers is provided in pyFuRNAce.

  3. Origami The origami is the final RNA nanostructure. In pyFuRNAce, an Origami is simply a collection of motifs in a grid. The Origami concatenates motifs horizontally (in rows) and vertically, automatically joining the vertical junctions. In principle, any RNA nanostructure can be represented as an origami:

    • motifs (e.g., [[pf.TetraLoop(), pf.Stem(10), pf.Dovetail(-1)], [pf.KissingLoop180(), pf.Stem(8), pf.Dovetail(-2)]])

When your nanostructure blueprint is ready, pyFuRNAce provides functions to optimize the RNA sequence (in the generate subpackage), design PCR primers, or set up oxDNA simulations (prepare subpackage).

Examples of how to use the pyFuRNAce API are available in the Tutorials section.

Design Core Objects

Strand

class pyfurnace.design.core.strand.Strand(strand='', directionality='53', start=None, direction=None, coords=None, strands_block=None, **kwargs)[source]

Bases: Callback

Represents a single RNA strand in a hybrid 1D/2D/3D representation.

Parameters:
strandstr, optional

The strand text characters (default is empty).

directionality{‘53’, ‘35’}, optional

The directionality of the strand (default is ‘53’).

startPosition, optional

The starting position of the strand in 2D space (default is Position.zero()). If set to ‘minimal’, the start position is calculated as the minimal start position required to draw the strand in 2D to avoid negative coordinates.

directionDirection, optional

The initial direction of the strand in 2D space (default is Direction.RIGHT).

coordsCoords, optional

The 3D coordinates for the strand (if not provided, they will be calculated).

strands_blockStrandsBlock, optional

The block of strands to which the strand belongs.

**kwargsdict

Arbitrary keyword arguments passed to the Callback class.

Attributes:
coordsCoords

The oxDNA 3D coordinates of the strand.

directionDirection

The starting (x, y) 2D direction to build the strand in 2D.

directionalitystr

The directionality of the sequence (‘53’ or ‘35’)

directionsTuple[Direction]

A tuple of the directions of each character of the strand in 2D space (x,y coordinates).

endPosition

The last position of the strand: it is the last element of the positions.

end_directionDirection

The last direction of the strand.

max_posPosition

The maximum x, y coordinates of the strand in 2D space.

min_posPosition

The minimum x, y coordinates of the strand in 2D space.

minimal_dimensionsPosition

The minimum start Positions required to draw the strand in 2D without reaching negative positions.

next_posPosition

The next position of the strand: it is the last position plus the end_direction.

pk_infoOptional[dict]

The pseudoknot information of the strand (if any).

positionsTuple[Position]

A tuple of the positions of each character of the strand in 2D space (x,y coordinates).

prec_posPosition

The preceding position of the strand: it is the start position minus the direction.

seq_positionsTuple[Position]

The positions of each nucleotide in the strand sequence (x,y coordinates).

sequenceSequence

The complete sequence of the strand.

sequence_listList[Sequence]

The list of consecutive sequences in the strand.

sequence_sliceList[slice]

The list of slices of the sequence in the strand.

startPosition

Start position of the strand in the 2D representation.

strandstr

The strand text characters.

strands_blockStrandsBlock

The block of strands that has locked 3D coordinates transformation (their relative position in the 3D space doesn’t change when joined to other strands).

Methods

copy([callback])

Create a copy of the current strand, including coordinates and attributes.

draw([canvas, return_string, plane])

Draw the strand in 2D space using a canvas.

extend(direction[, until, check])

Extend the strand in the specified direction by a given length.

flip([horizontally, vertically, flip_start])

Flip the 2D structure of the strand.

from_json(json_data)

Create a Strand object from a JSON dictionary.

from_json_file(file_path)

Create a Strand object from a JSON file.

get_base_at_pos(pos)

Get the base at the specified 2D position in the strand.

get_char_at_pos(pos)

Get the character at the specified 2D position in the strand.

get_position_map()

Get a dictionary of positions as keys and the corresponding characters as values.

insert(idx, val)

Insert a character into the strand at the specified index.

invert()

Invert the start and end positions of the strand, effectively reversing the sequence directionalty and 3D coordinates orientation.

join(other[, trigger_callbacks])

Join this strand with another strand, aligning their start and end positions and direction.

join_strands(strand1, strand2)

Join two strands together if they match in the right direction and have a compatible directionality.

pop(idx)

Remove and return a character from the strand at the specified index.

register_callback(callback)

Register a new callback function to be executed when an event occurs.

reverse()

Reverse the directionality of the strand sequence (5' to 3' becomes 3' to 5' and vice versa).

save_3d_model([filename, return_text, pdb, ...])

Save the 3D structure of the strand in oxDNA format (.dat, .top) and optionally as PDB.

save_json([filename, return_data])

Save the Strand instance to a JSON file.

shift(shift_position[, check])

Shift the strand position in the 2D layout.

to_json()

Serialize the Strand instance to a JSON-compatible dictionary.

transform(transformation_matrix)

Apply a transformation matrix to the strand's 3D coordinates.

property coords: Coords

The oxDNA 3D coordinates of the strand. If the coordinates are not set, they are calculated for a strand in a perfect helix with the same length of the strand.

copy(callback=None)[source]

Create a copy of the current strand, including coordinates and attributes.

Return type:

Strand

Parameters:
callbackcallable, default None

A callback function to be registered in the copied strand.

Returns:
Strand

A deep copy of the strand.

property direction: Direction

The starting (x, y) 2D direction to build the strand in 2D.

property directionality: Literal['53', '35']

The directionality of the sequence (‘53’ or ‘35’)

property directions: Tuple[Direction]

A tuple of the directions of each character of the strand in 2D space (x,y coordinates).

draw(canvas=None, return_string=True, plane=0)[source]

Draw the strand in 2D space using a canvas. The canvas is a list of strings, where each string is a line of the canvas. The strand is drawn using the characters and positions of the strand.

Return type:

Optional[str]

Parameters:
canvaslist, default None

The canvas to draw the strand on. If None, a new canvas is created.

return_stringbool, default True

If True, return the drawn canvas as a string (for printing).

planeint, default 0

The plane to draw the strand on (experimental). If 0, the strand is drawn in the default plane.

Returns:
str or None

The drawn canvas as a string if return_string is True, otherwise None.

Raises:
MotifStructureError

If the canvas is not large enough to draw the strand or a position is trying to overwrite a symbol in the canvas.

property end: Position

The last position of the strand: it is the last element of the positions.

property end_direction: Direction

The last direction of the strand.

extend(direction, until=None, check=True)[source]

Extend the strand in the specified direction by a given length.

Return type:

None

Parameters:
directionUnion[Position, Tuple[int, int]], default (1, 0)

The direction to extend the strand in. It can be a Position object or a tuple of (x, y) coordinates. It must contain coordinates that are either 1, -1 or 0, where 0 is the coordinate that does not change.

untilUnion[Position, Tuple[int, int]], default None

The position until which to extend the strand. If None, the strand is extended until the origin position (0, 0).

checkbool, default True

If True, check the direction and until position for validity.

flip(horizontally=True, vertically=False, flip_start=True)[source]

Flip the 2D structure of the strand. This affects the orientation on the canvas but does not revert the sequence.

Return type:

None

Parameters:
horizontallybool, default=True

Whether to flip the strand horizontally (mirror along the y-axis).

verticallybool, default=False

Whether to flip the strand vertically (mirror along the x-axis).

flip_startbool, default=True

Whether to also flip the starting point of the strand.

classmethod from_json(json_data)[source]

Create a Strand object from a JSON dictionary. The json dictionary is parsed, and is consumed to create the Motif object.

Return type:

Strand

Parameters:
json_dataDict[str, Any]

The JSON dictionary containing the strand attributes.

Returns:
Strand

The created Strand object.

classmethod from_json_file(file_path)[source]

Create a Strand object from a JSON file.

Return type:

Strand

Parameters:
file_pathUnion[str, Path]

The path to the JSON file containing the strand attributes.

Returns:
Strand

The created Strand object.

get_base_at_pos(pos)[source]

Get the base at the specified 2D position in the strand.

Return type:

str

Parameters:
posPosition or tuple of int

The position to get the base from.

Returns:
str

The base at the specified position.

get_char_at_pos(pos)[source]

Get the character at the specified 2D position in the strand.

Return type:

str

Parameters:
posPosition or tuple of int

The position to get the character from.

Returns:
str

The character at the specified position.

get_position_map()[source]

Get a dictionary of positions as keys and the corresponding characters as values.

Return type:

Dict[Tuple[int, int], str]

Returns:
Dict[Tuple[int, int], str]

A dictionary mapping positions to characters.

insert(idx, val)[source]

Insert a character into the strand at the specified index.

Return type:

None

Parameters:
idxint

The index at which to insert the character.

valstr

The character(s) to insert into the strand.

invert()[source]

Invert the start and end positions of the strand, effectively reversing the sequence directionalty and 3D coordinates orientation.

Return type:

Strand

Returns:
Strand

The updated strand instance.

join(other, trigger_callbacks=True)[source]

Join this strand with another strand, aligning their start and end positions and direction. This behaves like the @staticmethod join_strands, but it modifies the current strand instead of creating a new one. Check the join_strands method for more details.

Return type:

Optional[Strand]

Parameters:
otherStrand

The other strand to join.

trigger_callbacksbool, default True

If True, trigger the callbacks after joining the strands.

Returns:
Strand or None

The joined strand, or None if the strands cannot be joined.

static join_strands(strand1, strand2)[source]

Join two strands together if they match in the right direction and have a compatible directionality. This also combines the pseudoknot information and the 3D coordinates of the strands (transforming the coordinates of the second strand to match the first strand extension). The directionality of the combined strand is taken from the first strand if it has a sequence, otherwise it is taken from the second strand. The callbacks of the first strand are used for the new strand. The strands block of the joined strand includes the strands blocks of both strands.

Return type:

Optional[Strand]

Parameters:
strand1Strand

The first strand to join.

strand2Strand

The second strand to join.

Returns:
Optional[Strand]

The joined strand if possible, otherwise None.

property max_pos: Position

The maximum x, y coordinates of the strand in 2D space.

property min_pos: Position

The minimum x, y coordinates of the strand in 2D space.

property minimal_dimensions: Position

The minimum start Positions required to draw the strand in 2D without reaching negative positions. Calculating the minimal dimensions doesn’t take into acount structural errors.

property next_pos: Position

The next position of the strand: it is the last position plus the end_direction. Useful for joining two strands.

pop(idx)[source]

Remove and return a character from the strand at the specified index.

Return type:

str

Parameters:
idxint

The index of the character to remove.

Returns:
str

The removed character.

property positions: Tuple[Position]

A tuple of the positions of each character of the strand in 2D space (x,y coordinates).

property prec_pos: Position

The preceding position of the strand: it is the start position minus the direction. Useful for joining two strands.

reverse()[source]

Reverse the directionality of the strand sequence (5’ to 3’ becomes 3’ to 5’ and vice versa).

Return type:

Strand

Returns:
Strand

The updated strand instance.

save_3d_model(filename='strand', return_text=False, pdb=False, box_size=(1000.0, 1000.0, 1000.0), **kwargs)[source]

Save the 3D structure of the strand in oxDNA format (.dat, .top) and optionally as PDB.

Return type:

Optional[Tuple[str, str]]

Parameters:
filenamestr, default=’strand’

The base name for the output files.

return_textbool, default=False

If True, returns the configuration and topology text instead of saving to file (used for real-time visualization).

pdbbool, default=False

If True, exports the structure as a PDB file (requires oxDNA_analysis_tools).

box_sizeIterable of float, default=(1000.0, 1000.0, 1000.0)

The dimensions of the simulation box (x, y, z) in oxDNA simulation units.

**kwargsdict

Additional keyword arguments passed to the PDB export.

Returns:
tuple of str or None

Returns (conf_text, top_text) if return_text is True, otherwise None.

save_json(filename='Strand', return_data=False)[source]

Save the Strand instance to a JSON file.

Return type:

Optional[Dict[str, Any]]

Parameters:
filenamestr, default ‘Strand’

The name of the JSON file to save the strand to.

return_databool, default False

If True, return the JSON data as a dictionary instead of saving to file.

Returns:
Dict[str, Any] or None

The JSON data as a dictionary if return_data is True, otherwise None.

property seq_positions: Tuple[Position]

The positions of each nucleotide in the strand sequence (x,y coordinates).

property sequence: Sequence

The complete sequence of the strand.

property sequence_list: List[Sequence]

The list of consecutive sequences in the strand.

property sequence_slice: List[slice]

The list of slices of the sequence in the strand.

shift(shift_position, check=True)[source]

Shift the strand position in the 2D layout.

Return type:

Strand

Parameters:
shift_positionPosition or Direction or tuple of int

The shift to apply in x and y direction.

checkbool, default True

If True, check if the shift is valid (i.e. not negative coordinates).

Returns:
Strand

The updated strand instance.

property start

Start position of the strand in the 2D representation.

property strand: str

The strand text characters.

property strands_block: StrandsBlock

The block of strands that has locked 3D coordinates transformation (their relative position in the 3D space doesn’t change when joined to other strands).

to_json()[source]

Serialize the Strand instance to a JSON-compatible dictionary.

Return type:

Dict[str, Any]

Returns:
Dict[str, Any]

A dictionary representation of the Strand instance.

transform(transformation_matrix)[source]

Apply a transformation matrix to the strand’s 3D coordinates. Check the Coords class for the transformation matrix format.

Return type:

None

Parameters:
transformation_matrixarray-like

The transformation matrix to apply.

class pyfurnace.design.core.strand.StrandsBlock(*args)[source]

Bases: set

A container class that holds a collection of Strand instances.

This class inherits from Python’s built-in list and is designed to manage a group of Strand objects. It provides methods for adding, removing, joining, and transforming strands in the block. All the strands in the block have locked 3D coordinates respect to each other. This means that when a strand in the block is transformed, all the other strands in the block are transformed as well with the same transformation matrix. This is foundamental for managing 3D structures of motifs.

Parameters:
*argsStrand

Strand instances to be added to the block.

**kwargsAny

Additional keyword arguments passed to the list constructor.

Attributes:
itemslist

The list of Strand instances stored in the block.

Methods

add(item)

Append a Strand instance to the StrandsBlock.

clear

Remove all elements from this set.

copy

Return a shallow copy of a set.

difference

Return the difference of two or more sets as a new set.

difference_update

Remove all elements of another set from this set.

discard

Remove an element from a set if it is a member.

intersection

Return the intersection of two sets as a new set.

intersection_update

Update a set with the intersection of itself and another.

isdisjoint

Return True if two sets have a null intersection.

issubset

Report whether another set contains this set.

issuperset

Report whether this set contains another set.

pop

Remove and return an arbitrary set element.

remove(item)

Remove a Strand instance from the StrandsBlock.

symmetric_difference

Return the symmetric difference of two sets as a new set.

symmetric_difference_update

Update a set with the symmetric difference of itself and another.

transform(T)

Apply a transformation matrix to all the strands in the StrandsBlock.

union

Return the union of sets as a new set.

update(*others[, avoid_strands])

Update the strands block with the strands in the input iterable.

add(item)[source]

Append a Strand instance to the StrandsBlock.

Return type:

None

Parameters:
itemStrand

The Strand instance to append.

Raises:
ValueError

If the item is not an instance of Strand.

remove(item)[source]

Remove a Strand instance from the StrandsBlock.

Return type:

None

Parameters:
itemStrand

The Strand instance to remove.

Raises:
ValueError

If the item is not an instance of Strand.

transform(T)[source]

Apply a transformation matrix to all the strands in the StrandsBlock. For the transformation matrix format, check the Coords class and its transform method.

Return type:

None

Parameters:
Tnp.ndarray

The transformation matrix to apply to each strand.

Notes

This method assumes that the transformation matrix is compatible with the strand’s coordinate system.

update(*others, avoid_strands=None)[source]

Update the strands block with the strands in the input iterable. This method is similar to the add method, but it allows for adding multiple strands at once. It also allows for avoiding specific strands in the update process.

Return type:

None

Parameters:
*otherStrandsBlock

The StrandsBlock instances to update with.

avoid_strandsset of Strand, default None

A set of strands to avoid in the update process.

Raises
ValueError

If any of the input arguments is not a StrandsBlock, or if avoid_strand is not a Strand.

Motif

class pyfurnace.design.core.motif.Motif(*strands, basepair=None, structure=None, autopairing=True, lock_coords=True, join=True, copy=False, **kwargs)[source]

Bases: Callback

Represents a structural motif in an RNA Origami design.

A Motif is composed of multiple Strand objects, defining an RNA secondary structure with base pair interactions. It supports coordinate locking, strand joining, sequence assignment, and 2D motif visualization.

Parameters:
*strandslist of Strand, optional

A list of Strand objects to initialize the motif.

basepairBasePair, dict, optional

A dictionary defining base pair connections, with Position objects as keys and values representing paired positions.

structurestr, optional

A dot-bracket notation representation of the motif’s structure. If this is provided, the basepair parameter is ignored.

autopairingbool, default True

If True, automatically pairs bases based on complementary interactions. If a basepair or structure is given, autopairing is turned off.

lock_coordsbool, default True

If True, locks the coordinate system for all strands in the motif. When a strand coordinate transformed, all other strands are transformed.

joinbool, default True

If True, attempts to merge consecutive strands where possible.

copybool, default False

If True, creates copies of the input strands instead of using references.

**kwargsdict

Additional arguments to pass to the parent Callback class.

Attributes:
autopairingbool

Indicates whether the motif automatically pairs bases.

basepairBasePair

A dictionary with positions as key and the paired position as values.

junctionsdict

A dictionary with Direction as key (right: (1,0), bottom: (0,1), left: (-1,0), top: (0,1)) and an ordered list of junction positon as value.

lock_coordsbool

Boolean indicating if the coordinates are locked in the same block.

max_postuple of int

The maximum x, y coordinates occupied of the motif.

min_postuple of int

The minimum x, y coordinates occupied of the motif.

num_charint

The maximum length of the motif lines.

num_linesint

The number of lines in the motif structure.

pair_mapdict

The dictionary of the paired indexes (alternative to the dot bracket notation).

positionstuple of Position

A tuple of the positions of each character of each strand in 2D space (x,y coordinates).

seq_positionstuple of Position

The positions of each nucleotide in the motif sequence (x,y coordinates).

sequenceSequence

Return the sequence of the motif.

strandslist of Strand

The list of strands in the motif.

structurestr

Return the dot bracket representation of the motif.

Methods

align(*motifs[, axis, extend, ...])

Align motifs along a given axis by shifting them (without concatenating).

append(strand[, join, copy])

Append a strand to the motif.

concat(*motifs[, axis, extend, copy, align, ...])

Concatenate multiple motifs along a specified axis.

copy([callback])

Return a copy of the motif.

copy_strands_preserve_blocks(strands[, motif])

Copy a list of strands while preserving strand blocks.

extend_junctions([skip_axis, ...])

Extend the junctions of the motif in the direction of the junctions.

flip([horizontally, vertically, ...])

Flip the strands of the motif horizontally and/or vertically inplace.

folding_barriers([kl_delay])

Compute the folding barriers for a given RNA secondary structure.

from_file(file_path, **kwargs)

Create a Motif object from a text file containing a motif sketch.

from_json(json_data, **kwargs)

Create a Motif object from a JSON string or dictionary.

from_json_file(file_path, **kwargs)

Create a Motif object from a JSON file.

from_list(motif_list, **kwargs)

Create a Motif object from a list of strings representing a motif sketch.

from_structure([structure, sequence, ...])

Parse a structure or sequence representation to a Motif object.

from_text(motif_text, **kwargs)

Create a Motif object from a text string representing a motif sketch.

get_position_map()

Get a dictionary of positions as keys and the corresponding characters as values.

get_sequential_shift(motifs, *args[, axis, ...])

Calculate the shift needed to align motifs sequentially.

get_strand_index_map()

Get a dictionary of positions as keys and the index of the strand in the motif as values.

insert(index, strand[, join, copy])

Insert a strand at a given index in the motif.

join_strands(strands)

Attempt to join consecutive strands and return the list of joined strands.

pop([index])

Remove and return the strand at the specified index.

register_callback(callback)

Register a new callback function to be executed when an event occurs.

replace_all_strands(strands[, copy, join])

Replace all the strands in the motif with the provided list of strands.

rotate([times])

Rotate the motif 90 degrees clockwise.

save_3d_model([filename, config, topology, ...])

Save the motif 3D structure in a file for structural 3D modeling.

save_fasta([filename])

Save the motif sequences in a FASTA file.

save_json([filename, return_data])

Save the motif representation as a JSON file.

save_text([filename])

Save the motif representation as a text file.

shift(shift_vect[, extend])

Shift the motif of the given shift vector.

sort([key, reverse])

Sort the strands in the motif.

strip([skip_axis])

Remove the empty lines/columns in the motif structure.

to_json()

Convert the Motif instance to a JSON-serializable dictionary.

trace(motif_list, pos, direction, limits)

Trace strands in a motif representation in a recursive manner.

Notes

  • The motif is built from strands and supports strand merging.

  • Base pairs can be set manually or inferred automatically.

  • Supports transformations, file export, and visual representation.

static align(*motifs, axis=1, extend=False, align_junctions=None, align_to='first', return_shifts=False, **kwargs)[source]

Align motifs along a given axis by shifting them (without concatenating).

Return type:

Union[List[Motif], Tuple[List[Motif], List[Tuple[int, int]]]]

Parameters:
*motifsList[Motif]

List of motifs to align.

axisint, default 1

The numpy axis along which motifs are aligned (1 for horizontal, 0 for vertical).

extendbool, default False

If True, junctions are extended to accommodate the shift.

align_junctionsOptional[List[Tuple[int, int]]], default None

List of tuples specifying which junctions to align.

align_tostr, default “first”

Specifies how to align the motifs. Options: “first”, “last”, “center”. “first” aligns the first junction of the first motif with the first junction of the second motif. “last” aligns the last junction of the first motif with the last junction of the second motif. “center” aligns the center of the first motif with the center of the second motif.

return_shiftsbool, default False

If True, returns the shifts applied to each motif during alignment, along with the aligned motifs (useful for Origami alignment). If False, only the aligned motifs are returned.

**kwargsdict

Parse if calling the motifs list explicitly.

Returns:
List[Motif]

The list of aligned motifs.

List[Tuple[int, int]], optional

The list of shifts applied to each motif during alignment. Only returned if return_shifts is True.

append(strand, join=True, copy=False)[source]

Append a strand to the motif.

Return type:

Motif

Parameters:
strandStrand

The strand to be added.

joinbool, default True

Whether to attempt joining the new strand with existing strands.

copybool, default False

If True, a copy of the strand is appended.

Returns:
Motif

The updated motif.

Raises:
ValueError

If the provided strand is not a Strand instance.

property autopairing: bool

Indicates whether the motif automatically pairs bases.

property basepair: BasePair

A dictionary with positions as key and the paired position as values.

classmethod concat(*motifs, axis=1, extend=False, copy=True, align=True, position_based=False, align_junctions=None, unlock_strands=False, return_shifts=False, **kwargs)[source]

Concatenate multiple motifs along a specified axis.

Return type:

Motif

Parameters:
*motifslist of Motif

List of motifs to concatenate.

axisint, default 1

The numpy axis along which motifs are aligned. 1 for horizontal alignment, 0 for vertical alignment.

extendbool, default False

Whether to extend junctions before concatenation.

copybool, default True

Whether to copy motifs before concatenation.

alignbool, default True

Whether to align motifs before concatenation.

position_basedbool, default False

Whether to align motifs based on positions instead of junctions.

align_junctionslist of tuple, optional

List of junction indices for alignment.

unlock_strandsbool, default False

Whether to unlock all strands, so they are not part of the same Strand block (different coordinate systems).

return_shiftsbool, default False

Whether to return the shift values for each motif to be aligned and concatenated. If True, a list of tuples with the shifts is returned, along with the concatenated motif (useful for Origami alignment).

**kwargsdict

Additional arguments to pass to the Motif constructor.

Returns:
Motif

The concatenated Motif object.

List[Tuple[int, int]], optional

The list of shifts applied to each motif during alignment. Only returned if return_shifts is True.

copy(callback=None, **kwargs)[source]

Return a copy of the motif.

This method creates a custom deep copy of the current motif, preserving its strand arrangements, base pairings, and additional attributes.

Return type:

Motif

Parameters:
callbackcallable, default None

A callback function to be registered in the copied motif.

**kwargsdict

If the keyword ‘deepcopy’ with a list of attributes names is passed, the attributes will deepcopyed instead referenced. Same for the keyword ‘copy’ with a list of attributes names.

Returns:
Motif or subclass

A new instance of the motif or its subclass, with the same properties and attributes as the original.

static copy_strands_preserve_blocks(strands, motif=None)[source]

Copy a list of strands while preserving strand blocks. Ensures that strands that belong to the same motif remain linked together.

Return type:

List[Strand]

Parameters:
strandslist of Strand

The list of strands to be copied.

motifMotif, optional

If provided, associates the strands with the given motif and registers callback functions.

Returns:
list of Strand

A list of copied strands.

extend_junctions(skip_axis=None, skip_directions=None, until=None)[source]

Extend the junctions of the motif in the direction of the junctions. Unless the skip_axis is specified, the junctions are extended in all directions. The until parameter allows to specify the position until which to extend the junctions in the positive direction.

Return type:

Motif

Parameters:
skip_axis: int, optional

The numpy axis to skip when extending the junctions (1 for horizontal, 0 for vertical).

skip_directions: List[Direction], optional

The list of directions to skip when extending the junctions.

untilPosition, optional

The position until which to extend the junctions If None, extend until the end of the motif in all directions (to the origin and to the maximum position).

Returns:
Motif

The motif with the extended junctions.

Raises:
ValueError

If the axis parameter is not None, 0 or 1.

MotifStructureError

If there is an error in extending the junction

flip(horizontally=True, vertically=True, strand_index=None, reorder=False)[source]

Flip the strands of the motif horizontally and/or vertically inplace.

Return type:

Motif

Parameters:
horizontallybool, default True

If True, flip the strands horizontally.

verticallybool, default True

If True, flip the strands vertically.

strand_indexlist, default None

The list of indices of the strands to flip. If None, all the strands are flipped.

reorderbool, default False

If True, reorder the strands after flipping, so that the first strand is the one with the 5’ end, then the strand with the lowest y start position, and finally the strand with the lowest x start position.

Returns:
Motif

The motif with the flipped strands.

folding_barriers(kl_delay=150)

Compute the folding barriers for a given RNA secondary structure. This function is based on ROAD: https://www.nature.com/articles/s41557-021-00679-1 This function analyzes the dot-bracket representation of the RNA secondary structure to determine folding barriers based on base pair topology and kinetic delay.

Return type:

Tuple[str, int]

Parameters:
structurestr

The dot-bracket notation representing the secondary structure of the RNA. If folding barriers is called from a Motif or Origami, the structure is already provided by the object in the dot-bracket format.

kl_delayint, optional, default=150

The number of nucleotides (nts) of delay before kissing loops (KLs) snap closed. A typical realistic value is around 350 (~1 second), while a more conservative setting is 150 by default.

Returns:
Tuple[str, int]

A tuple containing: - A string representing the barrier map where: ‘─’ = no barrier (0 penalty), ‘▂’ = opening pair weak barrier (1 penalty), ‘▄’ = cloding pair weak barrier (1 penalty), ‘█’ = strong barrier (2 penalty). - An integer score indicating the total penalty based on barrier strengths.

Notes

The function assigns barrier strengths based on the topology of base pairs and kinetic constraints, ensuring proper folding predictions.

classmethod from_file(file_path, **kwargs)[source]

Create a Motif object from a text file containing a motif sketch. Each Strand is read starting from the 5 symbol. If you want to add the 5’ terminal symbol, start the strand with 55. Only one symbol should be placed next to the 5 start of the strand in order to guess the right direction. Alternatively, you can use symbols ^v>< to start a strand and indicate the start direction (up, down, right, left); in this case you can place multiple symbols next to the start symbol.

Return type:

Motif

Parameters:
file_pathstr

Path to the file containing the motif structure.

**kwargsdict

Additional arguments to pass to the Motif constructor.

Returns:
Motif

The constructed Motif object.

classmethod from_json(json_data, **kwargs)[source]

Create a Motif object from a JSON string or dictionary. The json dictionary is parsed, and is consumed to create the Motif object.

Return type:

Motif

Parameters:
json_datastr or dict

The JSON string or dictionary representing the motif.

**kwargsdict

Additional arguments to pass to the Motif constructor.

Returns:
Motif

The constructed Motif object.

classmethod from_json_file(file_path, **kwargs)[source]

Create a Motif object from a JSON file.

Return type:

Motif

Parameters:
file_pathstr

Path to the JSON file representing the motif.

**kwargsdict

Additional arguments to pass to the Motif constructor.

Returns:
Motif

The constructed Motif object.

classmethod from_list(motif_list, **kwargs)[source]

Create a Motif object from a list of strings representing a motif sketch. Each Strand is read starting from the 5 symbol. If you want to add the 5’ terminal symbol, start the strand with 55. Only one symbol should be placed next to the 5 start of the strand in order to guess the right direction. Alternatively, you can use symbols ^v>< to start a strand and indicate the start direction (up, down, right, left); in this case you can place multiple symbols next to the start symbol.

Return type:

Motif

Parameters:
motif_listlist of str

The list of strings representing the motif.

**kwargsdict

Additional arguments to pass to the Motif constructor.

Returns:
Motif

The constructed Motif object.

classmethod from_structure(structure=None, sequence=None, pk_energy=-8.5, pk_denergy=0.5, **kwargs)[source]

Parse a structure or sequence representation to a Motif object. If a structure is not provided, it is calculated from the sequence with RNAfold. If a sequence is not provided, it is assumed to be a sequence of ‘N’s of the same length as the structure.

Return type:

Motif

Parameters:
structureUnion[str, dict, BasePair, Node]

The structure representation to convert.

sequencestr, optional

The sequence or sequence constraints of the motif.

pk_energyfloat, optional

The energy of the pseudoknots (if present).

pk_denergyfloat, optional

The energy tolerance of the pseudoknots (if present).

**kwargsdict

Additional arguments to pass to the Motif constructor.

Returns:
Motif

The Motif object created from the structure representation.

classmethod from_text(motif_text, **kwargs)[source]

Create a Motif object from a text string representing a motif sketch. Each Strand is read starting from the 5 symbol. If you want to add the 5’ terminal symbol, start the strand with 55. Only one symbol should be placed next to the 5 start of the strand in order to guess the right direction. Alternatively, you can use symbols ^v>< to start a strand and indicate the start direction (up, down, right, left); in this case you can place multiple symbols next to the start symbol.

Return type:

Motif

Parameters:
motif_textstr

The motif structure in text format.

**kwargsdict

Additional arguments to pass to the Motif constructor.

Returns:
Motif

The constructed Motif object.

get_position_map()[source]

Get a dictionary of positions as keys and the corresponding characters as values.

Return type:

Dict[Tuple[int, int], str]

Returns:
Dict[Tuple[int, int], str]

A dictionary mapping positions to characters.

static get_sequential_shift(motifs, *args, axis=1, position_based=True)[source]

Calculate the shift needed to align motifs sequentially.

Return type:

List[int]

Parameters:
motifsList[Motif]

List of motifs to align.

*args: List[Motif]

Additional motifs to align.

axisint, default 1

The numpy axis along which the shift is computed (1 for horizontal, 0 for vertical).

position_basedbool, default True

If True, the shift is calculated based on motif positions rather than junctions.

Returns:
List[int]

A list of shift integers for each motif along the axis.

Examples

m1:
    --NN--
      ::
    --NN--
m2:
    --SK--
      ::
    --SK--
Resulting shift: 2
    [0, 2]
To have:
    --NN----SK--
      ::    ::
    --NN----SK--
get_strand_index_map()[source]

Get a dictionary of positions as keys and the index of the strand in the motif as values.

Return type:

Dict[Tuple[int, int], int]

Returns:
Dict[Tuple[int, int], int]

A dictionary mapping positions to strand indexes

insert(index, strand, join=True, copy=False)[source]

Insert a strand at a given index in the motif.

Return type:

Motif

Parameters:
indexint

The index at which to insert the strand.

strandStrand

The strand to be inserted.

joinbool, default True

Whether to attempt joining the new strand with existing strands.

copybool, default False

If True, a copy of the strand is inserted.

Returns:
Motif

The updated motif.

Raises:
ValueError

If strand is not a Strand instance.

static join_strands(strands)[source]

Attempt to join consecutive strands and return the list of joined strands.

Return type:

List[Strand]

Parameters:
strandsList[Strand]

The list of strands to be joined.

Returns:
List[Strand]

The list of joined strands.

property junctions: Dict[Tuple[int, int], Tuple[Tuple[int, int]]]

A dictionary with Direction as key (right: (1,0), bottom: (0,1), left: (-1,0), top: (0,1)) and an ordered list of junction positon as value.

property lock_coords: bool

Boolean indicating if the coordinates are locked in the same block.

property max_pos: Tuple[int, int]

The maximum x, y coordinates occupied of the motif.

property min_pos: Tuple[int, int]

The minimum x, y coordinates occupied of the motif.

property num_char: int

The maximum length of the motif lines.

property num_lines: int

The number of lines in the motif structure.

property pair_map: Dict[int, int | None]

The dictionary of the paired indexes (alternative to the dot bracket notation).

pop(index=-1)[source]

Remove and return the strand at the specified index.

Return type:

Strand

Parameters:
indexint, default -1

The index of the strand to remove.

Returns:
Strand

The removed strand.

property positions: Tuple[Position]

A tuple of the positions of each character of each strand in 2D space (x,y coordinates).

replace_all_strands(strands, copy=True, join=False)[source]

Replace all the strands in the motif with the provided list of strands.

Return type:

Motif

Parameters:
strandsList[Strand]

The list of strands to replace the current strands.

copybool, default True

If True, the strands are copied before replacing the current strands.

joinbool, default False

Whether to attempt joining the new strands.

Returns:
Motif

The updated motif.

Raises:
ValueError

If any of the provided strands is not a Strand instance.

rotate(times=1)[source]

Rotate the motif 90 degrees clockwise.

Return type:

Motif

Parameters:
timesint, default 1

The number of times to rotate the motif.

Returns:
Motif

The rotated motif.

save_3d_model(filename='motif', config=True, topology=True, forces=False, pk_forces=False, return_text=False, sequence=None, pdb=False, box_size=(1000.0, 1000.0, 1000.0), **kwargs)[source]

Save the motif 3D structure in a file for structural 3D modeling. This function save the 3D oxDNA motif representation in conformation and topology xoDNA-format files, and optionally in PDB format. It can also save additional force constraints for oxDNA simulation and protein configurations if specified.

Return type:

Optional[Tuple[str, str]]

Parameters:
filenamestr, optional, default=”motif”

The base filepath for the generated oxDNA files (without extension).

configbool, default=True

If True, generates a configuration (.dat) file with nucleotide positions.

topologybool, default=True

If True, generates a topology (.top) file specifying strand connectivity.

forcesbool, default=False

If True, saves force constraints for base-pair interactions.

pk_forcesbool, default=False

If True, saves force constraints specifically for pseudoknots.

return_textbool, default=False

If True, returns the generated oxDNA configuration and topology as strings instead of writing to files (used for real-time visualization).

sequencestr, optional

If provided, uses the given sequence to generate the topology.

pdbbool, optional, default=False

If True, exports a PDB (Protein Data Bank) file for visualization.

box_sizeIterable of float, default=(1000.0, 1000.0, 1000.0)

The dimensions of the simulation box (x, y, z) in oxDNA simulation units.

**kwargs

Additional arguments for customizing force constraints and PDB export settings.

Returns:
Optional[Tuple[str, str]]

If return_text is True, returns a tuple containing: - The configuration file content as a string. - The topology file content as a string. Otherwise, returns None.

Notes

This function requires the oxDNA analysis tools package to be installed for the generation of force constraints and pdb export.

save_fasta(filename='motif')[source]

Save the motif sequences in a FASTA file.

Return type:

None

Parameters:
filenamestr, optional

The filepath to save (without extension). Default is ‘motif’.

save_json(filename='motif', return_data=False)[source]

Save the motif representation as a JSON file.

Return type:

Optional[Dict[str, Any]]

Parameters:
filenamestr, default ‘motif’

The filepath to save (without extension). Default is ‘motif’.

return_databool, default False

If True, return the JSON data instead of saving to a file.

Returns:
dict, optional

The JSON data if return_data is True.

save_text(filename='motif')[source]

Save the motif representation as a text file.

Return type:

None

Parameters:
filename_pathstr, optional

The filepath to save (without extension). Default is ‘motif’.

property seq_positions: Tuple[Position]

The positions of each nucleotide in the motif sequence (x,y coordinates). The sequence has always the directionality 5’ to 3’

property sequence: str

Return the sequence of the motif.

shift(shift_vect, extend=False)[source]

Shift the motif of the given shift vector.

Return type:

Motif

Parameters:
shift_vectTuple[int, int]

The (x, y) shift values.

extendbool, default False

Whether to extend junctions when shifting (in the direction opposite to the shifting direction).

Returns:
Motif

The shifted motif.

Raises:
ValueError

If shifting moves strands to negative positions.

sort(key=None, reverse=False)[source]

Sort the strands in the motif.

Return type:

Motif

Parameters:
keyfunction, optional

The function to use to sort the strands. If None, the strands are sorted by:

  • strands with a 5’ end first

  • lowest starting y position

  • lowest starting x position

reversebool, default False

If True, sort in descending order.

Returns:
Motif

The motif with the sorted strands.

property strands: List[Strand]

The list of strands in the motif.

strip(skip_axis=None)[source]

Remove the empty lines/columns in the motif structure.

Return type:

Motif

Parameters:
skip_axis: int, optional

The numpy axis to skip when stripping the motif (1 for horizontal, 0 for vertical).

Returns:
Motif

The stripped motif.

property structure: str

Return the dot bracket representation of the motif.

to_json()[source]

Convert the Motif instance to a JSON-serializable dictionary.

Return type:

Dict[str, Any]

Returns:
Dict[str, Any]

A dictionary representation of the Motif instance.

static trace(motif_list, pos, direction, limits)[source]

Trace strands in a motif representation in a recursive manner.

Return type:

str

Parameters:
motif_listlist of str

The list of strings of the motif sketch.

postuple of int

The starting position.

directiontuple of int

The tracing direction.

limitstuple of int

The boundary limits.

Returns:
str

The traced strand sequence.

Origami

class pyfurnace.design.core.origami.Origami(matrix=None, *args, align='left', copy=False, ss_assembly=False, **kwargs)[source]

Bases: Callback

A class for building and manipulating RNA Origami structures.

The Origami class organizes RNA Motif objects into a 2D matrix to represent spatial arrangements of strands. It supports stacking motifs horizontally and vertically, calculating vertical junctions and connections, assembling the full origami structure in a motif object, and exporting the full structure and sequence.

Parameters:
matrixMotif or list of Motif or list of list of Motif

A motif or 1D/2D list of Motifs to initialize the origami layout.

*argsMotif or list of Motif

Additional motifs or rows of motifs to add to the matrix.

align{‘left’, ‘first’, ‘center’}, default=’left’

How rows are vertically aligned. Left: align each row to the left. First: align to the first crossover in each row. Center: align every row to the center of the widest row.

copybool, default=False

Whether to create a copy of the motifs before adding them to the origami.

ss_assemblybool, default=False

Wether to assemble the 3D structure of the origami without locking the coordinates of the motifs.

**kwargsdict

Additional keyword arguments passed to the Callback base class.

Attributes:
alignstr

The alignment type of the rows of the origami.

assembledMotif

The matrix of the origami with the motif shifted in the correct position for the assembly.

num_charList[int]

The number of characters in each line of the origami.

num_linesint

The number of lines in the origami.

num_motifsint

The number of motifs in the origami.

pair_mapdict

The dictionary of the paired indexes (alternative to the dot bracket notation).

pos_index_mapDict[Position, Tuple[int, int]]

A dictionary with the symbols position (x, y) as keys and the matrix index (y, x) of the motif that contains it as values.

index_shift_mapDict[Position, Tuple[int, int]]

A dictionary with the slice of the motif in the matrix as key (y, x) and positional shift of the motif as values (y, x).

pseudoknotsdict

A dictionary with the pseudoknot information.

sequenceSequence

The sequence of the origami, as a Sequence.

seq_positionsTuple[Position]

The positions of each nucleotide in the motif sequence (x,y coordinates).

ss_assemblybool

Boolean indicating if the origami 3d structure is assembled without locking the coordinates of the motifs.

strandsList[Strand]

The strands of the origami.

structurestr

The dot-bracket structure of the origami.

Methods

append(item[, copy])

Append a Motif or a list of Motifs to the end of the matrix.

barrier_repr([kl_delay, barriers, return_list])

Overlay folding barrier characters onto the structure visualization.

clear_sequence([clear_kissing_loops, ...])

Clear the sequences of all stems in the origami, resetting it to the default state.

copy()

Create a deep copy of the Origami.

duplicate_line(idx[, insert_idx])

Duplicate a line of motifs and optionally insert it elsewhere.

folding_barriers([kl_delay])

Compute the folding barriers for a given RNA secondary structure.

from_json(json_data)

Create an Origami object from a JSON string or dictionary.

from_json_file(file_path)

Create an Origami object from a JSON file.

from_structure([structure, sequence, ...])

Parse a structure or sequence representation to an Origami object.

get_motif_at_position(position)

Get a motif from its position in 2D coordinates.

get_motif_at_seq_index(index)

Get the motif that contains the given sequence index.

get_motif_type(motif_type)

Get all motifs in the Origami that match the given type.

get_slice_at_seq_index(index)

Get matrix coordinates of the motif containing the given sequence index.

improve_folding_pathway([kl_delay])

Suggest a better folding pathway by circularly shifting the structure.

index(condition[, return_matrix_format])

Find the matrix coordinates of motifs that satisfy a given condition.

insert(idx, item[, copy])

Insert a Motif or list of Motifs at a specific position.

pop(idx)

Remove and return a motif or line of motifs at the given index.

register_callback(callback)

Register a new callback function to be executed when an event occurs.

reload()

Recompute the internal structure and regenerate the assembled motif.

remove(motif)

Remove a specific motif from the matrix.

save_3d_model([filename, config, topology, ...])

Save the motif 3D structure in a file for structural 3D modeling.

save_fasta(filename[, return_text])

Save the sequence of the Origami to a FASTA file.

save_json([filename, return_data])

Save the Origami instance to a JSON file.

save_text(filename[, to_road, return_text])

Save only the structure part of the Origami to a text file.

to_json()

Convert the Origami instance to a JSON-serializable dictionary.

to_road()

Try to convert the Origami's text representation into ROAD-compatible format.

See also

Motif, Strand, Sequence
property align: Literal['left', 'first', 'center']

The alignment type of the rows of the origami.

append(item, copy=True)[source]

Append a Motif or a list of Motifs to the end of the matrix. If the item is a single Motif, it is appended to the last line of the matrix. If the item is a list of Motifs, it is appended as a new line in the matrix.

Return type:

None

Parameters:
itemMotif or list of Motif

The motif(s) to append.

copybool, default=True

Whether to copy motifs before appending.

Raises:
TypeError

If item is not a Motif or a list of Motifs.

property assembled

The matrix of the origami with the motif shifted in the correct position for the assembly. The assembled matrix contains rows with the vertical connection motifs.

barrier_repr(kl_delay=150, barriers=None, return_list=False)[source]

Overlay folding barrier characters onto the structure visualization.

Return type:

Union[str, List[str]]

Parameters:
kl_delayint, default=150

Delay parameter for computing folding barriers.

barriersstr, optional

Precomputed folding barrier string. If None, it will be recomputed.

return_listbool, default=False

Whether to return the result as a list of lines instead of a string.

Returns:
str or list of str

The annotated structure as a single string or a list of lines.

clear_sequence(clear_kissing_loops=True, clear_tetraloops=False)[source]

Clear the sequences of all stems in the origami, resetting it to the default state.

Return type:

None

Parameters:
clear_tetraloopsbool, default=True

Whether to clear the sequences of tetraloops.

clear_kissing_loopsbool, default=True

Whether to clear the sequences of kissing loops.

Returns:
None
copy()[source]

Create a deep copy of the Origami.

Return type:

Origami

Returns:
Origami

A new instance identical to the current one.

duplicate_line(idx, insert_idx=None)[source]

Duplicate a line of motifs and optionally insert it elsewhere.

Return type:

None

Parameters:
idxint

Index of the line to duplicate.

insert_idxint, optional

Line index at which to insert the duplicated line. If None, it will be added at the end.

Raises:
ValueError

If the given idx is not an integer.

folding_barriers(kl_delay=150)

Compute the folding barriers for a given RNA secondary structure. This function is based on ROAD: https://www.nature.com/articles/s41557-021-00679-1 This function analyzes the dot-bracket representation of the RNA secondary structure to determine folding barriers based on base pair topology and kinetic delay.

Return type:

Tuple[str, int]

Parameters:
structurestr

The dot-bracket notation representing the secondary structure of the RNA. If folding barriers is called from a Motif or Origami, the structure is already provided by the object in the dot-bracket format.

kl_delayint, optional, default=150

The number of nucleotides (nts) of delay before kissing loops (KLs) snap closed. A typical realistic value is around 350 (~1 second), while a more conservative setting is 150 by default.

Returns:
Tuple[str, int]

A tuple containing: - A string representing the barrier map where: ‘─’ = no barrier (0 penalty), ‘▂’ = opening pair weak barrier (1 penalty), ‘▄’ = cloding pair weak barrier (1 penalty), ‘█’ = strong barrier (2 penalty). - An integer score indicating the total penalty based on barrier strengths.

Notes

The function assigns barrier strengths based on the topology of base pairs and kinetic constraints, ensuring proper folding predictions.

classmethod from_json(json_data)[source]

Create an Origami object from a JSON string or dictionary. The json dictionary is parsed, and is consumed to create the Motif object.

Return type:

Origami

Parameters:
json_datastr or dict

A JSON string or dictionary representing the origami.

Returns:
Origami

An Origami object created from the JSON data.

classmethod from_json_file(file_path)[source]

Create an Origami object from a JSON file.

Return type:

Origami

Parameters:
file_pathstr

The path to the JSON file containing the origami data.

Returns:
Origami

An Origami object created from the JSON file.

classmethod from_structure(structure=None, sequence=None, pk_energy=-8.5, pk_denergy=0.5, motif_list=None, **kwargs)[source]

Parse a structure or sequence representation to an Origami object. If a structure is not provided, it is calculated from the sequence with RNAfold. If a sequence is not provided, it is assumed to be a sequence of ‘N’s of the same length as the structure.

Return type:

Origami

Parameters:
structureUnion[str, dict, BasePair, Node]

The structure representation to convert.

sequencestr, optional

The sequence or sequence constraints of the motif.

pk_energyfloat, optional

The energy of the pseudoknots (if present).

pk_denergyfloat, optional

The energy tolerance of the pseudoknots (if present).

motif_listList[Motif], optional

A list of specific motifs to parse the structure. By default, the motifs are stems and aptamers.

**kwargsdict

Additional arguments to pass to the Motif constructor.

Returns:
Origami

The Origami object created from the structure representation.

get_motif_at_position(position)[source]

Get a motif from its position in 2D coordinates.

Return type:

Motif

Parameters:
positionPosition

Global coordinate (x, y) in the assembled structure.

Returns:
Motif

The motif located at the position.

Raises:
ValueError

If the position is not valid or not found in the map.

get_motif_at_seq_index(index)[source]

Get the motif that contains the given sequence index.

Return type:

Motif

Parameters:
indexint

Sequence index in the full assembled sequence.

Returns:
Motif

Motif containing the base at the given index.

get_motif_type(motif_type)[source]

Get all motifs in the Origami that match the given type.

Return type:

List[Motif]

Parameters:
motif_typetype

Motif subclass/type to filter.

Returns:
List[Motif]

All motifs of the specified type.

get_slice_at_seq_index(index)[source]

Get matrix coordinates of the motif containing the given sequence index.

Return type:

Tuple[int, int]

Parameters:
indexint

Index in the full sequence.

Returns:
Tuple[int, int]

(row, column) coordinates in the matrix.

Raises:
ValueError

If the index is not found.

improve_folding_pathway(kl_delay=150)[source]

Suggest a better folding pathway by circularly shifting the structure. This method attempts to find a better folding pathway by shifting the structure to a new position. IMPORTANT: this method is designed for simple origami blueprints based on DAE crossovers and may not work correctly for different structures.

Return type:

Origami

Parameters:
kl_delayint, default=150

Delay parameter for kinetic loop folding.

Returns:
Origami

A new Origami object with an optimized folding pathway.

index(condition, return_matrix_format=False)[source]

Find the matrix coordinates of motifs that satisfy a given condition.

Return type:

Union[List[Tuple[int, int]], List[List[int]]]

Parameters:
conditionCallable[[Motif], bool] or Motif or Type[Motif]
  • A function that takes a Motif and returns True if it matches,

  • a Motif instance to match directly (==, e.g. pf.Tetraloop()),

  • or a Motif class to match by isinstance (e.g. pf.Stem).

return_matrix_formatbool, default=False

If True, returns indices in matrix format (row, column), otherwise returns a flat list of indices. The matrix format is a list of lists (row-wise) of indices (column-wise).

Returns:
Union[List[Tuple[int, int]], List[List[int]]]

List of (row, column) indices of matching motifs. If return_matrix_format is True, returns a list of lists (row-wise) of indices (column-wise).

Raises:
ValueError

If condition is not a callable, a Motif instance, or a Motif subclass.

property index_shift_map: dict

A dictionary with the slice of the motif in the matrix as key (y, x) and positional shift of the motif as values (y, x). The shift is the difference between the position of the motif in the matrix and the position of the motif in the assembled origami.

insert(idx, item, copy=True)[source]

Insert a Motif or list of Motifs at a specific position.

Return type:

None

Parameters:
idxint, slice, tuple of int

The index or coordinate at which to insert the item(s).

itemMotif or list of Motif

The motif(s) to insert.

copybool, default=True

Whether to copy motifs before inserting.

Raises:
ValueError

If the index or item is invalid.

property num_char: List[int]

The number of characters in each line of the origami.

property num_lines: int

The number of lines in the origami.

property num_motifs: int

The number of motifs in the origami.

property pair_map: dict

The dictionary of the paired indexes (alternative to the dot bracket notation).

pop(idx)[source]

Remove and return a motif or line of motifs at the given index.

Return type:

Union[Motif, List[Motif]]

Parameters:
idxint, slice, tuple of int

The index or coordinates to remove from.

Returns:
Motif or list of Motif

The removed motif(s).

Raises:
ValueError

If the index is not valid.

property pos_index_map: dict

A dictionary with the symbols position (x, y) as keys and the matrix index (y, x) of the motif that contains it as values.

property positions: List[Position]

The positions of the characters in the origami. Is the same as calling the assembled.motif.positions.

property pseudoknots: dict

A dictionary with the pseudoknot information. The dictionary has pseudoknot IDs as keys and the pseudoknot information as values. The pseudoknot information is a dictionary with the following keys:

  • ind_fwd: a list of tuples (start, end) with the indices of the forward

    sequences of the pseudoknot

  • ind_rev: a list of tuples (start, end) with the indices of the reverse

    sequences of the pseudoknot

  • E: the energy of the pseudoknot

  • dE: the energy tolerance of the pseudoknot

reload()[source]

Recompute the internal structure and regenerate the assembled motif.

Return type:

None

remove(motif)[source]

Remove a specific motif from the matrix.

Return type:

None

Parameters:
motifMotif

The motif to remove.

save_3d_model(filename='motif', config=True, topology=True, forces=False, pk_forces=False, return_text=False, sequence=None, pdb=False, box_size=(1000.0, 1000.0, 1000.0), **kwargs)

Save the motif 3D structure in a file for structural 3D modeling. This function save the 3D oxDNA motif representation in conformation and topology xoDNA-format files, and optionally in PDB format. It can also save additional force constraints for oxDNA simulation and protein configurations if specified.

Return type:

Optional[Tuple[str, str]]

Parameters:
filenamestr, optional, default=”motif”

The base filepath for the generated oxDNA files (without extension).

configbool, default=True

If True, generates a configuration (.dat) file with nucleotide positions.

topologybool, default=True

If True, generates a topology (.top) file specifying strand connectivity.

forcesbool, default=False

If True, saves force constraints for base-pair interactions.

pk_forcesbool, default=False

If True, saves force constraints specifically for pseudoknots.

return_textbool, default=False

If True, returns the generated oxDNA configuration and topology as strings instead of writing to files (used for real-time visualization).

sequencestr, optional

If provided, uses the given sequence to generate the topology.

pdbbool, optional, default=False

If True, exports a PDB (Protein Data Bank) file for visualization.

box_sizeIterable of float, default=(1000.0, 1000.0, 1000.0)

The dimensions of the simulation box (x, y, z) in oxDNA simulation units.

**kwargs

Additional arguments for customizing force constraints and PDB export settings.

Returns:
Optional[Tuple[str, str]]

If return_text is True, returns a tuple containing: - The configuration file content as a string. - The topology file content as a string. Otherwise, returns None.

Notes

This function requires the oxDNA analysis tools package to be installed for the generation of force constraints and pdb export.

save_fasta(filename, return_text=False)[source]

Save the sequence of the Origami to a FASTA file.

Return type:

Optional[str]

Parameters:
filenamestr

Path to the output file.

return_textbool, default=False

If True, return the text instead of saving it to a file.

Returns:
Optional[str]

The FASTA text if return_text is True.

save_json(filename='Origami', return_data=False)[source]

Save the Origami instance to a JSON file.

Return type:

Optional[Dict[str, Any]]

Parameters:
filenamestr, default ‘Origami’

Path to the output file.

return_databool, default False

If True, return the JSON data instead of saving it to a file.

Returns:
Optional[Dict[str, Any]]

The JSON data if return_data is True.

save_text(filename, to_road=False, return_text=False)[source]

Save only the structure part of the Origami to a text file.

Return type:

Optional[str]

Parameters:
filenamestr

Path to the output file.

to_roadbool, default=False

If True, convert to ROAD-compatible format.

return_textbool, default=False

If True, return the text instead of saving it to a file.

Returns:
Optional[str]

The text if return_text is True.

property seq_positions: Tuple[Position]

The positions of each nucleotide in the motif sequence (x,y coordinates). The sequence has always the directionality 5’ to 3’

property sequence: Sequence

The sequence of the origami, as a Sequence.

property ss_assembly: bool

Boolean indicating if the origami 3d structure is assembled without locking the coordinates of the motifs.

property strands: List[Strand]

The strands of the origami.

property structure: str

The dot-bracket structure of the origami.

to_json()[source]

Convert the Origami instance to a JSON-serializable dictionary.

Return type:

Dict[str, Any]

Returns:
Dict[str, Any]

A dictionary representation of the Origami.

to_road()[source]

Try to convert the Origami’s text representation into ROAD-compatible format.

Return type:

str

Returns:
str

ROAD-compatible structure representation.

Sequence

class pyfurnace.design.core.sequence.Sequence(sequence='', directionality='53', **kwargs)[source]

Bases: Callback

Represents a nucleotide sequence with 5’ to 3’ or 3’ to 5’ directionality.

This class provides functionality for manipulating RNA sequences with support for slicing, translation, complementarity, GC content, and integration with structure-aware tools.

Parameters:
sequencestr, optional

The nucleotide sequence.

directionality{‘53’, ‘35’}, optional

Directionality of the sequence (default is ‘53’).

**kwargsdict

Additional arguments passed to the Callback base class.

Attributes:
directionalitystr

directionality of the sequence (either ‘53’ or ‘35’)

Methods

complement()

Return the complement of the sequence.

copy(**kwargs)

Create a copy of the sequence.

distance(other)

Compute the number of mismatched bases between this sequence and another.

find(sub)

Find the first occurrence of a subsequence in the sequence.

find_repeated_subsequence([min_length])

Find all subsequences of minimum length that appear more than once.

gc_content([extended_alphabet])

Calculate the GC content of the sequence.

get_random_sequence([structure])

Generate a randomized sequence compatible with the IUPAC symbols and optionally a dot-bracket structure to be respected.

lower()

Convert sequence to lowercase.

molecular_weight()

Calculate the molecular weight of the sequence.

pop(idx)

Remove and return a nucleotide at the given index.

register_callback(callback)

Register a new callback function to be executed when an event occurs.

replace(old, new)

Replace all occurrences of old with new in the sequence.

reverse([inplace])

Reverse the directionality of the sequence.

reverse_complement()

Return the reverse complement of the sequence.

split([sep])

Split the sequence by a separator.

translate(dictionary[, inplace])

Translate the sequence using a mapping dictionary.

upper()

Convert sequence to uppercase.

complement()[source]

Return the complement of the sequence.

Return type:

Sequence

Returns:
Sequence

Complementary sequence.

copy(**kwargs)[source]

Create a copy of the sequence.

Return type:

Sequence

Returns:
Sequence

A new Sequence instance.

property directionality

directionality of the sequence (either ‘53’ or ‘35’)

distance(other)[source]

Compute the number of mismatched bases between this sequence and another.

Return type:

int

Parameters:
otherstr or Sequence

Sequence to compare against.

Returns:
int

Number of incompatible positions.

Raises:
ValueError

If the input is invalid or lengths do not match.

find(sub)[source]

Find the first occurrence of a subsequence in the sequence.

Return type:

int

Parameters:
substr

Subsequence to find.

Returns:
int

Index of the first occurrence of the subsequence, or -1 if not found.

find_repeated_subsequence(min_length=8)[source]

Find all subsequences of minimum length that appear more than once.

Return type:

Set[str]

Parameters:
min_lengthint, optional

Minimum length of subsequence (default is 8).

Returns:
set of str

Repeated subsequences.

gc_content(extended_alphabet=False)[source]

Calculate the GC content of the sequence.

Return type:

float

Parameters:
extended_alphabetbool, optional

Whether to include ambiguous base codes (e.g., S, M, R) in the calculation.

Returns:
float

GC content percentage.

get_random_sequence(structure='')[source]

Generate a randomized sequence compatible with the IUPAC symbols and optionally a dot-bracket structure to be respected.

Return type:

Sequence

Parameters:
structurestr, optional

Dot-bracket structure.

Returns:
str

A new randomized sequence.

lower()[source]

Convert sequence to lowercase.

Return type:

str

Returns:
str

Lowercase sequence string.

molecular_weight()[source]

Calculate the molecular weight of the sequence.

Return type:

float

Returns:
float

Total molecular weight in Daltons.

pop(idx)[source]

Remove and return a nucleotide at the given index.

Return type:

str

Parameters:
idxint

Index of nucleotide to remove.

Returns:
str

The removed character.

replace(old, new)[source]

Replace all occurrences of old with new in the sequence.

Return type:

Sequence

Parameters:
oldstr

Character to replace.

newstr

Replacement character.

Returns:
Sequence

Updated sequence.

reverse(inplace=False)[source]

Reverse the directionality of the sequence.

Return type:

Sequence

Parameters:
inplacebool, optional

If True, reverse in-place. Otherwise, return a new Sequence.

Returns:
Sequence

Reversed sequence.

reverse_complement()[source]

Return the reverse complement of the sequence.

Return type:

Sequence

Returns:
Sequence

Reverse-complemented sequence.

split(sep=None)[source]

Split the sequence by a separator.

Return type:

List[Sequence]

Parameters:
sepstr, optional

Separator to use (default is None, meaning split on whitespace).

Returns:
list of Sequence

List of subsequences.

translate(dictionary, inplace=False)[source]

Translate the sequence using a mapping dictionary.

Return type:

Sequence

Parameters:
dictionarydict

Dictionary to translate each character.

inplacebool, optional

If True, modify the current sequence. Otherwise, return a new instance.

Returns:
Sequence

Translated sequence.

upper()[source]

Convert sequence to uppercase.

Return type:

str

Returns:
str

Uppercase sequence string.

Basepair

class pyfurnace.design.core.basepair.BasePair(*args, **kwargs)[source]

Bases: MutableMapping, Callback

A bidirectional dictionary that maintains a mapping between keys and values, ensuring that each value has a unique corresponding key and vice versa.

Inherits from MutableMapping to provide dictionary-like behavior and from Callback to support event-driven notifications on updates.

Parameters:
*argstuple

Positional arguments passed to the internal dictionary.

**kwargsdict

Keyword arguments passed to the internal dictionary. Special keys callback and callbacks are removed before processing.

Attributes:
callbacks

Get the list of registered callbacks.

Methods

clear()

copy(**kwargs)

Create a copy of the dictionary.

get(key[, default])

Retrieve a value by key, returning a default if not found.

items()

Return the dictionary's key-value pairs.

keys()

Return the dictionary's keys.

pop(k[,d])

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem()

as a 2-tuple; but raise KeyError if D is empty.

register_callback(callback)

Register a new callback function to be executed when an event occurs.

setdefault(k[,d])

shift(shift)

Apply a shift transformation to the key-value pairs.

update(*args, **kwargs)

Update the dictionary with new key-value pairs.

values()

Return the dictionary's values.

copy(**kwargs)[source]

Create a copy of the dictionary.

Return type:

BasePair

Parameters:
**kwargsdict

Additional parameters for the new instance.

Returns:
BasePair

A new instance of BasePair with the same data.

get(key, default=None)[source]

Retrieve a value by key, returning a default if not found.

Return type:

Any

Parameters:
keyhashable

The key to retrieve.

defaultAny, optional

The value to return if key is not found (default is None).

Returns:
Any

The corresponding value or the default.

items()[source]

Return the dictionary’s key-value pairs.

Return type:

Any

keys()[source]

Return the dictionary’s keys.

Return type:

Any

shift(shift)[source]

Apply a shift transformation to the key-value pairs. The shift is added to both the keys and values.

Return type:

BasePair

Parameters:
shifthashable

The amount to shift each key and value.

Returns:
BasePair

A new instance with shifted keys and values.

update(*args, **kwargs)[source]

Update the dictionary with new key-value pairs.

Return type:

BasePair

Parameters:
*argsdict

Dictionaries to merge into the current instance.

**kwargsdict

Additional key-value pairs to update.

Returns:
BasePair

The updated instance.

values()[source]

Return the dictionary’s values.

Return type:

Any

Common Variables

Useful collections

pyfurnace.design.core.symbols.nucleotides = {'&', 'A', 'B', 'C', 'D', 'G', 'H', 'K', 'M', 'N', 'R', 'S', 'U', 'V', 'W', 'X', 'Y'}

Set of all accepted nucleotides, including standard bases and extended IUPAC codes.

pyfurnace.design.core.symbols.iupac_code = {'&': {'&'}, 'A': {'A'}, 'B': {'C', 'G', 'U'}, 'C': {'C'}, 'D': {'A', 'G', 'U'}, 'G': {'G'}, 'H': {'A', 'C', 'U'}, 'K': {'G', 'U'}, 'M': {'A', 'C'}, 'N': {'A', 'C', 'G', 'U'}, 'R': {'A', 'G'}, 'S': {'C', 'G'}, 'U': {'U'}, 'V': {'A', 'C', 'G'}, 'W': {'A', 'U'}, 'X': {'A', 'C', 'G', 'U'}, 'Y': {'C', 'U'}}

Dictionary mapping IUPAC codes to corresponding sets of nucleotides. Source: https://www.bioinformatics.org/sms/iupac.html

pyfurnace.design.core.symbols.base_pairing = {'&': {'&'}, 'A': {'B', 'D', 'H', 'K', 'N', 'U', 'W', 'Y'}, 'B': {'A', 'B', 'C', 'D', 'G', 'H', 'K', 'M', 'N', 'R', 'S', 'U', 'V', 'W', 'Y'}, 'C': {'B', 'D', 'G', 'K', 'N', 'R', 'S', 'V'}, 'D': {'A', 'B', 'C', 'D', 'G', 'H', 'K', 'M', 'N', 'R', 'S', 'U', 'V', 'W', 'Y'}, 'G': {'B', 'C', 'D', 'H', 'K', 'M', 'N', 'S', 'U', 'V', 'W', 'Y'}, 'H': {'A', 'B', 'D', 'G', 'H', 'K', 'M', 'N', 'R', 'S', 'U', 'V', 'W', 'Y'}, 'K': {'A', 'B', 'C', 'D', 'G', 'H', 'K', 'M', 'N', 'R', 'S', 'U', 'V', 'W', 'Y'}, 'M': {'B', 'D', 'G', 'H', 'K', 'N', 'R', 'S', 'U', 'V', 'W', 'Y'}, 'N': {'A', 'B', 'C', 'D', 'G', 'H', 'K', 'M', 'N', 'R', 'S', 'U', 'V', 'W', 'Y'}, 'R': {'B', 'C', 'D', 'H', 'K', 'M', 'N', 'S', 'U', 'V', 'W', 'Y'}, 'S': {'B', 'C', 'D', 'G', 'H', 'K', 'M', 'N', 'R', 'S', 'U', 'V', 'W', 'Y'}, 'U': {'A', 'B', 'D', 'G', 'H', 'K', 'M', 'N', 'R', 'S', 'V', 'W'}, 'V': {'B', 'C', 'D', 'G', 'H', 'K', 'M', 'N', 'R', 'S', 'U', 'V', 'W', 'Y'}, 'W': {'A', 'B', 'D', 'G', 'H', 'K', 'M', 'N', 'R', 'S', 'U', 'V', 'W', 'Y'}, 'X': {'A', 'B', 'C', 'D', 'G', 'H', 'K', 'M', 'N', 'R', 'S', 'U', 'V', 'W', 'X', 'Y'}, 'Y': {'A', 'B', 'D', 'G', 'H', 'K', 'M', 'N', 'R', 'S', 'V', 'W'}}

Dictionary mapping IUPAC codes to the set of codes they can base pair with.

pyfurnace.design.core.symbols.db_pairs = {'(': ')', '<': '>', 'A': 'a', 'B': 'b', 'C': 'c', 'D': 'd', 'E': 'e', 'F': 'f', 'G': 'g', 'H': 'h', 'I': 'i', 'J': 'j', 'K': 'k', 'L': 'l', 'M': 'm', 'N': 'n', 'O': 'o', 'P': 'p', 'Q': 'q', 'R': 'r', 'S': 's', 'T': 't', 'U': 'u', 'V': 'v', 'W': 'w', 'X': 'x', 'Y': 'y', 'Z': 'z', '[': ']', '{': '}'}

Dictionary mapping dot-bracket symbols to their corresponding pairing symbols.

pyfurnace.design.core.symbols.all_pk_symbols = ('[', ']', '{', '}', '<', '>', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z')

Tuple containing all possible pseudoknot symbols used in dot-bracket notation.

pyfurnace.design.core.symbols.accept_symbol = {' ', '!', '&', '(', ')', '*', '+', '-', '.', '/', '3', '5', ':', '<', '=', '>', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', '•', '↑', '↓', '⊗', '⊙', '─', '│', '┊', '┼', '╭', '╮', '╯', '╰', '▂', '▄', '█', '◦'}

Set of all accepted symbols including nucleotides, dots, brackets, and special ROAD symbols.

pyfurnace.design.core.symbols.bp_symbols = {'!', '*', ':', '=', '┊'}

Set of symbols representing base pairs.

pyfurnace.design.core.symbols.T7_PROMOTER = 'TAATACGACTCACTATA'

Sequence representing the T7 promoter.

Translators for strings characters

pyfurnace.design.core.symbols.pseudo_to_dot

String translator mapping all pseudoknot symbols to dots.

pyfurnace.design.core.symbols.pair_db_sym

String translator to map each dot-bracket opening symbol to its closing counterpart and vice versa.

pyfurnace.design.core.symbols.nucl_to_none

String translator that removes all nucleotides from a string.

pyfurnace.design.core.symbols.symb_to_none

String translator that removes all accepted symbols from a string.

pyfurnace.design.core.symbols.nucl_to_pair

String translator that maps nucleotides (including IUPAC codes) to their complementary base.

pyfurnace.design.core.symbols.only_nucl

String translator that removes all non-nucleotide symbols from a string.

pyfurnace.design.core.symbols.horiz_flip

String translator for horizontal flip of strand turning symbols.

pyfurnace.design.core.symbols.verti_flip

String translator for vertical flip of strand turning symbols.

pyfurnace.design.core.symbols.rotate_90

String translator for 90 degree rotation of strand symbols.

pyfurnace.design.core.symbols.symb_to_road

String translator for converting normal symbols to ROAD strand symbols.

Common functions

This module contains general utility functions and constants for the pyfurnace package.

It includes: functions for manipulating RNA strands and sequences, utilities for RNA structures (dot-bracket notation, pair maps, trees) folding barriers calculation for canonical co-transcriptional RNA Origami

exception pyfurnace.design.core.symbols.AmbiguosStructure(message)[source]

Warning raised when a structure is ambiguous or potentially problematic.

This can occur in cases where: - The strand routing is not clear

Parameters:
messagestr

Description of the ambiguity or issue.

exception pyfurnace.design.core.symbols.MotifStructureError[source]

Exception raised when a motif’s secondary structure is invalid or inconsistent.

This error typically indicates issues such as: - Overlapping or conflicting strands - Joining strands with different directionalities - Logical inconsistencies in structural motifs

pyfurnace.design.core.symbols.base_pair_difference(s1, s2, pair_map1=None, pair_map2=None, ignore_ind=(), accept_unpaired_ind=(), **kwargs)[source]

Find indices where base pairing differs between two structures.

Return type:

List[int]

Parameters:
s1str

First structure (dot-bracket notation).

s2str

Second structure.

pair_map1dict, optional

Precomputed pair map for s1.

pair_map2dict, optional

Precomputed pair map for s2.

ignore_inditerable of int, optional

Indices to ignore in the comparison.

accept_unpaired_inditerable of int, optional

Indices allowed to be unpaired in s2 without penalty.

Returns:
list of int

Indices of base pairs that differ.

pyfurnace.design.core.symbols.base_pair_distance(s1, s2, pair_map1=None, pair_map2=None, ignore_ind=(), accept_unpaired_ind=(), **kwargs)[source]

Compute the number of base pair differences between two structures.

Return type:

int

Parameters:
s1str

First dot-bracket structure.

s2str

Second dot-bracket structure.

pair_map1dict, optional

Pair map for s1.

pair_map2dict, optional

Pair map for s2.

ignore_inditerable of int, optional

Indices to ignore.

accept_unpaired_inditerable of int, optional

Positions where being unpaired in s2 is allowed.

Returns:
int

Total number of mismatched base pairs.

pyfurnace.design.core.symbols.complement(sequence)[source]

Return the complement of an RNA sequence using IUPAC base-pairing rules.

Return type:

str

Parameters:
sequencestr

RNA sequence composed of standard and extended IUPAC nucleotide symbols.

Returns:
str

Complementary sequence with each base replaced by its pair.

pyfurnace.design.core.symbols.dot_bracket_to_pair_map(dot_bracket)[source]

Convert dot-bracket notation into a pair map.

Return type:

BasePair

Parameters:
dot_bracketstr

Secondary structure in dot-bracket notation.

Returns:
BasePair

A bidirectional dictionary mapping nucleotide indices to their paired partner (or None).

pyfurnace.design.core.symbols.dot_bracket_to_stacks(dot_bracket, only_opening=False)[source]

Identify contiguous structural elements (stacks) in a dot-bracket string.

Return type:

Tuple[str, List[Tuple[int, int]]]

Parameters:
dot_bracketstr

RNA structure in dot-bracket format.

only_openingbool, optional

Whether to return only stacks that start with an opening symbol.

Returns:
tuple of str and list of tuple
  • A reduced dot-bracket string marking distinct stacks.

  • A list of (start_index, end_index) tuples for each stack.

pyfurnace.design.core.symbols.dot_bracket_to_tree(dot_bracket, sequence=None)[source]

Convert a dot-bracket RNA structure into a hierarchical tree of nodes.

Return type:

Node

Parameters:
dot_bracketstr

RNA structure in dot-bracket format. Pseudoknots are ignored.

sequencestr, optional

Sequence constraints associated with each index.

Returns:
Node

Root node of the tree representing the full structure.

pyfurnace.design.core.symbols.folding_barriers(structure, kl_delay=150)[source]

Compute the folding barriers for a given RNA secondary structure. This function is based on ROAD: https://www.nature.com/articles/s41557-021-00679-1 This function analyzes the dot-bracket representation of the RNA secondary structure to determine folding barriers based on base pair topology and kinetic delay.

Return type:

Tuple[str, int]

Parameters:
structurestr

The dot-bracket notation representing the secondary structure of the RNA. If folding barriers is called from a Motif or Origami, the structure is already provided by the object in the dot-bracket format.

kl_delayint, optional, default=150

The number of nucleotides (nts) of delay before kissing loops (KLs) snap closed. A typical realistic value is around 350 (~1 second), while a more conservative setting is 150 by default.

Returns:
Tuple[str, int]

A tuple containing: - A string representing the barrier map where: ‘─’ = no barrier (0 penalty), ‘▂’ = opening pair weak barrier (1 penalty), ‘▄’ = cloding pair weak barrier (1 penalty), ‘█’ = strong barrier (2 penalty). - An integer score indicating the total penalty based on barrier strengths.

Notes

The function assigns barrier strengths based on the topology of base pairs and kinetic constraints, ensuring proper folding predictions.

pyfurnace.design.core.symbols.gc_content(seq, extended_alphabet=True)[source]

Calculate GC content (optionally including ambiguous nucleotides).

Return type:

float

Parameters:
seqstr

The RNA sequence.

extended_alphabetbool, optional

Whether to include ambiguous IUPAC symbols (e.g., S, K) as partial GC.

Returns:
float

Proportion of GC content in the sequence.

pyfurnace.design.core.symbols.hamming_distance(s1, s2, ignore_ind=(), **kwargs)[source]

Compute the Hamming distance between two strings, ignoring specified indices.

Return type:

int

Parameters:
s1str

First sequence or structure.

s2str

Second sequence or structure.

ignore_inditerable of int, optional

Indices to exclude from comparison.

Returns:
int

Number of differing characters at unignored positions.

pyfurnace.design.core.symbols.mutate_nucleotide(sequence, sequence_constraints, nucl_ind, pair_map)[source]

Mutate a nucleotide in the sequence and update its paired counterpart accordingly.

Return type:

Tuple[Optional[str], Optional[str]]

Parameters:
sequencestr

Original RNA sequence.

sequence_constraintsstr

A string of IUPAC codes representing base constraints for each position.

nucl_indint

Index of the nucleotide to mutate.

pair_mapdict of int to int or None

A mapping of indices representing base pairs.

Returns:
tuple of (str or None, str or None)

A tuple with the new nucleotide and its paired base if applicable.

pyfurnace.design.core.symbols.pair_map_to_dot_bracket(pair_map, structure_length=None)[source]

Convert a base pair map into dot-bracket notation.

Return type:

str

Parameters:
pair_mapdict

Mapping from nucleotide index to paired index or None.

structure_lengthint, optional

Total length of the structure. If None, computed from the map.

Returns:
str

Dot-bracket notation representing the structure.

pyfurnace.design.core.symbols.pair_nucleotide(nucleotide, iupac_symbol='N')[source]

Return a nucleotide that can pair with the given nucleotide, optionally constrained by an IUPAC symbol.

Return type:

str

Parameters:
nucleotidestr

The base to find a pair for.

iupac_symbolstr, optional

Constraint based on allowed base-pairing (IUPAC code).

Returns:
str

A valid pairing nucleotide, or the complement of the input base.

pyfurnace.design.core.symbols.reverse_complement(sequence)[source]

Return the reverse complement of an RNA sequence.

Return type:

str

Parameters:
sequencestr

RNA sequence to reverse and complement.

Returns:
str

The reverse-complemented sequence.

pyfurnace.design.core.symbols.rotate_dot_bracket(dot_bracket, shift_left)[source]

Rotate a dot-bracket structure leftward by a given number of positions.

Return type:

str

Parameters:
dot_bracketstr

RNA secondary structure in dot-bracket notation.

shift_leftint

Number of positions to rotate to the left.

Returns:
str

Rotated dot-bracket structure.

pyfurnace.design.core.symbols.tree_to_dot_bracket(node, dot_bracket=None, seq_constraints=False)[source]

Convert a tree of Nodes into a dot-bracket structure and optional sequence constraints.

Return type:

Union[str, Tuple[str, str]]

Parameters:
nodeNode

Root node of the RNA structure tree.

dot_bracketlist of str, optional

Accumulator for the dot-bracket string.

seq_constraintsbool or list of str

If True, collect sequence constraints using the seq attribute.

Returns:
str or tuple of (str, str)

Dot-bracket string, and sequence constraints if requested.

Motifs

Stem

class pyfurnace.design.motifs.stem.Stem(length=0, sequence='', wobble_interval=5, wobble_tolerance=2, wobble_insert='middle', strong_bases=True, **kwargs)[source]

Represents a helical RNA stem motif consisting of complementary base-paired strands.

The Stem class models a double-stranded RNA region with optional support for wobble base pairs and short-sequences set to strong bases. It can be created from a user-defined sequence or automatically generated based on a target length.

Parameters:
lengthint, optional

Number of base pairs in the stem. Ignored if sequence is provided.

sequencestr or Sequence, optional

Sequence for the top strand. If provided, the bottom strand is inferred as its reverse complement.

wobble_intervalint, optional

Spacing interval for inserting wobble base pairs, e.g., every N bases. Default is 5. Ignored if sequence is given.

wobble_toleranceint, optional

Maximum random deviation from the defined wobble interval. Default is 2.

wobble_insert{“middle”, “start”, “end”}, optional

Positioning strategy for wobble base insertions. Default is “middle”.

strong_basesbool, optional

If True, use strong (GC) base pairing for short stems (≤ 3 bp). Default is True.

**kwargsdict, optional

Additional keyword arguments passed to the Motif superclass.

Attributes:
lengthint

Number of nucleotides in a stem

wobble_intervalint

Interval used for wobble base insertion. Zero if sequence is specified.

wobble_toleranceint

Allowed range of randomness around the wobble interval.

wobble_insertstr

Strategy for where to place wobble base pairs.

strandslist of Strand

The list of strands in the motif.

Methods

align(*motifs[, axis, extend, ...])

Align motifs along a given axis by shifting them (without concatenating).

append(strand[, join, copy])

Append a strand to the motif.

concat(*motifs[, axis, extend, copy, align, ...])

Concatenate multiple motifs along a specified axis.

copy([callback])

Return a copy of the motif.

copy_strands_preserve_blocks(strands[, motif])

Copy a list of strands while preserving strand blocks.

extend_junctions([skip_axis, ...])

Extend the junctions of the motif in the direction of the junctions.

flip([horizontally, vertically, ...])

Flip the strands of the motif horizontally and/or vertically inplace.

folding_barriers([kl_delay])

Compute the folding barriers for a given RNA secondary structure.

from_file(file_path, **kwargs)

Create a Motif object from a text file containing a motif sketch.

from_json(json_data, **kwargs)

Create a Motif object from a JSON string or dictionary.

from_json_file(file_path, **kwargs)

Create a Motif object from a JSON file.

from_list(motif_list, **kwargs)

Create a Motif object from a list of strings representing a motif sketch.

from_structure([structure, sequence, ...])

Parse a structure or sequence representation to a Motif object.

from_text(motif_text, **kwargs)

Create a Motif object from a text string representing a motif sketch.

get_position_map()

Get a dictionary of positions as keys and the corresponding characters as values.

get_sequential_shift(motifs, *args[, axis, ...])

Calculate the shift needed to align motifs sequentially.

get_strand_index_map()

Get a dictionary of positions as keys and the index of the strand in the motif as values.

insert(index, strand[, join, copy])

Insert a strand at a given index in the motif.

join_strands(strands)

Attempt to join consecutive strands and return the list of joined strands.

pop([index])

Remove and return the strand at the specified index.

register_callback(callback)

Register a new callback function to be executed when an event occurs.

replace_all_strands(strands[, copy, join])

Replace all the strands in the motif with the provided list of strands.

rotate([times])

Rotate the motif 90 degrees clockwise.

save_3d_model([filename, config, topology, ...])

Save the motif 3D structure in a file for structural 3D modeling.

save_fasta([filename])

Save the motif sequences in a FASTA file.

save_json([filename, return_data])

Save the motif representation as a JSON file.

save_text([filename])

Save the motif representation as a text file.

set_down_sequence(new_seq)

Set the sequence of the bottom strand

set_strong_bases(strong_bases)

Set wether to use strong bases for short stems

set_up_sequence(new_seq)

Set the sequence of the top strand

shift(shift_vect[, extend])

Shift the motif of the given shift vector.

sort([key, reverse])

Sort the strands in the motif.

strip([skip_axis])

Remove the empty lines/columns in the motif structure.

to_json()

Convert the Motif instance to a JSON-serializable dictionary.

trace(motif_list, pos, direction, limits)

Trace strands in a motif representation in a recursive manner.

property length

Number of nucleotides in a stem

set_down_sequence(new_seq)[source]

Set the sequence of the bottom strand

set_strong_bases(strong_bases)[source]

Set wether to use strong bases for short stems

set_up_sequence(new_seq)[source]

Set the sequence of the top strand

property wobble_insert
property wobble_interval
property wobble_tolerance

Dovetail

class pyfurnace.design.motifs.dovetail.Dovetail(length=0, sequence='', up_cross=True, down_cross=True, sign=1, wobble_interval=5, wobble_tolerance=2, wobble_insert='middle', strong_bases=None, **kwargs)[source]

Represents a double helix RNA stem with junction crossovers before and after the stem.

Parameters:
lengthint, optional

Number of base pairs in the stem. The sign determines dovetail direction. Ignored if sequence is provided.

sequencestr, optional

RNA sequence to assign to the top strand. Overrides length.

up_crossbool, optional

If True, includes a top dovetail crossover motif. Default is True.

down_crossbool, optional

If True, includes a bottom dovetail crossover motif. Default is True.

signint, optional

Direction of the dovetail: +1 (positive/right) or -1 (negative/left). If 0 or unspecified, inferred from length or sequence. Default is 1.

wobble_intervalint, optional

Periodicity of wobble base pairs in the stem. Default is 5.

wobble_toleranceint, optional

Allowed deviation in wobble periodicity. Default is 2.

wobble_insertstr, optional

Position of wobble insertions. Must be “start”, “middle”, or “end”. Default is “middle”.

strong_basesbool, optional

Whether to enforce GC-rich base pairs. If None, it defaults to True only when both up_cross and down_cross are True.

**kwargsdict

Additional keyword arguments passed to the parent Stem class.

Attributes:
up_crossbool

Returns boolian describing wether the dovetail has a top crossing

down_crossbool

Returns boolian describing wether the dovetail has a bottom crossing

signint

Direction of the dovetail: +1 (right/positive), -1 (left/negative).

lengthint

Number of nucleotides in a stem

sequencestr

Return the sequence of the motif.

Methods

align(*motifs[, axis, extend, ...])

Align motifs along a given axis by shifting them (without concatenating).

append(strand[, join, copy])

Append a strand to the motif.

concat(*motifs[, axis, extend, copy, align, ...])

Concatenate multiple motifs along a specified axis.

copy([callback])

Return a copy of the motif.

copy_strands_preserve_blocks(strands[, motif])

Copy a list of strands while preserving strand blocks.

extend_junctions([skip_axis, ...])

Extend the junctions of the motif in the direction of the junctions.

flip([horizontally, vertically, ...])

Flip the strands of the motif horizontally and/or vertically inplace.

folding_barriers([kl_delay])

Compute the folding barriers for a given RNA secondary structure.

from_file(file_path, **kwargs)

Create a Motif object from a text file containing a motif sketch.

from_json(json_data, **kwargs)

Create a Motif object from a JSON string or dictionary.

from_json_file(file_path, **kwargs)

Create a Motif object from a JSON file.

from_list(motif_list, **kwargs)

Create a Motif object from a list of strings representing a motif sketch.

from_structure([structure, sequence, ...])

Parse a structure or sequence representation to a Motif object.

from_text(motif_text, **kwargs)

Create a Motif object from a text string representing a motif sketch.

get_position_map()

Get a dictionary of positions as keys and the corresponding characters as values.

get_sequential_shift(motifs, *args[, axis, ...])

Calculate the shift needed to align motifs sequentially.

get_strand_index_map()

Get a dictionary of positions as keys and the index of the strand in the motif as values.

insert(index, strand[, join, copy])

Insert a strand at a given index in the motif.

join_strands(strands)

Attempt to join consecutive strands and return the list of joined strands.

pop([index])

Remove and return the strand at the specified index.

register_callback(callback)

Register a new callback function to be executed when an event occurs.

replace_all_strands(strands[, copy, join])

Replace all the strands in the motif with the provided list of strands.

rotate([times])

Rotate the motif 90 degrees clockwise.

save_3d_model([filename, config, topology, ...])

Save the motif 3D structure in a file for structural 3D modeling.

save_fasta([filename])

Save the motif sequences in a FASTA file.

save_json([filename, return_data])

Save the motif representation as a JSON file.

save_text([filename])

Save the motif representation as a text file.

set_down_sequence(sequence[, sign])

Set the sequence of the bottom strand

set_strong_bases(strong_bases)

Set wether to use strong bases for short stems

set_up_sequence(sequence[, sign])

Set the sequence of the top strand

shift(shift_vect[, extend])

Shift the motif of the given shift vector.

sort([key, reverse])

Sort the strands in the motif.

strip([skip_axis])

Remove the empty lines/columns in the motif structure.

to_json()

Convert the Motif instance to a JSON-serializable dictionary.

trace(motif_list, pos, direction, limits)

Trace strands in a motif representation in a recursive manner.

property down_cross

Returns boolian describing wether the dovetail has a bottom crossing

set_down_sequence(sequence, sign=None)[source]

Set the sequence of the bottom strand

set_up_sequence(sequence, sign=0)[source]

Set the sequence of the top strand

property up_cross

Returns boolian describing wether the dovetail has a top crossing

Loops

class pyfurnace.design.motifs.loops.Loop(open_left=False, sequence='', **kwargs)[source]

Represents a generic unpaired loop motif in an RNA structure. Optionally it can be initialized with a sequence or be oriented to the left.

Parameters:
open_leftbool, optional

Whether to flip the loop horizontally and vertically to open to the left. Default is False.

sequencestr, optional

Nucleotide sequence to include in the loop. If provided, creates a strand with the sequence and loop symbols. Default is “”.

**kwargsdict, optional

Additional keyword arguments passed to the parent Motif class.

Attributes:
strandslist of Strand

The list of strands in the motif.

flippedbool

Whether the motif has been flipped horizontally/vertically (if open_left=True).

Methods

align(*motifs[, axis, extend, ...])

Align motifs along a given axis by shifting them (without concatenating).

append(strand[, join, copy])

Append a strand to the motif.

concat(*motifs[, axis, extend, copy, align, ...])

Concatenate multiple motifs along a specified axis.

copy([callback])

Return a copy of the motif.

copy_strands_preserve_blocks(strands[, motif])

Copy a list of strands while preserving strand blocks.

extend_junctions([skip_axis, ...])

Extend the junctions of the motif in the direction of the junctions.

flip([horizontally, vertically, ...])

Flip the strands of the motif horizontally and/or vertically inplace.

folding_barriers([kl_delay])

Compute the folding barriers for a given RNA secondary structure.

from_file(file_path, **kwargs)

Create a Motif object from a text file containing a motif sketch.

from_json(json_data, **kwargs)

Create a Motif object from a JSON string or dictionary.

from_json_file(file_path, **kwargs)

Create a Motif object from a JSON file.

from_list(motif_list, **kwargs)

Create a Motif object from a list of strings representing a motif sketch.

from_structure([structure, sequence, ...])

Parse a structure or sequence representation to a Motif object.

from_text(motif_text, **kwargs)

Create a Motif object from a text string representing a motif sketch.

get_position_map()

Get a dictionary of positions as keys and the corresponding characters as values.

get_sequential_shift(motifs, *args[, axis, ...])

Calculate the shift needed to align motifs sequentially.

get_strand_index_map()

Get a dictionary of positions as keys and the index of the strand in the motif as values.

insert(index, strand[, join, copy])

Insert a strand at a given index in the motif.

join_strands(strands)

Attempt to join consecutive strands and return the list of joined strands.

pop([index])

Remove and return the strand at the specified index.

register_callback(callback)

Register a new callback function to be executed when an event occurs.

replace_all_strands(strands[, copy, join])

Replace all the strands in the motif with the provided list of strands.

rotate([times])

Rotate the motif 90 degrees clockwise.

save_3d_model([filename, config, topology, ...])

Save the motif 3D structure in a file for structural 3D modeling.

save_fasta([filename])

Save the motif sequences in a FASTA file.

save_json([filename, return_data])

Save the motif representation as a JSON file.

save_text([filename])

Save the motif representation as a text file.

shift(shift_vect[, extend])

Shift the motif of the given shift vector.

sort([key, reverse])

Sort the strands in the motif.

strip([skip_axis])

Remove the empty lines/columns in the motif structure.

to_json()

Convert the Motif instance to a JSON-serializable dictionary.

trace(motif_list, pos, direction, limits)

Trace strands in a motif representation in a recursive manner.

class pyfurnace.design.motifs.loops.TetraLoop(open_left=False, sequence='UUCG', **kwargs)[source]

Represents a specific 4-nucleotide tetraloop RNA motif. This class implements a canonical tetraloop structure (e.g., UUCG) with a predefined folding pattern and 3D coordinates.

Parameters:
open_leftbool, optional

Whether to flip the loop to open to the left. Default is False.

sequencestr, optional

4-nucleotide RNA sequence for the tetraloop. Default is “UUCG”.

**kwargsdict, optional

Additional keyword arguments passed to the Loop superclass. You can override the default strand using the strands argument.

Attributes:
strandslist of Strand

The list of strands in the motif.

sequencestr

Return the sequence of the motif.

_coordsCoords

3D coordinate data loaded from template structure (e.g., from PDB 2KOC).

Methods

align(*motifs[, axis, extend, ...])

Align motifs along a given axis by shifting them (without concatenating).

append(strand[, join, copy])

Append a strand to the motif.

concat(*motifs[, axis, extend, copy, align, ...])

Concatenate multiple motifs along a specified axis.

copy([callback])

Return a copy of the motif.

copy_strands_preserve_blocks(strands[, motif])

Copy a list of strands while preserving strand blocks.

extend_junctions([skip_axis, ...])

Extend the junctions of the motif in the direction of the junctions.

flip([horizontally, vertically, ...])

Flip the strands of the motif horizontally and/or vertically inplace.

folding_barriers([kl_delay])

Compute the folding barriers for a given RNA secondary structure.

from_file(file_path, **kwargs)

Create a Motif object from a text file containing a motif sketch.

from_json(json_data, **kwargs)

Create a Motif object from a JSON string or dictionary.

from_json_file(file_path, **kwargs)

Create a Motif object from a JSON file.

from_list(motif_list, **kwargs)

Create a Motif object from a list of strings representing a motif sketch.

from_structure([structure, sequence, ...])

Parse a structure or sequence representation to a Motif object.

from_text(motif_text, **kwargs)

Create a Motif object from a text string representing a motif sketch.

get_position_map()

Get a dictionary of positions as keys and the corresponding characters as values.

get_sequential_shift(motifs, *args[, axis, ...])

Calculate the shift needed to align motifs sequentially.

get_strand_index_map()

Get a dictionary of positions as keys and the index of the strand in the motif as values.

insert(index, strand[, join, copy])

Insert a strand at a given index in the motif.

join_strands(strands)

Attempt to join consecutive strands and return the list of joined strands.

pop([index])

Remove and return the strand at the specified index.

register_callback(callback)

Register a new callback function to be executed when an event occurs.

replace_all_strands(strands[, copy, join])

Replace all the strands in the motif with the provided list of strands.

rotate([times])

Rotate the motif 90 degrees clockwise.

save_3d_model([filename, config, topology, ...])

Save the motif 3D structure in a file for structural 3D modeling.

save_fasta([filename])

Save the motif sequences in a FASTA file.

save_json([filename, return_data])

Save the motif representation as a JSON file.

save_text([filename])

Save the motif representation as a text file.

set_sequence(new_sequence)

Set a new 4-nucleotide sequence for the tetraloop.

shift(shift_vect[, extend])

Shift the motif of the given shift vector.

sort([key, reverse])

Sort the strands in the motif.

strip([skip_axis])

Remove the empty lines/columns in the motif structure.

to_json()

Convert the Motif instance to a JSON-serializable dictionary.

trace(motif_list, pos, direction, limits)

Trace strands in a motif representation in a recursive manner.

set_sequence(new_sequence)[source]

Set a new 4-nucleotide sequence for the tetraloop.

Return type:

None

Parameters:
new_sequencestr

New tetraloop sequence. Must be exactly 4 nucleotides.

Returns:
None
Raises:
ValueError

If the provided sequence is not exactly 4 nucleotides long.

Kissing loops

class pyfurnace.design.motifs.kissing_loops.BranchedDimer(sequence='', pk_index='0', energy=-8.5, energy_tolerance=1.0, **kwargs)[source]

Branched kissing loop dimer with top and bottom interactions. The motif consists of three strands: - 1) A 180°KL dimer strand - 2) A branched kissing loop strand - 3) A connection strand for the branched kissing loop

The geometry is idealized to match the RNA-A helix structure, trying to adapt the branched kissing loop model from ROAD (https://doi.org/10.1038/s41557-021-00679-1).

Parameters:
sequencestr, optional

Sequence for the top kissing strand. Default is “”.

pk_indexstr or int, optional

Identifier for the pseudoknot. Default is ‘0’.

energyfloat, optional

Free energy of the motif. Default is -8.5.

energy_tolerancefloat, optional

Energy tolerance threshold. Default is 1.0.

**kwargsdict

Additional keyword arguments.

Attributes:
autopairing

Indicates whether the motif automatically pairs bases.

basepair

A dictionary with positions as key and the paired position as values.

callbacks

Get the list of registered callbacks.

energy

Returns the energy of the internal kissing loop

energy_tolerance

Returns the energy tolerance of the internal kissing loop

junctions

A dictionary with Direction as key (right: (1,0), bottom: (0,1), left: (-1,0), top: (0,1)) and an ordered list of junction positon as value.

lock_coords

Boolean indicating if the coordinates are locked in the same block.

max_pos

The maximum x, y coordinates occupied of the motif.

min_pos

The minimum x, y coordinates occupied of the motif.

num_char

The maximum length of the motif lines.

num_lines

The number of lines in the motif structure.

pair_map

The dictionary of the paired indexes (alternative to the dot bracket notation).

pk_index

Returns the pseudoknot symbol of the kissing loop

positions

A tuple of the positions of each character of each strand in 2D space (x,y coordinates).

seq_positions

The positions of each nucleotide in the motif sequence (x,y coordinates).

sequence

Return the sequence of the motif.

strands

The list of strands in the motif.

structure

Return the dot bracket representation of the motif.

Methods

align(*motifs[, axis, extend, ...])

Align motifs along a given axis by shifting them (without concatenating).

append(strand[, join, copy])

Append a strand to the motif.

complementary_pk_index([pk_index])

Returns the complementary pseudoknot symbol of the kissing loop

concat(*motifs[, axis, extend, copy, align, ...])

Concatenate multiple motifs along a specified axis.

copy([callback])

Return a copy of the motif.

copy_strands_preserve_blocks(strands[, motif])

Copy a list of strands while preserving strand blocks.

extend_junctions([skip_axis, ...])

Extend the junctions of the motif in the direction of the junctions.

flip([horizontally, vertically, ...])

Flip the strands of the motif horizontally and/or vertically inplace.

folding_barriers([kl_delay])

Compute the folding barriers for a given RNA secondary structure.

from_file(file_path, **kwargs)

Create a Motif object from a text file containing a motif sketch.

from_json(json_data, **kwargs)

Create a Motif object from a JSON string or dictionary.

from_json_file(file_path, **kwargs)

Create a Motif object from a JSON file.

from_list(motif_list, **kwargs)

Create a Motif object from a list of strings representing a motif sketch.

from_structure([structure, sequence, ...])

Parse a structure or sequence representation to a Motif object.

from_text(motif_text, **kwargs)

Create a Motif object from a text string representing a motif sketch.

get_kissing_sequence()

Returns the kissing sequence of the kissing loop

get_position_map()

Get a dictionary of positions as keys and the corresponding characters as values.

get_sequential_shift(motifs, *args[, axis, ...])

Calculate the shift needed to align motifs sequentially.

get_strand_index_map()

Get a dictionary of positions as keys and the index of the strand in the motif as values.

insert(index, strand[, join, copy])

Insert a strand at a given index in the motif.

join_strands(strands)

Attempt to join consecutive strands and return the list of joined strands.

pop([index])

Remove and return the strand at the specified index.

register_callback(callback)

Register a new callback function to be executed when an event occurs.

replace_all_strands(strands[, copy, join])

Replace all the strands in the motif with the provided list of strands.

rotate([times])

Rotate the motif 90 degrees clockwise.

save_3d_model([filename, config, topology, ...])

Save the motif 3D structure in a file for structural 3D modeling.

save_fasta([filename])

Save the motif sequences in a FASTA file.

save_json([filename, return_data])

Save the motif representation as a JSON file.

save_text([filename])

Save the motif representation as a text file.

set_down_sequence(new_seq)

Set the sequence of the bottom strand

set_sequence(new_seq)

Set the sequence of the strand

set_up_sequence(new_seq)

Set the sequence of the top strand

shift(shift_vect[, extend])

Shift the motif of the given shift vector.

sort([key, reverse])

Sort the strands in the motif.

strip([skip_axis])

Remove the empty lines/columns in the motif structure.

to_json()

Convert the Motif instance to a JSON-serializable dictionary.

trace(motif_list, pos, direction, limits)

Trace strands in a motif representation in a recursive manner.

set_down_sequence(new_seq)[source]

Set the sequence of the bottom strand

set_up_sequence(new_seq)[source]

Set the sequence of the top strand

class pyfurnace.design.motifs.kissing_loops.BranchedKissingLoop(open_left=False, sequence='', pk_index='0', energy=-8.5, energy_tolerance=1.0, **kwargs)[source]

Represents a 180° kissing loop motif with a branch connection. The motif consists of two strands: - 1) A kissing loop strand with a branch - 2) A connection strand for the branched kissing loop

The geometry is idealized to match the RNA-A helix structure, trying to adapt the branched kissing loop model from ROAD (https://doi.org/10.1038/s41557-021-00679-1).

Parameters:
open_leftbool, optional

Whether the motif is open on the left side. Default is False.

sequencestr, optional

RNA sequence used for the kissing strand. Default is an empty string.

pk_indexstr or int, optional

Pseudoknot identifier. Default is ‘0’.

energyfloat, optional

Free energy of the structure. Default is -8.5.

energy_tolerancefloat, optional

Tolerance for energy variations. Default is 1.0.

**kwargsdict

Additional keyword arguments.

Attributes:
autopairing

Indicates whether the motif automatically pairs bases.

basepair

A dictionary with positions as key and the paired position as values.

callbacks

Get the list of registered callbacks.

energy

Returns the energy of the internal kissing loop

energy_tolerance

Returns the energy tolerance of the internal kissing loop

junctions

A dictionary with Direction as key (right: (1,0), bottom: (0,1), left: (-1,0), top: (0,1)) and an ordered list of junction positon as value.

lock_coords

Boolean indicating if the coordinates are locked in the same block.

max_pos

The maximum x, y coordinates occupied of the motif.

min_pos

The minimum x, y coordinates occupied of the motif.

num_char

The maximum length of the motif lines.

num_lines

The number of lines in the motif structure.

pair_map

The dictionary of the paired indexes (alternative to the dot bracket notation).

pk_index

Returns the pseudoknot symbol of the kissing loop

positions

A tuple of the positions of each character of each strand in 2D space (x,y coordinates).

seq_positions

The positions of each nucleotide in the motif sequence (x,y coordinates).

sequence

Return the sequence of the motif.

strands

The list of strands in the motif.

structure

Return the dot bracket representation of the motif.

Methods

align(*motifs[, axis, extend, ...])

Align motifs along a given axis by shifting them (without concatenating).

append(strand[, join, copy])

Append a strand to the motif.

complementary_pk_index([pk_index])

Returns the complementary pseudoknot symbol of the kissing loop

concat(*motifs[, axis, extend, copy, align, ...])

Concatenate multiple motifs along a specified axis.

copy([callback])

Return a copy of the motif.

copy_strands_preserve_blocks(strands[, motif])

Copy a list of strands while preserving strand blocks.

extend_junctions([skip_axis, ...])

Extend the junctions of the motif in the direction of the junctions.

flip([horizontally, vertically, ...])

Flip the strands of the motif horizontally and/or vertically inplace.

folding_barriers([kl_delay])

Compute the folding barriers for a given RNA secondary structure.

from_file(file_path, **kwargs)

Create a Motif object from a text file containing a motif sketch.

from_json(json_data, **kwargs)

Create a Motif object from a JSON string or dictionary.

from_json_file(file_path, **kwargs)

Create a Motif object from a JSON file.

from_list(motif_list, **kwargs)

Create a Motif object from a list of strings representing a motif sketch.

from_structure([structure, sequence, ...])

Parse a structure or sequence representation to a Motif object.

from_text(motif_text, **kwargs)

Create a Motif object from a text string representing a motif sketch.

get_kissing_sequence()

Returns the kissing sequence of the kissing loop

get_position_map()

Get a dictionary of positions as keys and the corresponding characters as values.

get_sequential_shift(motifs, *args[, axis, ...])

Calculate the shift needed to align motifs sequentially.

get_strand_index_map()

Get a dictionary of positions as keys and the index of the strand in the motif as values.

insert(index, strand[, join, copy])

Insert a strand at a given index in the motif.

join_strands(strands)

Attempt to join consecutive strands and return the list of joined strands.

pop([index])

Remove and return the strand at the specified index.

register_callback(callback)

Register a new callback function to be executed when an event occurs.

replace_all_strands(strands[, copy, join])

Replace all the strands in the motif with the provided list of strands.

rotate([times])

Rotate the motif 90 degrees clockwise.

save_3d_model([filename, config, topology, ...])

Save the motif 3D structure in a file for structural 3D modeling.

save_fasta([filename])

Save the motif sequences in a FASTA file.

save_json([filename, return_data])

Save the motif representation as a JSON file.

save_text([filename])

Save the motif representation as a text file.

set_sequence(new_seq)

Set the sequence of the strand

shift(shift_vect[, extend])

Shift the motif of the given shift vector.

sort([key, reverse])

Sort the strands in the motif.

strip([skip_axis])

Remove the empty lines/columns in the motif structure.

to_json()

Convert the Motif instance to a JSON-serializable dictionary.

trace(motif_list, pos, direction, limits)

Trace strands in a motif representation in a recursive manner.

get_kissing_sequence()[source]

Returns the kissing sequence of the kissing loop

class pyfurnace.design.motifs.kissing_loops.KissingDimer(sequence='', pk_index='0', energy=-8.5, energy_tolerance=1.0, **kwargs)[source]

A kissing loop dimer composed of two complementary 180-degree loops. The geometry is idealized to match the RNA-A helix structure.

Parameters:
sequencestr, optional

Sequence of the top strand; bottom is inferred as reverse complement.

pk_indexstr or int, optional

Pseudoknot identifier for the dimer. Default is ‘0’.

energyfloat, optional

Free energy of the dimer. Default is -8.5.

energy_tolerancefloat, optional

Tolerance for energy deviation. Default is 1.0.

**kwargsdict

Additional keyword arguments.

Attributes:
autopairing

Indicates whether the motif automatically pairs bases.

basepair

A dictionary with positions as key and the paired position as values.

callbacks

Get the list of registered callbacks.

energy

Returns the energy of the internal kissing loop

energy_tolerance

Returns the energy tolerance of the internal kissing loop

junctions

A dictionary with Direction as key (right: (1,0), bottom: (0,1), left: (-1,0), top: (0,1)) and an ordered list of junction positon as value.

lock_coords

Boolean indicating if the coordinates are locked in the same block.

max_pos

The maximum x, y coordinates occupied of the motif.

min_pos

The minimum x, y coordinates occupied of the motif.

num_char

The maximum length of the motif lines.

num_lines

The number of lines in the motif structure.

pair_map

The dictionary of the paired indexes (alternative to the dot bracket notation).

pk_index

Returns the pseudoknot symbol of the kissing loop

positions

A tuple of the positions of each character of each strand in 2D space (x,y coordinates).

seq_positions

The positions of each nucleotide in the motif sequence (x,y coordinates).

sequence

Return the sequence of the motif.

strands

The list of strands in the motif.

structure

Return the dot bracket representation of the motif.

Methods

align(*motifs[, axis, extend, ...])

Align motifs along a given axis by shifting them (without concatenating).

append(strand[, join, copy])

Append a strand to the motif.

complementary_pk_index([pk_index])

Returns the complementary pseudoknot symbol of the kissing loop

concat(*motifs[, axis, extend, copy, align, ...])

Concatenate multiple motifs along a specified axis.

copy([callback])

Return a copy of the motif.

copy_strands_preserve_blocks(strands[, motif])

Copy a list of strands while preserving strand blocks.

extend_junctions([skip_axis, ...])

Extend the junctions of the motif in the direction of the junctions.

flip([horizontally, vertically, ...])

Flip the strands of the motif horizontally and/or vertically inplace.

folding_barriers([kl_delay])

Compute the folding barriers for a given RNA secondary structure.

from_file(file_path, **kwargs)

Create a Motif object from a text file containing a motif sketch.

from_json(json_data, **kwargs)

Create a Motif object from a JSON string or dictionary.

from_json_file(file_path, **kwargs)

Create a Motif object from a JSON file.

from_list(motif_list, **kwargs)

Create a Motif object from a list of strings representing a motif sketch.

from_structure([structure, sequence, ...])

Parse a structure or sequence representation to a Motif object.

from_text(motif_text, **kwargs)

Create a Motif object from a text string representing a motif sketch.

get_kissing_sequence()

Returns the kissing sequence of the kissing loop

get_position_map()

Get a dictionary of positions as keys and the corresponding characters as values.

get_sequential_shift(motifs, *args[, axis, ...])

Calculate the shift needed to align motifs sequentially.

get_strand_index_map()

Get a dictionary of positions as keys and the index of the strand in the motif as values.

insert(index, strand[, join, copy])

Insert a strand at a given index in the motif.

join_strands(strands)

Attempt to join consecutive strands and return the list of joined strands.

pop([index])

Remove and return the strand at the specified index.

register_callback(callback)

Register a new callback function to be executed when an event occurs.

replace_all_strands(strands[, copy, join])

Replace all the strands in the motif with the provided list of strands.

rotate([times])

Rotate the motif 90 degrees clockwise.

save_3d_model([filename, config, topology, ...])

Save the motif 3D structure in a file for structural 3D modeling.

save_fasta([filename])

Save the motif sequences in a FASTA file.

save_json([filename, return_data])

Save the motif representation as a JSON file.

save_text([filename])

Save the motif representation as a text file.

set_down_sequence(new_seq)

Set the sequence of the bottom strand

set_sequence(new_seq)

Set the sequence of the strand

set_up_sequence(new_seq)

Set the sequence of the top strand

shift(shift_vect[, extend])

Shift the motif of the given shift vector.

sort([key, reverse])

Sort the strands in the motif.

strip([skip_axis])

Remove the empty lines/columns in the motif structure.

to_json()

Convert the Motif instance to a JSON-serializable dictionary.

trace(motif_list, pos, direction, limits)

Trace strands in a motif representation in a recursive manner.

set_down_sequence(new_seq)[source]

Set the sequence of the bottom strand

set_up_sequence(new_seq)[source]

Set the sequence of the top strand

class pyfurnace.design.motifs.kissing_loops.KissingDimer120(sequence='', pk_index='0', energy=-8.5, energy_tolerance=1.0, **kwargs)[source]

Dimer of two complementary kissing loops based on the 120-degree model.

Parameters:
sequencestr, optional

RNA sequence for the top strand. Default is “”.

pk_indexstr or int, optional

Pseudoknot symbol. Default is ‘0’.

energyfloat, optional

Energy of the dimer motif. Default is -8.5.

energy_tolerancefloat, optional

Allowed energy deviation. Default is 1.0.

**kwargsdict

Additional keyword arguments.

Attributes:
autopairing

Indicates whether the motif automatically pairs bases.

basepair

A dictionary with positions as key and the paired position as values.

callbacks

Get the list of registered callbacks.

energy

Returns the energy of the internal kissing loop

energy_tolerance

Returns the energy tolerance of the internal kissing loop

junctions

A dictionary with Direction as key (right: (1,0), bottom: (0,1), left: (-1,0), top: (0,1)) and an ordered list of junction positon as value.

lock_coords

Boolean indicating if the coordinates are locked in the same block.

max_pos

The maximum x, y coordinates occupied of the motif.

min_pos

The minimum x, y coordinates occupied of the motif.

num_char

The maximum length of the motif lines.

num_lines

The number of lines in the motif structure.

pair_map

The dictionary of the paired indexes (alternative to the dot bracket notation).

pk_index

Returns the pseudoknot symbol of the kissing loop

positions

A tuple of the positions of each character of each strand in 2D space (x,y coordinates).

seq_positions

The positions of each nucleotide in the motif sequence (x,y coordinates).

sequence

Return the sequence of the motif.

strands

The list of strands in the motif.

structure

Return the dot bracket representation of the motif.

Methods

align(*motifs[, axis, extend, ...])

Align motifs along a given axis by shifting them (without concatenating).

append(strand[, join, copy])

Append a strand to the motif.

complementary_pk_index([pk_index])

Returns the complementary pseudoknot symbol of the kissing loop

concat(*motifs[, axis, extend, copy, align, ...])

Concatenate multiple motifs along a specified axis.

copy([callback])

Return a copy of the motif.

copy_strands_preserve_blocks(strands[, motif])

Copy a list of strands while preserving strand blocks.

extend_junctions([skip_axis, ...])

Extend the junctions of the motif in the direction of the junctions.

flip([horizontally, vertically, ...])

Flip the strands of the motif horizontally and/or vertically inplace.

folding_barriers([kl_delay])

Compute the folding barriers for a given RNA secondary structure.

from_file(file_path, **kwargs)

Create a Motif object from a text file containing a motif sketch.

from_json(json_data, **kwargs)

Create a Motif object from a JSON string or dictionary.

from_json_file(file_path, **kwargs)

Create a Motif object from a JSON file.

from_list(motif_list, **kwargs)

Create a Motif object from a list of strings representing a motif sketch.

from_structure([structure, sequence, ...])

Parse a structure or sequence representation to a Motif object.

from_text(motif_text, **kwargs)

Create a Motif object from a text string representing a motif sketch.

get_kissing_sequence()

Returns the kissing sequence of the kissing loop

get_position_map()

Get a dictionary of positions as keys and the corresponding characters as values.

get_sequential_shift(motifs, *args[, axis, ...])

Calculate the shift needed to align motifs sequentially.

get_strand_index_map()

Get a dictionary of positions as keys and the index of the strand in the motif as values.

insert(index, strand[, join, copy])

Insert a strand at a given index in the motif.

join_strands(strands)

Attempt to join consecutive strands and return the list of joined strands.

pop([index])

Remove and return the strand at the specified index.

register_callback(callback)

Register a new callback function to be executed when an event occurs.

replace_all_strands(strands[, copy, join])

Replace all the strands in the motif with the provided list of strands.

rotate([times])

Rotate the motif 90 degrees clockwise.

save_3d_model([filename, config, topology, ...])

Save the motif 3D structure in a file for structural 3D modeling.

save_fasta([filename])

Save the motif sequences in a FASTA file.

save_json([filename, return_data])

Save the motif representation as a JSON file.

save_text([filename])

Save the motif representation as a text file.

set_down_sequence(new_seq)

Set the sequence of the bottom strand

set_sequence(new_seq)

Set the sequence of the strand

set_up_sequence(new_seq)

Set the sequence of the top strand

shift(shift_vect[, extend])

Shift the motif of the given shift vector.

sort([key, reverse])

Sort the strands in the motif.

strip([skip_axis])

Remove the empty lines/columns in the motif structure.

to_json()

Convert the Motif instance to a JSON-serializable dictionary.

trace(motif_list, pos, direction, limits)

Trace strands in a motif representation in a recursive manner.

set_down_sequence(new_seq)[source]

Set the sequence of the bottom strand

set_up_sequence(new_seq)[source]

Set the sequence of the top strand

class pyfurnace.design.motifs.kissing_loops.KissingLoop(open_left=False, sequence='', seq_len=0, pk_index='0', energy=-8.5, energy_tolerance=1.0, **kwargs)[source]

Represents a pseudoknotted kissing loop motif in RNA secondary structure.

Parameters:
open_leftbool, optional

If True, the loop is open on the left side. Default is False.

sequencestr, optional

RNA sequence of the internal kissing loop. Default is an empty string.

seq_lenint, optional

Expected length of the sequence. Used for validation. Default is 0.

pk_indexstr or int, optional

Pseudoknot index or symbol identifying the loop. Default is ‘0’.

energyfloat, optional

Free energy (in kcal/mol) associated with the loop. Default is -8.5.

energy_tolerancefloat, optional

Tolerance on the energy for acceptable structural variants. Default is 1.0.

**kwargsdict

Additional arguments passed to the parent Loop constructor.

Attributes:
pk_indexstr

Returns the pseudoknot symbol of the kissing loop

energyfloat

Returns the energy of the internal kissing loop

energy_tolerancefloat

Returns the energy tolerance of the internal kissing loop

Methods

align(*motifs[, axis, extend, ...])

Align motifs along a given axis by shifting them (without concatenating).

append(strand[, join, copy])

Append a strand to the motif.

complementary_pk_index([pk_index])

Returns the complementary pseudoknot symbol of the kissing loop

concat(*motifs[, axis, extend, copy, align, ...])

Concatenate multiple motifs along a specified axis.

copy([callback])

Return a copy of the motif.

copy_strands_preserve_blocks(strands[, motif])

Copy a list of strands while preserving strand blocks.

extend_junctions([skip_axis, ...])

Extend the junctions of the motif in the direction of the junctions.

flip([horizontally, vertically, ...])

Flip the strands of the motif horizontally and/or vertically inplace.

folding_barriers([kl_delay])

Compute the folding barriers for a given RNA secondary structure.

from_file(file_path, **kwargs)

Create a Motif object from a text file containing a motif sketch.

from_json(json_data, **kwargs)

Create a Motif object from a JSON string or dictionary.

from_json_file(file_path, **kwargs)

Create a Motif object from a JSON file.

from_list(motif_list, **kwargs)

Create a Motif object from a list of strings representing a motif sketch.

from_structure([structure, sequence, ...])

Parse a structure or sequence representation to a Motif object.

from_text(motif_text, **kwargs)

Create a Motif object from a text string representing a motif sketch.

get_kissing_sequence()

Returns the kissing sequence of the kissing loop

get_position_map()

Get a dictionary of positions as keys and the corresponding characters as values.

get_sequential_shift(motifs, *args[, axis, ...])

Calculate the shift needed to align motifs sequentially.

get_strand_index_map()

Get a dictionary of positions as keys and the index of the strand in the motif as values.

insert(index, strand[, join, copy])

Insert a strand at a given index in the motif.

join_strands(strands)

Attempt to join consecutive strands and return the list of joined strands.

pop([index])

Remove and return the strand at the specified index.

register_callback(callback)

Register a new callback function to be executed when an event occurs.

replace_all_strands(strands[, copy, join])

Replace all the strands in the motif with the provided list of strands.

rotate([times])

Rotate the motif 90 degrees clockwise.

save_3d_model([filename, config, topology, ...])

Save the motif 3D structure in a file for structural 3D modeling.

save_fasta([filename])

Save the motif sequences in a FASTA file.

save_json([filename, return_data])

Save the motif representation as a JSON file.

save_text([filename])

Save the motif representation as a text file.

set_sequence(new_seq)

Set the sequence of the strand

shift(shift_vect[, extend])

Shift the motif of the given shift vector.

sort([key, reverse])

Sort the strands in the motif.

strip([skip_axis])

Remove the empty lines/columns in the motif structure.

to_json()

Convert the Motif instance to a JSON-serializable dictionary.

trace(motif_list, pos, direction, limits)

Trace strands in a motif representation in a recursive manner.

complementary_pk_index(pk_index=None)[source]

Returns the complementary pseudoknot symbol of the kissing loop

Return type:

str

Parameters:
pk_indexstr or int, optional

The pseudoknot index to complement. If None, uses the current pk_index.

Returns:
str

The complementary pseudoknot index.

property energy

Returns the energy of the internal kissing loop

property energy_tolerance

Returns the energy tolerance of the internal kissing loop

get_kissing_sequence()[source]

Returns the kissing sequence of the kissing loop

property pk_index

Returns the pseudoknot symbol of the kissing loop

set_sequence(new_seq)[source]

Set the sequence of the strand

class pyfurnace.design.motifs.kissing_loops.KissingLoop120(open_left=False, sequence='', pk_index='0', energy=-8.5, energy_tolerance=1.0, **kwargs)[source]

Kissing loop motif based on structural template from PDB entry 1BJ2.

Parameters:
open_leftbool, optional

Whether the loop is open on the left side. Default is False.

sequencestr, optional

RNA sequence to use. Default is an empty string.

pk_indexstr or int, optional

Pseudoknot index or label. Default is ‘0’.

energyfloat, optional

Free energy (kcal/mol) of the loop. Default is -8.5.

energy_tolerancefloat, optional

Tolerance on the energy value. Default is 1.0.

**kwargsdict

Additional arguments passed to the parent constructor.

Attributes:
autopairing

Indicates whether the motif automatically pairs bases.

basepair

A dictionary with positions as key and the paired position as values.

callbacks

Get the list of registered callbacks.

energy

Returns the energy of the internal kissing loop

energy_tolerance

Returns the energy tolerance of the internal kissing loop

junctions

A dictionary with Direction as key (right: (1,0), bottom: (0,1), left: (-1,0), top: (0,1)) and an ordered list of junction positon as value.

lock_coords

Boolean indicating if the coordinates are locked in the same block.

max_pos

The maximum x, y coordinates occupied of the motif.

min_pos

The minimum x, y coordinates occupied of the motif.

num_char

The maximum length of the motif lines.

num_lines

The number of lines in the motif structure.

pair_map

The dictionary of the paired indexes (alternative to the dot bracket notation).

pk_index

Returns the pseudoknot symbol of the kissing loop

positions

A tuple of the positions of each character of each strand in 2D space (x,y coordinates).

seq_positions

The positions of each nucleotide in the motif sequence (x,y coordinates).

sequence

Return the sequence of the motif.

strands

The list of strands in the motif.

structure

Return the dot bracket representation of the motif.

Methods

align(*motifs[, axis, extend, ...])

Align motifs along a given axis by shifting them (without concatenating).

append(strand[, join, copy])

Append a strand to the motif.

complementary_pk_index([pk_index])

Returns the complementary pseudoknot symbol of the kissing loop

concat(*motifs[, axis, extend, copy, align, ...])

Concatenate multiple motifs along a specified axis.

copy([callback])

Return a copy of the motif.

copy_strands_preserve_blocks(strands[, motif])

Copy a list of strands while preserving strand blocks.

extend_junctions([skip_axis, ...])

Extend the junctions of the motif in the direction of the junctions.

flip([horizontally, vertically, ...])

Flip the strands of the motif horizontally and/or vertically inplace.

folding_barriers([kl_delay])

Compute the folding barriers for a given RNA secondary structure.

from_file(file_path, **kwargs)

Create a Motif object from a text file containing a motif sketch.

from_json(json_data, **kwargs)

Create a Motif object from a JSON string or dictionary.

from_json_file(file_path, **kwargs)

Create a Motif object from a JSON file.

from_list(motif_list, **kwargs)

Create a Motif object from a list of strings representing a motif sketch.

from_structure([structure, sequence, ...])

Parse a structure or sequence representation to a Motif object.

from_text(motif_text, **kwargs)

Create a Motif object from a text string representing a motif sketch.

get_kissing_sequence()

Returns the kissing sequence of the kissing loop

get_position_map()

Get a dictionary of positions as keys and the corresponding characters as values.

get_sequential_shift(motifs, *args[, axis, ...])

Calculate the shift needed to align motifs sequentially.

get_strand_index_map()

Get a dictionary of positions as keys and the index of the strand in the motif as values.

insert(index, strand[, join, copy])

Insert a strand at a given index in the motif.

join_strands(strands)

Attempt to join consecutive strands and return the list of joined strands.

pop([index])

Remove and return the strand at the specified index.

register_callback(callback)

Register a new callback function to be executed when an event occurs.

replace_all_strands(strands[, copy, join])

Replace all the strands in the motif with the provided list of strands.

rotate([times])

Rotate the motif 90 degrees clockwise.

save_3d_model([filename, config, topology, ...])

Save the motif 3D structure in a file for structural 3D modeling.

save_fasta([filename])

Save the motif sequences in a FASTA file.

save_json([filename, return_data])

Save the motif representation as a JSON file.

save_text([filename])

Save the motif representation as a text file.

set_sequence(new_seq)

Set the sequence of the strand

shift(shift_vect[, extend])

Shift the motif of the given shift vector.

sort([key, reverse])

Sort the strands in the motif.

strip([skip_axis])

Remove the empty lines/columns in the motif structure.

to_json()

Convert the Motif instance to a JSON-serializable dictionary.

trace(motif_list, pos, direction, limits)

Trace strands in a motif representation in a recursive manner.

class pyfurnace.design.motifs.kissing_loops.KissingLoop180(open_left=False, sequence='', pk_index='0', energy=-8.5, energy_tolerance=1.0, **kwargs)[source]

Kissing loop from HIV with idealized helical geometry for 180-degree interaction.

Parameters:
open_leftbool, optional

Whether the loop is open on the left. Default is False.

sequencestr, optional

RNA sequence for the motif. Default is an empty string.

pk_indexstr or int, optional

Pseudoknot index for identification. Default is ‘0’.

energyfloat, optional

Free energy of the motif. Default is -8.5.

energy_tolerancefloat, optional

Acceptable energy deviation. Default is 1.0.

**kwargsdict

Additional keyword arguments.

Attributes:
autopairing

Indicates whether the motif automatically pairs bases.

basepair

A dictionary with positions as key and the paired position as values.

callbacks

Get the list of registered callbacks.

energy

Returns the energy of the internal kissing loop

energy_tolerance

Returns the energy tolerance of the internal kissing loop

junctions

A dictionary with Direction as key (right: (1,0), bottom: (0,1), left: (-1,0), top: (0,1)) and an ordered list of junction positon as value.

lock_coords

Boolean indicating if the coordinates are locked in the same block.

max_pos

The maximum x, y coordinates occupied of the motif.

min_pos

The minimum x, y coordinates occupied of the motif.

num_char

The maximum length of the motif lines.

num_lines

The number of lines in the motif structure.

pair_map

The dictionary of the paired indexes (alternative to the dot bracket notation).

pk_index

Returns the pseudoknot symbol of the kissing loop

positions

A tuple of the positions of each character of each strand in 2D space (x,y coordinates).

seq_positions

The positions of each nucleotide in the motif sequence (x,y coordinates).

sequence

Return the sequence of the motif.

strands

The list of strands in the motif.

structure

Return the dot bracket representation of the motif.

Methods

align(*motifs[, axis, extend, ...])

Align motifs along a given axis by shifting them (without concatenating).

append(strand[, join, copy])

Append a strand to the motif.

complementary_pk_index([pk_index])

Returns the complementary pseudoknot symbol of the kissing loop

concat(*motifs[, axis, extend, copy, align, ...])

Concatenate multiple motifs along a specified axis.

copy([callback])

Return a copy of the motif.

copy_strands_preserve_blocks(strands[, motif])

Copy a list of strands while preserving strand blocks.

extend_junctions([skip_axis, ...])

Extend the junctions of the motif in the direction of the junctions.

flip([horizontally, vertically, ...])

Flip the strands of the motif horizontally and/or vertically inplace.

folding_barriers([kl_delay])

Compute the folding barriers for a given RNA secondary structure.

from_file(file_path, **kwargs)

Create a Motif object from a text file containing a motif sketch.

from_json(json_data, **kwargs)

Create a Motif object from a JSON string or dictionary.

from_json_file(file_path, **kwargs)

Create a Motif object from a JSON file.

from_list(motif_list, **kwargs)

Create a Motif object from a list of strings representing a motif sketch.

from_structure([structure, sequence, ...])

Parse a structure or sequence representation to a Motif object.

from_text(motif_text, **kwargs)

Create a Motif object from a text string representing a motif sketch.

get_kissing_sequence()

Returns the kissing sequence of the kissing loop

get_position_map()

Get a dictionary of positions as keys and the corresponding characters as values.

get_sequential_shift(motifs, *args[, axis, ...])

Calculate the shift needed to align motifs sequentially.

get_strand_index_map()

Get a dictionary of positions as keys and the index of the strand in the motif as values.

insert(index, strand[, join, copy])

Insert a strand at a given index in the motif.

join_strands(strands)

Attempt to join consecutive strands and return the list of joined strands.

pop([index])

Remove and return the strand at the specified index.

register_callback(callback)

Register a new callback function to be executed when an event occurs.

replace_all_strands(strands[, copy, join])

Replace all the strands in the motif with the provided list of strands.

rotate([times])

Rotate the motif 90 degrees clockwise.

save_3d_model([filename, config, topology, ...])

Save the motif 3D structure in a file for structural 3D modeling.

save_fasta([filename])

Save the motif sequences in a FASTA file.

save_json([filename, return_data])

Save the motif representation as a JSON file.

save_text([filename])

Save the motif representation as a text file.

set_sequence(new_seq)

Set the sequence of the strand

shift(shift_vect[, extend])

Shift the motif of the given shift vector.

sort([key, reverse])

Sort the strands in the motif.

strip([skip_axis])

Remove the empty lines/columns in the motif structure.

to_json()

Convert the Motif instance to a JSON-serializable dictionary.

trace(motif_list, pos, direction, limits)

Trace strands in a motif representation in a recursive manner.

get_kissing_sequence()[source]

Returns the kissing sequence of the kissing loop

Aptamers

class pyfurnace.design.motifs.aptamers.Aptamer(*strands, basepair=None, structure=None, autopairing=True, lock_coords=True, join=True, copy=False, **kwargs)[source]

Base class for all aptamers, inheriting from the Motif class. This class is used to create aptamers with specific sequences and coordinates. At the moment, it does not add any additional functionality to the Motif class, but it can be used to create a common interface for all aptamers or for screening motifs in an origami.

Attributes:
autopairing

Indicates whether the motif automatically pairs bases.

basepair

A dictionary with positions as key and the paired position as values.

callbacks

Get the list of registered callbacks.

junctions

A dictionary with Direction as key (right: (1,0), bottom: (0,1), left: (-1,0), top: (0,1)) and an ordered list of junction positon as value.

lock_coords

Boolean indicating if the coordinates are locked in the same block.

max_pos

The maximum x, y coordinates occupied of the motif.

min_pos

The minimum x, y coordinates occupied of the motif.

num_char

The maximum length of the motif lines.

num_lines

The number of lines in the motif structure.

pair_map

The dictionary of the paired indexes (alternative to the dot bracket notation).

positions

A tuple of the positions of each character of each strand in 2D space (x,y coordinates).

seq_positions

The positions of each nucleotide in the motif sequence (x,y coordinates).

sequence

Return the sequence of the motif.

strands

The list of strands in the motif.

structure

Return the dot bracket representation of the motif.

Methods

align(*motifs[, axis, extend, ...])

Align motifs along a given axis by shifting them (without concatenating).

append(strand[, join, copy])

Append a strand to the motif.

concat(*motifs[, axis, extend, copy, align, ...])

Concatenate multiple motifs along a specified axis.

copy([callback])

Return a copy of the motif.

copy_strands_preserve_blocks(strands[, motif])

Copy a list of strands while preserving strand blocks.

extend_junctions([skip_axis, ...])

Extend the junctions of the motif in the direction of the junctions.

flip([horizontally, vertically, ...])

Flip the strands of the motif horizontally and/or vertically inplace.

folding_barriers([kl_delay])

Compute the folding barriers for a given RNA secondary structure.

from_file(file_path, **kwargs)

Create a Motif object from a text file containing a motif sketch.

from_json(json_data, **kwargs)

Create a Motif object from a JSON string or dictionary.

from_json_file(file_path, **kwargs)

Create a Motif object from a JSON file.

from_list(motif_list, **kwargs)

Create a Motif object from a list of strings representing a motif sketch.

from_structure([structure, sequence, ...])

Parse a structure or sequence representation to a Motif object.

from_text(motif_text, **kwargs)

Create a Motif object from a text string representing a motif sketch.

get_position_map()

Get a dictionary of positions as keys and the corresponding characters as values.

get_sequential_shift(motifs, *args[, axis, ...])

Calculate the shift needed to align motifs sequentially.

get_strand_index_map()

Get a dictionary of positions as keys and the index of the strand in the motif as values.

insert(index, strand[, join, copy])

Insert a strand at a given index in the motif.

join_strands(strands)

Attempt to join consecutive strands and return the list of joined strands.

pop([index])

Remove and return the strand at the specified index.

register_callback(callback)

Register a new callback function to be executed when an event occurs.

replace_all_strands(strands[, copy, join])

Replace all the strands in the motif with the provided list of strands.

rotate([times])

Rotate the motif 90 degrees clockwise.

save_3d_model([filename, config, topology, ...])

Save the motif 3D structure in a file for structural 3D modeling.

save_fasta([filename])

Save the motif sequences in a FASTA file.

save_json([filename, return_data])

Save the motif representation as a JSON file.

save_text([filename])

Save the motif representation as a text file.

shift(shift_vect[, extend])

Shift the motif of the given shift vector.

sort([key, reverse])

Sort the strands in the motif.

strip([skip_axis])

Remove the empty lines/columns in the motif structure.

to_json()

Convert the Motif instance to a JSON-serializable dictionary.

trace(motif_list, pos, direction, limits)

Trace strands in a motif representation in a recursive manner.

pyfurnace.design.motifs.aptamers.Biotin(**kwargs)[source]

Returns the biotin-binding aptamer motif.

Based on PDB structure 1F27.

pyfurnace.design.motifs.aptamers.Broccoli(**kwargs)[source]

Returns the Broccoli aptamer motif.

A fluorescent aptamer derived from PDB 7ZJ5.

pyfurnace.design.motifs.aptamers.Ispinach(**kwargs)[source]

Returns the ISpinach aptamer motif.

A fluorescent RNA aptamer modeled from PDB 5OB3.

pyfurnace.design.motifs.aptamers.L7Ae(**kwargs)[source]

Returns the L7Ae protein-binding aptamer.

Structure based on PDB 1RLG.

pyfurnace.design.motifs.aptamers.MS2(open_left=False, **kwargs)[source]

Returns the MS2 coat protein-binding aptamer.

Based on PDB 1ZDH, extended by 3 nucleotides.

pyfurnace.design.motifs.aptamers.MalachiteGreen(open_left=False, **kwargs)[source]

Returns the full Malachite Green aptamer motif.

Derived from the structure in PDB 1Q8N.

pyfurnace.design.motifs.aptamers.MalachiteGreenShort(**kwargs)[source]

Returns a truncated version of the Malachite Green aptamer.

Designed for minimal structural features. Based on PDB 1Q8N.

pyfurnace.design.motifs.aptamers.Mango(open_left=False, **kwargs)[source]

Returns the Mango aptamer as a loop-based motif.

A fluorogenic aptamer based on PDB 5V3F.

pyfurnace.design.motifs.aptamers.OrangeBroccoli(**kwargs)[source]

Returns the Orange Broccoli aptamer motif. Pubblication: https://doi.org/10.1038/nchembio.2477

Structure from the Broccoli PDB 7ZJ5.

pyfurnace.design.motifs.aptamers.PIP3(open_left=False, **kwargs)[source]

Returns the PIP3-binding aptamer motif. Pubblication: https://doi.org/10.1038/ncb3473

Structure generated with RNA Composer for synthetic design. (https://doi.org/10.1093/nar/gks339, https://doi.org/10.1002/prot.26578)

pyfurnace.design.motifs.aptamers.PIP3_mut1(open_left=False, **kwargs)[source]

Returns mutant 1 of the PIP3 aptamer. Sequence-modified variant for functional screening. Pubblication: https://doi.org/10.1038/ncb3473

Structure generated with RNA Composer for synthetic design. (https://doi.org/10.1093/nar/gks339, https://doi.org/10.1002/prot.26578)

pyfurnace.design.motifs.aptamers.PIP3_mut3(open_left=False, **kwargs)[source]

Returns mutant 3 of the PIP3 aptamer. Sequence-modified variant for functional screening. Pubblication: https://doi.org/10.1038/ncb3473

Structure generated with RNA Composer for synthetic design. (https://doi.org/10.1093/nar/gks339, https://doi.org/10.1002/prot.26578)

pyfurnace.design.motifs.aptamers.PIP3_mut5(open_left=False, **kwargs)[source]

Returns mutant 5 of the PIP3 aptamer. Sequence-modified variant for functional screening. Pubblication: https://doi.org/10.1038/ncb3473

Structure generated with RNA Composer for synthetic design. (https://doi.org/10.1093/nar/gks339, https://doi.org/10.1002/prot.26578)

pyfurnace.design.motifs.aptamers.PP7(open_left=False, **kwargs)[source]

Returns the PP7 coat protein-binding aptamer.

Derived from PDB 2QUX.

pyfurnace.design.motifs.aptamers.Pepper(**kwargs)[source]

Returns the Pepper aptamer motif.

A compact fluorescent RNA aptamer. Based on PDB 7ZJ5.

pyfurnace.design.motifs.aptamers.RedBroccoli(**kwargs)[source]

Returns the Red Broccoli aptamer motif. Pubblication: https://doi.org/10.1038/nchembio.2477

Structure from the Broccoli PDB 7ZJ5.

pyfurnace.design.motifs.aptamers.Streptavidin(open_left=False, **kwargs)[source]

Returns the Streptavidin-binding aptamer. Pubblication: https://doi.org/10.1093/nar/gkt956

Modeled using RNA Composer based on experimental data. (https://doi.org/10.1093/nar/gks339, https://doi.org/10.1002/prot.26578)

pyfurnace.design.motifs.aptamers.TAR_TAT(open_left=False, **kwargs)[source]

Returns the HIV TAR-TAT binding aptamer.

Structure based on PDB 6MCE.

pyfurnace.design.motifs.aptamers.Thrombin_exosite1(open_left=False, **kwargs)[source]

Returns the thrombin exosite 1-binding aptamer. Used for anticoagulant and structural studies. Pubblication: https://doi.org/10.1111/j.1538-7836.2012.04679.x

Modeled using RNA Composer based on experimental data. (https://doi.org/10.1093/nar/gks339, https://doi.org/10.1002/prot.26578)

pyfurnace.design.motifs.aptamers.Thrombin_exosite2(open_left=False, **kwargs)[source]

Returns the thrombin exosite 2-binding aptamer.

Based on modified PDB structure 5DO4 (replaced fluorinated ribose with regular ribose).

pyfurnace.design.motifs.aptamers.create_aptamer(*args, inherit_from=None, **kwargs)[source]

Create an Aptamer object, optionally inheriting from a specified base class.

Parameters:
argslist

Positional arguments to be passed to the Aptamer constructor.

inherit_fromclassmethod, optional

A class from which the Aptamer class should inherit. If not provided, the Aptamer class will be used as is.

kwargsdict

Keyword arguments to be passed to the Aptamer constructor.

Returns:
Aptamer
An instance of the Aptamer class, optionally inheriting from the specified

inherit_from class.

Utilities

Motif Utilities

class pyfurnace.design.utils.motif_lib.Utils(*args, hflip=False, vflip=False, rotate=0, **kwargs)[source]

Utility class that extends the Motif class with optional flipping and rotation.

Parameters:
*argstuple

Positional arguments passed to the base Motif class.

hflipbool, optional

If True, apply a horizontal flip to the motif. Default is False.

vflipbool, optional

If True, apply a vertical flip to the motif. Default is False.

rotateint, optional

Rotation in degrees (usually 90, 180, 270). Default is 0.

**kwargsdict

Additional keyword arguments passed to the Motif base class.

Attributes:
autopairing

Indicates whether the motif automatically pairs bases.

basepair

A dictionary with positions as key and the paired position as values.

callbacks

Get the list of registered callbacks.

junctions

A dictionary with Direction as key (right: (1,0), bottom: (0,1), left: (-1,0), top: (0,1)) and an ordered list of junction positon as value.

lock_coords

Boolean indicating if the coordinates are locked in the same block.

max_pos

The maximum x, y coordinates occupied of the motif.

min_pos

The minimum x, y coordinates occupied of the motif.

num_char

The maximum length of the motif lines.

num_lines

The number of lines in the motif structure.

pair_map

The dictionary of the paired indexes (alternative to the dot bracket notation).

positions

A tuple of the positions of each character of each strand in 2D space (x,y coordinates).

seq_positions

The positions of each nucleotide in the motif sequence (x,y coordinates).

sequence

Return the sequence of the motif.

strands

The list of strands in the motif.

structure

Return the dot bracket representation of the motif.

Methods

align(*motifs[, axis, extend, ...])

Align motifs along a given axis by shifting them (without concatenating).

append(strand[, join, copy])

Append a strand to the motif.

concat(*motifs[, axis, extend, copy, align, ...])

Concatenate multiple motifs along a specified axis.

copy([callback])

Return a copy of the motif.

copy_strands_preserve_blocks(strands[, motif])

Copy a list of strands while preserving strand blocks.

extend_junctions([skip_axis, ...])

Extend the junctions of the motif in the direction of the junctions.

flip([horizontally, vertically, ...])

Flip the strands of the motif horizontally and/or vertically inplace.

folding_barriers([kl_delay])

Compute the folding barriers for a given RNA secondary structure.

from_file(file_path, **kwargs)

Create a Motif object from a text file containing a motif sketch.

from_json(json_data, **kwargs)

Create a Motif object from a JSON string or dictionary.

from_json_file(file_path, **kwargs)

Create a Motif object from a JSON file.

from_list(motif_list, **kwargs)

Create a Motif object from a list of strings representing a motif sketch.

from_structure([structure, sequence, ...])

Parse a structure or sequence representation to a Motif object.

from_text(motif_text, **kwargs)

Create a Motif object from a text string representing a motif sketch.

get_position_map()

Get a dictionary of positions as keys and the corresponding characters as values.

get_sequential_shift(motifs, *args[, axis, ...])

Calculate the shift needed to align motifs sequentially.

get_strand_index_map()

Get a dictionary of positions as keys and the index of the strand in the motif as values.

insert(index, strand[, join, copy])

Insert a strand at a given index in the motif.

join_strands(strands)

Attempt to join consecutive strands and return the list of joined strands.

pop([index])

Remove and return the strand at the specified index.

register_callback(callback)

Register a new callback function to be executed when an event occurs.

replace_all_strands(strands[, copy, join])

Replace all the strands in the motif with the provided list of strands.

rotate([times])

Rotate the motif 90 degrees clockwise.

save_3d_model([filename, config, topology, ...])

Save the motif 3D structure in a file for structural 3D modeling.

save_fasta([filename])

Save the motif sequences in a FASTA file.

save_json([filename, return_data])

Save the motif representation as a JSON file.

save_text([filename])

Save the motif representation as a text file.

shift(shift_vect[, extend])

Shift the motif of the given shift vector.

sort([key, reverse])

Sort the strands in the motif.

strip([skip_axis])

Remove the empty lines/columns in the motif structure.

to_json()

Convert the Motif instance to a JSON-serializable dictionary.

trace(motif_list, pos, direction, limits)

Trace strands in a motif representation in a recursive manner.

pyfurnace.design.utils.motif_lib.single_strand(sequence='', loop=False, **kwargs)[source]

Creates a single-stranded region motif, optionally forming a loop.

Return type:

Utils

Parameters:
sequencestr, optional

The nucleotide sequence for the single-stranded region. Default is an empty string.

loopbool, optional

If True, the single-stranded region forms a loop. Default is False.

**kwargsdict

Additional keyword arguments passed to the Utils constructor.

Returns:
Utils

A single-stranded region Utils object.

pyfurnace.design.utils.motif_lib.start_end_stem(up_left='3', up_right='5', down_left='-', down_right='-', **kwargs)[source]

Creates a Utils motif representing the start or end of a stem with optional strand labels. For each position, the acceptable values are: ‘3’, ‘5’, ‘─’, ‘-’, ‘’, or None.

Return type:

Utils

Parameters:
up_leftstr or None, optional. Default is ‘3’.

Label for the top-left strand.

up_rightstr or None, optional

Label for the top-right strand. Default is ‘5’.

down_leftstr or None, optional

Label for the bottom-left strand. Default is ‘-‘.

down_rightstr or None, optional

Label for the bottom-right strand. Default is ‘-‘.

**kwargsdict

Additional keyword arguments passed to the Utils constructor.

Returns:
Utils

An instance of the Utils class with the appropriate strands.

Creates a stem cap motif with a curved connection and vertical segments.

Return type:

Utils

Returns:
Utils

A stem cap Utils object.

Creates a double vertical link motif using two parallel vertical strands.

Return type:

Utils

Returns:
Utils

A vertical double link Utils object.

Creates a vertical link motif represented by a single vertical strand.

Return type:

Utils

Returns:
Utils

A vertical link Utils object.

Origami Utilities

pyfurnace.design.utils.origami_lib.convert_angles_to_dt(angles_list)[source]

Convert a list of helix angles into corresponding dovetail values based on a predefined mapping.

Return type:

List[int]

Parameters:
angles_listlist of float

List of helix angles in degrees. Angles will be wrapped modulo 360.

Returns:
list of int

Corresponding dovetail values for each angle in the input list.

pyfurnace.design.utils.origami_lib.ipython_clickable_txt(origami, max_height='500', barriers=None, gradient=False, font_size=12, overlay_data=None, norm_cmap_function=None)[source]

Generate an interactive, scrollable HTML view of a RNA origami structure with clickable motifs that display their indexes in a JavaScript alert.

Return type:

str

Parameters:
origamiOrigami

An Origami object representing the RNA structure.

max_heightstr or int, optional

The maximum height of the scrollable view in pixels. Default is ‘500’.

barriersoptional

Optional barrier data to overlay on the origami representation.

gradientbool or str, optional

Whether to color motifs using a gradient. If str, interpreted as colormap name from matplotlib. Default is False.

font_sizeint, optional

Font size of the text in pixels. Default is 12.

overlay_data: dict, optional

Dictinary of the overlay data. Default is None. Format is {“Parameter name”: [nt1_value, nt2_value, …]} If a gradient is given, it is based on this data.

norm_cmap_function: function, optional

Function to normalize the overlay data to generate the colormap only (the data itself is not changed). Only applied if overlay_data is not None. Default is None.

Returns:
str

An HTML string rendered via IPython’s display system.

Notes

  • This function uses inline CSS and JavaScript for visual styling and interaction.

  • Clicking a motif will trigger a JavaScript alert showing its position.

pyfurnace.design.utils.origami_lib.ipython_display_3d(origami, **kwargs)[source]

Display a 3D representation of an Origami structure within a J upyter notebook using oxDNA.

Return type:

None

Parameters:
origamiOrigami

The Origami structure to visualize.

**kwargsdict, optional

Additional keyword arguments passed to the oxdna_conf visualization function.

Returns:
None
pyfurnace.design.utils.origami_lib.ipython_display_txt(origami_text, max_height='500')[source]

Render plain text (e.g., a textual representation of an origami object) as a scrollable HTML block in Jupyter.

Return type:

None

Parameters:
origami_textstr, Origami

The content to display in scrollable format.

max_heightstr, optional

Maximum height of the scrollable box in pixels (default is ‘500’).

Returns:
None
pyfurnace.design.utils.origami_lib.log_norm(data, eps=1e-12)[source]

Normalize data using logarithmic normalization.

Parameters:
dataarray-like

The input data to be normalized.

epsfloat, optional

A small value to avoid log(0) issues (default is 1e-12).

Returns:
normalized_valuesarray-like

The log-normalized data.

pyfurnace.design.utils.origami_lib.simple_origami(dt_list, kl_columns=1, main_stem=None, left_stem_kl=None, stem_pos=None, start=0, add_terminal_helix=True, end_helix_len=8, use_angles=False, add_start_end=True, align='first')[source]

Construct an RNA origami object based on a sequence of dovetail values and kissing loop parameters.

Return type:

Origami

Parameters:
dt_listlist of int

List of dovetail values representing inter-helix connections.

kl_columnsint, optional

Number of kissing loop repeats in each helix (default is 1).

main_stemint or list of int or list of list of int, optional

Length(s) of the main stem in each kissing loop. Can be a single int, a list (same for all loops), or a matrix for per-loop customization.

left_stem_klint or list of int or list of list of int, optional

Length(s) of the left stem for each kissing loop. Defaults to automatic computation.

stem_posint or list of int, optional

Position(s) of the main stem insertion among helices. Default is 0 for all.

startint, optional

Index of the main stem where origami building starts (default is 0).

add_terminal_helixbool, default True

Whether to prepend and append helices with no dovetails.

end_helix_lenint, optional

Length of the stems at the ends of the helices (default is 8).

use_anglesbool, optional

If True, interpret dt_list as helix angles and convert them to dovetail values (default is False).

add_start_endbool, default True

Whether to add a start-end motif in the initial helix.

alignstr, optional

Alignment method for the origami object (default is ‘first’).

Returns:
Origami

The assembled Origami structure.

pyfurnace.design.utils.origami_lib.template_2_helix()[source]

Generate the RNA origami template for a 2-helix structure. Reference: 1. Krissanaprasit, A. et al. A functional RNA-origami as direct thrombin

inhibitor with fast-acting and specific single-molecule reversal agents in vivo model. Molecular Therapy 32, 2286-2298 (2024).

Returns:
Origami

An Origami object representing the 2-helix RNA structure.

pyfurnace.design.utils.origami_lib.template_3_arms_droplet()[source]

Generate the RNA origami template for a 3-arms droplet structure.

References: 1. Stewart, J. M. et al. Modular RNA motifs for orthogonal phase separated

compartments. Nat Commun 15, (2024).

  1. Fabrini, G. et al. Co-transcriptional production of programmable RNA condensates

    and synthetic organelles. Nat. Nanotechnol. 19, 1665-1673 (2024).

  2. Monari, L., Braun, I., Poppleton, E. & Göpfrich, K. PyFuRNAce: An integrated

    design engine for RNA origami. (2025) doi:10.1101/2025.04.17.647389.

Returns:
Origami

An Origami object representing the 3-arms droplet structure.

pyfurnace.design.utils.origami_lib.template_4_arms_droplet()[source]

Generate the RNA origami template for a 4-arms droplet structure.

Reference: 1. Fabrini, G. et al. Co-transcriptional production of programmable RNA condensates

and synthetic organelles. Nat. Nanotechnol. 19, 1665-1673 (2024).

Returns:
Origami

An Origami object representing the 4-arms droplet structure.

pyfurnace.design.utils.origami_lib.template_pentagon_tile()[source]

Generate the RNA origami template for a pentagon tile structure. This follows the 3H-4DT design from Geary et al. (2021).

Reference: 1. Geary, C., Grossi, G., McRae, E. K. S., Rothemund, P. W. K. & Andersen, E. S.

RNA origami design tools enable cotranscriptional folding of kilobase-sized nanoscaffolds. Nat. Chem. 13, 549-558 (2021).

Returns:
Origami

An Origami object representing the pentagon tile structure.

pyfurnace.design.utils.origami_lib.template_rectangle_10H_3X()[source]

Generate the RNA origami template for a rectangle 10H-3X structure.

References: 1. Monari, L., Braun, I., Poppleton, E. & Göpfrich, K. PyFuRNAce: An integrated

design engine for RNA origami. (2025) doi:10.1101/2025.04.17.647389.

Returns:
Origami

An Origami object representing the rectangle 10H-3X structure.

pyfurnace.design.utils.origami_lib.template_rna_filament()[source]

Generate the RNA origami template for an RNA filament structure.

Reference: 1. Tran, M. P. et al. Genetic encoding and expression of RNA origami

cytoskeletons in synthetic cells. Nat. Nanotechnol. 20, 664-671 (2025).

Returns:
Origami

An Origami object representing the RNA filament structure.

pyfurnace.design.utils.origami_lib.template_rna_filament_ispinach()[source]

Generate the RNA origami template for an RNA filament structure. The tiles contains an ispinach aptamer for fluorescence imaging.

Reference: 1. Tran, M. P. et al. Genetic encoding and expression of RNA origami

cytoskeletons in synthetic cells. Nat. Nanotechnol. 20, 664-671 (2025).

Returns:
Origami

An Origami object representing the RNA filament structure.

Sequence Generation

pyfurnace.generate.road.generate_road(structure, sequence, pseudoknots='', name='origami', initial_sequence=None, callback=None, verbose=False, timeout=7200, directory=None, zip_directory=False, origami_code=None)[source]

Generate an RNA origami design using the ROAD Revolvr algorithm.

This function orchestrates the structure processing, pseudoknot embedding, and Perl-based design process for RNA origami, with optional support for real-time updates and zipped output.

Return type:

Union[str, Tuple[str, str]]

Parameters:
structurestr

RNA secondary structure in dot-bracket notation.

sequencestr

Initial sequence to use for the design (must match structure length).

pseudoknotsstr or dict, optional

Pseudoknot definitions in ROAD-compatible format (string or parsed dict).

namestr, optional

Base name for the design file (default is ‘origami’).

initial_sequencestr, optional

Optional initial sequence to pre-fill as the starting point of the optimization.

callbackcallable, optional

A function called during ROAD execution with progress updates: callback(structure, sequence, line, stage_name, stage_progress)

verbosebool, optional

If True, prints progress updates to the console. If callback is provided, this is ignored. Default is False.

timeoutint, optional

Timeout in seconds for the ROAD optimization (default is 7200 seconds = 2 hours).

directorystr, optional

Directory where files should be written. If None, a temporary directory is used.

zip_directorybool, optional

Whether to generate a .zip file with all intermediate and result files.

origami_codestr, optional

Source code (e.g., Python) representing the origami design, to be saved and zipped.

Returns:
str or tuple

If zip_directory is False: returns the designed RNA sequence as a string. If zip_directory is True: returns the tuple (designed_sequence, path_to_zip_file).

Raises:
ValueError

If the structure and sequence lengths do not match, or if multistrand ‘&’ is used.

Warning

  • If the working directory doesn’t exist, it is created.

  • If the final design file is missing, a warning is issued.

pyfurnace.generate.road.parallel_road(structure, sequence, pseudoknots='', name='origami', callback=None, verbose=False, timeout=7200, zip_directory=True, origami_code=None, initial_sequence=None, n_trials=8, save_to=None, wait_for_all=False)[source]

Run multiple ROAD optimization trials in parallel and return results.

You can choose between returning early on the first successful result or waiting for all trials to complete. Results can optionally be ZIP-archived and saved. If the wait_for_all flag is set to True, the sequences are returned sorted by their MFE frequency in the ensemble (highest to lowest).

Return type:

Union[str, Tuple[str, str]]

Parameters:
structurestr

Dot-bracket notation of the target RNA secondary structure.

sequencestr

Reference sequence with the same length as the structure.

pseudoknotsstr or dict, optional

ROAD-style or pyFuRNAce-style pseudoknot definition.

namestr, optional

Base name for output files (default: “origami”).

callbackcallable, optional

Optional function that receives real-time progress updates.

verbosebool, optional

If True, prints progress to console.

timeoutint, optional

Timeout in seconds per trial (default: 7200).

zip_directorybool, optional

Whether to save each trial’s output as a ZIP archive.

origami_codestr, optional

Python source code to include with the design output.

initial_sequencestr, optional

Optional sequence to use as a starting point in optimization.

n_trialsint, optional

Number of parallel optimization trials to run.

save_tostr, optional

Directory to store ZIP outputs if zip_directory=True.

wait_for_allbool, optional

If True, waits for all trials to finish and returns results sorted by MFE frequency. If False, returns as soon as the first trial succeeds.

Returns:
str or Tuple[str, str] or List[str]
  • If wait_for_all=False returns the first designed sequence.

  • If wait_for_all=True returns a list of designed sequences.

Raises:
RuntimeError

If no trials successfully generate a design.

Prepare

Primers

pyfurnace.prepare.utils.annealing_temp(mts, seq, tm_kwargs, method='IDT')[source]

Calculate the annealing temperature for PCR primers using either the IDT or Phusion method.

Return type:

float

Parameters:
mtsList[float]

List of melting temperatures (Tm) for the primers.

seqstr

DNA sequence for which the annealing temperature is to be calculated.

tm_kwargsdict

Dictionary of keyword arguments for Tm calculation, such as salt concentration, DMSO, etc.

methodstr, optional

Method to use for calculation. Either ‘IDT’ or ‘Phusion’. Default is ‘IDT’.

Returns:
float

Calculated annealing temperature, rounded to two decimal places.

Notes

  • The ‘IDT’ method applies a chemical correction and a weighted average formula.

  • The ‘Phusion’ method uses the minimum Tm, with an adjustment for primer length.

  • Certain keys in tm_kwargs (e.g., ‘dNTPs’, ‘DMSO’) are handled specifically

    for the ‘IDT’ method.

pyfurnace.prepare.utils.auto_design_primers(seq, target_temp=65.0, tm_func=functools.partial(<function Tm_NN>, nn_table={'init': (0.2, -5.7), 'init_A/T': (2.2, 6.9), 'init_G/C': (0, 0), 'init_oneG/C': (0, 0), 'init_allA/T': (0, 0), 'init_5T/A': (0, 0), 'sym': (0, -1.4), 'AA/TT': (-7.6, -21.3), 'AT/TA': (-7.2, -20.4), 'TA/AT': (-7.2, -21.3), 'CA/GT': (-8.5, -22.7), 'GT/CA': (-8.4, -22.4), 'CT/GA': (-7.8, -21.0), 'GA/CT': (-8.2, -22.2), 'CG/GC': (-10.6, -27.2), 'GC/CG': (-9.8, -24.4), 'GG/CC': (-8.0, -19.9)}, dnac1=500, dnac2=0, Na=0, K=50, Tris=20, Mg=1.5, Method=7, DMSO (%)=0, mt_method='Nearest Neighbor', mt_model='DNA_NN4', Primer=500))[source]
Return type:

Tuple[List[str], List[float]]

Automatically designs forward and reverse primers for a given DNA sequence,

optimizing for melting temperature (Tm) and primer quality.

Parameters:
seqSeq

The DNA sequence for which primers are to be designed.

target_tempfloat, optional

The target melting temperature (Tm) for the primers, by default 65.0°C.

tm_funcCallable, optional

A function to calculate the melting temperature of a primer sequence, by default uses make_tm_calculator().

Returns:
final_primerslist of str

A list containing the best forward and reverse primer sequences.

final_mtslist of float

A list containing the melting temperatures (Tm) of the selected primers.

Notes

  • The function evaluates primer candidates based on Tm, GC content, length,

    and dimerization potential.

  • Returns empty string and 0 Tm if no suitable primer is found for a direction.

pyfurnace.prepare.utils.calculate_gc(seq)[source]

Calculate the GC content percentage of a nucleotide sequence.

Return type:

float

Parameters:
seqstr

The nucleotide sequence for which to calculate the GC content.

Returns:
float

The GC content of the sequence as a percentage, rounded to one decimal place.

Notes

Ambiguous nucleotides are ignored in the calculation.

pyfurnace.prepare.utils.check_dimer(seq1, seq2, dict_format=False, basepair={'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A'})[source]

Check the dimerization of two sequences and return the best dimer found. The dimerization is checked in an extremely simple way, by aligning the two sequences and checking for WC basepairing at the same index. If dict_format is True, return a dictionary with all the dimers found.

Return type:

Union[str, dict]

pyfurnace.prepare.utils.make_tm_calculator(method_name='Nearest Neighbor', model_name='DNA_NN4', primer_conc=500, tm_kwargs={'DMSO (%)': 0, 'K': 50, 'Method': 7, 'Mg': 1.5, 'Na': 0, 'Primer': 500, 'Tris': 20, 'dNTPs': 0.2, 'mt_method': 'Nearest Neighbor', 'mt_model': 'DNA_NN4'})[source]

Creates a melting temperature (Tm) calculator function for DNA primers using specified calculation method and model. Parameters :rtype: callable

Options include “Nearest Neighbor”, “Empirical GC content”, and “Wallace, rule of thumb”. Default is “Nearest Neighbor”.

model_namestr, optional

The nearest neighbor model to use for Tm calculation. Only relevant if method_name is “Nearest Neighbor”. Default is “DNA_NN4”.

primer_concfloat, optional

The concentration of the primer (in nM) used in the calculation. Only relevant for “Nearest Neighbor” method. Default is 500.

tm_kwargsdict, optional

Additional keyword arguments for the Tm calculation method. May include chemical corrections (e.g., DMSO, dNTPs). Default is a copy of default_values.

Returns

callable

A function that takes a DNA sequence (str) and returns its melting temperature (float), possibly corrected for chemical additives.

Notes

  • If DMSO is specified in tm_kwargs, the returned function

    applies a chemical correction to the calculated Tm.

  • For “Nearest Neighbor” method, dNTPs and DMSO are removed

    from the keyword arguments before calculation.

  • For “Empirical formulas based on GC content”,

    DMSO is removed from the keyword arguments before calculation.

  • For “Wallace” method, no additional arguments are processed.

Examples

>>> tm_calc = make_tm_calculator(method_name="Nearest Neighbor", primer_conc=250)
>>> tm_calc("ATCGATCG")
62.5

Oxdna simulation setup

pyfurnace.prepare.oxdna_sim.oxdna_simulations(origami, oxdna_directory, directory=None, zip_directory=False, temperature=37, mc_relax_steps=5000.0, md_relax_steps=10000000.0, md_equil_steps=100000000.0, md_prod_steps=1000000000.0)[source]

Prepare the files for the OxDNA simulations. The function saves the files for oxdna simulations in the specified directory (created if it does not exist). The function also creates a zip file with the files for the simulations if the flag zip_directory is set to True. If the directory is set to None, the program automatically creates a zip file and returns the path to the zip file.

Return type:

Optional[str]

Parameters:
origamiOrigami

The origami object.

oxdna_directorystr

The path to the OxDNA executable. It is important to load sequence dependent parameters.

directorystr

The output directory for the MD simulations files. If None, the zip_directory flag is set to True.

zip_directorybool

If True, the function creates a zip file with the files for the simulations and returns the path to the zip file. If False, the function returns None.

temperatureUnion[int, float], optional

The temperature in Celsius, by default 37.

mc_relax_stepsUnion[int, float], optional

The number of Monte Carlo relaxation steps, by default 5e3.

md_relax_stepsUnion[int, float], optional

The number of MD relaxation steps, by default 1e7.

md_equil_stepsUnion[int, float], optional

The number of MD equilibration steps, by default 1e8.

md_prod_stepsUnion[int, float], optional

The number of MD production steps, by default 1e9.

Returns:
Union[str, None]

If zip_directory is True or directory is None, the function returns the path to the zip file. If zip_directory is False and directory is not None, the function returns None.