def test_short_with_insert(self):
     a = read_alignment(WITH_INSERT)
     recipe = RecipeMaker(a).recipe
     self.assertEqual(len(recipe.difficult), 0)
     self.assertEqual(len(recipe.add_fragment), 1)
     self.assertEqual(len(recipe.add_fragment_5p), 0)
     self.assertEqual(len(recipe.add_fragment_3p), 0)
 def test_overhang(self):
     """Gaps at begin and end should be used only if in the template."""
     a = read_alignment(OVERHANG_ALIGN)
     recipe = RecipeMaker(a).recipe
     self.assertEqual(len(recipe.add_fragment_5p), 1)
     self.assertEqual(len(recipe.add_fragment_5p[0]), 3)
     self.assertEqual(len(recipe.add_fragment_3p), 1)
     self.assertEqual(len(recipe.add_fragment_3p[0]), 4)
Esempio n. 3
0
def apply_missing_ends(alignment,  model):
    """*apply_missing_ends(alignment,  model)*
    
Attaches an extended fragment of structure at both
the 5' and 3' ends of the target, where there is no corresponding
part in the template.

:Arguments:
    * Alignment object
    * model
    """
    alignment = validate_alignment(alignment)
    model = validate_model(model)
    
    if alignment:
        model.alignment = alignment
        model.recipe = RecipeMaker(alignment).recipe
    model.add_missing_5p()
    model.add_missing_3p()
Esempio n. 4
0
def remove_mismatching_modifications(template, alignment, model):
    """*remove_mismatching_modifications(template, alignment, model)*

Removes all nucleotide modifications that occur in the template, 
and are not present in the target sequence. 
The nucleotides are transformed into standard bases from which the modifications originated.
   
:Arguments:
    * Template object
    * Alignment object
    * RnaModel object
    """
    template = validate_template(template)
    alignment = validate_alignment(alignment)
    model = validate_model(model)
    
    model.template = template
    model.alignment = alignment
    model.recipe = RecipeMaker(alignment).recipe
    model.remove_all_modifications_copy()
Esempio n. 5
0
def add_all_modifications(template, alignment, model):
    """*add_all_modifications(template, alignment, model)*

Adds all modifications that occur in the target sequence, and are
not present in the template.
    
:Arguments:
    * Template object
    * Alignment object
    * RnaModel object
    """
    template = validate_template(template)
    alignment = validate_alignment(alignment)
    model = validate_model(model)
    
    if template: model.template = template
    if alignment:
        model.alignment = alignment
        model.recipe = RecipeMaker(alignment).recipe
    model.add_all_modifications_copy()    
Esempio n. 6
0
def exchange_mismatches(template, alignment, model):
    """*exchange_mismatches(template, alignment, model)*
    
Exchanges the bases for all standard base mismatches in an alignment.
This applies all exchanges of one standard base by another.
Modified bases are not changed (use the apply_alignment command for that).
 
:Arguments:
    * Template object
    * Alignment object
    * RnaModel object
    """
    template = validate_template(template)
    alignment = validate_alignment(alignment)
    model = validate_model(model)
    
    if template: model.template = template
    if alignment:
        model.alignment = alignment
        model.recipe = RecipeMaker(alignment).recipe
    model.exchange_all_bases()
Esempio n. 7
0
def apply_alignment(template, alignment, model):
    """*apply_alignment(template, alignment, model)*

Applies all operations on single bases that are in an alignment:
Copying identical residues, exchanging mismatches, adding modifications,
and removing modifications. As a result, all these residues are copied
into a model (which may be empty).
For gaps in the alignment, nothing is done.

:Arguments:
    * Template object
    * Alignment object
    * RNAModel object
    """
    template = validate_template(template)
    alignment = validate_alignment(alignment)
    model = validate_model(model)
    
    model.alignment = alignment
    model.recipe = RecipeMaker(alignment).recipe
    model.template = template
    model.apply_alignment()
Esempio n. 8
0
 def __init__(self,
              template=None,
              alignment=None,
              model_chain_name='A',
              data_type=None,
              data=None,
              seq=None):
     ModernaStructure.__init__(self,
                               data_type=data_type,
                               data=data,
                               chain_name=model_chain_name,
                               seq=seq)
     #TODO: order of arguments is inconsistent.
     #TODO: template + alignment should be obligatory
     #TODO: replace alignment by recipe
     #TODO: rename to SingleTemplateModeling and/or refactor classes for tasks out.
     self.template = template
     if template:
         self.template.set_template_numeration()
     if alignment:
         self.recipe = RecipeMaker(alignment).recipe
     self.alignment = alignment
     self.s = ModernaSuperimposer()
Esempio n. 9
0
def copy_identical_residues(template, alignment, model, strict=True, modifications=True):
    """*copy_identical_residues(template, alignment, model, strict=True, modifications=True)*

Copies all bases identical identical in the alignment
from the template structure to a model. The residue numbers
do not change.

:Arguments:
    * Template object
    * Alignment object
    * RnaModel object
    * strict=1 complains and stops on any problem encountered (default); strict=0 goes on if single residues fail to be copied
    * modifications=0 does not copy modified bases; modifications=1 is default.
    """
    template = validate_template(template)
    alignment = validate_alignment(alignment)
    model = validate_model(model)
    
    if template: model.template = template
    if alignment:
        model.alignment = alignment
        model.recipe = RecipeMaker(alignment).recipe
    model.copy_all_residues(strict=strict, modifications=modifications)
Esempio n. 10
0
def apply_all_indels(alignment, model): 
    """*apply_all_indels(alignment, model)*
    
Finds and inserts the best fragment candidate for each gap region in the alignment. 
This command can be used to fill in gaps automatically. 
The procedure automatically retrieves the 20 best fitting candidates 
from the fragment database, checks whether they produce any clashes upon insertion, 
and inserts the best scoring candidate.

It depends, however on
    * gaps being shorter than 17 bases.
    (if longer a database of fragments up to 100 nt is available)

:Arguments:
    * Alignment object
    * RnaModel object
    """
    alignment = validate_alignment(alignment)
    model = validate_model(model)
    
    if alignment:
        model.alignment = alignment
        model.recipe = RecipeMaker(alignment).recipe
    model.insert_all_fragments()
 def setUp(self):
     """Loads the fasta file with alignmnet."""
     self.a = read_alignment(MINI_ALIGNMENT)
     self.recipe = RecipeMaker(self.a).recipe
 def test_close_gaps(self):
     """Gaps close to each other should also work."""
     a = read_alignment(CLOSEGAPS)
     recipe = RecipeMaker(a).recipe
     self.assertEqual(len(recipe.difficult), 0)
     self.assertEqual(len(recipe.add_fragment), 4)
 def test_no_overhan(self):
     a = read_alignment(NO_OVERHANG_ALIGN)
     recipe = RecipeMaker(a).recipe
     self.assertEqual(len(recipe.add_fragment_5p), 0)
     self.assertEqual(len(recipe.add_fragment_3p), 0)
 def test_boxes(self):
     for seq1, seq2, matches in BOX_SAMPLES:
         align = read_alignment("> 1\n%s\n> 2\n%s\n" % (seq1, seq2))
         recipe = RecipeMaker(align).recipe
         for ap, m in zip(align, matches):
             self.assertTrue(self.find_in_box(recipe, ap, m))