Thank so much Jared! So here is modified script:
#!/bin/bash pdb="./NpXynWT_apo_340K_MD_multi_0434.pdb" LENGTH="$(pymol -cQ -d " from pymol import cmd load ${pdb}, tmp sel = 'tmp and polymer' print(len(set([(i.chain, i.resi, i.resn) for i in cmd.get_model(sel).atom]))) ")" echo $LENGTH I guess it's a problem with the -cQ flag because without it your script gives me the full output, while I echoes the variable: PyMOL(TM) Molecular Graphics System, Version 1.7.2.1. Copyright (c) Schrodinger, LLC. All Rights Reserved. Created by Warren L. DeLano, Ph.D. PyMOL is user-supported open-source software. Although some versions are freely available, PyMOL is not in the public domain. If PyMOL is helpful in your work or study, then please volunteer support for our ongoing efforts to create open and affordable scientific software by purchasing a PyMOL Maintenance and/or Support subscription. More information can be found at "http://www.pymol.org". Enter "help" for a list of commands. Enter "help <command-name>" for information on a specific command. Hit ESC anytime to toggle between text and graphics. Command mode. No graphics front end. Detected 20 CPU cores. Enabled multithreaded rendering. PyMOL> PyMOL>from pymol import cmd PyMOL>load ./NpXynWT_apo_340K_MD_multi_0434.pdb, tmp CmdLoad: "./NpXynWT_apo_340K_MD_multi_0434.pdb" loaded as "tmp". PyMOL>sel = 'tmp and polymer' PyMOL>print(len(set([(i.chain, i.resi, i.resn) for i in cmd.get_model(sel).atom]))) 219 PyMOL: normal program termination. however with -cQ it gives me nothing :-) Hey Blaine, your script is very usefull but it does not work in my case. 1) fetch command gives me an error (which is not the case of "load" probably because I have outdated pymol). 2) I need to load pdbs inside of my shell script, meaning that I am looping a folder by bash routine and use it then with pymol to measure the length of PDB and save it as the variable (in bash!!), which is expected to be used on the next step... james пн, 24 июн. 2019 г. в 18:53, Jared Sampson <jared.samp...@columbia.edu>: > > Hi James - > > Try this, assigning to new variable LENGTH by using -Q flag to suppress other > output, and running in a subshell (untested, and assuming Bash): > > ``` > pdb="./NpXynWT_apo_340K_MD_multi_0434.pdb" > LENGTH=$(pymol -cQ -d " > from pymol import cmd > load ${pdb}, tmp > sel = 'tmp and polymer' > print(len(set([(i.chain, i.resi, i.resn) for i in cmd.get_model(sel).atom]))) > ") > ``` > > Hopefully that works, or at least gives you an idea of how it might be done. > > Best, > Jared > > > On June 24, 2019 at 12:08:07 PM, James Starlight (jmsstarli...@gmail.com) > wrote: > > pdb="./NpXynWT_apo_340K_MD_multi_0434.pdb" > pymol -c -d " > from pymol import cmd > load ${pdb}, tmp > sel = 'tmp and polymer' > print(len(set([(i.chain, i.resi, i.resn) for i in cmd.get_model(sel).atom]))) > " _______________________________________________ PyMOL-users mailing list Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net Unsubscribe: https://sourceforge.net/projects/pymol/lists/pymol-users/unsubscribe