Re: [PyMOL] Feature Requests/Ideas (Sean Law)
Hi! 1) Ever since I have used the ray function in PyMOL i ran into problems creating the right resolution/size of the ray trace images for posters/papers. I know its just a matter of x/y pixel settings, but every time i had to look it up again. However i wrote a little script embedded in the BNI-Tools plugin, where one easily can set the size and resolution of the ray trace image. Of course it would be nice to have VG, but maybe it is a "meantime solution". Load the BNI-Tools install it as plug-in and get to Plugin-->BNI PyMOLl Tools -->Create --> ray -->set and input the width-size in millimetre (mm) and the resolution (in dpi) you want to have. (or you can select a pre-set) 3) I have no solution for MD trajectories but BNI-Tools can also be used to import multiple pdb files (like snapshots) into the same object using different states. (The object is named like the first read in) Maybe it is useful to you. BNI PyMOLl Tools --> Load Files --> Multiple Files into states There is currently no user guide for BNI-Tools but most of the BNI-Tools commands act on the (sele) selection. If you want to give BNI-Tools a try download it from http://sourceforge.net/projects/bni-tools/ and experiment with it. Its not a completely bug-free version, so any bug-reports and suggestions are welcome. Regards, Georg -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ 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
Re: [PyMOL] Feature Requests/Ideas (Sean Law)
Georg, Thanks for the reply. My comments are below. > 1) Ever since I have used the ray function in PyMOL i ran into problems > creating the right resolution/size of the ray trace images for > posters/papers. I know its just a matter of x/y pixel settings, but > every time i had to look it up again. However i wrote a little script > embedded in the BNI-Tools plugin, where one easily can set the size and > resolution of the ray trace image. Of course it would be nice to have > VG, but maybe it is a "meantime solution". > Load the BNI-Tools install it as plug-in and get to Plugin-->BNI PyMOLl > Tools -->Create --> ray -->set and input the width-size in millimetre > (mm) and the resolution (in dpi) you want to have. (or you can select a > pre-set) So you'd like to see something like: ray 10cm, 20cm, dpi=300? ray 2.5in, 5in, dpi=300? > 3) I have no solution for MD trajectories but BNI-Tools can also be used > to import multiple pdb files (like snapshots) into the same object > using different states. (The object is named like the first read in) > Maybe it is useful to you. > BNI PyMOLl Tools --> Load Files --> Multiple Files into states This is easily achieved using a mixture of Python and the PyMOL API. Let's assume you have a 100 files in a directory, all trajectory snapshots. To load all 100 objects into one PyMOL object, just do: import glob for x in glob.glob("yourDirectoryName/*.pdb"): cmd.load(x, "myMultiStateObject") PyMOL know that if you load more than one structure into the same object name, to make it a multistate object. -- Jason -- Jason Vertrees, PhD PyMOL Product Manager Schrodinger, LLC (e) jason.vertr...@schrodinger.com (o) +1 (603) 374-7120 -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ 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
Re: [PyMOL] Feature Requests/Ideas (Sean Law)
Hi, > ray 10cm, 20cm, dpi=300? > ray 2.5in, 5in, dpi=300? I'd slightly modify that to read: ray 10,10,units=cm,resolution=300 where units can be pixels (default), cm, inches, meters, yards, lightyears... Cheers, Tsjerk -- Tsjerk A. Wassenaar, Ph.D. Computational Chemist Medicinal Chemist Neuropharmacologist -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ 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
Re: [PyMOL] Feature Requests/Ideas (Sean Law)
Several more votes for one of these from lots of people in my lab. On Wed, Jan 20, 2010 at 3:54 PM, Tsjerk Wassenaar wrote: > Hi, > > > ray 10cm, 20cm, dpi=300? > > ray 2.5in, 5in, dpi=300? > > I'd slightly modify that to read: > > ray 10,10,units=cm,resolution=300 > > where units can be pixels (default), cm, inches, meters, yards, > lightyears... > > Cheers, > > Tsjerk > > > -- > Tsjerk A. Wassenaar, Ph.D. > > Computational Chemist > Medicinal Chemist > Neuropharmacologist > > > -- > Throughout its 18-year history, RSA Conference consistently attracts the > world's best and brightest in the field, creating opportunities for > Conference > attendees to learn about information security's most important issues > through > interactions with peers, luminaries and emerging and established companies. > http://p.sf.net/sfu/rsaconf-dev2dev > ___ > 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 > -- Michael Lerner, Ph.D. IRTA Postdoctoral Fellow Laboratory of Computational Biology NIH/NHLBI 5635 Fishers Lane, Room T909, MSC 9314 Rockville, MD 20852 (UPS/FedEx/Reality) Bethesda MD 20892-9314 (USPS) -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev___ 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
Re: [PyMOL] Feature Requests/Ideas (Sean Law)
That seems like a modification that makes it less flexible. Now I can't do: ray 2.5in, 20cm, dpi=300 Don't ask me why I might want to use two different units, I just don't see a reason to make it so I cannot. I'm frequently surprised by my desires. And resolution is inconsistent with the png function, and less precise. I don't know what units I have with the resolution argument. One of my high ranking complaints about pymol has been certain inconsistencies in the api, so that's actually what I care about more. (Maybe I should write those up, but fixing these things is always hard because backwards compatibility kind of matters). Also, it would be nice to have this in the png function as well. As for units, I thought it would be nice to read the file used by the units unix type function (located at /usr/share/units.dat on my linux machine, /usr/share/misc/units.lib). Maybe ship with and support the mac/bsd one since that should be friendly with the pymol license and check for the system one at runtime. That way, if new units are ever invented, we get some (semi-)automatic support. -David - Original Message > From: Tsjerk Wassenaar > To: Jason Vertrees > Cc: Georg Steinkellner ; > pymol-users@lists.sourceforge.net > Sent: Wed, January 20, 2010 3:54:25 PM > Subject: Re: [PyMOL] Feature Requests/Ideas (Sean Law) > > Hi, > > > ray 10cm, 20cm, dpi=300? > > ray 2.5in, 5in, dpi=300? > > I'd slightly modify that to read: > > ray 10,10,units=cm,resolution=300 > > where units can be pixels (default), cm, inches, meters, yards, lightyears... > > Cheers, > > Tsjerk > > > -- > Tsjerk A. Wassenaar, Ph.D. > > Computational Chemist > Medicinal Chemist > Neuropharmacologist > > -- > Throughout its 18-year history, RSA Conference consistently attracts the > world's best and brightest in the field, creating opportunities for Conference > attendees to learn about information security's most important issues through > interactions with peers, luminaries and emerging and established companies. > http://p.sf.net/sfu/rsaconf-dev2dev > ___ > 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 -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ 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
Re: [PyMOL] Feature Requests/Ideas (Sean Law)
Hi David, Sorry to be more on the programmatic than on your pragmatic side. > That seems like a modification that makes it less flexible. Now I can't do: > > ray 2.5in, 20cm, dpi=300 > Okay, let's say you could do: ray 2.5, 20, units=(in,cm), resolution=300 providing either a single string, or a tuple of strings to indicate the units. The reason for preferring that for me is the pymol/python API. The x and y size should be floats, not strings, in order to make the API intuitive and allow direct invocation in a script, without doing something like cmd.ray("%s"%xsize+xunit,"%s"%ysize+yunit,...) You'd definitely want: xsize = calc_size(arguments) ysize = calc_size(arguments) cmd.ray(xsize,ysize,units="cm",...) > Don't ask me why I might want to use two different units, I just don't see a > reason to make it so I cannot. I'm frequently surprised by my desires. I'm also surprised by your anticipation on your desires :) > And resolution is inconsistent with the png function, and less precise. I > don't know what units I have with the resolution argument. One of my high > ranking complaints about pymol has been certain inconsistencies in the api, > so that's actually what I care about more. (Maybe I should write those up, > but fixing these things is always hard because backwards compatibility kind > of matters). Please indicate the API inconsistencies. Solving inconsistencies should be on everyone's wish list. > Also, it would be nice to have this in the png function as well. It's not possible to set both size and resolution as the png argument merely writes out the image there is. You could either control the resolution, adapting the size, or control the size, adapting the resolution. Cheers, Tsjerk -- Tsjerk A. Wassenaar, Ph.D. Computational Chemist Medicinal Chemist Neuropharmacologist -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ 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
Re: [PyMOL] Feature Requests/Ideas (Sean Law)
Hi David, > Doesn't png already take a size and resolution argument? > cmd.png(string filename, int width, int height, float dpi, int ray, int > quiet) > > so, now I do cmd.png('1acb.png', 5,4,units=in, dpi=300) ? Errm, that only makes sense if the viewport itself is resampled somehow when you don't do raytracing, but I don't think it is. More probable, one of both, size or resolution, will be disregarded. Consider that your viewport has a fixed number of pixels on x and on y (the same goes for a raytraced image). Now to write that to an image, you can say "I want to have so many pixels per inch" and see what size you end up with, or you can say, "I want to have it this large" and see what resolution you get. If you are demanding a specific size and resolution, there's no other option than to construct the image again (adapt viewport/raytrace). I hope this makes it clear. Cheers, Tsjerk -- Tsjerk A. Wassenaar, Ph.D. Computational Chemist Medicinal Chemist Neuropharmacologist -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ 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
Re: [PyMOL] Feature Requests/Ideas (Sean Law)
On Thu, Jan 21, 2010 at 9:46 AM, Tsjerk Wassenaar wrote: > Errm, that only makes sense if the viewport itself is resampled > somehow when you don't do raytracing, but I don't think it is. > I'm pretty sure it is resampled when you specify a width or height. All this below is with 1.2r1 incentive executable, but I'm pretty sure this also occurs on my trunk builds as well. Maybe this is some new behavior? I do: viewport 600,400 png out.png, 800,800 The viewport now looks the way it does if I did ray 800,800 (except not ray traced) and I get an 800x800 picture. Another example: png out.png, 1,1 Scene-Warning: Maximum OpenGL viewport dimension exceeded. ScenePNG: wrote 8192x8192 pixel image to file "out.png". PyMol seems to be saying to me, "I'm sampling an OpenGL viewport with the dimensions you specified to create this png" -David -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev___ 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
Re: [PyMOL] Feature Requests/Ideas (Sean Law)
Hi, So what happens if you try it after ray-tracing? T. On Thu, Jan 21, 2010 at 5:17 PM, David Hall wrote: > On Thu, Jan 21, 2010 at 9:46 AM, Tsjerk Wassenaar wrote: >> >> Errm, that only makes sense if the viewport itself is resampled >> somehow when you don't do raytracing, but I don't think it is. > > I'm pretty sure it is resampled when you specify a width or height. All > this below is with 1.2r1 incentive executable, but I'm pretty sure this also > occurs on my trunk builds as well. Maybe this is some new behavior? > > I do: > viewport 600,400 > png out.png, 800,800 > > The viewport now looks the way it does if I did ray 800,800 (except not ray > traced) and I get an 800x800 picture. > > Another example: > png out.png, 1,1 > Scene-Warning: Maximum OpenGL viewport dimension exceeded. ScenePNG: wrote > 8192x8192 pixel image to file "out.png". > > PyMol seems to be saying to me, "I'm sampling an OpenGL viewport with the > dimensions you specified to create this png" > > -David > -- Tsjerk A. Wassenaar, Ph.D. Computational Chemist Medicinal Chemist Neuropharmacologist -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ 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
Re: [PyMOL] Feature Requests/Ideas (Sean Law)
Don't forget the PNG command also takes a "ray" argument: png fileName, height=X, width=Y, ray=1, dpi=300 PyMOL will resample in that case. You always get a ray traced file from that command. If you do: ray 300, 300 png fileName.ong, height=1000, width=1000 You get a 1000,1000 non-ray traced image. -- J On Thu, Jan 21, 2010 at 11:32 AM, Tsjerk Wassenaar wrote: > Hi, > > So what happens if you try it after ray-tracing? > > T. > > On Thu, Jan 21, 2010 at 5:17 PM, David Hall wrote: >> On Thu, Jan 21, 2010 at 9:46 AM, Tsjerk Wassenaar wrote: >>> >>> Errm, that only makes sense if the viewport itself is resampled >>> somehow when you don't do raytracing, but I don't think it is. >> >> I'm pretty sure it is resampled when you specify a width or height. All >> this below is with 1.2r1 incentive executable, but I'm pretty sure this also >> occurs on my trunk builds as well. Maybe this is some new behavior? >> >> I do: >> viewport 600,400 >> png out.png, 800,800 >> >> The viewport now looks the way it does if I did ray 800,800 (except not ray >> traced) and I get an 800x800 picture. >> >> Another example: >> png out.png, 1,1 >> Scene-Warning: Maximum OpenGL viewport dimension exceeded. ScenePNG: wrote >> 8192x8192 pixel image to file "out.png". >> >> PyMol seems to be saying to me, "I'm sampling an OpenGL viewport with the >> dimensions you specified to create this png" >> >> -David >> > > > > -- > Tsjerk A. Wassenaar, Ph.D. > > Computational Chemist > Medicinal Chemist > Neuropharmacologist > > -- > Throughout its 18-year history, RSA Conference consistently attracts the > world's best and brightest in the field, creating opportunities for Conference > attendees to learn about information security's most important issues through > interactions with peers, luminaries and emerging and established companies. > http://p.sf.net/sfu/rsaconf-dev2dev > ___ > 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 > -- Jason Vertrees, PhD PyMOL Product Manager Schrodinger, LLC (e) jason.vertr...@schrodinger.com (o) +1 (603) 374-7120 -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ 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
Re: [PyMOL] Feature Requests/Ideas (Sean Law)
The ray command bugs me, so I'll take a stab at improving it this afternoon. Can someone tell me how to get the size of the current viewport? This solution: http://www.mail-archive.com/pymol-users@lists.sourceforge.net/msg05888.html width,height = cmd.get_session()['main'][0:2] doesn't seem to work for me: PyMOL>print sorted(cmd.get_session().keys()) ['cache', 'color_ext', 'colors', 'editor', 'movie', 'names', 'scene_dict', 'scene_order', 'selector_secrets', 'session', 'settings', 'unique_settings', 'version', 'view', 'view_dict', 'wizard'] -Michael On Wed, Jan 20, 2010 at 3:54 PM, Tsjerk Wassenaar wrote: > Hi, > > > ray 10cm, 20cm, dpi=300? > > ray 2.5in, 5in, dpi=300? > > I'd slightly modify that to read: > > ray 10,10,units=cm,resolution=300 > > where units can be pixels (default), cm, inches, meters, yards, > lightyears... > > Cheers, > > Tsjerk > > > -- > Tsjerk A. Wassenaar, Ph.D. > > Computational Chemist > Medicinal Chemist > Neuropharmacologist > > > -- > Throughout its 18-year history, RSA Conference consistently attracts the > world's best and brightest in the field, creating opportunities for > Conference > attendees to learn about information security's most important issues > through > interactions with peers, luminaries and emerging and established companies. > http://p.sf.net/sfu/rsaconf-dev2dev > ___ > 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 > -- Michael Lerner, Ph.D. IRTA Postdoctoral Fellow Laboratory of Computational Biology NIH/NHLBI 5635 Fishers Lane, Room T909, MSC 9314 Rockville, MD 20852 (UPS/FedEx/Reality) Bethesda MD 20892-9314 (USPS) -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev___ 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
Re: [PyMOL] Feature Requests/Ideas (Sean Law)
I think this works. It handles different units (in and cm). If you leave out width or height, it gets scaled correctly. If you leave them both out, you get whatever the current viewport size is (is there something better?). #!/usr/bin/env pymol from pymol import cmd def rayy(width=-1,height=-1,dpi=300,units='in',**kwargs): """ Slightly better version of the ray command. You can specify width and height in the units of your choice, e.g. rayy 3,2,units=in,dpi=300 rayy 3in,2in rayy 1in, 2 cm, dpi=600 Extra keyword arguments get passed on to the normal ray command. """ if type(dpi) in [type('')]: dpi = int(dpi) in_per_cm = 0.393700787 def todots(x,units,dpi): if type(x) in [type('')]: x = x.lower() if 'in' in x: units = 'in' elif 'cm' in x: units = 'cm' x = float(x.replace(units,'').strip()) if units == 'cm': x = x * in_per_cm elif units == 'in': pass else: raise ValueError('Unknown units (%s)'%units) print x,units,dpi return int(x * dpi) # How do we get current width/height of viewport? MainSceneGetSize perhaps # But it doesn't matter, as PyMOL will autoscale internally for us. try: height,width = todots(height,units,dpi),todots(width,units,dpi) except ValueError: print "Unknown units" return print 'width',width,'height',height cmd.ray(width=width,height=height,**kwargs) #cmd.png(self.filename.getvalue(), dpi=int(self.dpi.getvalue())) cmd.extend('rayy',rayy) On Thu, Jan 21, 2010 at 11:52 AM, Michael Lerner < mglerner+sourcefo...@gmail.com > wrote: > The ray command bugs me, so I'll take a stab at improving it this > afternoon. > > Can someone tell me how to get the size of the current viewport? > > This solution: > http://www.mail-archive.com/pymol-users@lists.sourceforge.net/msg05888.html > > width,height = cmd.get_session()['main'][0:2] > > > doesn't seem to work for me: > > PyMOL>print sorted(cmd.get_session().keys()) > ['cache', 'color_ext', 'colors', 'editor', 'movie', 'names', 'scene_dict', > 'scene_order', 'selector_secrets', 'session', 'settings', 'unique_settings', > 'version', 'view', 'view_dict', 'wizard'] > > -Michael > > On Wed, Jan 20, 2010 at 3:54 PM, Tsjerk Wassenaar wrote: > >> Hi, >> >> > ray 10cm, 20cm, dpi=300? >> > ray 2.5in, 5in, dpi=300? >> >> I'd slightly modify that to read: >> >> ray 10,10,units=cm,resolution=300 >> >> where units can be pixels (default), cm, inches, meters, yards, >> lightyears... >> >> Cheers, >> >> Tsjerk >> >> >> -- >> Tsjerk A. Wassenaar, Ph.D. >> >> Computational Chemist >> Medicinal Chemist >> Neuropharmacologist >> >> >> -- >> Throughout its 18-year history, RSA Conference consistently attracts the >> world's best and brightest in the field, creating opportunities for >> Conference >> attendees to learn about information security's most important issues >> through >> interactions with peers, luminaries and emerging and established >> companies. >> http://p.sf.net/sfu/rsaconf-dev2dev >> ___ >> 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 >> > > > > -- > Michael Lerner, Ph.D. > IRTA Postdoctoral Fellow > Laboratory of Computational Biology NIH/NHLBI > 5635 Fishers Lane, Room T909, MSC 9314 > Rockville, MD 20852 (UPS/FedEx/Reality) > Bethesda MD 20892-9314 (USPS) > -- Michael Lerner, Ph.D. IRTA Postdoctoral Fellow Laboratory of Computational Biology NIH/NHLBI 5635 Fishers Lane, Room T909, MSC 9314 Rockville, MD 20852 (UPS/FedEx/Reality) Bethesda MD 20892-9314 (USPS) -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev___ 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
Re: [PyMOL] Feature Requests/Ideas (Sean Law)
Here's a slightly improved version. It only kicks in if dpi is specified. I think that you could make the obvious modifications to the help message and argument list and use it as a replacement for cmd.ray (as long as you're aware of the fact that the argument list will be different). #!/usr/bin/env pymol from pymol import cmd def rayy(width=-1,height=-1,dpi=-1,units='in',**kwargs): """ Slightly better version of the ray command. You can specify width and height in the units of your choice, e.g. rayy 3,2,units=in,dpi=300 rayy 3in,2in rayy 1in, 2 cm, dpi=600 Extra keyword arguments get passed on to the normal ray command. Units can be 'in' or 'cm'. For backwards compatibility, the conversion to dpi (or dots per centimeter) is only performed when dpi is specified. """ if type(dpi) in [type('')]: dpi = int(dpi) in_per_cm = 0.393700787 def todots(x,units,dpi): if type(x) in [type('')]: x = x.lower() if 'in' in x: units = 'in' elif 'cm' in x: units = 'cm' x = float(x.replace(units,'').strip()) if (dpi == -1): return x if units == 'cm': x = x * in_per_cm elif units == 'in': pass else: raise ValueError('Unknown units (%s)'%units) print '%s%s at %sdpi'%(x,units,dpi) return int(x * dpi) # How do we get current width/height of viewport? MainSceneGetSize perhaps # But it doesn't matter, as PyMOL will autoscale internally for us when given -1. try: width,height = todots(width,units,dpi),todots(height,units,dpi) except ValueError: print "Unknown units" return print 'width',width,'height',height cmd.ray(width=width,height=height,**kwargs) cmd.extend('rayy',rayy) On Thu, Jan 21, 2010 at 2:39 PM, Michael Lerner < mglerner+sourcefo...@gmail.com > wrote: > I think this works. It handles different units (in and cm). If you leave > out width or height, it gets scaled correctly. If you leave them both out, > you get whatever the current viewport size is (is there something better?). > > #!/usr/bin/env pymol > > from pymol import cmd > > def rayy(width=-1,height=-1,dpi=300,units='in',**kwargs): > """ > Slightly better version of the ray command. > You can specify width and height in the units of your choice, e.g. > > rayy 3,2,units=in,dpi=300 > rayy 3in,2in > rayy 1in, 2 cm, dpi=600 > > Extra keyword arguments get passed on to the normal ray command. > """ > if type(dpi) in [type('')]: dpi = int(dpi) > in_per_cm = 0.393700787 > def todots(x,units,dpi): > if type(x) in [type('')]: > x = x.lower() > if 'in' in x: units = 'in' > elif 'cm' in x: units = 'cm' > x = float(x.replace(units,'').strip()) > if units == 'cm': x = x * in_per_cm > elif units == 'in': pass > else: raise ValueError('Unknown units (%s)'%units) > print x,units,dpi > return int(x * dpi) > # How do we get current width/height of viewport? MainSceneGetSize > perhaps > # But it doesn't matter, as PyMOL will autoscale internally for us. > try: > height,width = todots(height,units,dpi),todots(width,units,dpi) > except ValueError: > print "Unknown units" > return > print 'width',width,'height',height > cmd.ray(width=width,height=height,**kwargs) > #cmd.png(self.filename.getvalue(), dpi=int(self.dpi.getvalue())) > cmd.extend('rayy',rayy) > > On Thu, Jan 21, 2010 at 11:52 AM, Michael Lerner < > mglerner+sourcefo...@gmail.com > wrote: > >> The ray command bugs me, so I'll take a stab at improving it this >> afternoon. >> >> Can someone tell me how to get the size of the current viewport? >> >> This solution: >> >> http://www.mail-archive.com/pymol-users@lists.sourceforge.net/msg05888.html >> >> width,height = cmd.get_session()['main'][0:2] >> >> >> doesn't seem to work for me: >> >> PyMOL>print sorted(cmd.get_session().keys()) >> ['cache', 'color_ext', 'colors', 'editor', 'movie', 'names', 'scene_dict', >> 'scene_order', 'selector_secrets', 'session', 'settings', 'unique_settings', >> 'version', 'view', 'view_dict', 'wizard'] >> >> -Michael >> >> On Wed, Jan 20, 2010 at 3:54 PM, Tsjerk Wassenaar wrote: >> >>> Hi, >>> >>> > ray 10cm, 20cm, dpi=300? >>> > ray 2.5in, 5in, dpi=300? >>> >>> I'd slightly modify that to read: >>> >>> ray 10,10,units=cm,resolution=300 >>> >>> where units can be pixels (default), cm, inches, meters, yards, >>> lightyears... >>> >>> Cheers, >>> >>> Tsjerk >>> >>> >>> -- >>> Tsjerk A. Wassenaar, Ph.D. >>> >>> Computational Chemist >>> Medicinal Chemist >>> Neuropharmacologist >>> >>> >>> -- >>> Throughout its 18-year history, RSA Conference consistently attracts the >>> world's best and brightest in the