An RNA family, from a model and six genomes
A riboswitch is a piece of an mRNA that folds up in front of the gene it controls and binds a small molecule through its fold. The sequence can drift as long as every base pair keeps two complementary sides, so a change on one side has to be met by a change on the other. This page takes one such family, finds its copies in six bacterial genomes, aligns them and opens the result with the base pairs drawn over the columns, where each row shows whether its pairs still match.
The pipeline runs curl, python3, cmsearch, cmalign and FastTree.
Prerequisites#
curlandpython3- Infernal 1.1 for
cmsearchandcmalign,apt install infernalon Debian or Ubuntu,brew install infernalon macOS - FastTree,
apt install fasttree, orbrew install fasttree - nothing to read along: every figure below links to the live view it captured
Where the data comes from#
Rfam release 15.1 for the family, NCBI RefSeq for the genomes and their annotation, and the RCSB PDB for one crystal structure.
- the RF00162 covariance model: https://rfam.org/family/RF00162/cm
- the RF00162 seed alignment, 457 curated sequences with the consensus structure: https://rfam.org/family/RF00162/alignment/stockholm
- one RefSeq genome per request, here Bacillus subtilis 168: https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=NC_000964.3&rettype=fasta&retmode=text The other five are NC_003869.1, NC_003030.1, NC_003210.1, NC_007795.1 and NC_009089.1.
- the annotation of a 1500 nt window of one of those records, which names the gene a hit leads: https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=NC_000964.3&seq_start=1179185&seq_stop=1180684&strand=2&rettype=ft&retmode=text
- the sequence of the crystallized aptamer, PDB 2GIS: https://www.rcsb.org/fasta/entry/2GIS
- the finished alignment every link on this page opens, rehosted because
rfam.org sends no
Access-Control-Allow-Originheader and a browser cannot read it: https://gmod.org/JBrowseMSA/demo/data/rna/sam-riboswitch.sto
The family#
The SAM-I riboswitch, Rfam RF00162, sits in the leader of methionine and cysteine biosynthesis genes in Firmicutes and binds S-adenosylmethionine, the product those genes lead to. Rfam publishes two files for it: a seed alignment of 457 curated sequences carrying a consensus secondary structure, and a covariance model built from that seed. A covariance model scores a candidate on sequence and on fold at once, so it recognizes a copy that shares the fold and little of the sequence.
curl -o RF00162.cm https://rfam.org/family/RF00162/cm
curl -o RF00162.seed.sto https://rfam.org/family/RF00162/alignment/stockholm
1. Search six genomes#
Six Firmicutes, downloaded one FASTA at a time from NCBI and concatenated: B. subtilis 168, Caldanaerobacter subterraneus subsp. tengcongensis MB4, Clostridium acetobutylicum ATCC 824, Listeria monocytogenes EGD-e, Staphylococcus aureus NCTC 8325 and Clostridioides difficile 630.
# --cut_ga applies the family's curated gathering threshold, the one Rfam uses
# to decide membership
cmsearch --cut_ga --noali --cpu 4 --tblout hits.tbl RF00162.cm all-genomes.fa
The search over six chromosomes takes seconds, and the table has 37 rows:
37 hits
NC_000964.3 11 hits
NC_003030.1 7 hits
NC_003210.1 7 hits
NC_003869.1 3 hits
NC_007795.1 4 hits
NC_009089.1 5 hits
B. subtilis has eleven, and it is the species in which Grundy and Henkin first described the S box regulon.
2. Name each row by the gene it leads#
A riboswitch is a leader sequence, so each row is labeled with the gene downstream of it. NCBI serves the annotation of any window of a record as a feature table, so naming a hit takes one request. The hit at NC_000964.3:1180802-1180685 runs on the minus strand, so the window is the 1500 nt below it, read in the same direction:
curl -s "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore\
&id=NC_000964.3&seq_start=1179185&seq_stop=1180684&strand=2&rettype=ft&retmode=text"
90 >1500 gene
gene samT
locus_tag BSU_11010
90 >1500 CDS
product bifunctional homocysteine S-methyltransferase using (R,S)AdoMet and methylenetetrahydrofolate reductase [NAD(P)H]
The first CDS that reads forward in that frame is the gene downstream, and its
symbol plus a four-letter species prefix is the row name: Bsub_samT. Where the
annotation has no symbol the script uses the locus tag, as in
Cdif_CD630_RS06510 in the figures below.
35 of 37 hits named by a gene, 2 with no same-strand gene within 1500 nt
Those two keep their coordinate instead, Cace_1073888 and Saur_2391667. Both
sit in an intergenic gap whose flanking genes run the other way.
3. Align the hits to the model#
cmalign aligns each hit back to the same model, so a column means one
consensus position in every row:
cmalign --noprob -o cmalign.sto RF00162.cm hits.fa
37 rows x 187 columns, 108 consensus columns
62 columns are gaps in 90% or more of the rows
The model has 108 consensus positions and the alignment 187 columns. The other 79 are insertions, and most of them fall in one place: the hits run from 92 to 157 nt, and the rows at the long end put their extra sequence in the variable stem loop.
4. Put the pseudoknot back#
A covariance model pairs columns the way brackets nest, and a pseudoknot is a
pair that crosses a helix instead of nesting inside it. Rfam annotates the SAM-I
pseudoknot in the seed’s SS_cons with letters, A for an opening end and a
for its partner, and cmalign writes back only the nested helices its model
holds.
Both alignments mark their consensus columns in #=GC RF, so the k-th consensus
column of one is the k-th of the other. The build script copies the seed’s
SS_cons across that correspondence, along with RNA_ligand_SAM, the columns
Rfam marks as touching the ligand. The script leaves RNA_structural_elements
behind, because the seed spells the element names across its own columns, insert
columns included, and a per-column copy would keep the brackets and lose the
labels.
4 pseudoknot pairs copied from the seed
5. Infer a tree#
FastTree reads aligned DNA FASTA, so the build script converts the Stockholm
with U written as T and Rfam’s insert gaps written as -:
FastTree -nt -gtr -nosupport tree-input.afa > family.nwk
The script then writes the Newick into the Stockholm as a #=GF NH line, where
the viewer reads a tree from.
6. Open it#
The alignment, its consensus structure, the SAM contacts and the tree now travel
in one Stockholm file, so a ?data= link needs only its URL.
{
"msaview": {
"type": "MsaView",
"colorSchemeName": "nucleotide",
"colWidth": 8,
"rowHeight": 15,
"msaFilehandle": { "uri": "https://example.org/sam-riboswitch.sto" }
}
}

