Esempio 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)))
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)))
Esempio n. 3
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))
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))