Example #1
0
 def remove_one_modification_copy(self, residue, number_in_model):
     """
     """
     temp_resi = RNAResidue(residue)
     num = number_in_model or temp_resi.number
     remove_modification(temp_resi)
     self.add_residue(temp_resi, str(num))
     log.write_message('Residue %s: modification removed (%s ---> %s).' %
                       (num, residue.long_abbrev, temp_resi.long_abbrev))
 def test_mods_sanity(self):
     """Adding and removing many times should work as well."""
     #for mod in ['m1A','m66A','Am','t6A']:
     for mod in ['m1A', 'm6Am', 'Am', 't6A']:
         # there is no modification named m66A. There is m6Am
         self.assertEqual(BaseRecognizer().identify_resi(self.adenosine),
                          'A')
         add_modification(self.adenosine, mod)
         self.assertEqual(BaseRecognizer().identify_resi(self.adenosine),
                          mod)
         remove_modification(self.adenosine)
 def test_dna_exchange(self):
     """All combinations of DNA->DNA exchanges should work."""
     bases = ['dT', 'dA', 'dG', 'dC']
     br = BaseRecognizer()
     r = self.adenosine
     for b1 in bases:
         add_modification(r, b1)
         self.assertEqual(br.identify_resi(r), b1)
         for b2 in bases:
             remove_modification(r)
             add_modification(r, b2)
             self.assertEqual(br.identify_resi(r), b2)
Example #4
0
    def remove_all_modifications_copy(self):
        """
        Removes all unnecessary modifications from model acordong given alignment.
        Copies all this residues without modification into model.
        """
        if self.alignment and self.template:
            for ap in self.recipe.remove_modifications:
                res = self.template.template_residues[str(
                    ap.template_position)]
                temp_resi = RNAResidue(res)
                remove_modification(temp_resi)

                if temp_resi != ap.target_letter:
                    exchange_base(temp_resi, ap.target_letter.original_base)
                self.add_residue(temp_resi)
                log.write_message(
                    'Residue %s: modification removed (%s ---> %s).' %
                    (temp_resi.identifier, res.long_abbrev,
                     temp_resi.long_abbrev))
        else:
            raise RnaModelError('There is no template or/and alignmnt')
Example #5
0
def remove_modification(residue, model=None, new_number=None):
    """*remove_modification(residue, model=None, new_number=None)*
    
Removes base modifications from a single residue. The nucleotide is
transformed into the standard base from which the modification originated.
A RnaModel can be given optionally. If this is given, the
modified residue is subsequently copied to it.

Note that desoxynucleotides count as modified bases as well.
  
:Arguments:
    * residue from a Template or RnaModel object
    * RnaModel object (optional)
    * new residue number after copying (optional)
    """
    residue = validate_resi(residue)
    if model: model = validate_model(model)
    if new_number: new_number = validate_resnum(new_number)
    
    if model: 
        model.remove_one_modification_copy(residue, new_number)
    else:
        modifications.remove_modification(residue)
Example #6
0
 def test_res_names_remove_modif(self):
     """Names should be consistent after adding modifications."""
     remove_modification(self.s['10'])
     self.s.write_pdb_file(TEST_OUTPUT)
     rn = self.get_resnames(TEST_OUTPUT)
     self.assertEqual(rn[4], '  A')
Example #7
0
 def remove_all_modifications(self):
     """Removes all modifications from the model."""
     for resi in self:
         if resi.modified:
             remove_modification(resi)
 def test_remove_deoxy(self):
     struc = ModernaStructure('file', DNA_WITH_MISMATCH, 'E')
     r10 = struc['10']
     self.assertEqual(BaseRecognizer().identify_resi(r10), 'dG')
     remove_modification(r10)
     self.assertEqual(BaseRecognizer().identify_resi(r10), 'G')
 def test_remove(self):
     struc = ModernaStructure('file', MINI_TEMPLATE)
     r10 = struc['10']
     self.assertEqual(BaseRecognizer().identify_resi(r10), 'm2G')
     remove_modification(r10)
     self.assertEqual(BaseRecognizer().identify_resi(r10), 'G')