Exemplo n.º 1
0
def main():
    root = '/Users/iwelsh/GitHub/ShortScripts/proteinStructures'
    coords = gromos_cnf_parse(load_file(root + '/1d66_ss-dna_54a8.gch'))[1]
    #pdb = pdb_parse(load_file(root + '/3blg.pdb'))
    topo = gromos_topology_parse(load_file(root + '/1d66_ss-dna_54a8.top'))
    mol = Molecule('3BLG', cnf=coords, topo=topo)
    print(len(mol.atoms))
    #for atm in mol.atoms:
    #    print(atm.data['residue_name'])

    #unite_atoms(mol)
    conect_graph = mol.labeled_graph
    for atm in mol.atoms:
        atm.hcount = united_h_count(atm)
    with open(root + '/1d66_gch.pdb', 'w') as fh:
        fh.write(print_pdb(mol))
    with open(root + '/1d66_aa.pdb', 'w') as fh:
        fh.write(print_pdb(convert_to_aa(mol)))
Exemplo n.º 2
0
def main():
    root = '/Users/iwelsh/GitHub/ShortScripts/proteinStructures'
    coords = gromos_cnf_parse(load_file(root + '/1d66_ss-dna_54a8.gch'))[1]
    #pdb = pdb_parse(load_file(root + '/3blg.pdb'))
    topo = gromos_topology_parse(load_file(root + '/1d66_ss-dna_54a8.top'))
    mol = Molecule('3BLG', cnf=coords, topo=topo)
    print(len(mol.atoms))
    #for atm in mol.atoms:
    #    print(atm.data['residue_name'])
    
    #unite_atoms(mol)
    conect_graph = mol.labeled_graph
    for atm in mol.atoms:
        atm.hcount = united_h_count(atm)
    with open(root + '/1d66_gch.pdb','w') as fh:
        fh.write(print_pdb(mol))
    with open(root +'/1d66_aa.pdb','w') as fh:
        fh.write(print_pdb(convert_to_aa(mol)))
