File size: 1,486 Bytes
4e3b836
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from mpi4py import MPI
from mpi4py.futures import MPICommExecutor

from openbabel import pybel
from Bio.PDB import *
parser = PDBParser()

import os
molecular_weight_cutoff = 2500
def parse_ligand(fn):
    print(fn)
    try:
        struct = parser.get_structure('lig',fn)
        if len(list(struct.get_atoms())) > molecular_weight_cutoff:
            raise ValueError
        mol = next(pybel.readfile('pdb',fn))
        if mol.molwt > molecular_weight_cutoff:
            raise ValueError
        smi = mol.write('can').split('\t')[0]
        return smi
    except:
        return None


if __name__ == '__main__':
    import glob

    comm = MPI.COMM_WORLD
    with MPICommExecutor(comm, root=0) as executor:
        if executor is not None:
            import pandas as pd

            df = pd.read_table('biolip/data/BioLiP_2013-03-6_nr.txt',sep='\t',header=None,usecols=[0,4,5,6,13,14,15,16,19])
            df = df.rename(columns={0:'pdb',4:'chain',5:'l_id',6:'l_chain',
                                    13: 'affinity_lit',14: 'affinity_moad',15: 'affinity_pdbbind-cn',16:'affinity_bindingdb',
                                    19: 'seq'})
            base = 'biolip/data/ligand_nr/'
            df['ligand_fn'] = base + df['pdb']+'_'+df['chain']+'_'+df['l_id'].astype(str)+'_'+df['l_chain'].astype(str)+'.pdb'
            smiles = list(executor.map(parse_ligand, df['ligand_fn']))
            df['smiles'] = smiles
            df.to_parquet('data/biolip_complex.parquet')