Secondary Structure

class rnamake.secondary_structure.Basepair(res1, res2, bp_uuid=None)[source]

Bases: object

Parameters:
Attributes:
res1 : secondary_structure.Residue
First residue in basepair
res2 : secondary_structure.Residue
Second residue in basepair
uuid: uuid.uuid1
unique id to indentify this basepair when locating it in a motif or pose
name()[source]

get name of basepair: which is the combined name of both residues seperated by a “-”. The residue with the lower res number should come first

Returns:name of basepair
Return type:str
Examples:
# build basepair from stratch
>>> from rnamake.unittests import instances
>>> b = instances.secondary_structure_basepair()
>>> print b.res1
<SecondaryStructureResidue('C10 chain A')>

>>> print b.res2
<SecondaryStructureResidue('G15 chain A')>

>>> print b.name()
A10-A15
partner(r)[source]

get the other basepairing partner of a residue will throw an error if the supplied residue is not contained within this basepair

Parameters:res (secondary_structure.Residue object) – the residue that you want to get the partner of
class rnamake.secondary_structure.Chain(residues=None)[source]

Bases: object

secondary structure chain container. Contains a chain of connected residues. Chain should be from 5’ to 3’.

Parameters:residues (list of Residues.) – the residues that are to be included in chain. Optional.
Attributes:
residues : list of Residues
Residues contained in current chain
copy()[source]

creates deep copy of chain instance

Returns:copy of chain
Return type:secondary_structure.Chain
dot_bracket()[source]

gets the string verision of the secondary structure in dot_bracket notation of this chain

Returns:string of secondary structure in dot bracket notation of chain
Return type:str
Examples:
>>> from rnamake.unittests import instances
>>> c = instances.secondary_structure_chain()
>>> c.dot_bracket()
u'(((((((((((('
first()[source]

gets the first residue in the chain

Returns:5’ end of chain
Return type:secondary_structure.Residue
Examples:
>>> from rnamake.unittests import instances
>>> c = instances.secondary_structure_chain()
>>> c.first()
<SecondaryStructureResidue('G13 chain A')>
last()[source]

gets the first residue in the chain

Returns:5’ end of chain
Return type:secondary_structure.Residue
Examples:
>>> from rnamake.unittests import instances
>>> c = instances.secondary_structure_chain()
>>> c.last()
<SecondaryStructureResidue('G24 chain A')>
sequence()[source]

gets the string verision of the sequence in this chain

Returns:string of sequence of chain
Return type:str
Examples:
>>> from rnamake.unittests import instances
>>> c = instances.secondary_structure_chain()

# see the residue of each residue in the chain, all Gs
>>> for r in c: print r
...
<SecondaryStructureResidue('G13 chain A')>
<SecondaryStructureResidue('G14 chain A')>
<SecondaryStructureResidue('G15 chain A')>
<SecondaryStructureResidue('G16 chain A')>
<SecondaryStructureResidue('G17 chain A')>
<SecondaryStructureResidue('G18 chain A')>
<SecondaryStructureResidue('G19 chain A')>
<SecondaryStructureResidue('G20 chain A')>
<SecondaryStructureResidue('G21 chain A')>
<SecondaryStructureResidue('G22 chain A')>
<SecondaryStructureResidue('G23 chain A')>
<SecondaryStructureResidue('G24 chain A')>

>>> c.sequence()
u'GGGGGGGGGGGG'
to_str()[source]

stringify chain object. can be converted back with str_to_chain()

Returns:stringifed verision of chain
Return type:str
class rnamake.secondary_structure.Motif(structure=None, basepairs=None, ends=None, name='assembled', path='assembled', mtype=99, score=0, end_ids=None, id=None, r_struct=None)[source]

Bases: rnamake.secondary_structure.RNAStructure

