Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add abcd.py #35

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,10 @@ dmypy.json
.pyre/

.metals/
.vscode/
.vscode/


.DS_Store
**/.DS_Store

!.gitignore
30 changes: 30 additions & 0 deletions abcd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Posted in X.
# https://x.com/Flasushi/status/1791622447315460540

from rdkit import Chem
from rdkit import Chem
from rdkit.Chem import Descriptors
from rdkit.Chem import AllChem
import numpy as np

def compute_descriptors(smiles):
mol = Chem.MolFromSmiles(smiles)
if mol is None:
return None

mol_weight = Descriptors.MolWt(mol)
logp = Descriptors.MolLogP(mol)
num_h_donors = Descriptors.NumHDonors(mol)
num_h_acceptors = Descriptors.NumHAcceptors(mol)

fp = AllChem.GetMorganFingerprintAsBitVect(mol, 2, nBits=1024)
fp_arr = np.zeros((1,))
AllChem.DataStructs.ConvertToNumpyArray(fp, fp_arr)

descriptors = np.concatenate(([mol_weight, logp, num_h_donors, num_h_acceptors], fp_arr))

return descriptors


if __name__ == '__main__':
pass