tbereau / auto_martini

Automatic MARTINI parametrization of small organic molecules
GNU General Public License v2.0
59 stars 22 forks source link

package rdkit and smile format #16

Open zineb1202 opened 5 years ago

zineb1202 commented 5 years ago

hello, someone can help me please. I am still new in the use of python Boost.Python.ArgumentError: Python argument types in rdkit.Chem.rdmolops.AddHs(NoneType) did not match C++ signature: AddHs(RDKit::ROMol mol, bool explicitOnly=False, bool addCoords=False, boost::python::api::object onlyOnAtoms=None)

the code does not work for this file: [CH]C(=C=CC#C[C]C#C)C#CC#C 19 0 -122.66159367965076 -6.4558733515605669 this is the code:

import rdkit import rdkit.Chem from rdkit.Chem import AllChem from rdkit.Chem import Draw

with open("./ringinfo.txt","w") as f1: for i in range(1,259 ): fn = "./SMI/{}.smi".format(i) smiles = open(fn, "r").read().split()[0] mol = rdkit.Chem.AddHs(rdkit.Chem.MolFromSmiles(smiles)) rings = rdkit.Chem.GetSymmSSSR(mol) print(len(rings), file=f1) suppl = rdkit.Chem.SDMolSupplier('./SDF/{}.sdf'.format(i)) ms = [x for x in suppl if x is not None] p = rdkit.Chem.MolFromSmiles(smiles) subms = [x for x in ms if x.HasSubstructMatch(p)] AllChem.Compute2DCoords(p) for m in subms: AllChem.GenerateDepictionMatching2DStructure(m,p) img=Draw.MolsToGridImage(subms,molsPerRow=1,subImgSize=(600,600)) img.save('./FIG/{}.png'.format(i))

tbereau commented 5 years ago

Hi,

the code you're referring to seems to raise an exception upon loading rdkit.Chem.Draw. I would check the rdkit support for help--this is independent from auto martini.

Best, Tristan

zineb1202 commented 5 years ago

Hi, thank you for your reply, I have more than 1000 files, this code works in some files and the others not. I already showed an example of a file in which I have the problem.

zineb1202 commented 5 years ago

Boost.Python.ArgumentError Traceback (most recent call last)

in 8 fn = "./SMI/{}.smi".format(i) 9 smiles = open(fn, "r").read().split()[0] ---> 10 mol = rdkit.Chem.AddHs(rdkit.Chem.MolFromSmiles(smiles)) 11 rings = rdkit.Chem.GetSymmSSSR(mol) 12 print(len(rings), file=f1) ArgumentError: Python argument types in rdkit.Chem.rdmolops.AddHs(NoneType) did not match C++ signature: AddHs(class RDKit::ROMol mol, bool explicitOnly=False, bool addCoords=False, class boost::python::api::object onlyOnAtoms=None, bool addResidueInfo=False)
kkanekal commented 5 years ago

Hi,

It seems that auto_martini is having some trouble with your smiles string. If I use the string: C#CCC#CC=C=C(C)C#CC#C I am able to get a result. Because you have so many files, rather than hand-tune each smiles string, I'd recommend using the refactor branch, which is able to handle more complex smiles strings like the one you had input above. Simply type

git checkout refactor

The refactor branch also has two more significant changes to the code: a slightly larger value for the lonely atom penalty and the removal of the additivity check for molecules mapping to single beads only.

Best, Kiran

zineb1202 commented 5 years ago

Hi Kiran, thank you so much, where can I write this command? and I did not understand the last instructions that you wrote. best, zineb

kkanekal commented 5 years ago

Hi,

I am essentially saying that you could try to use an updated version of the code, the refactor branch. In the folder containing auto-martini you should be able to type the above command to get this version. If this does not work, it may be because you downloaded an archive of the code instead of cloning it using git. In this case, I suggest you type the following into your terminal command line:

git clone -b refactor https://github.com/tbereau/auto_martini.git

The "last instructions" from my earlier post were just detailing the changes made in the newer version.

Best, Kiran

zineb1202 commented 5 years ago

Hi, I understand now, and I use it but I found other problem:

Boost.Python.Traceback(most recent call last):

File "C:\Users\meriem hanine\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3267, in run_code exec(code_obj, self.user_global_ns, self.user_ns)

File "", line 1, in import auto_martini as am

File "C:\git\auto_martini\auto_martini.py", line 35, in from sanifix4 import AdjustAromaticNs

File "C:\git\auto_martini\sanifix4.py", line 277 print '#---------------------' ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print('#---------------------')?

this problem is related with version?

kkanekal commented 5 years ago

Hi,

I'd recommend opening the sanifix4.py file and adding parentheses to the print command on line 277 so that it looks like the following:

print ('#---------------------')

If you still have problems, this might be a specific issue with the version of python that you are using. The auto_martini code is meant to be used with Python 2.7.X.

Best, Kiran