ccsb-scripps / AutoDock-Vina

AutoDock Vina
http://vina.scripps.edu
Apache License 2.0
562 stars 199 forks source link

redirecting log file in the python script #213

Closed SoodabehGhaffari closed 1 year ago

SoodabehGhaffari commented 1 year ago

Hello, I am using the python script to do docking and I need the binding energy which outputs to the terminal to be saved to a file. One way is to do python dock.py > log.out, but I was wondering if I can get the log file by changing something in the python script. The python script that I am using is the same as first_example.py in your github.

Thank you

rwxayheee commented 1 year ago

Hi @SoodabehGhaffari, One possible way is to run "python first_example.py" as a subprocess in a parent python script. The parent script:

import subprocess
with open('myfile.log', "w") as outfile:
    subprocess.run(["python","first_example.py"], stdout=outfile)
diogomart commented 1 year ago

@SoodabehGhaffari I believe that all information in the STDOUT (a.k.a log.out) is also available directly from Python.