I have installed the Debian Stretch distribution Spyder3 and RDKit on my 64 bit Linux platform.

There were no warning or error messages during the istallation process.

However, when I attempted running a cookbook Python script (file attached), I got the following;

Python 3.5.3 (default, Jan 19 2017, 14:11:04)
Type "copyright", "credits" or "license" for more information.

IPython 6.1.0 -- An enhanced Interactive Python.

runfile('/home/comp/Apps/Python/untitled0.py', wdir='/home/comp/Apps/Python')
Traceback (most recent call last):

  File "<ipython-input-1-3842c59475d8>", line 1, in <module>
runfile('/home/comp/Apps/Python/untitled0.py', wdir='/home/comp/Apps/Python')

File "/usr/local/lib/python3.5/dist-packages/spyder/utils/site/sitecustomize.py", line 688, in runfile
    execfile(filename, namespace)

File "/usr/local/lib/python3.5/dist-packages/spyder/utils/site/sitecustomize.py", line 101, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "/home/comp/Apps/Python/untitled0.py", line 11, in <module>
    from rdkit import Chem

ImportError: No module named 'rdkit'

I would greatly appreciate pointers towards a solution to this problem.

Thanks in advance.

Stephen P. Molnar, Ph.D.                Life is a fuzzy set
www.molecular-modeling.net              Stochastic and multivariate
(614)312-7528 (c)
Skype: smolnar1
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
Created on Thu Aug 17 11:06:00 2017

@author: comp

""" contribution from Andrew Dalke """
import sys
from rdkit import Chem
from rdkit.Chem import AllChem

# Download this from http://pypi.python.org/pypi/futures
from concurrent import futures

# Download this from http://pypi.python.org/pypi/progressbar
import progressbar

## On my machine, it takes 39 seconds with 1 worker and 10 seconds with 4.
## 29.055u 0.102s 0:28.68 101.6%   0+0k 0+3io 0pf+0w

## With 4 threads it takes 11 seconds.
## 34.933u 0.188s 0:10.89 322.4%   0+0k 125+1io 0pf+0w

# (The "u"ser time includes time spend in the children processes.
#  The wall-clock time is 28.68 and 10.89 seconds, respectively.)

# This function is called in the subprocess.
# The parameters (molecule and number of conformers) are passed via a Python
def generateconformations(m, n):
    m = Chem.AddHs(m)
    ids=AllChem.EmbedMultipleConfs(m, numConfs=n)
    for id in ids:
        AllChem.UFFOptimizeMolecule(m, confId=id)
    # EmbedMultipleConfs returns a Boost-wrapped type which
    # cannot be pickled. Convert it to a Python list, which can.
    return m, list(ids)

smi_input_file, sdf_output_file = sys.argv[1:3]

n = int(sys.argv[3])

writer = Chem.SDWriter(sdf_output_file)

suppl = Chem.SmilesMolSupplier(smi_input_file, titleLine=False)

with futures.ProcessPoolExecutor(max_workers=max_workers) as executor:
    # Submit a set of asynchronous jobs
    jobs = []
    for mol in suppl:
        if mol:
            job = executor.submit(generateconformations, mol, n)

    widgets = ["Generating conformations; ", progressbar.Percentage(), " ",
               progressbar.ETA(), " ", progressbar.Bar()]
    pbar = progressbar.ProgressBar(widgets=widgets, maxval=len(jobs))
    for job in pbar(futures.as_completed(jobs)):
        for id in ids:
            writer.write(mol, confId=id)
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Rdkit-discuss mailing list

Reply via email to