forgi 2.0.0 documentation

«  forgi.threedee.model package   ::   Contents   ::   forgi.threedee.model.linecloud module  »

forgi.threedee.model.coarse_grain module

exception forgi.threedee.model.coarse_grain.AnnotationToolNotInstalled[source]

Bases: exceptions.ValueError

class forgi.threedee.model.coarse_grain.CoarseGrainRNA(graph_construction, sequence, name=None, infos=None, _dont_split=False)[source]

Bases: forgi.graph.bulge_graph.BulgeGraph

A coarse grain model of RNA structure based on the bulge graph representation.

Each stem is represented by four parameters (two endpoints) and two twist vetors pointing towards the centers of the base pairs at each end of the helix.

Initialize the new structure.

add_all_virtual_residues()[source]

Calls ftug.add_virtual_residues() for all stems of this RNA.

Note

Don’t forget to call this again if you changed the structure of the RNA, to avoid leaving it in an inconsistent state.

Warning

Virtual residues are only added to stems, not to loop regions. The position of residues in loops is much more flexible, which is why virtual residue positions for loops usually do not make sense. If the file was loaded from the PDB, residue positions from the PDB file are stored already.

add_bulge_coords_from_stems()[source]

Add the information about the starts and ends of the bulges (i and m elements). The stems have to be created beforehand.

This is called during loading of the RNA structure from pdb and from cg files.

after_coordinates_changed()[source]
bases = None

A dictionary storing the stem-bases (not the vres basis)

coords = None

Keys are element identifiers (e.g.: “s1” or “i3”), values are 2-tuples of vectors The first value of stem coordinates corresponds to the start of the stem (the one with the lowest nucleotide number), The second value to the end of the stem. If the coordinates for an element change, the virtual atom and virtual residue coordinates are automatically invalidated.

coords_from_directions(directions)[source]

Generate coordinates from direction vectors (using also their lengths)

Currently ignores the twists!

Parameters:directions – An array of vectors from the side of a cg-element with lower nucleotide number to the side with higher number The array is sorted by the corresponding element names alphabetically (sorted(defines.keys())
coords_to_directions()[source]

The directions of each coarse grain element. One line per cg-element.

The array is sorted by the corresponding element names alphabetically (sorted(defines.keys()) The directions usually point away from the elemnt’s lowest nucleotide. However h,t and f elements always point away from the connected stem.

element_physical_distance(element1, element2)[source]

Calculate the physical distance between two coarse grain elements.

Parameters:
  • element1 – The name of the first element (e.g. ‘s1’)
  • element2 – The name of the first element (e.g. ‘s2’)
Returns:

The closest distance between the two elements.

classmethod from_bg_string(cg_string)[source]

Populate this structure from the string representation of a graph.

classmethod from_pdb(pdb_filename, load_chains=None, remove_pseudoknots=False, dissolve_length_one_stems=True, secondary_structure=None, filetype=u'pdb', annotation_tool=None, query_PDBeChem=False)[source]
Parameters:
  • load_chains – A list of chain_ids or None (all chains)
  • secondary_structure – Only useful if we load only 1 component
  • filetype – One of ‘pdb’ or ‘cif’
  • query_PDBeChem – If true, query the PDBeChem database whenever a modified residue with unknown 3-letter code is encountered.
  • annotation_tool – One of “DSSR”, “MC-Annotate”, “forgi” or None. If this is None, we take the value of the configuration file (run forgi_config.py to create a config file). If no config file is given either, we see what tools are installed, preferring the newer DSSR over MC-Annotate and falling back to the fogi implementation if neither is in the PATH variable. If a string is given or the configuration file set, we never fall back to a different option but raise an error, if the requested tool is unavailable.
get_bulge_angle_stats(bulge)[source]

Return the angle stats for a particular bulge. These stats describe the relative orientation of the two stems that it connects.

Parameters:
  • bulge – The name of the bulge.
  • connections – The two stems that are connected by it.
Returns:

The angle statistics in one direction and angle statistics in the other direction

get_bulge_angle_stats_core(elem, forward=True)[source]

Return the angle stats for a particular bulge. These stats describe the relative orientation of the two stems that it connects.

Parameters:
  • elem – The name of the bulge.
  • connections – The two stems that are connected by it.
Returns:

ftms.AngleStat object

get_coordinates_array()[source]

Get all of the coordinates in one large array.

The coordinates are sorted in the order of the keys in coordinates dictionary.

Returns:A 2D numpy array containing all coordinates
get_loop_stat(d)[source]

Return the statistics for this loop.

These stats describe the relative orientation of the loop to the stem to which it is attached.

Parameters:d – The name of the loop
get_ordered_stem_poss()[source]
get_ordered_virtual_residue_poss(return_elements=False)[source]

Get the coordinates of all stem’s virtual residues in a consistent order.

This is used for RMSD calculation. If no virtual_residue_positions are known, self.add_all_virtual_residues() is called automatically.

Parameters:return_elements – In addition to the positions, return a list with the cg-elements these coordinates belong to
Returns:A numpy array.
get_poss_for_domain(elements, mode=u'vres')[source]

Get an array of coordinates only for the elements specified.

..note:

This code is still experimental in the current version of forgi.
Parameters:elements – A list of coarse grain element names.
get_stacking_helices(method=u'Tyagi')[source]

EXPERIMENTAL

Return all helices (longer stacking regions) as sets.

Two stems and one bulge are in a stacking relation, if self.is_stacking(bulge) is true and the stems are connected to the bulge. Further more, a stem is in a stacking relation with itself. A helix is the transitive closure this stacking relation.

Returns:A list of sets of element names.
get_stats(d)[source]

Calls get_loop_stat/ get_bulge_angle_stats or get_stem_stats, depending on the element d.

Returns:A 1- or 2 tuple of stats (2 in case of bulges. One for each direction)
get_stem_stats(stem)[source]

Calculate the statistics for a stem and return them. These statistics will describe the length of the stem as well as how much it twists.

Parameters:stem – The name of the stem.
Returns:A StemStat structure containing the above information.
get_twists(node)[source]

Get the array of twists for this node. If the node is a stem, then the twists will simply those stored in the array. If the node is an interior loop or a junction segment, then the twists will be the ones that are adjacent to it, projected to the plane normal to the element vector. If the node is a hairpin loop or a free end, then the same twist will be duplicated and returned twice.

Parameters:node – The name of the node
get_virtual_residue(pos, allow_single_stranded=False)[source]

Get the virtual residue position in the global coordinate system for the nucleotide at position pos (1-based)

Parameters:
  • pos – A 1-based nucleotide number
  • allow_single_stranded – If True and pos is not in a stem, return a rough estimate for the residue position instead of raising an error. Currenly, for non-stem elements, these positions are on the axis of the cg-element.
incomplete_elements
interacting_elements
is_stacking(bulge, method=u'Tyagi', verbose=False)[source]

EXPERIMENTAL

Reports, whether the stems connected by the given bulge are coaxially stacking.

Parameters:
  • bulge – STRING. Name of a interior loop or multiloop (e.g. “m3”)
  • method" – STRING. “Tyagi”: Use cutoffs from doi:10.1261/rna.305307, PMCID: PMC1894924.
Returns:

A BOOLEAN.

load_coordinates_array(coords)[source]

Read in an array of coordinates (as may be produced by get_coordinates_array) and replace the coordinates of this structure with it.

Parameters:coords – A 2D array of coordinates
Returns:self
longrange_iterator(filter_connected=False)[source]

Iterate over all long range interactions in this molecule.

Parameters:filter_connected – Filter interactions that are between elements which are connected (mostly meaning multiloops which connect to the same end of the same stem)
Returns:A generator yielding long-range interaction tuples (i.e. (‘s7’, ‘i2’))
project_from = None

A 3D vector. Used as hint, from what direction the Projection2D object should be generated in the default case.

radius_of_gyration(method=u'vres')[source]

Calculate the radius of gyration of this structure.

Parameters:method – A STRING. one of “fast” (use only coordinates of coarse grained stems) or “vres” (use virtual residue coordinates of stems)
Returns:A number with the radius of gyration of this structure.
reset_vatom_cache(key)[source]

Delete all cached information about virtual residues and virtual atoms. Used as on_call function for the observing of the self.coords dictionary.

Parameters:key – A coarse grain element name, e.g. “s1” or “m15”
rotate(angle, axis=u'x', unit=u'radians')[source]
rotate_translate(offset, rotation_matrix)[source]

First translate the RNA by offset, then rotate by rotation matrix

sorted_edges_for_mst()[source]

Keep track of all linked nodes. Used for the generation of the minimal spanning tree.

This overrides the function in bulge graph and adds an additional sorting criterion with lowest priority. Elements that have no entry in self.sampled should be preferedly broken. This should ensure that the minimal spanning tree is the same after saving and loading an RNA to/from a file, if changes of the minimal spanning tree were performed by ernwin.

stem_angle(stem1, stem2)[source]

Returns the angle between two stems.

If they are connected via a single element, use the direction pointing away from this element for both stems. Otherwise, use the direction from start to end.

stem_offset(ref_stem, stem2)[source]

How much is the offset between the start of stem 2 and the axis of stem1.

Assumes that stem1 and stem 2 are connected by a single bulge. Then the start of stem2 is defined to be the stem side closer to the bulge.

steric_value(elements, method=u'r**-2')[source]

Estimate, how difficult a set of elements was to build, by counting the atom density around the center of these elements

to_cg_string()[source]

Output this structure in string form.

to_file(filename)[source]
total_length()[source]

Calculate the combined length of all the elements.

transformed
v3dposs = None

generated by self.add_all_virtual_residues()

vbases = None

The coordinate system specific to each virtual residue (3x3 matrix, carthesian coordiantes) generated by self.add_all_virtual_residues()

vinvs = None

generated by self.add_all_virtual_residues() The inverse of the transposed basis.

virtual_atoms(key)[source]

Get virtual atoms for a key.

Parameters:key – An INTEGER: The number of the base in the RNA.
Returns:A dict {atom:coords}, e.g. {“C8”:np.array([x,y,z]), …}
vposs = None

The following 5 defaultdicts are cleared when coords or twists change. Global (carthesian) position of the virtual residue (=offset of the residue’s coordinate-system) generated by self.add_all_virtual_residues()

vvecs = None

generated by self.add_all_virtual_residues()

exception forgi.threedee.model.coarse_grain.RnaMissing3dError[source]

Bases: exceptions.LookupError

forgi.threedee.model.coarse_grain.add_longrange_interactions(cg, lines)[source]

Iterate over the lines in an MC-Annotate file and add information about interactions between non-adjacent elements.

Parameters:
  • cg – A CoarseGrainRNA structure
  • lines – All the lines in an MC-Annotate file
forgi.threedee.model.coarse_grain.breakpoints_from_seqids(seqids)[source]

Create the list of cofold cutpoints from the seq_ids. Return 1-based breakpoints

forgi.threedee.model.coarse_grain.profile(x)[source]

«  forgi.threedee.model package   ::   Contents   ::   forgi.threedee.model.linecloud module  »