def gen(lig_idx):
    dests = []
    ligs = []
    proteins = []

    lig_src = lig_src_base + str(lig_idx).zfill(4) + '.pk'
    with open(lig_src, 'rb') as f:
        lig_features, centers = pk.load(f)
    
    for pro_idx in idxs:
        dest = base_dest + '/' + str(pro_idx).zfill(4) + '_pro_' + str(lig_idx).zfill(4) + '_lig.npy'
        
        protein_path = protein_src_base +str(pro_idx).zfill(4)+'_pro_cg.pdb'
        
        if is_val:
            pro_features, _ = pdb_to_features(protein_path, centers)
        else: 
            pro_features, _ = test_pdb_to_features(protein_path, centers)
        pro_features = pro_features[:,:,:,[0,7]]

        combined = np.concatenate((pro_features, lig_features), axis=3)
        combined = combined.astype(np.float32)

        np.save(dest, combined)
        
        dests.append(dest)
        ligs.append(lig_idx)
        proteins.append(pro_idx)
    
    return dests, ligs, proteins
score = []

for lig_idx in tqdm(idxs, file=sys.stdout):
    lig_src = './processed_data/eval/ligands_2/' + str(lig_idx).zfill(
        4) + '.pk'
    with open(lig_src, 'rb') as f:
        lig_features, centers = pk.load(f)

    for pro_idx in tqdm(idxs, file=sys.stdout):
        dest = base_dest + '/' + str(pro_idx).zfill(4) + '_pro_' + str(
            lig_idx).zfill(4) + '_lig.npy'

        protein_path = './data/testing_data/' + str(pro_idx).zfill(
            4) + '_pro_cg.pdb'

        pro_features, _ = test_pdb_to_features(protein_path, centers)
        pro_features = pro_features[:, :, :, [0, 7]]

        combined = np.concatenate((pro_features, lig_features), axis=3)
        combined = combined.astype(np.float32)

        np.save(dest, combined)

        dests.append(dest)
        ligs.append(lig_idx)
        proteins.append(pro_idx)

csv_dest = f'./data/csv/test_acc10_2.csv'
pro_lig_record = pd.DataFrame(
    {
        'lig_id': ligs,
Esempio n. 3
0
import sys
'''
For generating ligands in test dataset
Code is almost exactly the same as gen_ligand2_descriptors.py
'''

ligands = []
ligand_root = './processed_data/eval/ligands_2'
Path(ligand_root).mkdir(exist_ok=True, parents=True)

### Generate the ligands
raw_ligand_paths = sorted(
    list(Path('./data/testing_data/').glob('*lig_cg.pdb')))

dests = []
idxs = []
idx = 0
for lig_path in tqdm(raw_ligand_paths, file=sys.stdout):
    features, centers = test_pdb_to_features(lig_path)
    features = features[:, :, :, [0, 7]]

    dest = ligand_root + '/' + str(idx + 1).zfill(4) + '.pk'
    with open(dest, 'wb') as f:
        pk.dump((features, centers), f)
        dests.append(dest)
        idxs.append(idx + 1)
        idx += 1

df = pd.DataFrame({'id': idxs, 'path': dests})
df.to_csv('./data/csv/ligand_2_data_eval.csv', index=None)