示例#1
0
def match_alignment_with_model(alignment, model):
    """*match_alignment_with_model(alignment, model)*

Checks, if the sequence of a model structure is equal to the first sequence in the alignment. 
Writes an according message and returns True or False.

Both sequences also count as equal if one has modified nucleotides, and 
the other the corresponding unmodified nucleotides in the same position, 
or if one of the sequences contains the wildcard symbol '.'. 
Thus, the sequence "AGU" is equal to both "A7Y" and "A.U".
    
:Arguments:
    * Alignment object
    * RnaModel object
    """
    alignment = validate_alignment(alignment)
    model = validate_model(model)
    
    log.write_message('\nChecking whether alignment matches with model.')
    am = AlignmentMatcher(alignment)
    seq = model.get_sequence()
    result = am.is_target_identical(seq)
    if not result:
        log.write_message("alignment and model match.\n")
    else:
        log.write_message("ALIGNMENT AND MODEL SEQUENCES DO NOT MATCH YET !!!\n")
    return result
示例#2
0
def match_template_with_alignment(template, alignment):
    """*match_template_with_alignment(template, alignment)*
    
Checks, if the sequence of the template structure is equal 
to the second sequence in the alignment. Writes an according message and returns True or False.
Small inconsistencies between both sequences, e.g. backbone breaks, or missing modification symbols
are corrected automatically in the alignment, and changes are reported in the logfile.

Both sequences also count as equal if one has modified nucleotides, and 
the other the corresponding unmodified nucleotides in the same position, 
or if one of the sequences contains the wildcard symbol '.'. 
Thus, the sequence "AGU" is equal to both "A7Y" and "A.U".

:Arguments:
    * Template object
    * Alignment object
    """
    template = validate_template(template)
    alignment = validate_alignment(alignment)
    
    log.write_message('Checking whether template matches with alignment.')
    am = AlignmentMatcher(alignment)
    seq = template.get_sequence()
    am.fix_template_seq(seq)
    result = am.is_template_identical(seq)
    if result:
        log.write_message("template and alignment match.\n")
    else:
        log.write_message("TEMPLATE AND ALIGNMENT DO NOT MATCH!\n")
    return result
 def test_adjust_target_seq(self):
     """Gaps inserted in target for extra _ in template."""
     modified = Sequence("GCG7APU_UALCYC.G")
     expected  = 'GCG7A----PU_UALCUC.G'
     a = AlignmentMatcher(self.ali)
     a.fix_template_seq(modified)
     self.assertEqual(self.ali.aligned_target_seq, Sequence("ACUGUGAYUA[-UACCU#PG"))
 def test_fix_template_seq(self):
     """Fix template sequence"""
     modified = Sequence("GCG7APU_UALCYC.G")
     expected  = 'GCG7A----PU_UALCUC.G'
     a = AlignmentMatcher(self.ali)
     a.fix_template_seq(modified)
     self.assertEqual(self.ali.template_seq, Sequence(expected.replace('-', '')))
     self.assertEqual(self.ali.aligned_template_seq, Sequence(expected))
    def test_fix_example(self):
        """Real-world example from Irina"""
        ali = read_alignment(""">1EIY:C|PDBID|CHAIN|SEQUENCE
GCCGAGGUAGCUCAGUUGGUAGAGCAUGCGACUGAAAAUCGCAGUGUCCGCGGUUCGAUUCCGCGCCUCGGCACCA
>1EHZ:A|PDBID|CHAIN|SEQUENCE
GCGGAUUUAGCUCAGUUGGGAGAGCGCCAGACUGAAGAUCUGGAGGUCCUGUGUUCGAUCCACAGAAUUCGCACCA""")
        am = AlignmentMatcher(ali)
        seq = Sequence('GCGGAUUUALCUCAGDDGGGAGAGCRCCAGABU#AAYAP?UGGAG7UC?UGUGTPCG"UCCACAGAAUUCGCACCA')
        self.assertFalse(am.is_template_identical(seq))
        am.fix_template_seq(seq)
        self.assertTrue(am.is_template_identical(seq))
    def test_fix_alignment_with_gap(self):
        """Real-world exaple from nettab - 1qf6 modeling on 1c0a"""
        ali = read_alignment(""">1QF6
DDGGD-AGAGAAA
>1C0A
UCGGUUAGAA---""")
        true_target_seq = ali.aligned_sequences[0]
        am = AlignmentMatcher(ali)
        seq = Sequence('DCGGDDAGAA')
        self.assertFalse(am.is_template_identical(seq))
        am.fix_template_seq(seq)
        self.assertTrue(am.is_template_identical(seq))
        self.assertEqual(ali.aligned_sequences[0], true_target_seq)
 def test_template_with_break(self):
     """Backbone gap breaks identity in template"""
     a = AlignmentMatcher(self.ali)
     with_break = Sequence("GCGGAUUUALCUCAG")
     self.assertTrue(a.is_template_identical, with_break)
 def test_is_template_identical(self):
     a = AlignmentMatcher(self.ali)
     self.assertFalse(a.is_template_identical(self.target_seq))
     self.assertTrue(a.is_template_identical(self.template_seq))
 def test_target_with_break(self):
     """Backbone gap breaks identity in target"""
     a = AlignmentMatcher(self.ali)
     with_break = Sequence("ACUGUGAY_UA[UACCU#PG")
     self.assertFalse(a.is_target_identical(with_break))
 def test_is_target_identical(self):
     """Compare template and target"""
     a = AlignmentMatcher(self.ali)
     self.assertTrue(a.is_target_identical(self.target_seq))
     self.assertFalse(a.is_target_identical(self.template_seq))
 def test_init(self):
     """Initializing Matcher"""
     a = AlignmentMatcher(self.ali)
     self.assertEqual(a.align, self.ali)