I am writing scripts to semi-automate some of my Quantum Chemistry software and have encountered a problem that has me baffled. The two scripts have the same form, the only difference being the commands. One script works, the other bombs.

The script that works is:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
calc_pdbqt

Created on Mon May 13 09:50:54 2019

copyrignt (c) 2019 Stephen P. Molnar, Ph.D.  All rights reserved
"""

import subprocess
with open('ligand') as infile:
    ligand = infile.read().strip().split()
for nvar in ligand:
    command = ["./pythonsh", "./prepare_ligand4.py",
        "-l", nvar + ".mol2",
        "-o", nvar + ".pdbqt" ]
    proc = subprocess.Popen(command, stdout=subprocess.PIPE)
    out, err = proc.communicate()
    print(out)
    print(err)
    if proc.returncode:
        print ('Subprocess FAILED:', proc.command)


while the script that bombs is:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
calc_pdf4

Created on Mon May 13 09:50:54 2019

copyrignt (c) 2019 Stephen P. Molnar, Ph.D.  All rights reserved
"""

import subprocess
with open('ligand') as infile:
    ligand = infile.read().strip().split()
for nvar in ligand:
    command = ["./pythonsh", "./prepare_pdf4.py",
        "-l", nvar + ".pdbqt",
        "-ro", nvar + ".dpf" ]
    proc = subprocess.Popen(command, stdout=subprocess.PIPE)
    out, err = proc.communicate()
    print(out)
    print(err)
    if proc.returncode:
        print ('Subprocess FAILED:', proc.command)

The errors are:

runfile('/home/comp/Apps/Models/1-NerveAgents/Ligands/calc_pdf.py', wdir='/home/comp/Apps/Models/1-NerveAgents/Ligands')
b''
None
/sdc1/Apps/MGLTools2-1.1/bin/python: can't open file './prepare_pdf4.py': [Errno 2] No such file or directory
Traceback (most recent call last):

  File "<ipython-input-1-078e132fa938>", line 1, in <module>
runfile('/home/comp/Apps/Models/1-NerveAgents/Ligands/calc_pdf.py', wdir='/home/comp/Apps/Models/1-NerveAgents/Ligands')

File "/home/comp/Apps/miniconda3/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 824, in runfile
    execfile(filename, namespace)

File "/home/comp/Apps/miniconda3/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

File "/home/comp/Apps/Models/1-NerveAgents/Ligands/calc_pdf.py", line 23, in <module>
    print ('Subprocess FAILED:', proc.command)

AttributeError: 'Popen' object has no attribute 'command'

I have attached the two scripts that are called and a test input file.

Googling has not helped me to find a solution and I would greatly appreciate your assistance.

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

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to