@@ -0,0 +1,2376 @@
+#!/usr/bin/env python3%0A'''Extract the PDB files from the pml file from the CATH databse.%0AThe extracted PDBs will be stored in a pdb file.%0AThe PDB files will be cleaned by reading into Rosetta.%0A'''%0A%0Aimport os%0Aimport sys%0A%0Aimport pyrosetta%0Afrom pyrosetta import rosetta%0A%0A%0Adef extract_pdbs_from_cath_pml(pml_file, output_path):%0A    '''Extract the PDB files from the pml file from the CATH databse.%0A    The extracted PDBs will be stored in a pdb file. %0A    '''%0A%0A    with open(pml_file, 'r') as f:%0A        while True:%0A            line = f.readline()%0A            if not line: break%0A         %0A            # Read one structure%0A%0A            if line.strip().startswith('cmd.read_pdbstr'):%0A                pdb_lines = %5Bline.strip()%5B19:%5D.strip('%5C%5C')%5D%0A                pdb_id = ''%0A%0A                while True:  %0A                    line = f.readline()%0A                    if line.strip().startswith('%22%22%22'):%0A                        pdb_id = line.strip()%5B5:12%5D%0A                        break%0A%0A                    pdb_line = line.strip().strip('%5C%5C')%0A                    if len(pdb_line) %3E 17:%0A                        pdb_line = pdb_line%5B0:16%5D + ' ' + pdb_line%5B17:%5D # Remove all altLoc flags%0A                    %0A                    pdb_lines.append(pdb_line) # Remove all altLoc flags%0A           %0A%0A                try:%0A                    pose = rosetta.core.pose.Pose()%0A                    rosetta.core.import_pose.pose_from_pdbstring(pose, '%5Cn'.join(pdb_lines))%0A                    %0A                    pose.dump_pdb(os.path.join(output_path, '%7B0%7D.pdb.gz'.format(pdb_id)))%0A%0A                except:%0A                    continue%0A%0Adef extract_all_pdbs(input_path, output_path, num_jobs, job_id):%0A    pml_files = %5Bf for f in os.listdir(input_path) if f.endswith('.pml')%5D%0A    %0A    for i, f in enumerate(pml_files):%0A        if job_id == i %25 num_jobs:%0A            os.makedirs(os.path.join(output_path, f%5B:-4%5D), exist_ok=True) %0A           %0A            extract_pdbs_from_cath_pml(os.path.join(input_path, f), os.path.join(output_path, f%5B:-4%5D))        %0A%0A%0A%0Aif __name__ == '__main__':%0A    %0A    data_path = sys.argv%5B1%5D%0A    input_path = sys.argv%5B2%5D%0A    %0A    num_jobs = 1%0A    job_id = 0%0A    if len(sys.argv) %3E 4:%0A      num_jobs = int(sys.argv%5B3%5D)%0A      job_id = int(sys.argv%5B4%5D) - 1%0A%0A%0A    pyrosetta.init(options='-ignore_unrecognized_res true')%0A%0A    extract_all_pdbs(input_path, data_path, num_jobs, job_id)%0A

Implement the extract_pdbs_from_cath_pml.py script