save command output to a file in pymol
0
0
Entering edit mode
4.8 years ago
ac.research ▴ 10

People I need your help,

I have the following command:

iterate n. CA, print resi + ':' + ss


I use this command in pymol to print out each residue number and its corresponding secondary structure. The command prints out the result in pymol itself.

My question is: How can I save the output from this command into a file?

AC Research

pymol bioinformatics python • 4.6k views
0
Entering edit mode

I'm not familiar with pymol, but I naively expect it's a python module you are running in the standard python interpreter (correct me if I'm wrong).
In that case, you could try the following:

with open('myoutputfile.txt', 'w') as output:
output.write(iterate n. CA, print resi + ':' + ss)

0
Entering edit mode

Well i think we are in the right direction, but not there yet.

I do get a syntax error regarding expressing the command correctly:

with open('myoutputfile.txt', 'w') as output: output.write(iterate n. CA, print resi + ':' + ss)                                                                                                               ^ SyntaxError: invalid syntax

is there a way to write the command in output.write() better?

0
Entering edit mode

with open('myoutputfile.txt', 'w') as output:
output.write(iterate n. CA + '\n' + resi + ':' + ss)


I've no idea what those python objects are, but we'll get there eventually I guess.

0
Entering edit mode

same synthax error, pointing to the same place.

0
Entering edit mode

More guess-work, perhaps someone with knowledge of pymol will come along soon

with open('myoutputfile.txt', 'w') as output:
iterate n. CA
output.write(resi + ':' + ss)

0
Entering edit mode

If you're using PyMol GUI, I don't think the above will work. If you imported it as a module in python itself that could work I believe.

I personally WAY prefer USCF Chimera which has a Python interpreter propely baked in, and supports scripting etc.

0
Entering edit mode

Given the obtained SynthaxError it looks like a standard python interpreter to me, but I don't know anything about the GUI...