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')