#=GF NH line, the Secondary-structure track from #=GC SS_cons, and
the Base pairs arcs from that same string: blue for the nested helices, red for
the pseudoknot. The other two tracks are the file’s remaining #=GC lines,
drawn as they stand: RNA_ligand_SAM, with an X at each column that touches the
ligand, and RF, the model’s own consensus sequence. The blank band across the
middle is the variable stem loop, which holds most of the 62 columns that are
gaps in 90% or more of the rows.7. The pseudoknot#

8. One helix, four base pairs#
The view below zooms to the helix that runs from column 13 to column 46, where a change on one side of a pair comes with a matching change on the other.

Columns 35 and 36 are the control, in the same frame. Column 36 varies more than
column 18 does, its commonest base holding 57% of the rows against 26 of 37.
SS_cons leaves both of them unpaired, and the last section searches the
alignment for whatever does pair with them.
9. Where the ligand touches#
Seven columns of the Rfam consensus are annotated as contacts with SAM, and the
#=GC RNA_ligand_SAM track marks each of them with an X. Written into the
snapshot as highlights as well, the same seven columns also get a labeled band
down the rows.

Three of the seven, columns 139 to 141, are one side of a helix whose other side is at columns 48 to 50.

The aptamer whose crystal structure is PDB 2GIS, the structure Rfam took those
contacts from, was cut out of one of the six genomes searched here. Comparing
the construct against every row, the longest stretch it shares with one is 48 nt
with Tten_TTE_RS08660, the riboswitch in front of the
methylenetetrahydrofolate reductase gene of C. subterraneus, against 34 nt for
the next row.
10. The tree#

