Hi James, You can put Jared's commands (below the load command is replaced with the fetch command) in a bash script called cntRei.sh and pass the PDB-ID from the command line. The $1 is a place holder for the first argument on the command line, the PDB-ID in this case. This will enable easy reuse of the code with other PDB files.
#!/bin/bash pymol -cQkd " from pymol import cmd fetch $1, type=pdb, tmp sel = 'tmp and chain A and polymer.protein' print(len(set([(i.chain, i.resi, i.resn) for i in cmd.get_model(sel).atom]))) " e.g., chmod +x cntResi.sh # must do only once ./cntResi.sh 1lw9 164 Best regards, Blaine ________________________________________ From: James Starlight [jmsstarli...@gmail.com] Sent: Monday, June 24, 2019 10:58 AM To: Jared Sampson; pymol-users Subject: [EXTERNAL] Re: [PyMOL] counting number of standard amino acids in PDB hi Jared, I have tried to use your script putting it into my https://urldefense.proofpoint.com/v2/url?u=http-3A__test.sh&d=DwIGaQ&c=VjzId-SM5S6aVB_cCGQ0d3uo9UfKByQ3sI6Audoy6dY&r=k0gMbcsdOcdbPUNV5tW66KQSZfXL0ewVDPVBp7tqbks&m=irGpLBGjJRRHhL2OEINOt-E-XHmSJzgTxLiXFPPM7yE&s=oiLydhz78vYkVUOODOTN_nOJGam-H3IZM5CdrNYZLP0&e= script I only changed the selection statement in sel = 'tmp and polymer.protein' instead of sel = 'tmp and chain A and polymer.protein' since in my protein there is no chains assigned pdb="./NpXynWT_apo_340K_MD_multi_0434.pdb" pymol -c -d " from pymol import cmd load ${pdb}, tmp sel = 'tmp and polymer.protein' print(len(set([(i.chain, i.resi, i.resn) for i in cmd.get_model(sel).atom]))) " execution of that sh script gave me the following error PyMOL(TM) Molecular Graphics System, Version https://urldefense.proofpoint.com/v2/url?u=http-3A__1.7.2.1&d=DwIGaQ&c=VjzId-SM5S6aVB_cCGQ0d3uo9UfKByQ3sI6Audoy6dY&r=k0gMbcsdOcdbPUNV5tW66KQSZfXL0ewVDPVBp7tqbks&m=irGpLBGjJRRHhL2OEINOt-E-XHmSJzgTxLiXFPPM7yE&s=OYqhYixQ0ZYt700enMnc7UcnEeNlBNoQh1WLCOg2d2k&e= . 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 "https://urldefense.proofpoint.com/v2/url?u=http-3A__www.pymol.org&d=DwIGaQ&c=VjzId-SM5S6aVB_cCGQ0d3uo9UfKByQ3sI6Audoy6dY&r=k0gMbcsdOcdbPUNV5tW66KQSZfXL0ewVDPVBp7tqbks&m=irGpLBGjJRRHhL2OEINOt-E-XHmSJzgTxLiXFPPM7yE&s=bx6O9IruCWuQD_P48i0VkZXzj_zRzHF7kE7jzIgHMEs&e= ". 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>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.protein' PyMOL>print(len(set([(i.chain, i.resi, i.resn) for i in cmd.get_model(sel).atom]))) Selector-Error: Invalid selection name "polymer.protein". ( tmp and polymer.protein )<-- PyMOL: normal program termination. пн, 24 июн. 2019 г. в 17:44, Jared Sampson <jared.samp...@columbia.edu>: > > Hi James - > > You can give multiple commands by leaving the quote open as you did on the > first line (see Thomas' post from a day or two ago), but the `print` > statement, even though it is valid Python 2, will not work across line breaks > as written unless inside a `python` / `python end` block (also unless you are > using Python 2!). I would suggest performing the print operation on a single > line. You'll also need to load your model and specify the selection using > PyMOL selection syntax such that it includes only protein residues (e.g. > polymer.protein). For example, for my PyMOL running Python 3.7 (which > requires using the `print()` function, i.e. with parentheses), the following > command works: > > ``` > pymol -cQkd " > from pymol import cmd > load my_structure.pdb, tmp > sel = 'tmp and chain A and polymer.protein' > print(len(set([(i.chain, i.resi, i.resn) for i in cmd.get_model(sel).atom]))) > " > ``` > > Here I put in the -Q option which suppresses all of PyMOL's normal output, as > well as -k, which prevents it from loading the .pymolrc file (for speed, > mostly). Also note the quotes in the `sel` variable assignment must be > single quotes to avoid closing the shell string. > > Hope that helps. > > Cheers, > Jared > > > > > On June 24, 2019 at 10:25:22 AM, James Starlight (jmsstarli...@gmail.com) > wrote: > > Thank you, Jared! > how do you think would it be possible to run this command from no-gui pymol? > > pymol -c -d " > from pymol import cmd > print len( set( [(i.chain,i.resi,i.resn) for i in > cmd.get_model(selection).atom] ) ) > " > > ? > > пн, 24 июн. 2019 г. в 16:17, Jared Sampson <jared.samp...@columbia.edu>: > > > > Hi James - > > > > Do any of the options from this previous BB discussion help? > > > > https://urldefense.proofpoint.com/v2/url?u=https-3A__sourceforge.net_p_pymol_mailman_message_28466955_&d=DwIGaQ&c=VjzId-SM5S6aVB_cCGQ0d3uo9UfKByQ3sI6Audoy6dY&r=k0gMbcsdOcdbPUNV5tW66KQSZfXL0ewVDPVBp7tqbks&m=irGpLBGjJRRHhL2OEINOt-E-XHmSJzgTxLiXFPPM7yE&s=6BbgPaZIB1a1vBmisO8u-F55457MjYKaXeQYpaEoyRI&e= > > > > Cheers, > > Jared > > > > > > On June 24, 2019 at 8:13:47 AM, James Starlight (jmsstarli...@gmail.com) > > wrote: > > > > Dear Pymol Users, > > > > that is not very related to pymol question but however probably it can > > be solved via pymol as well ;-) > > > > I am looking for some script (e.g. via running in pymol no-gui), which > > will count the number of standard amino acid residues in the given > > PDB. E.g. for particular pdb consisted of 9 residues complexed with > > part of the ligand I need to print the value of 9 (the end value of > > 6th column before TER) > > > > ATOM 1 N MET A 1 24.950 5.224 -5.601 1.00 30.01 N > > ATOM 2 CA MET A 1 24.822 3.740 -5.655 1.00 30.25 C > > ATOM 3 C MET A 1 23.719 3.091 -4.771 1.00 28.98 C > > ATOM 4 O MET A 1 23.417 1.937 -4.989 1.00 28.27 O > > ATOM 5 CB MET A 1 26.187 3.043 -5.448 1.00 31.03 C > > ATOM 6 CG MET A 1 26.869 3.182 -4.084 1.00 32.21 C > > ATOM 7 SD MET A 1 28.713 3.095 -4.227 1.00 34.63 S > > ATOM 8 CE MET A 1 29.205 3.597 -2.564 1.00 33.32 C > > ATOM 9 N LYS A 2 23.111 3.804 -3.818 1.00 27.78 N > > ATOM 10 CA LYS A 2 21.869 3.310 -3.188 1.00 27.21 C > > ATOM 11 C LYS A 2 20.671 4.237 -3.440 1.00 26.27 C > > ATOM 12 O LYS A 2 20.787 5.445 -3.300 1.00 25.96 O > > ATOM 13 CB LYS A 2 22.027 3.091 -1.684 1.00 27.32 C > > ATOM 14 CG LYS A 2 20.820 2.362 -1.065 1.00 27.75 C > > ATOM 15 CD LYS A 2 20.953 2.147 0.439 1.00 28.18 C > > ATOM 16 CE LYS A 2 19.928 1.130 0.938 1.00 29.30 C > > ATOM 17 NZ LYS A 2 20.083 0.809 2.386 1.00 30.36 N1+ > > ATOM 18 N PHE A 3 19.528 3.658 -3.808 1.00 24.92 N > > ATOM 19 CA PHE A 3 18.306 4.421 -4.054 1.00 24.39 C > > ATOM 20 C PHE A 3 17.161 3.823 -3.246 1.00 24.12 C > > ATOM 21 O PHE A 3 16.991 2.597 -3.202 1.00 23.77 O > > ATOM 22 CB PHE A 3 17.940 4.222 -5.535 1.00 23.83 C > > ATOM 23 CG PHE A 3 19.003 4.968 -6.434 1.00 23.81 C > > ATOM 24 CD1 PHE A 3 19.132 6.337 -6.585 1.00 23.27 C > > ATOM 25 CD2 PHE A 3 19.876 4.135 -7.129 1.00 23.46 C > > ATOM 26 CE1 PHE A 3 20.110 6.868 -7.412 1.00 23.22 C > > ATOM 27 CE2 PHE A 3 20.862 4.660 -7.952 1.00 23.19 C > > ATOM 28 CZ PHE A 3 20.975 6.027 -8.102 1.00 23.07 C > > ATOM 29 N THR A 4 16.374 4.691 -2.624 1.00 23.47 N > > ATOM 30 CA THR A 4 15.326 4.278 -1.704 1.00 23.33 C > > ATOM 31 C THR A 4 13.946 4.720 -2.188 1.00 22.67 C > > ATOM 32 O THR A 4 13.779 5.810 -2.726 1.00 22.24 O > > ATOM 33 CB THR A 4 15.584 4.875 -0.295 1.00 23.52 C > > ATOM 34 CG2 THR A 4 14.441 4.560 0.650 1.00 23.80 C > > ATOM 35 OG1 THR A 4 16.798 4.328 0.245 1.00 23.98 O > > ATOM 36 N VAL A 5 12.955 3.866 -1.980 1.00 22.25 N > > ATOM 37 CA VAL A 5 11.577 4.216 -2.276 1.00 22.46 C > > ATOM 38 C VAL A 5 10.685 4.011 -1.038 1.00 22.44 C > > ATOM 39 O VAL A 5 10.951 3.145 -0.201 1.00 21.37 O > > ATOM 40 CB VAL A 5 11.033 3.456 -3.533 1.00 21.81 C > > ATOM 41 CG1 VAL A 5 11.786 3.902 -4.782 1.00 20.47 C > > ATOM 42 CG2 VAL A 5 11.127 1.940 -3.368 1.00 21.55 C > > ATOM 43 N GLY A 6 9.660 4.845 -0.908 1.00 23.27 N > > ATOM 44 CA GLY A 6 8.676 4.684 0.154 1.00 24.59 C > > ATOM 45 C GLY A 6 8.727 5.731 1.249 1.00 25.69 C > > ATOM 46 O GLY A 6 7.834 5.767 2.101 1.00 26.30 O > > ATOM 47 N ASN A 7 9.764 6.568 1.261 1.00 26.66 N > > ATOM 48 CA ASN A 7 9.775 7.728 2.155 1.00 27.39 C > > ATOM 49 C ASN A 7 10.165 9.028 1.436 1.00 27.80 C > > ATOM 50 O ASN A 7 11.263 9.569 1.622 1.00 28.37 O > > ATOM 51 CB ASN A 7 10.619 7.470 3.421 1.00 28.21 C > > ATOM 52 CG ASN A 7 12.089 7.278 3.127 1.00 29.85 C > > ATOM 53 ND2 ASN A 7 12.938 7.964 3.897 1.00 32.41 N > > ATOM 54 OD1 ASN A 7 12.466 6.525 2.229 1.00 32.61 O > > ATOM 55 N GLY A 8 9.232 9.521 0.622 1.00 27.41 N > > ATOM 56 CA GLY A 8 9.422 10.752 -0.139 1.00 27.40 C > > ATOM 57 C GLY A 8 9.309 10.498 -1.629 1.00 27.35 C > > ATOM 58 O GLY A 8 8.449 11.071 -2.303 1.00 27.93 O > > ATOM 59 N GLN A 9 10.178 9.630 -2.136 1.00 26.80 N > > ATOM 60 CA GLN A 9 10.215 9.294 -3.552 1.00 26.37 C > > ATOM 61 C GLN A 9 9.834 7.833 -3.736 1.00 25.75 C > > ATOM 62 O GLN A 9 10.308 6.970 -2.997 1.00 25.25 O > > ATOM 63 CB GLN A 9 11.622 9.522 -4.115 1.00 26.74 C > > ATOM 64 CG GLN A 9 12.197 10.924 -3.899 1.00 27.40 C > > ATOM 65 CD GLN A 9 11.327 12.028 -4.475 1.00 29.17 C > > ATOM 66 NE2 GLN A 9 10.896 11.863 -5.726 1.00 29.46 N > > ATOM 67 OE1 GLN A 9 11.048 13.025 -3.800 1.00 31.02 O > > TER > > ATOM 1719 C1 0XB B 220 6.613 3.931 -16.928 1.00 11.35 C > > ATOM 1720 C2 0XB B 220 7.042 5.128 -16.070 1.00 14.60 C > > ATOM 1721 O2 0XB B 220 6.347 5.144 -14.862 1.00 15.67 O > > ATOM 1722 C3 0XB B 220 6.767 6.445 -16.786 1.00 17.91 C > > ATOM 1723 O3 0XB B 220 7.304 7.499 -15.962 1.00 20.75 O > > ATOM 1724 C4 0XB B 220 7.275 6.470 -18.142 1.00 17.97 C > > ATOM 1725 O4 0XB B 220 6.793 7.605 -18.882 1.00 21.45 O > > ATOM 1726 C5 0XB B 220 6.856 5.264 -18.860 1.00 15.05 C > > ATOM 1727 O5 0XB B 220 7.286 4.049 -18.182 1.00 12.43 O > > > > Thanks in advance! > > > > > > _______________________________________________ > > PyMOL-users mailing list > > Archives: > > https://urldefense.proofpoint.com/v2/url?u=http-3A__www.mail-2Darchive.com_pymol-2Dusers-40lists.sourceforge.net&d=DwIGaQ&c=VjzId-SM5S6aVB_cCGQ0d3uo9UfKByQ3sI6Audoy6dY&r=k0gMbcsdOcdbPUNV5tW66KQSZfXL0ewVDPVBp7tqbks&m=irGpLBGjJRRHhL2OEINOt-E-XHmSJzgTxLiXFPPM7yE&s=SuXKvz3fbyNlH5I-uOa5JlW2Wz4tKjiRiwjBVjRlnW8&e= > > Unsubscribe: > > https://urldefense.proofpoint.com/v2/url?u=https-3A__sourceforge.net_projects_pymol_lists_pymol-2Dusers_unsubscribe&d=DwIGaQ&c=VjzId-SM5S6aVB_cCGQ0d3uo9UfKByQ3sI6Audoy6dY&r=k0gMbcsdOcdbPUNV5tW66KQSZfXL0ewVDPVBp7tqbks&m=irGpLBGjJRRHhL2OEINOt-E-XHmSJzgTxLiXFPPM7yE&s=dNlAyYELmzzML6T0AOaHXC2H3071uuwHMvy3xKTLSIY&e= _______________________________________________ PyMOL-users mailing list Archives: https://urldefense.proofpoint.com/v2/url?u=http-3A__www.mail-2Darchive.com_pymol-2Dusers-40lists.sourceforge.net&d=DwIGaQ&c=VjzId-SM5S6aVB_cCGQ0d3uo9UfKByQ3sI6Audoy6dY&r=k0gMbcsdOcdbPUNV5tW66KQSZfXL0ewVDPVBp7tqbks&m=irGpLBGjJRRHhL2OEINOt-E-XHmSJzgTxLiXFPPM7yE&s=SuXKvz3fbyNlH5I-uOa5JlW2Wz4tKjiRiwjBVjRlnW8&e= Unsubscribe: https://urldefense.proofpoint.com/v2/url?u=https-3A__sourceforge.net_projects_pymol_lists_pymol-2Dusers_unsubscribe&d=DwIGaQ&c=VjzId-SM5S6aVB_cCGQ0d3uo9UfKByQ3sI6Audoy6dY&r=k0gMbcsdOcdbPUNV5tW66KQSZfXL0ewVDPVBp7tqbks&m=irGpLBGjJRRHhL2OEINOt-E-XHmSJzgTxLiXFPPM7yE&s=dNlAyYELmzzML6T0AOaHXC2H3071uuwHMvy3xKTLSIY&e= _______________________________________________ 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