File size: 1,184 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
from mpi4py import MPI
from mpi4py.futures import MPICommExecutor

from openbabel import pybel
from Bio import SeqIO

import os
def parse_complex(fn):
    try:
        name = os.path.basename(fn)
        seq = str(next(SeqIO.parse(fn+'/'+name+'_protein.pdb', "pdb-seqres")).seq)
        mol = next(pybel.readfile('sdf',fn+'/'+name+'_ligand.sdf'))
        smi = mol.write('can').split('\t')[0]
        return name, seq, smi
    except:
        return None


if __name__ == '__main__':
    import glob

    filenames = glob.glob('pdbbind/data/v2019-other-PL/*')
    filenames.extend(glob.glob('pdbbind/data/refined-set/*'))
    comm = MPI.COMM_WORLD
    with MPICommExecutor(comm, root=0) as executor:
        if executor is not None:
            result = executor.map(parse_complex, filenames)
            result = list(result)
            names = [r[0] for r in result if r is not None]
            seqs = [r[1] for r in result if r is not None]
            all_smiles = [r[2] for r in result if r is not None]

            import pandas as pd
            df = pd.DataFrame({'name': names, 'seq': seqs, 'smiles': all_smiles})
            df.to_parquet('data/pdbbind_complex.parquet')