Complete secondary structure container for representing an RNA Motif. Contains both the sequence indentity of each residue with its corresponding dot bracket notation symbol but also includes basepair objects to represent the pairs between residues. This class parallels the motif.Motif class for describing RNA with 3D coordinates. Having a parallel class for secondary structure makes it simple to move between secondary structure and full atom representations of RNA.

Parameters:
  • structure (secondary_structure.Structure) – structure containing residue and chain information for this RNAStructure instance
  • basepairs (list of secondary_structure.Basepairs) – basepairs contained in RNAStructure
  • ends (list of secondary_structure.Basepairs) – the basepairs at the end of chains. These define connection points to other Motifs
  • name (str) – name of Motif
  • path (str) – location of where Motif originated from, this is just a place holder for converting from motif.Motif
  • mtype (motif_type) – motif_type enum value, to indentify what type of motif this is
  • score (float) – the score generated by motif_scorer.MotifScorer
  • end_ids (list of strs) – strings indenifying the secondary structure and sequence in the perspective of a given basepair end see assign_end_id_new()
  • id (uuid.uuid1) – unique indentifer for motif
  • r_struct – an RNAStructure instance to setup from
Attributes:
structure: secondary_structure.Structure
structure containing residue and chain information for this Motif instance
basepairs: list of secondary_structure.Basepairs
Basepairs between residues
ends: list of secondary_structure.Basepairs
Basepair ends where RNA structures can be connected
name: str
the name of the Motif
path: str
location of where Motif originated from, this is just a place holder for converting from motif.Motif
score : float
the score generated by motif_scorer.MotifScorer, estimates secondary structure stability
end_ids: list of strs
strings indenifying the secondary structure and sequence in the perspective of a given basepair end see assign_end_id_new()
chains()

wrapper for Structure.chains()

copy()[source]

creates a deep copy of Motif instance

Returns:deep copy of instance
Return type:secondary_structure.Motif
copy_w_res(res, bps)[source]

creates a deep copy of Motif instance replacing residues and basepairs that were already created. This is used when a pose is being copied to make sure there are duplicate copies of residues and basepairs.

Parameters:
  • res (list of secondary_structure.Residues) – list of residues that were already copied
  • bps (list of secondary_structure.Basepairs) – list of basepairs that were already copied
Returns:

deep copy of instance

Return type:

secondary_structure.Motif

dot_bracket()

wrapper for Structure.dot_bracket()

get_basepair(res1=None, res2=None, uuid=None, name=None)

Finds a specific basepair based on many possible parameters.

Parameters:
  • res1 (secondary_structure.Residue) – first residue to be included in basepair
  • res2 (secondary_structure.Residue) – second residue to be included in basepair if both res1 and res2 are specified the basepair must be a pair between these two.
  • uuid (uuid.uuid1) – basepair unique indentifier
  • name (str) – name of basepair, from function Basepair.name()
get_residue(num=None, chain_id=None, i_code=None, uuid=None)

wrapper for Structure.get_residue()

replace_sequence(seq)

changes the sequence of structure.

Parameters:seq (str) – the new sequence of structure
Returns:None
residues()

wrapper for Structure.residues()

sequence()

wrapper for Structure.sequence()

to_str()[source]

creates a stringified verision of this instance

Returns:stringified verision of instance
Return type:str
class rnamake.secondary_structure.Pose(structure=None, basepairs=None, ends=None, name='assembled', path='assembled', score=0, end_ids=None, r_struct=None)[source]

Bases: rnamake.secondary_structure.RNAStructure

Complete secondary structure container for representing an RNA Pose. Contains both the sequence indentity of each residue with its corresponding dot bracket notation symbol but also includes basepair objects to represent the pairs between residues. This class parallels the pose.Pose class for describing RNA with 3D coordinates. Having a parallel class for secondary structure makes it simple to move between secondary structure and full atom representations of RNA. A pose is a composite structure containing more then one motif.

