Question: save command output to a file in pymol
0
gravatar for ac.research
2.4 years ago by
ac.research10
ac.research10 wrote:

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

python pymol bioinformatics • 2.1k views
ADD COMMENTlink written 2.4 years ago by ac.research10

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 REPLYlink written 2.4 years ago by WouterDeCoster39k

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 REPLYlink modified 2.4 years ago by WouterDeCoster39k • written 2.4 years ago by ac.research10

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 REPLYlink modified 2.4 years ago • written 2.4 years ago by WouterDeCoster39k

same synthax error, pointing to the same place.

ADD REPLYlink modified 2.4 years ago by WouterDeCoster39k • written 2.4 years ago by ac.research10

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 REPLYlink written 2.4 years ago by WouterDeCoster39k

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 REPLYlink written 2.4 years ago by jrj.healey13k

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

ADD REPLYlink written 2.4 years ago by WouterDeCoster39k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1760 users visited in the last hour