The tree comes from 187 columns of a 108 nt RNA. It places related rows next to each other for reading, and its deeper branching is poorly supported.
11. Check it against the raw data#
The figures show the consensus structure Rfam supplies. The last step of the build script re-derives what it can from the alignment alone, and prints three counts.
Every pair in SS_cons, over every row that has a base in both columns: 1223
complementary out of 1322, or 92.5%. Watson-Crick and GU both count, since GU is
a pair a helix accepts.
paired columns: 1223/1322 = 92.5% can pair
pseudoknot only: 126/148 = 85.1% can pair
unpaired columns drawn at random: 8934/25415 = 35.2% can pair
The third line is the same statistic over pairs of columns drawn at random from
the columns SS_cons leaves unpaired. Two nucleotide columns agree by chance
often enough to matter, and 35.2% is how often.
The last check throws the structure away. For each of the ten most variable columns, search every other column for the one it pairs with best:
col commonest base best partner SS_cons pairs them with
58 31% 131 at 74% 131
133 32% 56 at 79% 56
131 34% 58 at 74% 58
57 37% 132 at 91% 132
56 40% 133 at 79% 133
132 40% 57 at 91% 57
1 41% 11 at 73% 187
159 41% 172 at 86% 172
171 41% 146 at 70% 160
187 41% 5 at 81% 1
7 of 10 find the partner SS_cons names
Seven of the ten land on the column the published structure pairs them with, out of 98 candidates each. The three that miss are columns 1, 171 and 187, two of them at the ends of the alignment where fewer rows have a base at all.
The same search over the five most variable columns SS_cons leaves unpaired,
which have no partner to find:
col commonest base best partner SS_cons pairs them with
60 44% 131 at 62% -
136 44% 55 at 85% -
165 49% 30 at 66% -
36 57% 5 at 76% -
178 57% 5 at 84% -
Column 36, the control from the helix figure, tops out at 76%. Two of the five
reach the eighties, since a column scores well against any nearly invariant
column carrying a complementary base. The seven hits above each found one
specific column out of 98, the one SS_cons names, and these five did not.
Reproduce it end to end#
curl -O https://raw.githubusercontent.com/GMOD/JBrowseMSA/main/docs/tutorials/scripts/build_rna_family.sh
bash build_rna_family.sh out/
The script fetches the model, the seed and the six genomes, runs every command
above and writes out/sam-riboswitch.sto, the file the links on this page open.
The numbers quoted here are the ones it prints.
See also#
- Data layers
- A protein family from a list of accessions
- The SARS-CoV-2 furin insert and PDB 6VXX
- User guide
References#
- Grundy FJ, Henkin TM. The S box regulon: a new global transcription termination control system for methionine and cysteine biosynthesis genes in gram-positive bacteria. Molecular Microbiology 30:737-749.
- Montange RK, Batey RT. Structure of the S-adenosylmethionine riboswitch regulatory mRNA element. Nature 441:1172-1175.
- Nawrocki EP, Eddy SR. Infernal 1.1: 100-fold faster RNA homology searches. Bioinformatics 29:2933-2935.
- Ontiveros-Palacios N, et al. Rfam 15: RNA families database in 2025. Nucleic Acids Research 53:D258-D267.
- Price MN, Dehal PS, Arkin AP. FastTree 2: approximately maximum-likelihood trees for large alignments. PLoS ONE 5:e9490.