Ejemplo n.º 1
0
def test_PeptideBuilder(pdb_code):
    # retrieve pdb file
    pdb_file = "%s_clean.pdb" % (pdb_code)
    
    # build backbone model from all angles and bond lengths
    structure_backbone= PeptideBuilder.make_structure_from_geos(build_backbone_model(pdb_file))
    
    # build backbone model from all angles
    structure_all_angles= PeptideBuilder.make_structure_from_geos(build_all_angles_model(pdb_file))
    
    # build models from dihedral angles only
    structure_omega, structure_phi_psi=build_phi_psi_model(pdb_file)
    
    # compare models to original structure
    RMS_backbone_50, RMS_backbone_150, RMS_backbone, size= compare_structure(pdb_file, make_pdb_file(structure_backbone, "Backbone_" + pdb_file))
    RMS_phi_psi_50, RMS_phi_psi_150, RMS_phi_psi, size= compare_structure(pdb_file, make_pdb_file(structure_phi_psi, "PhiPsi_" + pdb_file))
    RMS_omega_50, RMS_omega_150, RMS_omega, size= compare_structure(pdb_file, make_pdb_file(structure_omega, "PhiPsiOmega_" + pdb_file))
    RMS_all_angles_50, RMS_all_angles_150, RMS_all_angles, size= compare_structure(pdb_file, make_pdb_file(structure_all_angles, "AllAngles_" + pdb_file))
    output_line= "%s\t%i\t%0.1f\t%0.1f\t%0.1f\t%0.1f\t%0.1f\t%0.1f\t%0.1f\t%0.1f\t%0.1f\t%0.1f\t%0.1f\t%0.1f\n" % \
        (pdb_code, \
         size, \
         RMS_phi_psi_50, \
         RMS_phi_psi_150, \
         RMS_phi_psi, \
         RMS_omega_50, \
         RMS_omega_150, \
         RMS_omega, \
         RMS_all_angles_50, \
         RMS_all_angles_150, \
         RMS_all_angles, \
         RMS_backbone_50, \
         RMS_backbone_150, \
         RMS_backbone )
    return output_line
Ejemplo n.º 2
0
def test_PeptideBuilder(pdb_code):
    # retrieve pdb file
    pdb_file = "%s_clean.pdb" % (pdb_code)

    # build backbone model from all angles and bond lengths
    structure_backbone = PeptideBuilder.make_structure_from_geos(
        build_backbone_model(pdb_file)
    )

    # build backbone model from all angles
    structure_all_angles = PeptideBuilder.make_structure_from_geos(
        build_all_angles_model(pdb_file)
    )

    # build models from dihedral angles only
    structure_omega, structure_phi_psi = build_phi_psi_model(pdb_file)

    # compare models to original structure
    RMS_backbone_50, RMS_backbone_150, RMS_backbone, size = compare_structure(
        pdb_file, make_pdb_file(structure_backbone, "Backbone_" + pdb_file)
    )
    RMS_phi_psi_50, RMS_phi_psi_150, RMS_phi_psi, size = compare_structure(
        pdb_file, make_pdb_file(structure_phi_psi, "PhiPsi_" + pdb_file)
    )
    RMS_omega_50, RMS_omega_150, RMS_omega, size = compare_structure(
        pdb_file, make_pdb_file(structure_omega, "PhiPsiOmega_" + pdb_file)
    )
    RMS_all_angles_50, RMS_all_angles_150, RMS_all_angles, size = compare_structure(
        pdb_file, make_pdb_file(structure_all_angles, "AllAngles_" + pdb_file)
    )
    output_line = (
        "%s\t%i\t%0.1f\t%0.1f\t%0.1f\t%0.1f\t%0.1f\t%0.1f\t%0.1f\t%0.1f\t%0.1f\t%0.1f\t%0.1f\t%0.1f\n"
        % (
            pdb_code,
            size,
            RMS_phi_psi_50,
            RMS_phi_psi_150,
            RMS_phi_psi,
            RMS_omega_50,
            RMS_omega_150,
            RMS_omega,
            RMS_all_angles_50,
            RMS_all_angles_150,
            RMS_all_angles,
            RMS_backbone_50,
            RMS_backbone_150,
            RMS_backbone,
        )
    )
    return output_line
