moleculemaker / chemscraper-frontend

MIT License
1 stars 0 forks source link

enable sort by number of atoms #76

Closed matthewberry closed 6 months ago

bodom0015 commented 6 months ago

I don't believe there is any way to currently get the number of atoms for each Molecule 🤔

Would we need to parse/analyze the chemical formula or the fingerprint or SMILE?

matthewberry commented 6 months ago

Hi @bodom0015, I believe you're correct that we don't have the number of atoms for each molecule yet.

From what I see, RDKit may have a good option for us: https://rdkit.org/docs/source/rdkit.Chem.rdchem.html#rdkit.Chem.rdchem.Mol.GetAtoms

Maybe in https://github.com/moleculemaker/mmli-backend/blob/main/app/services/rdkit_service.py we could add something like this:

    def getAtomCount(self, smileString):
        mol = Chem.MolFromSmiles(smileString)
        if mol is None:
            raise ValueError(f"Could not create molecule from SMILES: {smileString}")
        return len(mol.GetAtoms())
bodom0015 commented 6 months ago

Related backend PR: https://github.com/moleculemaker/mmli-backend/pull/30

Working on the frontend portion + sort, and will tag with this issue when I create the PR and deploy it to staging :+1:

EDIT - Related Frontend PR: https://github.com/moleculemaker/chemscraper-frontend/pull/99