I forgot to ask, how to retrieve residues within my selection to a list or something. Also, what does cmd.get_pdbstr do?
On Mon, May 1, 2017 at 10:54 PM, Ahmad Abdelzaher <underoath...@gmail.com> wrote: > OK I finally tried some of Jared suggestions, I'm not sure why > util.cnc doesn't work I get "NameError: name 'util' is not defined", > Again, I want to color by element, second option from the gui. Also > the script outputs black screenshots, nothing is there, so there is a > bug somewhere! I attached the script and pdb below. I would appreciate > your help. > > import __main__ > __main__.pymol_argv = ['pymol','-qc'] > import pymol > from pymol import cmd, stored > > pymol.finish_launching() > > residues = {'3s4m.pdb': {'102': 'THR', > '143': 'TYR', > '158': 'SER', > '166': 'TYR', > '173': 'TRP', > '181': 'SER', > '183': 'HIS', > '206': 'SER', > '95': 'TYR'}} > > for name, data in residues.items(): > for resnumber, resname in data.items(): > cmd.delete('all') > cmd.load(name, name) > bare_name = name.split('.')[0] > cmd.select('%s_%s%s' % (bare_name, resname, resnumber), 'byres > resn %s around 3' % resnumber) > #selee = cmd.get_pdbstr('%s' % name.split('.')[0]) > #print(selee) > cmd.dist('mysele_polar_conts','%s_%s%s' % (bare_name, resname, > resnumber),'all within 5 of %s_%s%s' % (name.split('.')[0], resname, > resnumber), quiet=1,mode=2,label=0,reset=1) > cmd.show_as('sticks', '%s_%s%s' % (bare_name, resname, resnumber)) > #util.cnc('%s' % name.split('.')[0]) > cmd.hide('everything', 'all and not %s_%s%s' % (bare_name, > resname, resnumber)) > cmd.zoom('%s_%s%s' % (bare_name, resname, resnumber), 5) > cmd.png('%s_%s%s.png' % (bare_name, resname, resnumber), ray=1) > > On Sat, Apr 29, 2017 at 3:34 PM, Ahmad Abdelzaher > <underoath...@gmail.com> wrote: >> Thanks Jared. A lot of fantastic tips there. Much appreciated. >> >> Regards. >> >> On Sat, Apr 29, 2017 at 6:03 AM, Jared Sampson >> <jared.samp...@columbia.edu> wrote: >>> Hi Ahmad - >>> >>> Here are a few suggestions: >>> >>> I'm still a bit new to the API so I'm not sure which commands to use. >>> At least I know I will start with cmd.select(string name, string >>> selection). >>> >>> How can I tell Pymol to: >>> >>> 1) look within a certain radius distance, and return resi's within >>> that distacne. >>> >>> >>> cmd.select('mysele', 'byres all within 5 of sele') >>> >>> See https://pymolwiki.org/index.php/Selection_Algebra for more handy >>> operators (`beyond`, `around`, `expand`, etc.) >>> >>> >>> 2) find all polar interactions within a distance, >>> >>> >>> You can use cmd.distance (https://pymolwiki.org/index.php/Distance), e.g. >>> (as done in the GUI by [A] > find > polar contacts...) >>> >>> cmd.dist("mysele_polar_conts","mysele","all within 5 of >>> mysele",quiet=1,mode=2,label=0,reset=1) >>> >>> or for a list of atoms, check out https://pymolwiki.org/index.php/Polarpairs >>> >>> >>> use sticks, >>> >>> >>> cmd.show('sticks', 'mysele') >>> >>> or to hide all other representations, >>> >>> cmd.show_as('sticks', 'mysele') >>> >>> >>> color by atom >>> >>> >>> util.cnc('mysele') >>> >>> I use this one all the time ("cnc" == color non-carbon). There is also >>> `util.cbc` == color by chain. >>> >>> >>> hide everything else >>> >>> >>> cmd.hide('everything', 'all and not mysele') >>> >>> >>> and output an image of the selections and interactions around it. >>> >>> >>> cmd.zoom('mysele', 5) >>> cmd.png('mysele.png', ray=1) >>> >>> >>> Please feel free to throw in any useful commands that can you might think is >>> helpful. >>> >>> >>> One useful trick to learn new commands is to open a log file (via `log_open >>> log.pml` or the File menu) and then perform the desired action in the GUI. >>> The log file will show the API commands that are called from the GUI. It >>> doesn't work for everything (e.g. wizards), but for most basic actions, it >>> should be helpful. At least it will give you the right command to look up >>> on the PyMOL wiki! >>> >>> Hope that helps. >>> >>> Cheers, >>> Jared >>> >>> >>> Your help is greatly appreciated. >>> >>> Regards. >>> >>> ------------------------------------------------------------------------------ >>> Check out the vibrant tech community on one of the world's most >>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot >>> _______________________________________________ >>> PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net) >>> Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users >>> Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net >>> >>> ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net) Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net