Parameters:
  • structure (secondary_structure.Structure) – structure containing residue and chain information for this RNAStructure instance
  • basepairs (list of secondary_structure.Basepairs) – basepairs contained in RNAStructure
  • ends (list of secondary_structure.Basepairs) – the basepairs at the end of chains. These define connection points to other Motifs
  • name (str) – name of Motif
  • path (str) – location of where Pose originated from, this is just a place holder for converting from pose.Pose
  • score (float) – the score generated by motif_scorer.MotifScorer
  • end_ids (list of strs) – strings indenifying the secondary structure and sequence in the perspective of a given basepair end see assign_end_id_new()
  • id (uuid.uuid1) – unique indentifer for motif
  • r_struct – an RNAStructure instance to setup from
Attributes:
structure: secondary_structure.Structure
structure containing residue and chain information for this Motif instance
basepairs: list of secondary_structure.Basepairs
Basepairs between residues
ends: list of secondary_structure.Basepairs
Basepair ends where RNA structures can be connected
name: str
the name of the Pose
path: str
location of where Pose originated from, this is just a place holder for converting from pose.Pose
score : float
the score generated by motif_scorer.MotifScorer, estimates secondary structure stability
end_ids: list of strs
strings indenifying the secondary structure and sequence in the perspective of a given basepair end see assign_end_id_new()
motifs: list of secondary_structure.Motifs
all motifs that are contained in this Pose, excluding helices which need to be built and are stored in helices. Instead motifs stores all basepair steps as seperate motifs
helices: list of secondary_structure.Motifs
helical motifs that are more then 2 basepairs. needs to be build with Pose.build_helices()
build_helices()[source]

finds all basepair step motifs and builds helices from them. This is only required for external applications such as rosetta. helices get stored in member variable helices.

chains()

wrapper for Structure.chains()

copy()[source]

creates a deep copy of instance

Returns:deep copy
Return type:secondary_structure.Pose
dot_bracket()

wrapper for Structure.dot_bracket()

get_basepair(res1=None, res2=None, uuid=None, name=None)

Finds a specific basepair based on many possible parameters.

Parameters:
  • res1 (secondary_structure.Residue) – first residue to be included in basepair
  • res2 (secondary_structure.Residue) – second residue to be included in basepair if both res1 and res2 are specified the basepair must be a pair between these two.
  • uuid (uuid.uuid1) – basepair unique indentifier
  • name (str) – name of basepair, from function Basepair.name()
get_residue(num=None, chain_id=None, i_code=None, uuid=None)

wrapper for Structure.get_residue()

motif(m_id)[source]

gets a motif by its unique indentifer

Parameters:m_id (uuid.uuid1) – motifs unique indentifier, Motif.id
Returns:motif matching to its unique indentifier
Return type:secondary_structure.Motif
replace_sequence(seq)[source]

changes the sequence of structure.

Parameters:seq (str) – the new sequence of structure
Returns:None
residues()

wrapper for Structure.residues()

sequence()

wrapper for Structure.sequence()

to_str()[source]

generates a stringified verision of this instance.

Returns:stringified verision of pose
Return type:str
class rnamake.secondary_structure.RNAStructure(structure=None, basepairs=None, ends=None, name='assembled', path='assembled', score=0, end_ids=None)[source]

Bases: object

Complete secondary structure container for representing a RNA. Contains both the sequence indentity of each residue with its corresponding dot bracket notation symbol but also includes basepair objects to represent the pairs between residues. This class parallels the rna_structure.RNAStructure class for describing RNA with 3D coordinates. Having a parallel class for secondary structure makes it simple to move between secondary structure and full atom representations of RNA. RNAStructure is rarely called directly but serves as an abstract class for both Motif and Pose so for example use please see those classes.

Parameters:
  • structure (secondary_structure.Structure) – structure containing residue and chain information for this RNAStructure instance
  • basepairs (list of secondary_structure.Basepairs) – basepairs contained in RNAStructure
  • ends (list of secondary_structure.Basepairs) – the basepairs at the end of chains. These define connection points to other RNAStructures
  • name (str) – name of RNAStructure
  • path (str) – location of where RNAStructure originated from, this is just a place holder for converting from rna_structure.RNAStructure
  • score (float) – the score generated by motif_scorer.MotifScorer
  • end_ids (list of strs) – strings indenifying the secondary structure and sequence in the perspective of a given basepair end see assign_end_id_new()