def test_make_structure_from_geos():
    """Build a helix containing all 20 amino acids from list of geometries.
    The structure should be identical to `extended.pdb`
    """
    geos = [Geometry.geometry(aa) for aa in "ACDEFGHIKLMNPQRSTVWY"]
    structure = PeptideBuilder.make_structure_from_geos(geos)
    assert compare_to_reference(structure, "extended.pdb")
Ejemplo n.º 4
0
    
out.set_structure(structure)
out.save("test2.pdb")

# Print out all geometries
outfile = open("test3.txt", 'w')
for aa in "ACDEFGHIKLMNPQRSTVWY":
    print(outfile, Geometry.geometry(aa))

# Build a helix containing all 20 amino acids from list of geometries.
# The structure should be identical to test1.pdb

geos = []
for aa in "ACDEFGHIKLMNPQRSTVWY":
    geos.append(Geometry.geometry(aa))
structure = PeptideBuilder.make_structure_from_geos(geos)
out.set_structure(structure)
out.save("test4.pdb")

# Build a peptide containing all 20 amino acids in extended conformation.
# The structure should be identical to test1.pdb

structure = PeptideBuilder.make_extended_structure("ACDEFGHIKLMNPQRSTVWY")
out.set_structure(structure)
out.save("test4.pdb")

# Build a peptide containing all 20 amino acids from list of geometries.
# The structure should be identical to test1.pdb