def run_md_jobs(root, mols, descrips):
    molecules = {
                 'AMINO-1': {'rigid':{'aa':[16,13,7,9],
                                     'ua':[8,7,5,6],
                                     'gamess':[2,1,8,9],
                                     },
                            'name':'G564',
                            },
                 'AMINO0': {'rigid':{'aa':[2,5,8,13],
                                     'ua':[1,2,3,8],
                                     'gamess':[2,1,8,9],
                                     },
                            'name':'N0GW',
                            },
                 'AMINO1': {'rigid':{'aa':[2,5,8,16],
                                     'ua':[1,2,3,8],
                                     'gamess':[2,1,8,9],
                                     },
                            'name':'SHJ0',
                            },
                 'AMINO2': {'rigid':{'aa':[7,10,12,15],
                                     'ua':[5,6,7,8],
                                     'gamess':[2,1,8,9],
                                     },
                            'name':'6AT1',
                            },
                 'CHLORO-1': {'rigid':{'aa':[2,5,8,14],
                                     'ua':[1,2,3,6],
                                     'gamess':[2,1,8,9],
                                     },
                            'name':'PCRN',
                            },
                 'CHLORO0': {'rigid':{'aa':[2,5,8,11],
                                     'ua':[1,2,3,5],
                                     'gamess':[2,1,8,9],
                                     },
                            'name':'682F',
                            },
                 'CHLORO1': {'rigid':{'aa':[2,5,8,14],
                                     'ua':[1,2,3,6],
                                     'gamess':[2,1,8,9],
                                     },
                            'name':'ZB0H',
                            },
                 'CHLORO2': {'rigid':{'aa':[10,8,17,20],
                                     'ua':[5,4,7,8],
                                     'gamess':[2,1,8,9],
                                     },
                            'name':'35MG',
                            },
                 'HYDRO-1': {'rigid':{'aa':[15,12,6,8],
                                     'ua':[7,6,4,5],
                                     'gamess':[2,1,8,9],
                                     },
                            'name':'H5JT',
                            },
                 'HYDRO0': {'rigid':{'aa':[2,5,8,12],
                                     'ua':[1,2,3,7],
                                     'gamess':[2,1,8,9],
                                     },
                            'name':'G096',
                            },
                 'HYDRO1': {'rigid':{'aa':[2,5,8,15],
                                     'ua':[1,2,3,7],
                                     'gamess':[2,1,8,9],
                                     },
                            'name':'W6KL',
                            },
                 'HYDRO2': {'rigid':{'aa':[2,5,8,10],
                                     'ua':[1,2,3,4],
                                     'gamess':[2,1,8,9],
                                     },
                            'name':'5KRK',
                            },
                 'METH-1': {'rigid':{'aa':[2,5,8,14],
                                     'ua':[1,2,3,5],
                                     'gamess':[2,1,8,9],
                                     },
                            'name':'G011',
                            },
                 'METH0': {'rigid':{'aa':[2,5,8,14],
                                     'ua':[1,2,3,5],
                                     'gamess':[2,1,8,9],
                                     },
                            'name':'G011',
                            },
                 'METH1': {'rigid':{'aa':[2,5,8,10],
                                     'ua':[1,2,3,4],
                                     'gamess':[2,1,8,9],
                                     },
                            'name':'4MUW',
                            },
                 'METH2': {'rigid':{'aa':[2,5,8,10],
                                     'ua':[1,2,3,4],
                                     'gamess':[2,1,8,9],
                                     },
                            'name':'YE4E',
                            },
                 'THIO-1': {'rigid':{'aa':[2,5,8,15],
                                     'ua':[1,2,3,7],
                                     'gamess':[2,1,8,9],
                                     },
                            'name':'ZK6W',
                            },
                 'THIO0': {'rigid':{'aa':[2,5,8,12],
                                     'ua':[1,2,3,7],
                                     'gamess':[2,1,8,9],
                                     },
                            'name':'1QIU',
                            },
                 'THIO1': {'rigid':{'aa':[2,5,8,15],
                                     'ua':[1,2,3,7],
                                     'gamess':[2,1,8,9],
                                     },
                            'name':'5G2Q',
                            },
                 'THIO2': {'rigid':{'aa':[6,9,18,21],
                                     'ua':[4,5,8,9],
                                     'gamess':[2,1,8,9],
                                     },
                            'name':'PJLY',
                            },
                 }
    descriptors = {'Original': ['rigid']}
    #'AMINO-1'  : {'gamess':[2,1,8,9], 'aa' : [16,13,7,9], 'ua' : [8,7,5,6], }
    #for m in sorted(molecules):
    #    print("'{}' : {},".format(m, molecules[m]['rigid']))
    #return
    with open(root + '/Parameters/Templates/dihedral.template','r') as fh:
        imd_temp_1 = fh.read()
    with open(root + '/Parameters/Templates/dihedral2.template','r') as fh:
        imd_temp_2 = fh.read()
    with open(root + '/Parameters/Templates/dihedral3.template','r') as fh:
        imd_temp_3 = fh.read()
    with open(root + '/Parameters/Templates/dihedral_constraint.template','r') as fh:
        constraint_temp = fh.read()
    
    for m in mols:
        
        forms = dict(mol=m, root=root)
        aa_mtb = inlib.gromos_mtb_parse(genlib.load_file('{root}/Parameters/{mol}/{mol}.aa.mtb'.format(**forms)))
        ua_mtb = inlib.gromos_mtb_parse(genlib.load_file('{root}/Parameters/{mol}/{mol}.ua.mtb'.format(**forms)))
        
        aa_work_mol = storage.Molecule(molecules[m]['name'], mtb=aa_mtb)
        ua_work_mol = storage.Molecule(molecules[m]['name'], mtb=ua_mtb)
        
        for d in descrips:
            forms['des'] = d
            forms['outdir'] = '{root}/{des}/{mol}/MD_data'.format(**forms)
            forms['name'] = molecules[m]['name']
            if not os.path.exists('{outdir}'.format(**forms)):
                os.makedirs('{outdir}'.format(**forms))
            with open('{outdir}/{mol}.aa.1.imd'.format(**forms),'w') as fh:
                fh.write(imd_temp_1.format(**{'numberOfAtoms':aa_work_mol.atom_count}))
            with open('{outdir}/{mol}.ua.1.imd'.format(**forms),'w') as fh:
                fh.write(imd_temp_1.format(**{'numberOfAtoms':ua_work_mol.atom_count}))
            with open('{outdir}/{mol}.aa.2.imd'.format(**forms),'w') as fh:
                fh.write(imd_temp_2.format(**{'numberOfAtoms':aa_work_mol.atom_count}))
            with open('{outdir}/{mol}.ua.2.imd'.format(**forms),'w') as fh:
                fh.write(imd_temp_2.format(**{'numberOfAtoms':ua_work_mol.atom_count}))
            with open('{outdir}/{mol}.aa.3.imd'.format(**forms),'w') as fh:
                fh.write(imd_temp_3.format(**{'numberOfAtoms':aa_work_mol.atom_count}))
            with open('{outdir}/{mol}.ua.3.imd'.format(**forms),'w') as fh:
                fh.write(imd_temp_3.format(**{'numberOfAtoms':ua_work_mol.atom_count}))
                
                
            os.chdir('{root}'.format(**forms))
            
            os.system(('/usr/local/gromos++/bin/make_top @build Parameters/{mol}/{mol}.aa.mtb Parameters/54A7.mtb '
                       '@param Parameters/54A7.ifp @seq {name} @solv H2O > {outdir}/{mol}.aa.top'.format(**forms)))
            os.system(('/usr/local/gromos++/bin/make_top @build Parameters/{mol}/{mol}.ua.mtb Parameters/54A7.mtb '
                       '@param Parameters/54A7.ifp @seq {name} @solv H2O > {outdir}/{mol}.ua.top'.format(**forms)))
            
            for a in range(0,360,5):
                skip_angle = False
                forms['ang2'] = a
                if a == 180:
                    a = 179
                forms['ang'] = a
                try:
                    with open('{root}/{des}/{mol}/{mol}.{ang:03}.log'.format(**forms), 'r') as fh:
                        gamess = extract_conformation(fh.readlines(), scale=1, key='name', optimised=False)
                except FileNotFoundError:
                    with open('{root}/{des}/{mol}/{mol}.{ang2:03}.log'.format(**forms), 'r') as fh:
                        gamess = extract_conformation(fh.readlines(), scale=1, key='name', optimised=False)     
                for atm in aa_work_mol.atoms:
                    try:
                        atm.xyz = gamess[atm.atm_name.upper()]['vec']
                    except TypeError:
                        print('TypeError', atm.atm_name, d, m, a)
                        skip_angle = True
                        break
                    except KeyError:
                        print('KeyError', atm.atm_name, d, m, a)
                        raise
                if skip_angle:
                    continue
                for atm in ua_work_mol.atoms:
                    atm.xyz = gamess[atm.atm_name.upper()]['vec']
                with open('{outdir}/{mol}.{ang:03}.aa.cnf'.format(**forms), 'w') as fh:
                    fh.write(outlib.print_gromos_cnf(aa_work_mol))
                with open('{outdir}/{mol}.{ang:03}.ua.cnf'.format(**forms), 'w') as fh:
                    fh.write(outlib.print_gromos_cnf(ua_work_mol))
                #with open('{outdir}/{mol}.{ang:03}.aa.pdb'.format(**forms), 'w') as fh:
                #    fh.write(outlib.print_pdb(aa_work_mol))
                #with open('{outdir}/{mol}.{ang:03}.ua.pdb'.format(**forms), 'w') as fh:
                #    fh.write(outlib.print_pdb(ua_work_mol))
                angs_aa, angs_ua = [], []
                for des in descriptors[d]:
                    atm_a = aa_work_mol.atom(molecules[m][des]['aa'][0]).xyz
                    atm_b = aa_work_mol.atom(molecules[m][des]['aa'][1]).xyz
                    atm_c = aa_work_mol.atom(molecules[m][des]['aa'][2]).xyz
                    atm_d = aa_work_mol.atom(molecules[m][des]['aa'][3]).xyz
                    ang = dihedral_angle(atm_a,atm_b,atm_c,atm_d,scale='deg')
                    angs_aa.append('   {1}  {2}  {3}  {4}  1.0  {0:.3f}  0.0   0.0001'.format(ang, *molecules[m][des]['aa']))
                    angs_ua.append('   {1}  {2}  {3}  {4}  1.0  {0:.3f}  0.0   0.0001'.format(ang, *molecules[m][des]['ua']))
                with open('{outdir}/{mol}.{ang:03}.aa.constraints.dat'.format(**forms), 'w') as fh:
                    fh.write(constraint_temp.format(**{'constraints':'\n'.join(angs_aa)}))
                with open('{outdir}/{mol}.{ang:03}.ua.constraints.dat'.format(**forms), 'w') as fh:
                    fh.write(constraint_temp.format(**{'constraints':'\n'.join(angs_ua)}))
                # first pass
                os.system(('/opt/local/gromosXX-1773/bin/md @topo {outdir}/{mol}.aa.top @conf {outdir}/{mol}.{ang:03}.aa.cnf '
                           '@input {outdir}/{mol}.aa.1.imd @fin {outdir}/{mol}.{ang:03}.aa.min.1.cnf @develop '
                           '@dihrest {outdir}/{mol}.{ang:03}.aa.constraints.dat > {outdir}/{mol}.{ang:03}.aa.1.log'.format(**forms) ))
                
                os.system(('/opt/local/gromosXX-1773/bin/md @topo {outdir}/{mol}.ua.top @conf {outdir}/{mol}.{ang:03}.ua.cnf '
                           '@input {outdir}/{mol}.ua.1.imd @fin {outdir}/{mol}.{ang:03}.ua.min.1.cnf @develop '
                           '@dihrest {outdir}/{mol}.{ang:03}.ua.constraints.dat > {outdir}/{mol}.{ang:03}.ua.1.log'.format(**forms) ))
