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
ADD COMMENT
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)
ADD REPLY
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?

ADD REPLY
0
Entering edit mode

And what about:

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.

ADD REPLY
0
Entering edit mode

same synthax error, pointing to the same place.

ADD REPLY
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)
ADD REPLY
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.

ADD REPLY
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...

ADD REPLY

Login before adding your answer.

Traffic: 2287 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6