Esempio n. 1
0
def create_fragment(pdb_path, anchor5=None, anchor3=None, chain_name='A', sequence=None):
    """*create_fragment(pdb_path, anchor5=None, anchor3=None, chain_name='A', sequence=None)*

To insert small pieces of custom PDB structures into models, fragments can be used. 
This command loads a fragment, and defines one or two connection points, to which 
the fragment will be inserted by superposition. It returns a ModernaFragment object.

To add a ModernaFragment object to a model, the insert_fragment command should be used.
The scenarios for adding either involve superposition of a single residue with the model
on the 5' end of the fragment, or on the 3' end, or both.
   
:Arguments:
    * path to pdb file with the fragment
    * residue to which the 5' end of the fragment will be superimposed
    * residue to which the 3' end of the fragment will be superimposed
    * chain name of the fragment in the file (optional; A by default)
    * sequence that should be modeled onto the fragment upon insertion (optional; the sequence should not include the 1-2 anchor residues, it therefore has to be shorter than the fragment)
    """
    pdb_path = validate_path(pdb_path)
    if anchor5: anchor5 = validate_resi(anchor5)
    if anchor3: anchor3 = validate_resi(anchor3)
    if sequence: sequence = validate_seq(sequence)
    struc = ModernaStructure(data_type='file', data=pdb_path, chain_name=chain_name)
    
    if anchor5 and anchor3:
        fr = ModernaFragment53(struc, anchor5=anchor5, anchor3=anchor3, new_sequence=sequence, strict=False)
    elif anchor5:
        fr = ModernaFragment5(struc, anchor5=anchor5, new_sequence=sequence, strict=False)
    elif anchor3:
        fr = ModernaFragment3(struc, anchor3=anchor3, new_sequence=sequence, strict=False)
    else:
        raise ModernaError("Anchor residues need to be specified.")
    return fr
Esempio n. 2
0
 def add_missing_3p(self):
     """ """
     if self.alignment and len(self.recipe.add_fragment_3p) > 0:
         anchor5 = [r for r in self][-1]
         ap_list = self.recipe.add_fragment_3p[0]
         seq = Sequence(''.join(
             [ap.target_letter.short_abbrev for ap in ap_list]))
         all_resis = [r for r in Template(SINGLE_STRAND, 'file', 'A')]
         while len(all_resis) - 1 < len(ap_list):
             all_resis = self._elongate_strand(all_resis)
         frag_resis = all_resis[:len(ap_list) + 1]
         struc = ModernaStructure('residues', frag_resis)
         frag = ModernaFragment5(struc,
                                 anchor5=anchor5,
                                 new_sequence=seq,
                                 keep=keep_first)
         self.insert_fragment(frag)
Esempio n. 3
0
 def test_add_on_3_end_replace(self):
     """Model sequence should change accordingly."""
     five_overwrite = ModernaFragment5(self.s2, anchor5=self.m['9'])
     self.m.insert_fragment(five_overwrite)
     self.assertEqual(self.m.get_sequence(), Sequence("GCGGAUUUACGG"))
     self.assertTrue(five_overwrite.rmsd <= 1.00, 0)
Esempio n. 4
0
 def test_add_on_3_end(self):
     """Model sequence should change accordingly."""
     five = ModernaFragment5(self.s1, anchor5=self.m['15'])
     self.m.insert_fragment(five)
     self.assertEqual(self.m.get_sequence(), Sequence("GCGGAUUUALCUCAGCGG"))
     self.assertTrue(five.rmsd <= 1.00)
Esempio n. 5
0
 def test_attributes(self):
     five = ModernaFragment5(self.s1, anchor5=self.m['15'])
     self.assertEqual(len(five.anchor_residues), 1)
     self.assertEqual(len(five.nonanchor_residues), 3)
     self.assertTrue(str(five))