예제 #1
0
def create_model(template=None, alignment=None, model_chain_name=None):
    """*create_model(template=None, alignment=None, model_chain_name=None)*
  
Creates a RNA structure model.
Produces a RnaModel object that can be saved
in a variable (see example).

If no arguments are given, an empty RNAModel is created.
If both a Template and an Alignment are given as arguments,
the complete model is built automatically.
The chain id that the model should have can be specified optionally.

:Arguments:
    * Template object (optional)
    * Alignment object (optional)
    * chain id of the model to be built
    """
    if template: template = validate_template(template)
    if alignment: alignment = validate_alignment(alignment)
    
    model = RnaModel(template=template, alignment=alignment, model_chain_name=model_chain_name, data_type=None, data=None)
    if template and alignment:
        if not match_template_with_alignment(template,alignment):
            raise ModernaError("""Template and alignment sequences do not match!
The model cannot be built automatically.
Template : %s
Alignment: %s
"""%(template.get_sequence(),alignment.template_seq))
        model.create_model()
        match_alignment_with_model(alignment,model)
    return model
예제 #2
0
    def test_model_with_5p3p_ends(self):
        a = read_alignment('''> target
CAUGCGGAYYYALCUCAGGUA
> mini_template
---GCGGAUUUALCUCAG---
''')
        m = RnaModel(self.t, a)
        m.create_model()
        self.assertEqual(m.get_sequence(), Sequence('CAUGCGGAYYYALCUCAGGUA'))
예제 #3
0
    def test_model_with_hydro_template(self):
        """If the template contains hydrogens, modifications should be added."""
        t = Template(RNA_HYDRO, 'file', 'B')
        a = read_alignment("""> 3tra_A.pdb Z73314.1/2358-2429
UPA
> 1qru_B.pdb X55374.1/1-72
CAA
""")
        m = RnaModel(t, a)
        m.create_model()
        self.assertEqual(m.get_sequence(), Sequence('UPA'))
예제 #4
0
    def test_number_gap(self):
        """Builds model with numbering gap in the template."""
        a = read_alignment("""> target
CCGACCUUCGGCCACCUGACAGUCCUGUGCGGGAAACCGCACAGGACUGUCAACCAGGUAAUAUAACCACCGGGAAACGGUGGUUAUAUUACCUGGUACGCCUUGACGUGGGGGAAACCCCACGUCAAGGCGUGGUGGCCGAAGGUCGG
> template
CCGACCUUCGGCCACCUGACAGUCCUGUGCGG----CCGCACAGGACUGUCAACCAGGUAAUAUAACCACCGG----CGGUGGUUAUAUUACCUGGUACGCCUUGACGUGGGG----CCCCACGUCAAGGCGUGGUGGCCGAAGGUCGG
""")
        t = Template(JMB_TEMPLATE, 'file')
        clean_structure(t)
        m = RnaModel(t, a)
        m.create_model()
        self.assertEqual(m.get_sequence().seq_without_breaks, a.target_seq)
예제 #5
0
    def test_model_with_alignment_adjustment(self):
        """Introduces small corrections on alignment."""
        a = read_alignment("""> target
ACUGUGAYUA[UACCU#P-G
> template with small errors.
GCG7A----U.UAGCUCA_G
        """)
        t = Template(MINI_TEMPLATE, 'file')
        match_template_with_alignment(t, a)
        m = RnaModel(t, a)
        m.create_model()
        self.assertEqual(m.get_sequence(), Sequence("ACUGUGAYUA[UACCU#PG"))
예제 #6
0
    def test_model_with_close_gaps(self):
        t = Template('test_data/rna_structures/2du3_excerpt.ent', 'file', 'D')
        a = read_alignment('''> 1qru_B.pdb X55374.1/1-72
GCA-UUCCG
> 2du3_D.pdb
CUUUA-CCC
''')
        m = RnaModel()
        copy_some_residues([t['944'], t['946'], t['947']], m)
        lc = find_fragment(m, '946', '947', Sequence('U'))
        insert_fragment(m, lc[0])
        lc = find_fragment(m, '944', '946', Sequence(''))
        insert_fragment(m, lc[0])
        return  #TODO: remove
        # generate model
        m = RnaModel(t, a)
        m.create_model()
예제 #7
0
 def test_gap_optimization_example_2(self):
     t = Template('test_data/gaps/mini_1h4s_T_gap2.pdb', 'file', 'T')
     a = read_alignment('test_data/gaps/ali_gap2.fasta')
     m = RnaModel(t, a)
     m.create_model()
예제 #8
0
 def test_create_model_with_unknown(self):
     """Alignment that contains unknown bases in the target."""
     a = read_alignment(MINI_ALIGNMENT_WITH_UNK)
     m = RnaModel(self.t, a)
     m.create_model()
     self.assertEqual(m.get_sequence(), Sequence('..CUGUQQUACCU#P'))