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

Make FragIt agnostic to underlying APIs #27

Open
cstein opened this issue Sep 11, 2017 · 1 comment
Open

Make FragIt agnostic to underlying APIs #27

cstein opened this issue Sep 11, 2017 · 1 comment
Milestone

Comments

@cstein
Copy link
Member

cstein commented Sep 11, 2017

Currently we rely on OpenBabel to parse the SMARTS and give us the atoms of the corresponding fragments. We should also make an effort to support other APIs such as RDKit.

There is some code available in src/openbabelwrapper.py which could be used as a starting point.

I suppose something like which is easily testable depending only on the classes themselves.

class FragmentationBase(object):
    """ A virtual class with all the support the fragmentation class needs except smarts handling """
    pass

class OBFragmentation(FragmentationBase):
    """ Make openbabel specific implementation of Fragmentation class """
    pass

class RDKitFragmentation(FragmentationBase):
    """ Make RDKit specific implementation of Fragmentation class """
    pass

some logic would then be built-in depending on what packages are available. Some things that the classes should provide:

  • Based on a smarts fragmentation pattern, yield list of fragments.
  • Calculate the charge of fragments in a somewhat consistent fashion
    • Perhaps we should start making SMARTS patterns for charges too. See ???

Initially we will ignore things like fragment grouping and so on.

@cstein cstein added this to the 2.0 milestone Sep 11, 2017
@cstein
Copy link
Member Author

cstein commented Sep 21, 2017

Another option is to make the underlying molecule agnostic to the representation:

class MoleculeBase(object):
    def __init__(self, filename):
        self._filename = filename

    def getNumAtoms(self):
        raise NotImplemented

class OBMolecule(MoleculeBase):
    def __init__(self, filename):
        MoleculeBase.__init__(self, filename)
        self._mol = #load molecule with openbabel

    def getNumAtoms(self):
        return self._mol.GetNumAtoms()

class RDKitMolecule(MoleculeBase):
    pass

Using this approach, the fragmentation class will only interact with a molecule which exposes all the necessary features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant