Creation of RNA alignments from databases

In [1]:
from pyrna.db import Rfam
rfam = Rfam(use_website = True)
aligned_rnas, species, consensus2D = rfam.get_entry(rfam_id = 'RF00058', nse_labels = 0)

structural_alignment = to_clustalw(consensus2D, aligned_rnas)
print structural_alignment
AP006878.1/1107433-1107263	GCCGACAGCGAGGGGACAGUCAGUCUCCUCGCA-GGGCUCGGUACAACCGCCUCCGCAAG
BA000001.2/1531413-1531580	GCCGACAGCGAGGGUACAAUA----CCCUCGCAAGGGCUCGGUCAACCCGCCCCCGCAAG
AF468962.1/1-168	GCCGACAGCGAGGGUACAAUA----CCCUCGCAAGGGCUCGGUCAACCCGCCCCCGCAAG
AJ248284.1/11131-11298	GCCGACAGCGAGGGUACAAU-----CCCUCGCAGGGGCUCGGUCUACCCGCCCCCGCAAG

AP006878.1/1107433-1107263	GU-AUCGGGUUCCGUGAGCGGAGCGUGCUCACGCCGAGCCCACAGGGCCGGGAGCAUCCA
BA000001.2/1531413-1531580	GU-UUCGGGGUCGAUGAGCGGGGUGUGCUCACGCCGAGCCUACAGGGCCGG-UGCAUCCG
AF468962.1/1-168	GU-UUCGGGUUCGAUGAGCGGGGUGUGCUCACGCCGAGCCUACAGGGCCGG-UGCAUCCG
AJ248284.1/11131-11298	GUGUUCGGGUUCGAUGAGCGGGGUGUGCUCACGCCGAGCCCACAGGGCCGG-UGCAUCCG

AP006878.1/1107433-1107263	CCCGCGGGAGCAGUGACCGC-GGGCCUCUGUACCCGGCCCACAUUUCGAUGCCC
BA000001.2/1531413-1531580	CCCGCGGGAUUAAUGACCGCUGGGUCUCUGUUGCCGGCCCACAAUAAAGUUUAA
AF468962.1/1-168	CCCGCGGGAUCAAUGACCGCUGGGUCUCUGUUGCCGGCCCACAAAAGUAUUUUA
AJ248284.1/11131-11298	CCCGCGGGAUCAAUGACCGCCGGGUCUCUGUUGCCGGCCUACAGCAAAAAUUUA

