Keywords
RNA, Python, RNA tertiary structure, RNA secondary structure, coaxial stacking, pseudo knots
This article is included in the Bioinformatics gateway.
This article is included in the Python collection.
RNA, Python, RNA tertiary structure, RNA secondary structure, coaxial stacking, pseudo knots
In RNA 3D structure prediction, knowledge-based potentials are commonly used, especially for coarse-grained approaches that are suitable for larger RNA molecules1. The creation of such potentials requires knowledge extraction from solved RNA structures, usually taken from the Protein Data Bank (PDB)2. PDB files and their newer replacement, MMCIF files, contain atomic coordinates and additional information in the header fields, but do not contain any base-pairing annotations. To extract information about base pairs and their types3, dedicated software like MC-Annotate4, RNAView5, FR3D6, DSSR7 or the RNApdbee web server8 is required. Due to the hierarchical organization of the RNA energy landscape9, it is often most convenient to treat secondary and tertiary structure of RNA molecules separately and predict tertiary structures given a secondary structure10.
For knowledge extraction from RNA-containing PDB files, it is highly desirable to have a software library at hand, which understands the semantics of RNA secondary structures and makes tasks like iterating over loops of a certain type straightforward. Ideally, such a library should be written in an easily accessible scripting language, be well documented and tested and should be available under an open-source license.
Libraries other than the forgi library presented here only partly fill these needs. The Vienna RNA package11 can be used to predict secondary structures from sequence, including advanced features like G-Quadruplex prediction and incorporation of SHAPE data. It provides Python and Perl bindings, but deals exclusively with secondary structure. Biopython12,13 is useful for dealing with RNA sequence data and can be used to load RNA 3D structures, but has no dedicated support for RNA secondary structure. PyCogent14, a library for genomic biology, has extensive support for nucleic acid sequences, but contains only a lightweight class for RNA secondary structures and code for pseudo knot removal15. A stand-alone version of the latter was included into the forgi library under the terms of the GNU General Public License 3.0. More specialized libraries include modeRNA16 (homology modeling, Python) and the FR3D suite6 (RNA motif search, Matlab). Here, we present the forgi library17, which is centered on RNA secondary structure elements (such as stems, bulges and loops) and makes them usable for 3D structure analysis. forgi aims at providing a high level API for many common operations, but can be easily extended with new functionality. The flexibility of providing an open source library in a scripting language is a clear benefit over other programs that are only distributed as binaries. While not restricted to work with PDB or MMCIF files, forgi shines especially where 3D information is analyzed in the context of its secondary structure environment.
The forgi library17 is strongly object-oriented, but takes advantage of module-level Python functions where appropriate. The core object representing the secondary structure is the BulgeGraph object, which holds a Sequence instance for the primary sequence. To include secondary structure based 3D coordinates, the BulgeGraph’s subclass, CoarseGrainRNA is available. For all-atom 3D analysis, the forgi library has a built-in integration with Biopython.
We will briefly describe the three main data structures that hold the sequence, secondary structure and the tertiary structure representation of an RNA.
Primary structure: The Sequence class. Each BulgeGraph holds a Sequence object. Since forgi supports loading of data from PDB files (see below), this Sequence object has to account for many special cases arising from experimental considerations, which will be detailed in the following paragraphs. There are two numbering schemes commonly used for sequences: 1-based indexing and indexing based on an external reference. In particular, many sequences in structural experiments use “1” to dedicate the first residue of a biological macro-molecule, whereas the first residue actually used in the experiment can be upstream of the functional RNA (leading to negative indices) or after the start of the biological unit (leading to an index above 1). The latter is especially common if fragments of larger RNA molecules like the ribosome are studied. Finally, experimenters might decide to insert nucleotides in the middle of a molecule. In order not to affect the numbering of subsequent residues, these inserted residues get the same number as the previous one, followed by a letter (called insertion code).
To handle both kinds of indexing, the Sequence class distinguishes indices by type. Integer indices always refer to 1-based indexing, while tuples compatible to the indices used in Biopython’s PDB module are interpreted as the second kind of indices.
For many applications, it is necessary to restrict the RNA alphabet to 4 letters (i.e. 4 residue types), “G”, “C”, “A” and “U”. However, in the cell many RNA molecules are post-transcriptionally modified at certain positions. Many modifications, including the methylation of OH or NH2 groups and A to I editing, have been implicated with a variety of biological functions18. During parsing of PDB files, we automatically convert such modified residues to the unmodified parent, but in addition store the modification as an annotation in the Sequence object. The corresponding unmodified parents for 3-letter codes of common modified residues were obtained from PDBeChem19 (http://www.ebi.ac.uk/pdbe-srv/pdbechem/) and the forgi library has the ability to query this database on the fly if it encounters a new 3-letter code.
Finally, many experimental 3D structures do not contain coordinates for all residues present in the experiment. The forgi Sequence class stores two version of the sequence, with and without missing residues.
The secondary structure of an RNA is internally represented as a graph, the Bulge Graph, where secondary structure elements (stems, single-stranded regions, interior loops and hairpin loops) form the nodes. Whenever these elements are adjacent along the backbone, they are connected by an edge in this graph. During the Bulge Graph creation, each node gets a unique name such as “s0” for the first stem or “h0” for the first hairpin. The concept of the Bulge Graph, illustrated in Figure 1, has been described previously in more detail20 and is related to the independently developed RAG (RNA as Graph) approach21.
forgi supports element-based transformations of the Bulge Graph, such as condensing the secondary structure to an representation similar to RNAshapes22, which we use to classify pseudo knots, for example (see below).
The BulgeGraph object allows for easy identification, selection and classification of structural domains, such as multi loops, helices consisting of multiple stems and bulges (termed “rods” in forgi), and pseudo knots.
The CoarseGrainRNA class holds 3D structures. 3D structures are loaded from PDB or MMCIF files using Biopython’s PDB module13. In order to assign a secondary structure to the RNA, forgi can call either MC-Annotate4 (Linux only, no MMCIF-support, binary available at http://major.iric.ca/MajorLabEn/MC-Tools.html) or DSSR7 (binary available after free registration at http://forum.x3dna.org). As an alternative, forgi has a built-in heuristic for the detection of canonical base pairs and GU wobble pairs. This heuristic is based on distances along the hydrogen bonds and the coplanarity of the bases, and is not intended to compete with the power of more specialized tools since it will fail in some edge cases, e.g. involving modified residues or residues with missing atoms. This heuristic is a useful fallback, if the above mentioned programs are not available.
During loading of the RNA, a helix axis is assigned to stems as described previously20. For each stem, we store start and end coordinates of the helix axis as well as two twist vectors that point towards the minor groove at the beginning and the end of the stem. Similarly, start and end coordinates for bulges, loops and single-stranded regions are stored and can be accessed using the element’s name.
forgi 2.0 now fully supports co- and multi-fold structures and can load multiple chains that are connected by base pairs into a single CoarseGrainRNA object, while chains not connected by any base pair are loaded into separate objects.
Using Biopython’s KD-Tree implementation (Bio.PDB.NeighborSearch), a list of residues within 6 angstrom from a non-RNA C or N atom is obtained. These residues are considered protein-/ligand interacting. Knowledge of interacting residues is particularly useful to avoid biases in statistics about structural features of bare RNA.
A cleaned version of the PDB as Biopython chains is stored in the CoarseGrainRNA’s chains attribute. This cleaned version has the names of modified residues converted to their canonical parent and non-RNA molecules removed.
forgi17 is compatible with Python 2.7, 3.5 and 3.6, should run on all operating systems where its dependencies are available and has been tested on Linux, Mac and Windows. It makes heavy use of the NumPy23 library to speed-up array-based calculations and also depends on SciPy24, NetworkX25, Biopython12,13, pandas26,27 and appdirs, all available via the Python Package Index (PyPi) or Anaconda.
Helpful utility scripts. forgi comes with the two very useful scripts: rnaConvert.py can be used to convert between many common file formats for RNA structures, including the Vienna format and fasta variants, the bpseq format, the connectivity table (ct) format, MMCIF format and PDB files. visualize_rna.py can be used to display a coarse-grained representation of an RNA’s secondary structure in PyMol alongside the all atom structure from PDB files, producing visualizations like those in Figure 3 and Figure 5.
Analysis of stacking geometries. To illustrate how the forgi library makes secondary structure elements usable for 3D structure analysis, we used it to analyze the stacking of adjacent helices in multi loops and pseudo knots in a representative set of RNA 3D structures28 (version 3.36, available at http://rna.bgsu.edu/rna3dhub/nrlist/).
While loading these 3D structures into forgi, DSSR7 (Version v1.7.1-2017nov01) was called to obtain the secondary structure and nucleotide level reference stacking annotations. We count a pair of connected helices as stacking, if at least one nucleotide of the first helix’s closing/opening base pair is in a continuous stack with at least one nucleotide of the second helix’s opening/closing base pair. This allows for any number of stacking nucleotides between the stems (not necessarily connected via the backbone) and for bulged out nucleotides which do not contribute to the stack. Our definition of stacking is more relaxed than stricter criteria used elsewhere29.
For each pair of adjacent stems within a junction, we used forgi to calculate a number of properties, such as the angle between the stem vectors, the separation vector between the stems’ ends and an offset calculated as distance between two rays that start at the helix end and extend the helix axis.
The following code is a simplified example how forgi can be used to calculate such properties:
from forgi import load_rna from forgi.threedee.utilities.vector import vec_angle
def main(): # Load the PDB into CoarseGrainRNA instances # rnas is a list, because a PDB can contain multiple connected components # This also loads the DSSR json annotations. rnas = load_rna("Path/to/PDB/file.cif", pdb_remove_pk=False, pdb_annotation_tool="DSSR")
for rna in rnas: for junction in rna.junctions: print_junction_angles(rna, junction)
def print_junction_angles(rna, junction): """ :param rna: A BulgeGraph Object :param junction: A list of element names (strings) """
for ml in junction : # rna.edges holds adjacent nodes in the BulgeGraph stem1, stem2 = rna.edges[ml] # rna.coords holds the 3D coordinates of structure elements # rna.coords ["s0"] returns a tuple start –, end–coordinates of stem "s0" # Furthermore rna.coords has the get_direction function to give the # vector pointing from the start to the end coordinate. d1 = rna.coords.get_direction(stem1) d2 = rna.coords.get_direction(stem2) angle = vec_angle (d1, d2) # imported above is_stacking_dssr = (ml in rna.dssr.stacking_loops()) print("{}\t{}".format(angle, is_stacking_dssr))
We then used pandas26,27, Matplotlib30 and a custom library (https://github.com/Bernhard10/filterAndView) to analyze and visualize the collected data. The results were collected for different classes of RNA independently. This was necessary, because the representative sets of RNA structures contain, by design, homologs of the same molecule in multiple species.
For the classification of pseudo knots, Reidys’ concept31 based on the definition of the mathematical genus is used. Classes of pseudo knots are defined based on their shadow representations, which contain only crossing base pairs and only one base pair each. On the level of these shadows, only four distinct classes exhibit genus 1, two of which are well known: the H-type pseudo knot and the kissing hairpin. pseudo knots with higher genus contain, among others, the case where a genus 1 pseudo knot is nested within another pseudo knot.
In combination with the forgi library, we wrote a tool that is able to convert structures to their shadow representation, identify and classify the pseudo knots within the structure and describe their helix arrangement in the 3D structure. This tool, called pseudoknot_analyzer.py, is distributed with the forgi library in the folder “examples”. We used it to gather statistics about simple H-type and kissing hairpin pseudo knots. Figure 4a, b illustrates how we measured the angle between stems in pseudo knots via vector directions. In kissing hairpins the angles α and β restrict the possible values of the angle γ. We also include the representative structure of an intermolecular kissing hairpin interaction (lacking the green connection in Figure 4b) in our analysis. In this special case α and β are indistinguishable and were assigned arbitrarily.
We used the helix-centered representation of the 3D structure to analyze the geometry of coaxially stacking helices. The relative geometry of two cylinders in 3D space can be described by five parameters: A separation vector (three parameters) and two angles for the relative orientation in 3D space. In Figure 2 and Figure 4, we show the single angle calculated between the vectors along the helix axes, as a proxy for these parameters.
The distribution of angles between adjacent stems in tRNAs multi loops (see Figure 2a) shows the expected bimodal distribution with one mode slightly below 90° and another mode between 160° and 170°, which fits to the known helix arrangement in the L-shaped tRNA. As confirmed by comparison to annotations with DSSR, the second peak is almost exclusively due to stacking helices, even at angles as small as 140°. In Figure 3 we show an example of such a coaxial stack that has been strongly bent (possibly by the tRNA synthetase) without completely breaking the stack or affecting the canonical tRNA secondary structure.
The second family of RNA molecules with lots of data available is ribosomal RNA. Here we find that the angle of adjacent stems in multi loops is almost uniformly distributed above 20° until a peak from 135° to 170°, where DSSR annotates roughly half of the geometries as stacking (see Figure 2c). 7% of the stacking geometries and 67% of the non-stacking geometries with an angle above 140° also have an offset above 10Å between the extended stem axes.
Additionally we analyzed the angle distribution between the stems forming simple H-type pseudo knots or kissing hairpins. Most angles measured within an H-type pseudo knot are between 120° and 180° (see Figure 4c). In this range, 35 out of 67 instances correspond to stacking. One example within this range is shown in Figure 5a, which represents a processed non-coding RNA, which regulates a bacterial antiviral system (PDB id 2XD034).
The distribution illustrated in Figure 4d shows mainly values between 130° and 180° for the angles β and especially α. One additional angle measurement between the two regular stems (see Figure 4d, angle γ) shows one peak at about 20° and one at about 65°. Within the class of kissing hairpins we often find coaxial stacking, but most of the time only one of the two regular stems stacks with the kissing stem in the middle. With the help of the coarse grained representation we were able to divide the class of kissing hairpins into three different structural families (see Figure 5b-d).
The first family is especially common among (A-)riboswitches. Here the two regular stems are oriented almost parallel (γ below to 32°) with the second one (counting from the 5’ end) stacking onto the kissing stem. The angles α and β are above 130°. One example is the structure with PDB id 5KPY35 shown in Figure 5b. Here, the link from the first regular stem stacks onto it and interacts with the kissing stem via base multiplets and A-Minor interactions. This way, the roughly parallel orientation of all 3 stems is stabilized by stacking and base-pairing interactions. Interestingly, the kissing stem is more parallel to the first stem than to the second stem, onto which it stacks directly (α > β).
The second structural family is shown in Figure 5c. Here the two regular stems are close to 90°, whereas the kissing stem is along the arc between them. This conformation is found in several groups of non coding RNA including some 23S ribosomal RNA and the cobalamin riboswitch regulatory element (PDB id 4FRN36) shown in Figure 5c.
The two families as well as some conformations in between are observable within intramolecular pseudo knots. As mentioned, forgi is also able to model multiple RNA chains that interact with each other forming an intermolecular complex. One example is the dimerization initiation site of the HIV type 1 (PDB id 1ZCI37), illustrated in Figure 5d and being the only example of the third family of kissing hairpin pseudo knots. Here the kissing hairpin interaction shows a nearly perfect coaxial stacking between all three involved stems. In this case β is close to 0°, because stacking takes place at the other side of the kissing stem and thus the complementary angle is close to 180°.
Using the forgi library17 we have analyzed the relative orientation of helices in junctions and pseudo knots. While stacking between adjacent helices is common, we found that their orientation often deviates significantly from co-linearity, suggesting that junctions introduce flexibility into the RNA structure while still maintaining the benefit of stacking interactions. Previous studies that assign coaxial geometries based on manual inspection38 miss this deviation from coaxiality that becomes apparent once you actually calculate the helix axis. Our approach allowed us to perform this analysis on the scale of stems, as opposed to the smaller all-atom scale used by the program DSSR and in previous surveys39 or the level of networks of (noncanonical) base pairs38.
Conversely, we found that out of 1257 pairs of adjacent stems in ribosomal RNA structures with an angle above 140°, only roughly half (608) are annotated as stacking by DSSR. This becomes clear if we consider that the angle between stems is only a proxy for a 5-dimensional orientation parameter. In particular, a large offset means that stem axes with an angle close to 180° can be parallel without being coaxially stacked. Indeed, it is not uncommon that all three stems in a 3-way junction are roughly parallel, with two stems forming a coaxial stack and the third having a higher offset40.
There is growing interest in predicting pseudo knots in RNA structures as they are involved in a variety of biological functions41. The forgi library allows us to easily identify pseudo knots in RNA 3D structures and gather statistics on the frequency of pseudo knot types, sizes, and composition. Kissing hairpins formed between two RNA molecules are known to often form continuous stacks between all three helices, such as the pseudo knot in Figure 5d. In contrast to these intermolecular kissing hairpins, we find that stacking between all three helices is seldom possible in intramolecular pseudo knots. Instead we find that the limited length of all loop segments makes it nearly impossible to form coaxial stacking of all three stems in one line in a single RNA chain. Thus, in the main families of kissing hairpin conformations, the regular (outer) stems are oriented parallelly or almost perpendicular with the kissing helix stacking onto at most one of the two regular stems. These structures are often further stabilized by base triplets like those found in Figure 5b.
Similar to stacking conformations in multi loops, many stacking helices in pseudo knots form angles below 180°. A deviation of the coaxiality between stems can have multiple reasons such as a higher flexibility of short helices within a pseudo knot as well as strain from short stem connections. But there are also structures that show more classical coaxial stacking like PDB id 2XD0, see Figure 5a.
Results and challenges of the application of forgi to the analysis of pseudo knots are described in more detail in the thesis by Beckmann42.
Varying additional parameters like the minimal number of base pairs required to count an interaction as a helix allow for a better understanding about the principles of the formation of three-dimensional RNA structures. The insight in the world of pseudo knots and multi loops presented here can support the improvement of the prediction of RNA structures and help identify unrealistic multi-loop conformations predicted by current RNA structures prediction tools. We are now in the process of implementing additional features for the RNA 3D structure prediction program Ernwin20 based on our findings about stacking and pseudo knots.
forgi17 is a multi-purpose Python library for dealing with RNA on the levels of sequence, secondary structure and tertiary structure. By providing our code as a Python library, we give users of our tool more flexibility than a single executable program could provide. Furthermore, our code is fully open source, giving researchers the possibility to comprehend and where needed extend the inner workings of the code.
forgi is well documented, with a tutorial available at https://ViennaRNA.github.io/forgi/ and a complete API documentation following the Python standard of docstrings parsable by Sphinx. It contains an extensive automatic test suite (unit and integration tests) and has been optimized for speed, maintainability and usefulness.
The PDB ids analyzed were taken from version 3.36 of the representative sets of RNA 3D structures28 at a cutoff of 4 Å, http://rna.bgsu.edu/rna3dhub/nrlist/release/3.36/4.0A.
Open Science Framework: 3D based on 2D: forgi 2.0 Extended Data. https://doi.org/10.17605/OSF.IO/HDJRU43. This project contains the following extended data files:
assignment_of_classes_to_pdbids.csv: Assignment of PDB ids to RNA type. These annotations were generated in a semi-manual way.
multiloop_angles.csv: Angles and offsets measured in PDB structures for multi loops, generated with the script describe_rna.py, which is available in the examples folder of forgi.
pseudoknot_angles.tsv: Angles measured in pseudoknots, generated with pseudoknot_analyzer.py, which is available in the examples folder of forgi.
Extended data are available under the terms of the Creative Commons Zero "No rights reserved" data waiver (CC0 1.0 Public domain dedication).
Software available from: https://pypi.org/project/forgi/ (pip install forgi) and Bioconda.
Archived source code at time of publication: https://doi.org/10.5281/zenodo.258287017.
License: GNU General Public License 3.0.
This work was partly funded by the Austrian science fund (FWF) projects F 43 “RNA regulation of the transcriptome” and I 2874 “Prediction of RNA-RNA interactions” and Doctoral College W 1207 “RNA Biology”.
The funders had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript.
We thank all contributors, who submitted a pull-request or filed an issue in the forgi repository on github. We thank Roman Ochsenreiter for proofreading, Gregor Entzian for useful inputs about many quirks in the PDB format and for proofreading and Lorena Pantano for creating the first version of a Bioconda recipe for forgi.
Views | Downloads | |
---|---|---|
F1000Research | - | - |
PubMed Central
Data from PMC are received and updated monthly.
|
- | - |
Is the rationale for developing the new software tool clearly explained?
Yes
Is the description of the software tool technically sound?
Yes
Are sufficient details of the code, methods and analysis (if applicable) provided to allow replication of the software development and its use by others?
Yes
Is sufficient information provided to allow interpretation of the expected output datasets and any results generated using the tool?
Yes
Are the conclusions about the tool and its performance adequately supported by the findings presented in the article?
Yes
Competing Interests: No competing interests were disclosed.
Reviewer Expertise: RNA bioinformatics
Is the rationale for developing the new software tool clearly explained?
Yes
Is the description of the software tool technically sound?
Yes
Are sufficient details of the code, methods and analysis (if applicable) provided to allow replication of the software development and its use by others?
Partly
Is sufficient information provided to allow interpretation of the expected output datasets and any results generated using the tool?
Yes
Are the conclusions about the tool and its performance adequately supported by the findings presented in the article?
Yes
Competing Interests: No competing interests were disclosed.
Reviewer Expertise: Structural bioinformatics
Alongside their report, reviewers assign a status to the article:
Invited Reviewers | ||
---|---|---|
1 | 2 | |
Version 2 (revision) 23 Apr 19 |
read | |
Version 1 14 Mar 19 |
read | read |
Provide sufficient details of any financial or non-financial competing interests to enable users to assess whether your comments might lead a reasonable person to question your impartiality. Consider the following examples, but note that this is not an exhaustive list:
Sign up for content alerts and receive a weekly or monthly email with all newly published articles
Already registered? Sign in
The email address should be the one you originally registered with F1000.
You registered with F1000 via Google, so we cannot reset your password.
To sign in, please click here.
If you still need help with your Google account password, please click here.
You registered with F1000 via Facebook, so we cannot reset your password.
To sign in, please click here.
If you still need help with your Facebook account password, please click here.
If your email address is registered with us, we will email you instructions to reset your password.
If you think you should have received this email but it has not arrived, please check your spam filters and/or contact for further assistance.
Comments on this article Comments (0)