geos = []
for aa in "ACDEFGHIKLMNPQRSTVWY":
Ejemplo n.º 5
0
def build_exact_model(structure, chain_index):
    model=structure[0]
    chain=model[chain_index]
    model_structure_geo=[]
    prev="0"
    N_prev="0"
    CA_prev="0"
    C_prev="0"
    O_prev="0"
    prev_res=""
    rad=180.0/math.pi
    for res in chain:
        name=res.get_resname()
        if(name !="HOH"):
            geo=Geometry.geometry(resdict[name])
            if(prev=="0"):
                N_prev= res['N']
                CA_prev= res['CA']
                C_prev= res['C']
                O_prev= res['O']
                prev="1"
            else:   
                n1=N_prev.get_vector()
                ca1=CA_prev.get_vector()
                c1=C_prev.get_vector()
                o1=O_prev.get_vector()
                
                O_curr=res['O']
                C_curr=res['C']
                N_curr=res['N']
                CA_curr=res['CA']
                                
                o=O_curr.get_vector()
                c=C_curr.get_vector()
                n=N_curr.get_vector()
                ca=CA_curr.get_vector()

                geo.CA_C_N_angle=calc_angle(ca1, c1, n)*rad
                geo.C_N_CA_angle=calc_angle(c1, n, ca)*rad

                geo.peptide= N_curr-C_prev

                psi= calc_dihedral(n1, ca1, c1, n) ##goes to current res
                omega= calc_dihedral(ca1, c1, n, ca) ##goes to current res
                phi= calc_dihedral(c1, n, ca, c) ##goes to current res

                geo.psi_im1=psi*rad
                geo.omega=omega*rad
                geo.phi=phi*rad

                geo.CA_N_length= CA_curr - N_curr
                geo.CA_C_length= CA_curr - C_curr 
                geo.C_O_length= C_curr - O_curr

                geo.N_CA_C_angle= calc_angle(n, ca, c)*rad
                geo.CA_C_O_angle= calc_angle(ca, c, o)*rad

                geo.N_CA_C_O= calc_dihedral(n, ca, c, o)*rad

                N_prev= res['N']
                CA_prev= res['CA']
                C_prev= res['C']
                O_prev= res['O']
                
                if(name=='ALA'):
                    geo.CA_CB_length=CA_curr-res['CB']
                    
                    geo.C_CA_CB_angle= calc_angle(c, ca, res['CB'].get_vector())*rad
                    
                    geo.N_C_CA_CB_diangle= calc_dihedral(n, c, ca, res['CB'].get_vector())*rad

                elif(name=='GLU'):
                    geo.CA_CB_length=CA_curr-res['CB']
                    geo.C_CA_CB_angle=calc_angle(c, ca, res['CB'].get_vector())*rad
                    geo.N_C_CA_CB_diangle=calc_dihedral(n, c, ca, res['CB'].get_vector() )*rad

                    geo.CB_CG_length=res['CB']-res['CG']
                    geo.CA_CB_CG_angle=calc_angle(ca, res['CB'].get_vector(), res['CG'].get_vector())*rad
                    geo.N_CA_CB_CG_diangle=calc_dihedral(n, ca, res['CB'].get_vector(), res['CG'].get_vector())*rad

                    geo.CG_CD_length=res['CG']-res['CD']
                    geo.CB_CG_CD_angle=calc_angle(res['CB'].get_vector(), res['CG'].get_vector(), res['CD'].get_vector() )*rad
                    geo.CA_CB_CG_CD_diangle=calc_dihedral(ca, res['CB'].get_vector(), res['CG'].get_vector(), res['CD'].get_vector())*rad

                    geo.CD_OE1_length=res['CD']-res['OE1']
                    geo.CG_CD_OE1_angle=calc_angle(res['CG'].get_vector(), res['CD'].get_vector(), res['OE1'].get_vector() )*rad
                    geo.CB_CG_CD_OE1_diangle= calc_dihedral(res['CB'].get_vector(), res['CG'].get_vector(),res['CD'].get_vector(), res['OE1'].get_vector())*rad

                    geo.CD_OE2_length=res['CD']-res['OE2']
                    geo.CG_CD_OE2_angle=calc_angle(res['CG'].get_vector(), res['CD'].get_vector(), res['OE2'].get_vector() )*rad
                    geo.CB_CG_CD_OE2_diangle= calc_dihedral(res['CB'].get_vector(), res['CG'].get_vector(),res['CD'].get_vector(), res['OE2'].get_vector())*rad
                    
                elif(name=='HIS'):
                    geo.CA_CB_length=CA_curr-res['CB']
                    geo.CB_CG_length=(res['CB']-res['CG'])
                    geo.CG_ND1_length=(res['CG']-res['ND1'])
                    geo.CG_CD2_length=(res['CG']-res['CD2'])
                    geo.ND1_CE1_length=(res['ND1']-res['CE1'])
                    geo.CD2_NE2_length=(res['CD2']-res['NE2'])

                    geo.C_CA_CB_angle=(calc_angle(c, ca, res['CB'].get_vector()))*rad
                    geo.CA_CB_CG_angle=(calc_angle(ca, res['CB'].get_vector(), res['CG'].get_vector() ) )*rad
                    geo.CB_CG_ND1_angle= (calc_angle(res['CB'].get_vector(), res['CG'].get_vector(), res['ND1'].get_vector() ) )*rad
                    geo.CB_CG_CD2_angle=(calc_angle(res['CB'].get_vector(), res['CG'].get_vector(), res['CD2'].get_vector() ) )*rad
                    geo.CG_ND1_CE1_angle=(calc_angle(res['CG'].get_vector(), res['ND1'].get_vector(), res['CE1'].get_vector() ) )*rad
                    geo.CG_CD2_NE2_angle=(calc_angle(res['CG'].get_vector(), res['CD2'].get_vector(), res['NE2'].get_vector() ) )*rad
                    
                    geo.N_C_CA_CB_diangle=(calc_dihedral(n, c, ca, res['CB'].get_vector()))*rad
                    geo.N_CA_CB_CG_diangle=(calc_dihedral(n, ca, res['CB'].get_vector(), res['CG'].get_vector()))*rad
                    geo.CA_CB_CG_ND1_diangle=(calc_dihedral(ca, res['CB'].get_vector(), res['CG'].get_vector(), res['ND1'].get_vector()))*rad
                    geo.CA_CB_CG_CD2_diangle=(calc_dihedral(ca, res['CB'].get_vector(), res['CG'].get_vector(), res['CD2'].get_vector()))*rad
                    geo.CB_CG_ND1_CE1_diangle=(calc_dihedral(res['CB'].get_vector(), res['CG'].get_vector(), res['ND1'].get_vector(), res['CE1'].get_vector()))*rad
                    geo.CB_CG_CD2_NE2_diangle=(calc_dihedral(res['CB'].get_vector(), res['CG'].get_vector(), res['CD2'].get_vector(), res['NE2'].get_vector()))*rad
            
            model_structure_geo.append(geo)
    model_structure=PeptideBuilder.make_structure_from_geos(model_structure_geo)
    return model_structure
