Source code for schrodinger.protein.helix
"""
Module for converting residue sequences to 3D structures with an a-helix secondary
structure.
Copyright Schrodinger, LLC. All rights reserved.
"""
from schrodinger import structure
from schrodinger.protein import buildpeptide
from schrodinger.structutils import analyze
from schrodinger.structutils import build
# For backwards compatability:
get_fragment_structure = buildpeptide.get_fragment_structure
[docs]def process_sequence(line):
    """
    Create a 3D structure with a-helix secondary structure from the given
    sequence string.
    """
    # TODO: Consider moving most of this code into the buildpeptide.py module.
    delete_Ncap = False
    delete_Ccap = False
    if line.startswith("NH-"):
        delete_Ncap = True
        line = line[3:]
    if line.endswith("-OH"):
        delete_Ccap = True
        line = line[:-3]
    st = None
    fromatom = None
    toatom = None
    for i, c in enumerate(line):
        try:
            fragname = structure.RESIDUE_MAP_1_TO_3_LETTER[c]
        except KeyError:
            raise ValueError('Could not get 3-letter code for residue "%s"' % c)
        if i == 0:
            # FIXME print this when in debug mode
            # print "Placing first fragment:", fragname
            st = buildpeptide.get_fragment_structure(fragname)
            # Find the NMA cap to replace with the next residue:
            matches = analyze.evaluate_smarts_canvas(st, "O=CN[C;H3]")
            m = matches[0]
            fromatom = m[1]
            toatom = m[2]
        else:
            # FIXME print this when in debug mode
            # print "Growing:", fragname
            fromatom, toatom = buildpeptide.grow_fragment(
                st, fromatom, toatom, "peptide", fragname, "forward(N-to-C)")
    if delete_Ncap:
        del_atoms = analyze.evaluate_asl(st, 'res.ptype "ACE "')
        st.deleteAtoms(del_atoms)
        build.add_hydrogens(st)
    if delete_Ccap:
        del_atoms = analyze.evaluate_asl(st, 'res.ptype "NMA "')
        st.deleteAtoms(del_atoms)
        build.add_hydrogens(st)
        # Locate the aldehyde (there will only be one):
        matches = analyze.evaluate_smarts_canvas(st, "[#1][C-0X3]=[O-0X1]")
        if len(matches):
            # Replace the aldehyde with a hydroxyl
            m = matches[0]
            resname = st.atom[m[1]].pdbres
            resnum = st.atom[m[1]].resnum
            oxygen, hydrogen = buildpeptide.grow_fragment(
                st, m[1], m[0], "organic", "Hydroxyl", "forward")
            # Give it the same resname as the previous residue:
            st.atom[oxygen].pdbres = resname
            st.atom[oxygen].resnum = resnum
            st.atom[hydrogen].pdbres = resname
            st.atom[hydrogen].resnum = resnum
    if delete_Ncap:
        # FIXME renumber residues so that the first residue starts with
        # 1 instead of 2 (due to deleted ACE cap).
        pass
    return st