I have been trying to get (through the pymolpy3 package happy to change) the commands and output from the internal console saved in a txt file. So far, I can see the output generated in the console when I am running the script but no output is saved.
For reference
Uimport pymolPy3
import sys
# Redirect stdout to a log file
log_file_path = r'C:\path\logs.log'
sys.stdout = open(log_file_path, 'w')
# Launch PyMOL without the GUI
pm = pymolPy3.pymolPy3(0)
# Load structure
pdb = '4PXF'
# Fetch the PDB file for your protein
pm(f"fetch {pdb}, async=0")
# Select and show only existing residues (no missing residues)
pm("select existing_residues, resi first_existing_residue-last_existing_residue")
pm("show sticks, existing_residues")
# Get the amino acid sequence of existing residues
pm("iterate_state 1, existing_residues and name CA, resn")
#Save the session
# Quit PyMOL
pm("quit")
# Close the log file
sys.stdout.close()
It returns an empty log file, whereas the console output is
PyMOL(TM) 2.5.5 - Incentive Product
Copyright (C) Schrodinger, LLC
This Executable Build integrates and extends Open-Source PyMOL.
Detected 12 CPU cores. Enabled multithreaded rendering.
PyMOL>fetch 4PXF, async=0
TITLE Crystal structure of the active G-protein-coupled receptor opsin in complex with the finger-loop peptide derived from the full-length arrestin-1
ExecutiveLoad-Detail: Detected mmCIF
CmdLoad: ".\4pxf.cif" loaded as "4PXF".
PyMOL>select existing_residues, resi first_existing_residue-last_existing_residue
Selector: selection "existing_residues" defined with 2844 atoms.
PyMOL>show sticks, existing_residues
PyMOL>iterate_state 1, existing_residues and name CA, resn
'ASN'
'VAL'
'GLY'
'TRP'
'SER'
'ARG'
...
IterateState: iterated over 334 atom coordinate states.
As you can guess I am more interested in the 3 letter combinations.
Any help is welcome, as I have been stuck in this stage for a while now. Thank you in advance!
PS. The previous stackoverflow post on something similar does not work in displaying isnide the txt the 3 letter amino acid residues
I have tried different system logs, running the automation scripts through cmd and straight into a txt file through bash commands. The previous stackoverflow answer does not work in my case
without launching the GUI I can save the list of aas with:
saves
log_file.txt
file:not able to save all the console output (and there is no console here !!) using How can I save command outputs in PyMOL to a txt file accepted answer
Same result using :
with output file
log.txt
:Again not able to save all the console output (and there is no console here !!) using How can I save command outputs in PyMOL to a txt file accepted answer