Exemplo n.º 4
0
def run_md_jobs(root, mols, descrips):
    molecules = {
        'AMINO-1': {
            'rigid': {
                'aa': [16, 13, 7, 9],
                'ua': [8, 7, 5, 6],
                'gamess': [2, 1, 8, 9],
            },
            'name': 'G564',
        },
        'AMINO0': {
            'rigid': {
                'aa': [2, 5, 8, 13],
                'ua': [1, 2, 3, 8],
                'gamess': [2, 1, 8, 9],
            },
            'name': 'N0GW',
        },
        'AMINO1': {
            'rigid': {
                'aa': [2, 5, 8, 16],
                'ua': [1, 2, 3, 8],
                'gamess': [2, 1, 8, 9],
            },
            'name': 'SHJ0',
        },
        'AMINO2': {
            'rigid': {
                'aa': [7, 10, 12, 15],
                'ua': [5, 6, 7, 8],
                'gamess': [2, 1, 8, 9],
            },
            'name': '6AT1',
        },
        'CHLORO-1': {
            'rigid': {
                'aa': [2, 5, 8, 14],
                'ua': [1, 2, 3, 6],
                'gamess': [2, 1, 8, 9],
            },
            'name': 'PCRN',
        },
        'CHLORO0': {
            'rigid': {
                'aa': [2, 5, 8, 11],
                'ua': [1, 2, 3, 5],
                'gamess': [2, 1, 8, 9],
            },
            'name': '682F',
        },
        'CHLORO1': {
            'rigid': {
                'aa': [2, 5, 8, 14],
                'ua': [1, 2, 3, 6],
                'gamess': [2, 1, 8, 9],
            },
            'name': 'ZB0H',
        },
        'CHLORO2': {
            'rigid': {
                'aa': [10, 8, 17, 20],
                'ua': [5, 4, 7, 8],
                'gamess': [2, 1, 8, 9],
            },
            'name': '35MG',
        },
        'HYDRO-1': {
            'rigid': {
                'aa': [15, 12, 6, 8],
                'ua': [7, 6, 4, 5],
                'gamess': [2, 1, 8, 9],
            },
            'name': 'H5JT',
        },
        'HYDRO0': {
            'rigid': {
                'aa': [2, 5, 8, 12],
                'ua': [1, 2, 3, 7],
                'gamess': [2, 1, 8, 9],
            },
            'name': 'G096',
        },
        'HYDRO1': {
            'rigid': {
                'aa': [2, 5, 8, 15],
                'ua': [1, 2, 3, 7],
                'gamess': [2, 1, 8, 9],
            },
            'name': 'W6KL',
        },
        'HYDRO2': {
            'rigid': {
                'aa': [2, 5, 8, 10],
                'ua': [1, 2, 3, 4],
                'gamess': [2, 1, 8, 9],
            },
            'name': '5KRK',
        },
        'METH-1': {
            'rigid': {
                'aa': [2, 5, 8, 14],
                'ua': [1, 2, 3, 5],
                'gamess': [2, 1, 8, 9],
            },
            'name': 'G011',
        },
        'METH0': {
            'rigid': {
                'aa': [2, 5, 8, 14],
                'ua': [1, 2, 3, 5],
                'gamess': [2, 1, 8, 9],
            },
            'name': 'G011',
        },
        'METH1': {
            'rigid': {
                'aa': [2, 5, 8, 10],
                'ua': [1, 2, 3, 4],
                'gamess': [2, 1, 8, 9],
            },
            'name': '4MUW',
        },
        'METH2': {
            'rigid': {
                'aa': [2, 5, 8, 10],
                'ua': [1, 2, 3, 4],
                'gamess': [2, 1, 8, 9],
            },
            'name': 'YE4E',
        },
        'THIO-1': {
            'rigid': {
                'aa': [2, 5, 8, 15],
                'ua': [1, 2, 3, 7],
                'gamess': [2, 1, 8, 9],
            },
            'name': 'ZK6W',
        },
        'THIO0': {
            'rigid': {
                'aa': [2, 5, 8, 12],
                'ua': [1, 2, 3, 7],
                'gamess': [2, 1, 8, 9],
            },
            'name': '1QIU',
        },
        'THIO1': {
            'rigid': {
                'aa': [2, 5, 8, 15],
                'ua': [1, 2, 3, 7],
                'gamess': [2, 1, 8, 9],
            },
            'name': '5G2Q',
        },
        'THIO2': {
            'rigid': {
                'aa': [6, 9, 18, 21],
                'ua': [4, 5, 8, 9],
                'gamess': [2, 1, 8, 9],
            },
            'name': 'PJLY',
        },
    }
    descriptors = {'Original': ['rigid']}
    #'AMINO-1'  : {'gamess':[2,1,8,9], 'aa' : [16,13,7,9], 'ua' : [8,7,5,6], }
    #for m in sorted(molecules):
    #    print("'{}' : {},".format(m, molecules[m]['rigid']))
    #return
    with open(root + '/Parameters/Templates/dihedral.template', 'r') as fh:
        imd_temp_1 = fh.read()
    with open(root + '/Parameters/Templates/dihedral2.template', 'r') as fh:
        imd_temp_2 = fh.read()
    with open(root + '/Parameters/Templates/dihedral3.template', 'r') as fh:
        imd_temp_3 = fh.read()
    with open(root + '/Parameters/Templates/dihedral_constraint.template',
              'r') as fh:
        constraint_temp = fh.read()

    for m in mols:

        forms = dict(mol=m, root=root)
        aa_mtb = inlib.gromos_mtb_parse(
            genlib.load_file(
                '{root}/Parameters/{mol}/{mol}.aa.mtb'.format(**forms)))
        ua_mtb = inlib.gromos_mtb_parse(
            genlib.load_file(
                '{root}/Parameters/{mol}/{mol}.ua.mtb'.format(**forms)))

        aa_work_mol = storage.Molecule(molecules[m]['name'], mtb=aa_mtb)
        ua_work_mol = storage.Molecule(molecules[m]['name'], mtb=ua_mtb)

        for d in descrips:
            forms['des'] = d
            forms['outdir'] = '{root}/{des}/{mol}/MD_data'.format(**forms)
            forms['name'] = molecules[m]['name']
            if not os.path.exists('{outdir}'.format(**forms)):
                os.makedirs('{outdir}'.format(**forms))
            with open('{outdir}/{mol}.aa.1.imd'.format(**forms), 'w') as fh:
                fh.write(
                    imd_temp_1.format(
                        **{'numberOfAtoms': aa_work_mol.atom_count}))
            with open('{outdir}/{mol}.ua.1.imd'.format(**forms), 'w') as fh:
                fh.write(
                    imd_temp_1.format(
                        **{'numberOfAtoms': ua_work_mol.atom_count}))
            with open('{outdir}/{mol}.aa.2.imd'.format(**forms), 'w') as fh:
                fh.write(
                    imd_temp_2.format(
                        **{'numberOfAtoms': aa_work_mol.atom_count}))
            with open('{outdir}/{mol}.ua.2.imd'.format(**forms), 'w') as fh:
                fh.write(
                    imd_temp_2.format(
                        **{'numberOfAtoms': ua_work_mol.atom_count}))
            with open('{outdir}/{mol}.aa.3.imd'.format(**forms), 'w') as fh:
                fh.write(
                    imd_temp_3.format(
                        **{'numberOfAtoms': aa_work_mol.atom_count}))
            with open('{outdir}/{mol}.ua.3.imd'.format(**forms), 'w') as fh:
                fh.write(
                    imd_temp_3.format(
                        **{'numberOfAtoms': ua_work_mol.atom_count}))

            os.chdir('{root}'.format(**forms))

            os.system((
                '/usr/local/gromos++/bin/make_top @build Parameters/{mol}/{mol}.aa.mtb Parameters/54A7.mtb '
                '@param Parameters/54A7.ifp @seq {name} @solv H2O > {outdir}/{mol}.aa.top'
                .format(**forms)))
            os.system((
                '/usr/local/gromos++/bin/make_top @build Parameters/{mol}/{mol}.ua.mtb Parameters/54A7.mtb '
                '@param Parameters/54A7.ifp @seq {name} @solv H2O > {outdir}/{mol}.ua.top'
                .format(**forms)))

            for a in range(0, 360, 5):
                skip_angle = False
                forms['ang2'] = a
                if a == 180:
                    a = 179
                forms['ang'] = a
                try:
                    with open(
                            '{root}/{des}/{mol}/{mol}.{ang:03}.log'.format(
                                **forms), 'r') as fh:
                        gamess = extract_conformation(fh.readlines(),
                                                      scale=1,
                                                      key='name',
                                                      optimised=False)
                except FileNotFoundError:
                    with open(
                            '{root}/{des}/{mol}/{mol}.{ang2:03}.log'.format(
                                **forms), 'r') as fh:
                        gamess = extract_conformation(fh.readlines(),
                                                      scale=1,
                                                      key='name',
                                                      optimised=False)
                for atm in aa_work_mol.atoms:
                    try:
                        atm.xyz = gamess[atm.atm_name.upper()]['vec']
                    except TypeError:
                        print('TypeError', atm.atm_name, d, m, a)
                        skip_angle = True
                        break
                    except KeyError:
                        print('KeyError', atm.atm_name, d, m, a)
                        raise
                if skip_angle:
                    continue
                for atm in ua_work_mol.atoms:
                    atm.xyz = gamess[atm.atm_name.upper()]['vec']
                with open('{outdir}/{mol}.{ang:03}.aa.cnf'.format(**forms),
                          'w') as fh:
                    fh.write(outlib.print_gromos_cnf(aa_work_mol))
                with open('{outdir}/{mol}.{ang:03}.ua.cnf'.format(**forms),
                          'w') as fh:
                    fh.write(outlib.print_gromos_cnf(ua_work_mol))
                #with open('{outdir}/{mol}.{ang:03}.aa.pdb'.format(**forms), 'w') as fh:
                #    fh.write(outlib.print_pdb(aa_work_mol))
                #with open('{outdir}/{mol}.{ang:03}.ua.pdb'.format(**forms), 'w') as fh:
                #    fh.write(outlib.print_pdb(ua_work_mol))
                angs_aa, angs_ua = [], []
                for des in descriptors[d]:
                    atm_a = aa_work_mol.atom(molecules[m][des]['aa'][0]).xyz
                    atm_b = aa_work_mol.atom(molecules[m][des]['aa'][1]).xyz
                    atm_c = aa_work_mol.atom(molecules[m][des]['aa'][2]).xyz
                    atm_d = aa_work_mol.atom(molecules[m][des]['aa'][3]).xyz
                    ang = dihedral_angle(atm_a,
                                         atm_b,
                                         atm_c,
                                         atm_d,
                                         scale='deg')
                    angs_aa.append(
                        '   {1}  {2}  {3}  {4}  1.0  {0:.3f}  0.0   0.0001'.
                        format(ang, *molecules[m][des]['aa']))
                    angs_ua.append(
                        '   {1}  {2}  {3}  {4}  1.0  {0:.3f}  0.0   0.0001'.
                        format(ang, *molecules[m][des]['ua']))
                with open(
                        '{outdir}/{mol}.{ang:03}.aa.constraints.dat'.format(
                            **forms), 'w') as fh:
                    fh.write(
                        constraint_temp.format(
                            **{'constraints': '\n'.join(angs_aa)}))
                with open(
                        '{outdir}/{mol}.{ang:03}.ua.constraints.dat'.format(
                            **forms), 'w') as fh:
                    fh.write(
                        constraint_temp.format(
                            **{'constraints': '\n'.join(angs_ua)}))
                # first pass
                os.system((
                    '/opt/local/gromosXX-1773/bin/md @topo {outdir}/{mol}.aa.top @conf {outdir}/{mol}.{ang:03}.aa.cnf '
                    '@input {outdir}/{mol}.aa.1.imd @fin {outdir}/{mol}.{ang:03}.aa.min.1.cnf @develop '
                    '@dihrest {outdir}/{mol}.{ang:03}.aa.constraints.dat > {outdir}/{mol}.{ang:03}.aa.1.log'
                    .format(**forms)))

                os.system((
                    '/opt/local/gromosXX-1773/bin/md @topo {outdir}/{mol}.ua.top @conf {outdir}/{mol}.{ang:03}.ua.cnf '
                    '@input {outdir}/{mol}.ua.1.imd @fin {outdir}/{mol}.{ang:03}.ua.min.1.cnf @develop '
                    '@dihrest {outdir}/{mol}.{ang:03}.ua.constraints.dat > {outdir}/{mol}.{ang:03}.ua.1.log'
                    .format(**forms)))
