add 2d conformers
Browse files- data/pdb.parquet +2 -2
- parse_complexes.py +24 -4
- pdb_protein_ligand_complexes.py +4 -3
data/pdb.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3cbbee08b3cd8659d95f45643d8a053c29a4d6017c9d563721a5b7b4707e5f1b
|
| 3 |
+
size 412327231
|
parse_complexes.py
CHANGED
|
@@ -88,7 +88,17 @@ def tokenize_ligand(mol):
|
|
| 88 |
else:
|
| 89 |
token_pos.append((np.nan, np.nan, np.nan))
|
| 90 |
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
def read_ligand_expo():
|
| 94 |
"""
|
|
@@ -191,15 +201,17 @@ def process_entry(df_dict, pdb_fn):
|
|
| 191 |
|
| 192 |
ligand_smiles = []
|
| 193 |
ligand_xyz = []
|
|
|
|
| 194 |
|
| 195 |
for mol, name in zip(ligand_mols, ligand_names):
|
| 196 |
print('Processing {} and {}'.format(pdb_name, name))
|
| 197 |
-
smi, xyz = tokenize_ligand(mol)
|
| 198 |
ligand_smiles.append(smi)
|
| 199 |
ligand_xyz.append(xyz)
|
|
|
|
| 200 |
|
| 201 |
seq, receptor_xyz = get_protein_sequence_and_coords(protein)
|
| 202 |
-
return pdb_name, seq, receptor_xyz, ligand_names, ligand_smiles, ligand_xyz
|
| 203 |
except Exception as e:
|
| 204 |
print(repr(e))
|
| 205 |
|
|
@@ -225,7 +237,15 @@ if __name__ == '__main__':
|
|
| 225 |
lig_id = [l for r in result if r is not None for l in r[3]]
|
| 226 |
lig_smiles = [s for r in result if r is not None for s in r[4]]
|
| 227 |
lig_xyz = [xyz for r in result if r is not None for xyz in r[5]]
|
|
|
|
| 228 |
|
| 229 |
import pandas as pd
|
| 230 |
-
df = pd.DataFrame({
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
df.to_parquet('data/pdb.parquet',index=False)
|
|
|
|
| 88 |
else:
|
| 89 |
token_pos.append((np.nan, np.nan, np.nan))
|
| 90 |
|
| 91 |
+
k = 0
|
| 92 |
+
conf_2d = AllChem.Compute2DCoords(mol)
|
| 93 |
+
token_pos_2d = []
|
| 94 |
+
for i,token in enumerate(masked_tokens):
|
| 95 |
+
if token != '':
|
| 96 |
+
token_pos_2d.append(tuple(mol.GetConformer(conf_2d).GetAtomPosition(atom_order[k])))
|
| 97 |
+
k += 1
|
| 98 |
+
else:
|
| 99 |
+
token_pos_2d.append((0.,0.,0.))
|
| 100 |
+
|
| 101 |
+
return smi, token_pos, token_pos_2d
|
| 102 |
|
| 103 |
def read_ligand_expo():
|
| 104 |
"""
|
|
|
|
| 201 |
|
| 202 |
ligand_smiles = []
|
| 203 |
ligand_xyz = []
|
| 204 |
+
ligand_xyz_2d = []
|
| 205 |
|
| 206 |
for mol, name in zip(ligand_mols, ligand_names):
|
| 207 |
print('Processing {} and {}'.format(pdb_name, name))
|
| 208 |
+
smi, xyz, xyz_2d = tokenize_ligand(mol)
|
| 209 |
ligand_smiles.append(smi)
|
| 210 |
ligand_xyz.append(xyz)
|
| 211 |
+
ligand_xyz_2d.append(xyz_2d)
|
| 212 |
|
| 213 |
seq, receptor_xyz = get_protein_sequence_and_coords(protein)
|
| 214 |
+
return pdb_name, seq, receptor_xyz, ligand_names, ligand_smiles, ligand_xyz, ligand_xyz_2d
|
| 215 |
except Exception as e:
|
| 216 |
print(repr(e))
|
| 217 |
|
|
|
|
| 237 |
lig_id = [l for r in result if r is not None for l in r[3]]
|
| 238 |
lig_smiles = [s for r in result if r is not None for s in r[4]]
|
| 239 |
lig_xyz = [xyz for r in result if r is not None for xyz in r[5]]
|
| 240 |
+
lig_xyz_2d = [xyz for r in result if r is not None for xyz in r[6]]
|
| 241 |
|
| 242 |
import pandas as pd
|
| 243 |
+
df = pd.DataFrame({
|
| 244 |
+
'pdb_id': pdb_id,
|
| 245 |
+
'lig_id': lig_id,
|
| 246 |
+
'seq': seq,
|
| 247 |
+
'smiles': lig_smiles,
|
| 248 |
+
'receptor_xyz': receptor_xyz,
|
| 249 |
+
'ligand_xyz': lig_xyz,
|
| 250 |
+
'ligand_xyz_2d': lig_xyz_2d})
|
| 251 |
df.to_parquet('data/pdb.parquet',index=False)
|
pdb_protein_ligand_complexes.py
CHANGED
|
@@ -54,10 +54,10 @@ _URLs = {name: _URL+_file_names[name] for name in _file_names}
|
|
| 54 |
|
| 55 |
|
| 56 |
# TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
|
| 57 |
-
class
|
| 58 |
-
"""List of protein sequences, ligand SMILES, and complex
|
| 59 |
|
| 60 |
-
VERSION = datasets.Version("1.
|
| 61 |
|
| 62 |
def _info(self):
|
| 63 |
# TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
|
|
@@ -78,6 +78,7 @@ class ProteinLigandContacts(datasets.ArrowBasedBuilder):
|
|
| 78 |
"seq": datasets.Value("string"),
|
| 79 |
"smiles": datasets.Value("string"),
|
| 80 |
"ligand_xyz": datasets.Sequence(datasets.Sequence(datasets.Value('float32'))),
|
|
|
|
| 81 |
"receptor_xyz": datasets.Sequence(datasets.Sequence(datasets.Value('float32'))),
|
| 82 |
# These are the features of your dataset like images, labels ...
|
| 83 |
}
|
|
|
|
| 54 |
|
| 55 |
|
| 56 |
# TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
|
| 57 |
+
class PDBProteinLigandComplexes(datasets.ArrowBasedBuilder):
|
| 58 |
+
"""List of protein sequences, ligand SMILES, and complex coordinates."""
|
| 59 |
|
| 60 |
+
VERSION = datasets.Version("1.3.0")
|
| 61 |
|
| 62 |
def _info(self):
|
| 63 |
# TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
|
|
|
|
| 78 |
"seq": datasets.Value("string"),
|
| 79 |
"smiles": datasets.Value("string"),
|
| 80 |
"ligand_xyz": datasets.Sequence(datasets.Sequence(datasets.Value('float32'))),
|
| 81 |
+
"ligand_xyz_2d": datasets.Sequence(datasets.Sequence(datasets.Value('float32'))),
|
| 82 |
"receptor_xyz": datasets.Sequence(datasets.Sequence(datasets.Value('float32'))),
|
| 83 |
# These are the features of your dataset like images, labels ...
|
| 84 |
}
|