Attributes:
structure: secondary_structure.Structure
structure containing residue and chain information for this RNAStructure instance
basepairs: list of secondary_structure.Basepairs
Basepairs between residues
ends: list of secondary_structure.Basepairs
Basepair ends where RNA structures can be connected
name: str
the name of the RNAStructure
path: str
location of where RNAStructure originated from, this is just a place holder for converting from rna_structure.RNAStructure
score : float
the score generated by motif_scorer.MotifScorer, estimates secondary structure stability
end_ids: list of strs
strings indenifying the secondary structure and sequence in the perspective of a given basepair end see assign_end_id_new()
chains()[source]

wrapper for Structure.chains()

copy()[source]

creates deep copy of RNAStructure instance

Returns:copy of instance
Return type:RNAStructure
dot_bracket()[source]

wrapper for Structure.dot_bracket()

get_basepair(res1=None, res2=None, uuid=None, name=None)[source]

Finds a specific basepair based on many possible parameters.

Parameters:
  • res1 (secondary_structure.Residue) – first residue to be included in basepair
  • res2 (secondary_structure.Residue) – second residue to be included in basepair if both res1 and res2 are specified the basepair must be a pair between these two.
  • uuid (uuid.uuid1) – basepair unique indentifier
  • name (str) – name of basepair, from function Basepair.name()
get_residue(num=None, chain_id=None, i_code=None, uuid=None)[source]

wrapper for Structure.get_residue()

replace_sequence(seq)[source]

changes the sequence of structure.

Parameters:seq (str) – the new sequence of structure
Returns:None
residues()[source]

wrapper for Structure.residues()

sequence()[source]

wrapper for Structure.sequence()

class rnamake.secondary_structure.Residue(name, dot_bracket, num, chain_id, uuid, i_code='')[source]

Bases: object

An extremely stripped down container object for use for keeping track of secondary structure using dot bracket notation. Dot bracket notation is represented by a string of equal length of a sequence, example:

sequence: ‘GCAAAACG’

dot bracket: ‘((....))’

‘(‘ represent the 5’ end of a basepair, ‘)’ the 3’ end of the same base pair. Thus there should be an equal number of ‘(‘ and ‘)’ symbols. ‘.’ represents an unpaired residue.

This class along with others in this module are generally not instatinated outside RNAStructure, Motif and Pose.

Parameters:
  • name (str) – name of residue, etc A, G, C, U
  • dot_bracket (str) – dot bracket notation for secondary structure either ‘(‘, ‘.’, ‘)’
  • num (int) – number of residue
  • chain_id (str) – chain id of residue, etc “A” or “B”
  • uuid (uuid.uuid1) – residue unique indentifier
  • i_code (str) – residue insertaion code, usually “”
Attributes:
name: str
name of residue, etc A, G, C, U
dot_bracket: str
dot bracket notation for secondary structure either ‘(‘, ‘.’, ‘)’
num: int
number of residue
chain_id: str
chain id of residue, etc “A” or “B”
uuid: uuid.uuid1
residue unique indentifier
i_code: str
residue insertaion code, usually “”
Examples:
# create a new residue
>>> r = Residue("G", "(", 10, "A", uuid.uuid1())
copy()[source]

creates copy of current residue

Returns:copy of instatnce
Return type:secondary_structure.Residue
to_str()[source]

stringify residue object. can be converted back with str_to_residue()

Returns:stringifed verision of residue
Return type:str
class rnamake.secondary_structure.Structure(chains=None, sequence='', dot_bracket='')[source]

Bases: object

lightweight container class for storing secondary structure information for an entire RNA.