Exemplo n.º 5
0
def main():
    root = '/Users/iwelsh/GitHub/ExtractedData/Torsions/AdditionalFixedTorsions'
    for mol, data in mol_data():
        if not os.path.isdir(root + '/AlignedStructures/' + mol +
                             '/EM_Changes'):
            os.makedirs(root + '/AlignedStructures/' + mol + '/EM_Changes')
        formatting = dict(root=root + '/Original', mol=mol, root2=root)
        topo = gromos_topology_parse(
            load_file(
                '{root}/{mol}/MD_data/{mol}.ua.top'.format(**formatting)))
        cnf = gromos_cnf_parse(
            load_file('{root}/{mol}/MD_data/{mol}.000.ua'
                      '.min.1.cnf'.format(**formatting)))
        cnf_initial = gromos_cnf_parse(
            load_file(
                '{root}/{mol}/MD_data/{mol}.000.ua.cnf'.format(**formatting)))
        mol_ob = Molecule(mol, cnf=cnf[1], topo=topo)
        mol_ob_initial = Molecule(mol, cnf=cnf_initial[1], topo=topo)
        previous, previous_initial = [], []
        mol_ob.centre_molecule(data['ua'][1])
        mol_ob_initial.centre_molecule(data['ua'][1])
        for atm in data['ua'][:3]:
            previous.append(np.asarray(mol_ob.atom(atm).xyz))
            previous_initial.append(np.asarray(mol_ob_initial.atom(atm).xyz))
        previous = np.asarray(previous)
        previous_initial = np.asarray(previous_initial)

        for level, atoms in data.items():
            formatting = dict(root=root + '/Original',
                              level=level,
                              mol=mol,
                              root2=root)
            if level in ['gamess', 'aa']:
                topo = gromos_topology_parse(
                    load_file('{root}/{mol}/MD_data/{mol}.aa.top'.format(
                        **formatting)))
            else:
                topo = gromos_topology_parse(
                    load_file('{root}/{mol}/MD_data/{mol}.ua.top'.format(
                        **formatting)))
            for i in range(360):
                formatting['i'] = i
                try:
                    if level == 'gamess':
                        gamess = gamess_log_parse(
                            load_file('{root}/{mol}/{mol}.{i:03}.log'.format(
                                **formatting),
                                      blank_lines=True))
                        mol_ob2 = Molecule(mol,
                                           gamess=gamess[max(gamess)],
                                           topo=topo)
                        mol_ob2_initial = Molecule(mol,
                                                   gamess=gamess[min(gamess)],
                                                   topo=topo)
                    else:
                        cnf = gromos_cnf_parse(
                            load_file(
                                '{root}/{mol}/MD_data/{mol}.{i:03}.{level}'
                                '.min.1.cnf'.format(**formatting)))
                        cnf_initial = gromos_cnf_parse(
                            load_file(
                                '{root}/{mol}/MD_data/{mol}.{i:03}.{level}'
                                '.cnf'.format(**formatting)))
                        mol_ob2 = Molecule(mol, cnf=cnf[1], topo=topo)
                        mol_ob2_initial = Molecule(mol,
                                                   cnf=cnf_initial[1],
                                                   topo=topo)
                except FileNotFoundError:
                    continue

                current, current_initial = [], []
                if level == 'gamess':
                    mol_ob2.centre_molecule(data['aa'][1])
                    mol_ob2_initial.centre_molecule(data['aa'][1])
                    atms = data['aa']
                else:
                    try:
                        mol_ob2.centre_molecule(atoms[1])
                    except TypeError:
                        print(mol, level, i, atoms, len(mol_ob2.atoms))
                        print(mol_ob2.atom(atoms[1]).xyz)
                        for atm in mol_ob2.atoms:
                            print(atm.data)

                        raise
                    mol_ob2_initial.centre_molecule(atoms[1])
                    atms = atoms

                for atm in atms[:3]:
                    current.append(np.asarray(mol_ob2.atom(atm).xyz))
                    current_initial.append(
                        np.asarray(mol_ob2_initial.atom(atm).xyz))
                current = np.asarray(current)
                current_initial = np.asarray(current_initial)
                rot_mat = kabsch_alignment(current, previous)
                rot_mat_initial = kabsch_alignment(current_initial, previous)
                mol_ob2.rotate(rot_mat)
                mol_ob2_initial.rotate(rot_mat_initial)
                with open(
                    ('{root2}/AlignedStructures/{mol}/EM_Changes/'
                     '{mol}.{i:03}.{level}.initial.pdb'.format(**formatting)),
                        'w') as fh:
                    fh.write(print_pdb(mol_ob2_initial))
                with open(
                        '{root2}/AlignedStructures/{mol}/{mol}.{i:03}.{level}.pdb'
                        .format(**formatting), 'w') as fh:
                    fh.write(print_pdb(mol_ob2))