2D	.......(((((((...........)))))))..((((((((....(((((.((((.........))))........)))))...........))))))))...(((((((.........(((((((.........)))).))).........)))))))..............
In [2]:
consensus2d_to_booquet(structural_alignment)
Out[2]:
{'diagonals': [],
 'directly-linked-helices': [],
 'helices': [{'coords': [[0.0, 200], [0.0, 140]],
   'descriptions': [['BA000001.2/1531413-1531580', 'GCGAGGG', 'CCCUCGC'],
    ['AJ248284.1/11131-11298', 'GCGAGGG', 'CCCUCGC'],
    ['AF468962.1/1-168', 'GCGAGGG', 'CCCUCGC'],
    ['AP006878.1/1107433-1107263', 'GCGAGGG', 'UCCUCGC']],
   'location': [[8, 14], [26, 32]],
   'name': 'H1',
   'quantitative_value': 0.0},
  {'coords': [[40.0, 200], [40.0, 130]],
   'descriptions': [['BA000001.2/1531413-1531580', 'GGGCUCGG', 'CCGAGCCU'],
    ['AJ248284.1/11131-11298', 'GGGCUCGG', 'CCGAGCCC'],
    ['AF468962.1/1-168', 'GGGCUCGG', 'CCGAGCCU'],
    ['AP006878.1/1107433-1107263', 'GGGCUCGG', 'CCGAGCCC']],
   'location': [[35, 42], [94, 101]],
   'name': 'H2',
   'quantitative_value': 0.0},
  {'coords': [[40.0, 100.0], [40.0, 60.0]],
   'descriptions': [['BA000001.2/1531413-1531580', 'CCCGC', 'GCGGG'],
    ['AJ248284.1/11131-11298', 'CCCGC', 'GCGGG'],
    ['AF468962.1/1-168', 'CCCGC', 'GCGGG'],
    ['AP006878.1/1107433-1107263', 'ACCGC', 'GCGGA']],
   'location': [[47, 51], [78, 82]],
   'name': 'H3',
   'quantitative_value': 0.0},
  {'coords': [[40.0, 30.0], [40.0, 0.0]],
   'descriptions': [['BA000001.2/1531413-1531580', 'CCCG', 'CGGG'],
    ['AJ248284.1/11131-11298', 'CCCG', 'CGGG'],
    ['AF468962.1/1-168', 'CCCG', 'CGGG'],
    ['AP006878.1/1107433-1107263', 'UCCG', 'CGGG']],
   'location': [[53, 56], [66, 69]],
   'name': 'H4',
   'quantitative_value': 0.0},
  {'coords': [[80.0, 200], [80.0, 140]],
   'descriptions': [['BA000001.2/1531413-1531580', 'GGGCCGG', 'CCGGCCC'],
    ['AJ248284.1/11131-11298', 'GGGCCGG', 'CCGGCCU'],
    ['AF468962.1/1-168', 'GGGCCGG', 'CCGGCCC'],
    ['AP006878.1/1107433-1107263', 'GGGCCGG', 'CCGGCCC']],
   'location': [[105, 111], [154, 160]],
   'name': 'H5',
   'quantitative_value': 0.0},
  {'coords': [[80.0, 110.0], [80.0, 90.0]],
   'descriptions': [['BA000001.2/1531413-1531580', 'CCC', 'GGG'],
    ['AJ248284.1/11131-11298', 'CCC', 'GGG'],
    ['AF468962.1/1-168', 'CCC', 'GGG'],
    ['AP006878.1/1107433-1107263', 'CCC', 'GGG']],
   'location': [[121, 123], [142, 144]],
   'name': 'H6',
   'quantitative_value': 0.0},
  {'coords': [[80.0, 60.0], [80.0, 30.0]],
   'descriptions': [['BA000001.2/1531413-1531580', 'GCGG', 'CCGC'],
    ['AJ248284.1/11131-11298', 'GCGG', 'CCGC'],
    ['AF468962.1/1-168', 'GCGG', 'CCGC'],
    ['AP006878.1/1107433-1107263', 'GCGG', 'CCGC']],
   'location': [[124, 127], [137, 140]],
   'name': 'H7',
   'quantitative_value': 0.0}],
 'junctions': [{'coords': [[0.0, 125]],
   'descriptions': [['BA000001.2/1531413-1531580', 'UACAAUA'],
    ['AJ248284.1/11131-11298', 'UACAAU'],
    ['AF468962.1/1-168', 'UACAAUA'],
    ['AP006878.1/1107433-1107263', 'GACAGUCAGUC']],
   'location': [[14, 26]],
   'quantitative_value': 1.920286436967152},
  {'coords': [[40.0, 115]],
   'descriptions': [['BA000001.2/1531413-1531580', 'UCAA', 'GUGUGCUCACG'],
    ['AJ248284.1/11131-11298', 'UCUA', 'GUGUGCUCACG'],
    ['AF468962.1/1-168', 'UCAA', 'GUGUGCUCACG'],
    ['AP006878.1/1107433-1107263', 'UACA', 'GCGUGCUCACG']],
   'location': [[42, 47], [82, 94]],
   'quantitative_value': 0.0},
  {'coords': [[40.0, 45.0]],
   'descriptions': [['BA000001.2/1531413-1531580', 'C', 'GUCGAUGA'],
    ['AJ248284.1/11131-11298', 'C', 'UUCGAUGA'],
    ['AF468962.1/1-168', 'C', 'UUCGAUGA'],
    ['AP006878.1/1107433-1107263', 'C', 'UUCCGUGA']],
   'location': [[51, 53], [69, 78]],
   'quantitative_value': 0.0},
  {'coords': [[40.0, -15.0]],
   'descriptions': [['BA000001.2/1531413-1531580', 'CAAGGUUU'],
    ['AJ248284.1/11131-11298', 'CAAGGUGUU'],
    ['AF468962.1/1-168', 'CAAGGUUU'],
    ['AP006878.1/1107433-1107263', 'CAAGGUAU']],
   'location': [[56, 66]],
   'quantitative_value': 0.4330127018922193},
  {'coords': [[80.0, 125]],
   'descriptions': [['BA000001.2/1531413-1531580', 'UGCAUCCG', 'UCUCUGUUG'],
    ['AJ248284.1/11131-11298', 'UGCAUCCG', 'UCUCUGUUG'],
    ['AF468962.1/1-168', 'UGCAUCCG', 'UCUCUGUUG'],
    ['AP006878.1/1107433-1107263', 'GAGCAUCCA', 'CCUCUGUAC']],
   'location': [[111, 121], [144, 154]],
   'quantitative_value': 0.4330127018922193},
  {'coords': [[80.0, 15.0]],
   'descriptions': [['BA000001.2/1531413-1531580', 'GAUUAAUGA'],
    ['AJ248284.1/11131-11298', 'GAUCAAUGA'],
    ['AF468962.1/1-168', 'GAUCAAUGA'],
    ['AP006878.1/1107433-1107263', 'GAGCAGUGA']],
   'location': [[127, 137]],
   'quantitative_value': 0.0},
  {'coords': [[80.0, 75.0]],
   'descriptions': [['BA000001.2/1531413-1531580', '', 'U'],
    ['AJ248284.1/11131-11298', '', 'C'],
    ['AF468962.1/1-168', '', 'U'],
    ['AP006878.1/1107433-1107263', '', '']],
   'location': [[123, 124], [140, 142]],
   'quantitative_value': 0.4330127018922193}],
 'single_strands': [{'coords': [[-40.0, 200], [0.0, 200]],
   'descriptions': [['BA000001.2/1531413-1531580', 'GCCGACA'],
    ['AJ248284.1/11131-11298', 'GCCGACA'],
    ['AF468962.1/1-168', 'GCCGACA'],
    ['AP006878.1/1107433-1107263', 'GCCGACA']],
   'location': [1, 7],
   'name': 'SS1',
   'quantitative_value': 0.0},
  {'descriptions': [['BA000001.2/1531413-1531580', 'UACAAUA'],
    ['AJ248284.1/11131-11298', 'UACAAU'],
    ['AF468962.1/1-168', 'UACAAUA'],
    ['AP006878.1/1107433-1107263', 'GACAGUCAGUC']],
   'location': [15, 25],
   'name': 'SS2',
   'quantitative_value': 1.920286436967152},
  {'coords': [[0.0, 200], [40.0, 200]],
   'descriptions': [['BA000001.2/1531413-1531580', 'AA'],
    ['AJ248284.1/11131-11298', 'AG'],
    ['AF468962.1/1-168', 'AA'],
    ['AP006878.1/1107433-1107263', 'A']],
   'location': [33, 34],
   'name': 'SS3',
   'quantitative_value': 0.4330127018922193},
  {'descriptions': [['BA000001.2/1531413-1531580', 'UCAA'],
    ['AJ248284.1/11131-11298', 'UCUA'],
    ['AF468962.1/1-168', 'UCAA'],
    ['AP006878.1/1107433-1107263', 'UACA']],
   'location': [43, 46],
   'name': 'SS4',
   'quantitative_value': 0.0},
  {'descriptions': [['BA000001.2/1531413-1531580', 'C'],
    ['AJ248284.1/11131-11298', 'C'],
    ['AF468962.1/1-168', 'C'],
    ['AP006878.1/1107433-1107263', 'C']],
   'location': [52, 52],
   'name': 'SS5',
   'quantitative_value': 0.0},
  {'descriptions': [['BA000001.2/1531413-1531580', 'CAAGGUUU'],
    ['AJ248284.1/11131-11298', 'CAAGGUGUU'],
    ['AF468962.1/1-168', 'CAAGGUUU'],
    ['AP006878.1/1107433-1107263', 'CAAGGUAU']],
   'location': [57, 65],
   'name': 'SS6',
   'quantitative_value': 0.4330127018922193},
  {'descriptions': [['BA000001.2/1531413-1531580', 'GUCGAUGA'],
    ['AJ248284.1/11131-11298', 'UUCGAUGA'],
    ['AF468962.1/1-168', 'UUCGAUGA'],
    ['AP006878.1/1107433-1107263', 'UUCCGUGA']],
   'location': [70, 77],
   'name': 'SS7',
   'quantitative_value': 0.0},
  {'descriptions': [['BA000001.2/1531413-1531580', 'GUGUGCUCACG'],
    ['AJ248284.1/11131-11298', 'GUGUGCUCACG'],
    ['AF468962.1/1-168', 'GUGUGCUCACG'],
    ['AP006878.1/1107433-1107263', 'GCGUGCUCACG']],
   'location': [83, 93],
   'name': 'SS8',
   'quantitative_value': 0.0},
  {'coords': [[40.0, 200], [80.0, 200]],
   'descriptions': [['BA000001.2/1531413-1531580', 'ACA'],
    ['AJ248284.1/11131-11298', 'ACA'],
    ['AF468962.1/1-168', 'ACA'],
    ['AP006878.1/1107433-1107263', 'ACA']],
   'location': [102, 104],
   'name': 'SS9',
   'quantitative_value': 0.0},
  {'descriptions': [['BA000001.2/1531413-1531580', 'UGCAUCCG'],
    ['AJ248284.1/11131-11298', 'UGCAUCCG'],
    ['AF468962.1/1-168', 'UGCAUCCG'],
    ['AP006878.1/1107433-1107263', 'GAGCAUCCA']],
   'location': [112, 120],
   'name': 'SS10',
   'quantitative_value': 0.4330127018922193},
  {'descriptions': [['BA000001.2/1531413-1531580', 'GAUUAAUGA'],
    ['AJ248284.1/11131-11298', 'GAUCAAUGA'],
    ['AF468962.1/1-168', 'GAUCAAUGA'],
    ['AP006878.1/1107433-1107263', 'GAGCAGUGA']],
   'location': [128, 136],
   'name': 'SS11',
   'quantitative_value': 0.0},
  {'descriptions': [['BA000001.2/1531413-1531580', 'U'],
    ['AJ248284.1/11131-11298', 'C'],
    ['AF468962.1/1-168', 'U'],
    ['AP006878.1/1107433-1107263', '']],
   'location': [141, 141],
   'name': 'SS12',
   'quantitative_value': 0.4330127018922193},
  {'descriptions': [['BA000001.2/1531413-1531580', 'UCUCUGUUG'],
    ['AJ248284.1/11131-11298', 'UCUCUGUUG'],
    ['AF468962.1/1-168', 'UCUCUGUUG'],
    ['AP006878.1/1107433-1107263', 'CCUCUGUAC']],
   'location': [145, 153],
   'name': 'SS13',
   'quantitative_value': 0.0},
  {'coords': [[80.0, 200], [120.0, 200]],
   'descriptions': [['BA000001.2/1531413-1531580', 'ACAAUAAAGUUUAA'],
    ['AJ248284.1/11131-11298', 'ACAGCAAAAAUUUA'],
    ['AF468962.1/1-168', 'ACAAAAGUAUUUUA'],
    ['AP006878.1/1107433-1107263', 'ACAUUUCGAUGCCC']],
   'location': [161, 174],
   'name': 'SS14',
   'quantitative_value': 0.0}]}
In [ ]: