auto_martini
auto_martini copied to clipboard
package rdkit and smile format
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))
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
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.
Boost.Python.ArgumentError Traceback (most recent call last)
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)
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
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
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
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 "
File "C:\git\auto_martini\auto_martini.py", line 35, in
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?
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