File size: 930 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
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).split('.')[0]
        print(name)
        seq = str(next(SeqIO.parse(fn, "pdb-seqres")).seq)
        return name, seq
    except:
        return None


if __name__ == '__main__':
    import glob

    filenames = glob.glob('binding_moad/BindingMOAD_2020/*.bio1')
    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]

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