Exemplo n.º 6
0
def main():
    root = '/Users/iwelsh/GitHub/ExtractedData/Torsions/AdditionalFixedTorsions'
    for mol, data in mol_data():
        if not os.path.isdir(root + '/AlignedStructures/' + mol + '/EM_Changes'):
            os.makedirs(root + '/AlignedStructures/' + mol + '/EM_Changes')
        formatting = dict(root=root+'/Original', mol=mol, root2=root)
        topo = gromos_topology_parse(load_file('{root}/{mol}/MD_data/{mol}.ua.top'.format(**formatting)))
        cnf = gromos_cnf_parse(load_file('{root}/{mol}/MD_data/{mol}.000.ua'
                                             '.min.1.cnf'.format(**formatting)))
        cnf_initial = gromos_cnf_parse(load_file('{root}/{mol}/MD_data/{mol}.000.ua.cnf'.format(**formatting)))
        mol_ob = Molecule(mol, cnf=cnf[1], topo=topo)
        mol_ob_initial = Molecule(mol, cnf=cnf_initial[1], topo=topo)
        previous, previous_initial = [], []
        mol_ob.centre_molecule(data['ua'][1])
        mol_ob_initial.centre_molecule(data['ua'][1])
        for atm in data['ua'][:3]:
            previous.append(np.asarray(mol_ob.atom(atm).xyz))
            previous_initial.append(np.asarray(mol_ob_initial.atom(atm).xyz))
        previous = np.asarray(previous)
        previous_initial = np.asarray(previous_initial)
        
        for level, atoms in data.items():
            formatting = dict(root=root+'/Original', level=level, mol=mol, root2=root)
            if level in ['gamess','aa']:
                topo = gromos_topology_parse(load_file('{root}/{mol}/MD_data/{mol}.aa.top'.format(**formatting)))
            else:
                topo = gromos_topology_parse(load_file('{root}/{mol}/MD_data/{mol}.ua.top'.format(**formatting)))
            for i in range(360):
                formatting['i'] = i
                try:
                    if level == 'gamess':
                        gamess = gamess_log_parse(load_file('{root}/{mol}/{mol}.{i:03}.log'.format(**formatting),
                                                             blank_lines=True))
                        mol_ob2 = Molecule(mol, gamess=gamess[max(gamess)], topo=topo)
                        mol_ob2_initial = Molecule(mol, gamess=gamess[min(gamess)], topo=topo)
                    else:
                        cnf = gromos_cnf_parse(load_file('{root}/{mol}/MD_data/{mol}.{i:03}.{level}'
                                                         '.min.1.cnf'.format(**formatting)))
                        cnf_initial = gromos_cnf_parse(load_file('{root}/{mol}/MD_data/{mol}.{i:03}.{level}'
                                                         '.cnf'.format(**formatting)))
                        mol_ob2 = Molecule(mol, cnf=cnf[1], topo=topo)
                        mol_ob2_initial = Molecule(mol, cnf=cnf_initial[1], topo=topo)
                except FileNotFoundError:
                    continue
                    
                current, current_initial = [], []
                if level == 'gamess':
                    mol_ob2.centre_molecule(data['aa'][1])
                    mol_ob2_initial.centre_molecule(data['aa'][1])
                    atms = data['aa']
                else:
                    try:
                        mol_ob2.centre_molecule(atoms[1])
                    except TypeError:
                        print(mol, level, i, atoms, len(mol_ob2.atoms))
                        print(mol_ob2.atom(atoms[1]).xyz)
                        for atm in mol_ob2.atoms:
                            print(atm.data)
                        
                        raise
                    mol_ob2_initial.centre_molecule(atoms[1])
                    atms = atoms
                
                for atm in atms[:3]:
                    current.append(np.asarray(mol_ob2.atom(atm).xyz))
                    current_initial.append(np.asarray(mol_ob2_initial.atom(atm).xyz))
                current = np.asarray(current)
                current_initial = np.asarray(current_initial)
                rot_mat = kabsch_alignment(current, previous)
                rot_mat_initial = kabsch_alignment(current_initial, previous)
                mol_ob2.rotate(rot_mat)
                mol_ob2_initial.rotate(rot_mat_initial)
                with open(('{root2}/AlignedStructures/{mol}/EM_Changes/'
                          '{mol}.{i:03}.{level}.initial.pdb'.format(**formatting)), 'w') as fh:
                    fh.write(print_pdb(mol_ob2_initial))
                with open('{root2}/AlignedStructures/{mol}/{mol}.{i:03}.{level}.pdb'.format(**formatting), 'w') as fh:
                    fh.write(print_pdb(mol_ob2))