Giter Site home page Giter Site logo

Comments (2)

DrrDom avatar DrrDom commented on August 24, 2024

You are welcome!

If you would like to make replacements at a particular position there are two options.

Option 1. Remove a dummy atom, store the id of the attached atom (idx) and pass it as an argument replace_ids=[idx] to grow_mol. Before calling grow_mol you need to sanitize a molecule Chem.SanitizeMol(fragment) (that is why you have an error in the second case, after manipulation with a molecule you need to update internal states).

Option 2 (tricky). Replace a dummy atom with a hydrogen, sanitize a molecule and then call mutate_mol with min_size=0 and max_size=0. This will replace all explicit hydrogens in a molecule. While you maintain explicit hydrogens at attachment points only you will get what you want. This is less explicit and a more dangerous way.
In the example I decreased the radius to 2, because it cannot find such a context at radius 3 in a database.

idx = None
for atom in fragment.GetAtoms():
    if atom.GetAtomicNum() == 0:
        idx = atom.GetIdx()
        break

frag = Chem.EditableMol(fragment)
frag.ReplaceAtom(idx, Chem.Atom(1))
frag = frag.GetMol()
Chem.SanitizeMol(frag)

res = list(mutate_mol(frag, db_name='replacements.db', max_replacements=9, return_mol=True, min_size=0, max_size=0, radius=2))

from crem.

xescape avatar xescape commented on August 24, 2024

It seems like removing the dummy atom and running SanitizeMol solved my problems. Thank you for the timely help!

from crem.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.