Ejemplo n.º 6
0
def build_exact_model(structure, chain_index):
    model = structure[0]
    chain = model[chain_index]
    model_structure_geo = []
    prev = "0"
    N_prev = "0"
    CA_prev = "0"
    C_prev = "0"
    O_prev = "0"
    prev_res = ""
    rad = 180.0 / math.pi
    for res in chain:
        name = res.get_resname()
        if (name != "HOH"):
            geo = Geometry.geometry(resdict[name])
            if (prev == "0"):
                N_prev = res['N']
                CA_prev = res['CA']
                C_prev = res['C']
                O_prev = res['O']
                prev = "1"
            else:
                n1 = N_prev.get_vector()
                ca1 = CA_prev.get_vector()
                c1 = C_prev.get_vector()
                o1 = O_prev.get_vector()

                O_curr = res['O']
                C_curr = res['C']
                N_curr = res['N']
                CA_curr = res['CA']

                o = O_curr.get_vector()
                c = C_curr.get_vector()
                n = N_curr.get_vector()
                ca = CA_curr.get_vector()

                geo.CA_C_N_angle = calc_angle(ca1, c1, n) * rad
                geo.C_N_CA_angle = calc_angle(c1, n, ca) * rad

                geo.peptide = N_curr - C_prev

                psi = calc_dihedral(n1, ca1, c1, n)  ##goes to current res
                omega = calc_dihedral(ca1, c1, n, ca)  ##goes to current res
                phi = calc_dihedral(c1, n, ca, c)  ##goes to current res

                geo.psi_im1 = psi * rad
                geo.omega = omega * rad
                geo.phi = phi * rad

                geo.CA_N_length = CA_curr - N_curr
                geo.CA_C_length = CA_curr - C_curr
                geo.C_O_length = C_curr - O_curr

                geo.N_CA_C_angle = calc_angle(n, ca, c) * rad
                geo.CA_C_O_angle = calc_angle(ca, c, o) * rad

                geo.N_CA_C_O = calc_dihedral(n, ca, c, o) * rad

                N_prev = res['N']
                CA_prev = res['CA']
                C_prev = res['C']
                O_prev = res['O']

                if (name == 'ALA'):
                    geo.CA_CB_length = CA_curr - res['CB']

                    geo.C_CA_CB_angle = calc_angle(
                        c, ca, res['CB'].get_vector()) * rad

                    geo.N_C_CA_CB_diangle = calc_dihedral(
                        n, c, ca, res['CB'].get_vector()) * rad

                elif (name == 'GLU'):
                    geo.CA_CB_length = CA_curr - res['CB']
                    geo.C_CA_CB_angle = calc_angle(
                        c, ca, res['CB'].get_vector()) * rad
                    geo.N_C_CA_CB_diangle = calc_dihedral(
                        n, c, ca, res['CB'].get_vector()) * rad

                    geo.CB_CG_length = res['CB'] - res['CG']
                    geo.CA_CB_CG_angle = calc_angle(
                        ca, res['CB'].get_vector(),
                        res['CG'].get_vector()) * rad
                    geo.N_CA_CB_CG_diangle = calc_dihedral(
                        n, ca, res['CB'].get_vector(),
                        res['CG'].get_vector()) * rad

                    geo.CG_CD_length = res['CG'] - res['CD']
                    geo.CB_CG_CD_angle = calc_angle(
                        res['CB'].get_vector(), res['CG'].get_vector(),
                        res['CD'].get_vector()) * rad
                    geo.CA_CB_CG_CD_diangle = calc_dihedral(
                        ca, res['CB'].get_vector(), res['CG'].get_vector(),
                        res['CD'].get_vector()) * rad

                    geo.CD_OE1_length = res['CD'] - res['OE1']
                    geo.CG_CD_OE1_angle = calc_angle(
                        res['CG'].get_vector(), res['CD'].get_vector(),
                        res['OE1'].get_vector()) * rad
                    geo.CB_CG_CD_OE1_diangle = calc_dihedral(
                        res['CB'].get_vector(), res['CG'].get_vector(),
                        res['CD'].get_vector(), res['OE1'].get_vector()) * rad

                    geo.CD_OE2_length = res['CD'] - res['OE2']
                    geo.CG_CD_OE2_angle = calc_angle(
                        res['CG'].get_vector(), res['CD'].get_vector(),
                        res['OE2'].get_vector()) * rad
                    geo.CB_CG_CD_OE2_diangle = calc_dihedral(
                        res['CB'].get_vector(), res['CG'].get_vector(),
                        res['CD'].get_vector(), res['OE2'].get_vector()) * rad

                elif (name == 'HIS'):
                    geo.CA_CB_length = CA_curr - res['CB']
                    geo.CB_CG_length = (res['CB'] - res['CG'])
                    geo.CG_ND1_length = (res['CG'] - res['ND1'])
                    geo.CG_CD2_length = (res['CG'] - res['CD2'])
                    geo.ND1_CE1_length = (res['ND1'] - res['CE1'])
                    geo.CD2_NE2_length = (res['CD2'] - res['NE2'])

                    geo.C_CA_CB_angle = (calc_angle(
                        c, ca, res['CB'].get_vector())) * rad
                    geo.CA_CB_CG_angle = (calc_angle(
                        ca, res['CB'].get_vector(),
                        res['CG'].get_vector())) * rad
                    geo.CB_CG_ND1_angle = (calc_angle(
                        res['CB'].get_vector(), res['CG'].get_vector(),
                        res['ND1'].get_vector())) * rad
                    geo.CB_CG_CD2_angle = (calc_angle(
                        res['CB'].get_vector(), res['CG'].get_vector(),
                        res['CD2'].get_vector())) * rad
                    geo.CG_ND1_CE1_angle = (calc_angle(
                        res['CG'].get_vector(), res['ND1'].get_vector(),
                        res['CE1'].get_vector())) * rad
                    geo.CG_CD2_NE2_angle = (calc_angle(
                        res['CG'].get_vector(), res['CD2'].get_vector(),
                        res['NE2'].get_vector())) * rad

                    geo.N_C_CA_CB_diangle = (calc_dihedral(
                        n, c, ca, res['CB'].get_vector())) * rad
                    geo.N_CA_CB_CG_diangle = (calc_dihedral(
                        n, ca, res['CB'].get_vector(),
                        res['CG'].get_vector())) * rad
                    geo.CA_CB_CG_ND1_diangle = (calc_dihedral(
                        ca, res['CB'].get_vector(), res['CG'].get_vector(),
                        res['ND1'].get_vector())) * rad
                    geo.CA_CB_CG_CD2_diangle = (calc_dihedral(
                        ca, res['CB'].get_vector(), res['CG'].get_vector(),
                        res['CD2'].get_vector())) * rad
                    geo.CB_CG_ND1_CE1_diangle = (calc_dihedral(
                        res['CB'].get_vector(), res['CG'].get_vector(),
                        res['ND1'].get_vector(),
                        res['CE1'].get_vector())) * rad
                    geo.CB_CG_CD2_NE2_diangle = (calc_dihedral(
                        res['CB'].get_vector(), res['CG'].get_vector(),
                        res['CD2'].get_vector(),
                        res['NE2'].get_vector())) * rad

            model_structure_geo.append(geo)
    model_structure = PeptideBuilder.make_structure_from_geos(
        model_structure_geo)
    return model_structure
def test_make_structure_from_geos2():
    geos = []
    for aa in "ACDEFGHIKLMNPQRSTVWY":
        geos.append(Geometry.geometry(aa))
    structure = PeptideBuilder.make_structure_from_geos(geos)
    assert compare_to_reference(structure, "extended.pdb")