Parameters:
  • chains (list of secondary_structure.Chains) – secondary_structure.Chains that belong to this structure, this is done when a structure is being built from an existing 3D structure.Structure instance
  • sequence (str) – sequence of RNA of interest, e.g. “AAAGGGCCC”,
  • dot_bracket (str) – dot bracket notation of the secondary structure of RNA of interes, e.g. “(((())))”
Attributes:
chains: list of secondary_structure.Chains
the chains of RNA residues in this structure
Examples:
# create a new structure
>>> from rnamake import secondary_structure
>>> s = secondary_structure.Structure(sequence="GCGAAAACGC",
                                      dot_bracket="(((....)))")

>>> print s.sequence()
GCGAAAACGC
>>> print s.dot_bracket()
(((....)))

>>> s.get_residue(num=1)
<SecondaryStructureResidue('G1 chain A')>
copy()[source]

creates a deep copy of structure instance

Returns:copy of structure
Return type:secondary_structure.Structure
dot_bracket()[source]

Concats the secondary structure in the form of dot bracket notation of each Chain into one sequence for the entire RNA

Returns:sequence of structure
Return type:seq
get_residue(num=None, chain_id=None, i_code=None, uuid=None)[source]

find a residue based on residue num, chain_id, insert_code and uuid will return an error if more then one residue matches search to avoid confusion. Will return None is nothing matches search.

Parameters:
  • num (int) – residue number
  • chain_id (str) – what chain the residue belongs to
  • i_code (str) – the insertation code of the residue
  • uuid (uuid) – the unique indentifier that each residue is given
Returns:

Residue object

Return type:

residue.Residue

Examples:
>>> from rnamake import secondary_structure
>>> s = secondary_structure.Structure(sequence="GCGAAAACGC",
                                      dot_bracket="(((....)))")
>>> s.get_residue(num=1)
<SecondaryStructureResidue('G1 chain A')>
residues()[source]

Concats all residue objects from all Chain objects intos a unified list to be able to easily iterate through.

Returns:List of secondary_structure.Residue objects
sequence()[source]

Concats the sequence of each Chain into one sequence for the entire RNA

Returns:sequence of structure
Return type:seq
to_str()[source]

generates a stringified verision of this instance.

Returns:stringified verision of structure
Return type:str
rnamake.secondary_structure.assign_end_id_new(ss, end)[source]

generate a new end_id based on the secondary structure instance in the perspective of the supplied end. An end id is a composition of both the sequence and secondary structure in a single string.

Two GC pairs in a row would be: GG_LL_CC_RR. Sequence followed by secondary structure with L being left bracket, R being right bracket and U being dot.

Parameters:
  • ss – secondary structure instance either RNAStructure,Motif or Pose
  • end – secondary structure basepair that you want the end id to be in
Returns:

rnamake.secondary_structure.str_to_chain(s)[source]

converts a chain from string generated from Chain.to_str()

Parameters:s (str) – string created by Chain.to_str()
Returns:chain from str
Return type:secondary_structure.Chain
rnamake.secondary_structure.str_to_motif(s)[source]

converts a motif from string generated from Motif.to_str()

Parameters:s (str) – string created by Motif.to_str()
Returns:motif from str
Return type:secondary_structure.Motif
rnamake.secondary_structure.str_to_pose(s)[source]

converts a pose from string generated from Pose.to_str()

Parameters:s (str) – string created by Pose.to_str()
Returns:pose from str
Return type:secondary_structure.Pose
rnamake.secondary_structure.str_to_residue(s)[source]

converts a residue from string generated from Residue.to_str()

Parameters:s (str) – string created by Residue.to_str()
Returns:chain from str
Return type:secondary_structure.Residue
rnamake.secondary_structure.str_to_structure(s)[source]

converts a structure from string generated from Structure.to_str()

Parameters:s (str) – string created by Structure.to_str()
Returns:structure from str
Return type:secondary_structure.Structure