Manual control of zoom / scale in MarvinSpace GUI?

User 2477d057f2

23-04-2008 15:03:44

Hello





Is there any way to manually set the scale for viewing and exporting in the MarvinSpace GUI?





Ideally, the scale could be adjusted in units of pixels per Angstroms.





I need to export graphic files in identical scale in order to compare surface areas after rotating my molecules to the orientation producing the smallest area. (If you know of any way to automate this, please let me know. Also, if this is any way of measuring the 2D surface being displayed at any given time directly in MarvinSpace, please let me know.)





I appreciate your help.


Louis

ChemAxon 909aee4527

28-04-2008 05:31:08

Hi Louis,





apologies for not responding any sooner.


Yes, there are several ways of manually controlling the scale factor.





(1) Using the public API:


supposing you have an MSpaceEasy instance called mspace:


mspace.getGraphicScene().zoom(double);


Though it can be hard to find the actual zoom factor you need to use, though (2) can help you in this.





(2) Using scripting


- Launch MarvinSpace and load the molecule you wish to work with


- Choose File>Create Log File (you can give arbitrary extension) and choose No for logging mouse events


- set the view you are statisfied with


- File > Log current view


- File > Close Log File





The script is now created. You may wish to edit the file to remove unnecessary steps. If you only need the scale factor, it is in the line starting with --zoomTo. (You can also use this value in (1) directly)





You can use this file for other structures as well. The way you can set it to MarvinSpace depends on how you use it.


From API you can use the following method:


mspace.getEventHandler().processLog(InputStream, boolean);


(Set the boolean value to false, to prevent continuous repeating of the script.)





Please tell me if you need more help, I'll gladly try to give more details.





Kind regards,


Judit

User 2477d057f2

02-05-2008 14:47:24

Hi Judit





Thank you for the reply. I tried the scripting option and like it very much. The zoomto command appears to control the scale of the display as well as the scale of exported graphics. Perfect.





Question: If I write "zoomto 64" for example, what do the units become? 64 pixels per 1.54 Angstrom?








A few more questions for you concerning making scripts to simplify my work:





1) Can you teach me how to script the following operations:


a) Show van der Waals surface


b) export to a 1024x768 JPEG; or export to a custom sized JPEG


c) adjust window size (so I can match it to the size of my export file)


d) close current molecule and open next molecule


e) specify a file path (i.e. location) for opening files, for saving files, and for finding scripts





2) Is there any way to script a change in brightness and contrast of van der Waals surface display, so that the molecule becomes completely white (no shadow or depth) against a black background.





4) Now the really tough one:


Is there any way to count and readout the number of pixels taken by a molecule being displayed at any given time (after I have adjusted the scale and rotated the molecule to the desired orientation). This could be the number of white pixels after ajusting contrast and brightness, as above.





(This would be a measure of the 2D surface being projected onto the screen. Right now, I have to measure pixel area in Photoshop. For your information, the phys-chem property that I am trying to determine is the smallest frontal area of a molecule moving through a membrane.





Thank you so much. Every bit of info you provide saves me countless hours.





Cheers


Louis

ChemAxon 909aee4527

06-05-2008 13:24:46

Hi Louis,





We are using the same mechanism to test MarvinSpace by automatically running hundreds of scripts and generating images from each of them.





I will come back with a sample code and a detailed answer very soon!





Kind regards,


Judit

ChemAxon 909aee4527

13-05-2008 12:51:08

Hi Louis,





please accept my apologies for the late reply.





I've tried to simplify the MSpace tester as much as I can to help you.


In the attached zip file there is an MSpaceTester class. It requires the MarvinBeans.jar in the classpath to run. It takes 3 arguments: location of the script files, location of the generated image (result) files, and the reset log location.


There are examples to the arguments in the zip file, with some sample logs too.


The example generates 1024x768 images for every script file one after another.





An important note: the mspace component should be fully visible to properly generate images, no background-running or screen-saver allowed during this time.





In case you would like to create more logs, I suggest to use MarvinSpace to do it. When you select the Create Log File option fromn MarvinSpace, it automatically records you everything, the view is the only one that is recorded on request only (File>Log Current View). Don't forget to close the log file.





I think the pixel count can easily be solved, though not automatically. In case every component is hidden except the surface, the number of non-black pixels can be counted with a small algorithm shown below. I don't think the brightness and contrast really counts, but please correct me if I'm wrong :)





Please tell me if you need more assistence.


Kind regards,


Judit





Code:



    BufferedImage image1 = ImageIO.read( imageFile );


    int nonBlack = 0;


    int w = image1.getWidth();


    int h = image1.getHeight();


    int[] rawData1 = new int[w*h];


    image1.getRGB(0, 0, w, h, rawData1, 0, w);


    for(int i=0; i<w*h; i++) {


        if(rawDataMask[i]!=0xFF000000) {


            nonBlack++;


        }


    }


User 2477d057f2

13-05-2008 13:39:39

Thank you very much Judit!





I will experiment with this and give you feedback.





Was I correct about the scale when I apply a zoom factor?





My original question was: If I write "zoomto 64" for example, what do the units become? 64 pixels per 1.54 Angstrom?





Cheers


Louis

ChemAxon 909aee4527

15-05-2008 14:00:30

Hi Louis,





I'm sorry for skipping the zoom question.





The zoom parameter is the distance between the camera and the transformation center measured in Angstroms.





Since the transformation center can be changed, "zoomTo 64" is not enough to set for a fix view. It is also required to set the coordinates of the transformation center (along with shift values and the rotation matrix).


Usually we do not set these values manually, we prefer to save a fix view then applying it to other structures as well. However it is not reliable to use it on differently aligned structures.





I hope it is clearer now and helps you in your work.





Kind regards,


Judit

User 2477d057f2

15-05-2008 14:33:12

Hi Judit





Yes your explanation of the zoomto function certainly does clear things up.





Until you implement a true surface-area-projection function, I was hoping that applying the same zoomto to all the molecules in my library and then measuring the area on the screen would be workaround. But I see now that this is dangerously flawed.





Can you tell me how to write a script that will result in a "fix view" as you put it? Will this work for my purposes or will this also cause a distortion. If it does cause a distortion, will it be smaller than the distortion I am currently generating with the zoomto? Will it be possible to put units to my measurement? I desperately need a reliable estimate of projected surface area and I cannot wait for the feature to be implemented into Marvin.





I appreaciate your help.





Louis

ChemAxon efa1591b5a

22-05-2008 08:30:24

Hi Louis,





Judit is on holiday, I try to respond to your recent questions.





1. Regarding the surface area projection:


- why pixels? why not area in square Amstrong?


- is the ideal solution to find the minimum value by optimisation? - or instead do you want to find the minimum by eye inspection and manual rotation?


- total surface area is only what matters or properties may need to be considered (e.g. polar, hydrophobic etc.)?





I am not sure though, when could we implement it. If no optimisation is needed, just projecting the current view and calculate the area of the 2D projection, without any property mapping, then that's not a big pain probably.





We can also make a deal: could you yourself implement it? In that case we create a suitable API that for instance provides access to the surface triangles that you can directly use. What do you think?








2. Attached please find a sample script. You can write such scripts by yourself, though more convenient approach that hopefully is suitable for your needs is to record an event sequence in mspace. It goes like that:


- load your molecule (file open is not logged yet)


- select File->Create Log File..


- enter filename


- dialogue pops up, select 'log mouse events'


- tumble, zoom, generate surface, change coloring etc...


- when finished, stop recording event: File->Close Log File





The logfile is a low level script file, though human readable. Before the first event logged you can insert a line to load you input molecule (see attached example): load <filename>





There are two alternatives to run a script in mspace:


1. GUI


- start mspace


- File->Process Existing Log File, enter file name


2. Command line


- start mspace like that: mspace -lr <scriptfilename>





HTH


regards,


Miklos

User 2477d057f2

23-05-2008 15:46:42

Hello Miklos





Thank you for filling in for Judit.





However, after waiting a week for Judit's reply, it is frustrating to see that you did not quite follow the dialog.





Of course I want to measure the projected area (or a crude approximation of the projected area) in square Angstroms!





I've been asking once a week for the last three weeks how the "zoomto" command (which I apply in the hope of displaying all my compounds at the same scale) affects scale. In other words, how do I convert pixels to angstroms at any given zoomto??





Now Judit pointed out that the procedure I am using is causing distortions because the zoom measures the distance to the center of rotation of the displayed molecule. Therefore what I am seeing on the screen is not always at the same scale (despite the same zoomto command) because different molecules will have different distances between their surface and their center of rotation.





Judit mentionned "fixed views". I want to know what she meant and whether this will reduce distortions.





Until you implement a true surface area projection feature, I see no other choice than to measure displayed area, and to accept distortions due to "camera" distance, etc.





A true surface area projection feature would require some sort of optimization algorithm. However, I am perfectly content manually rotating molecules for the time being. I just need to know how to convert the area that I measure (by exporting the file and counting pixels in Photoshop) can be converted to undistorted areas (in square Angstroms)?





Any help is greatly appreciated. And I would love to help you, as you suggested, however my matrix algebra and programming skills are too limited.





Please let me know if there is a better way to dialog with Chemaxon. For example, is there a way to pay for technical support? My current project is being held up until I find a way to make the measurement I need from your wonderful program Marvin.





Cheers


Louis

ChemAxon efa1591b5a

27-05-2008 11:52:49

Hello Louis,





apologies for the confusion and in particular for the frustration I might have caused. Beside, please accept my apologies for the longer than usual response times you experienced, these are due to our Users' Group Meeting





I can only guess what Judit meant by 'fixed views'. Perhaps she thought of explicitly setting the transformation centre of the molecule being viewed. Using the mspace gui you can click an atom by the middle mouse button (no other way, so that can be troublesome if you're a mac user). From then on that atom becomes the transformation centre. With this you can reduce the distortion effect, though the transformation centre is still couple Angstrom's away form the surface.





If, however, you are using the API, then the explicit way of setting the transformation centre provides even greater flexibility: the setTransformationCenter() method of the GraphicScene class takes an arbitrary 3D Cartesian co-ordinate, so you can define a 'near-surface' location http://www.chemaxon.com/marvin/help/developer/beans/api/chemaxon/marvin/space/GraphicScene.html#setTransformationCenter(float[]).





Does this help?





Support is free. It's more usual that users boost the delivery of new features they require by funding the development. This is more straightforward in the present case as well, since the functionality you intend to use does not yet exist in MarvinSpace. This also ensures that you get exactly what you ask for.





I will discuss this issue with the financial management of CXN and then get back to you.





bests,


Miklos

ChemAxon efa1591b5a

29-05-2008 09:38:31

Hi Louis,





we are working on the specification of the minimum projected area problem. In order to meet your expectations I need to thoroughly understand your requirements.





1. What's your requirement in terms of accuracy? Namely, can the actual surface be interpolated by spheres or you need the exact surface? Apparently, the interpolation can be done on a very fine scale though with the expense of running time.





2. Do you need the projection of the surface or the projection of the convex hull of the surface? Is this latter more appropriate for your needs or not?


Do you have hollow molecules (like a carbon nano tubes) or these kind of structures are not relevant for your research?





3. What the typical size of your structures (number of atom, diameter)?





4. What kind of result do you need? The surface area and the projection vector is sufficient? Or you also need the projected polygon?





5. Do you have strict response time expectations?





6. Do you have any further requirement that I have not addressed?





Regards,


Miklos

User 2477d057f2

29-05-2008 14:19:20

Hi Miklos





Thank you for looking into the implementation of projected surface areas. I'm sure this feature will be useful for many users.





Let me answer your 6 questions:





1) Accuracy/resolution: This is meant to be a fairly crude measurement. I do not think that resolution will be a big issue. Since the projected area will be of van der Waals surfaces or solvent-accessible surfaces (2 parameters that already have some degree of error built-in), there is no point trying to make the measurement exceedingly accurate. The goal is simply to have distortion-free projections.





2) Surface projection versus projection of convex hull: I am interested in obtaining surface projections of a 3D rendered molecule from which can be calculated parameters such as a molecule's longest dimension, shortest dimension, ratio of longest to shortest dimension, largest 2D surface area, and smallest 2D surface area. These are measurements that will interest anyone doing SAR. The last measurement is the most important to me in the modelling of the resistance to movement of a molecule diffusing through a membrane. I do not work with nanotubes.





3) Typical molecular size: My dataset is composed of small phenolic molecules. Phenol would represent the smallest molecule I work with. The largest molecules have a MW below 600 (typically below 500), and are composed of typically less than 80 atoms. The molecules tend to be fairly planar.





4) Surface area versus projected polygon: I believe that projected area will be sufficient.





5) Implementation time: I would not presume to rush you in the implementation of this new feature. I am content to work for the moment with my crude approximations of smallest area. Ideally, I would want to refine my data for publication within one month. Please let me know what kind of timeline you have in mind and I will plan accordingly.





6) Further requiremements: My immediate requirements are for minimized 2D projected area (in square Angstroms) of a molecule rendered in 3D with van der Waals surfaces. But as discussed in point 2), it will be useful to many users if you extract as many molecular dimensions as possible from the projection technique (longest dimension, smallest dimension, ratio, largest projected area, smallest projected area, etc) for molecules rendered with either van der waals or solvent accessible surfaces.





Thank you


Louis

ChemAxon efa1591b5a

02-06-2008 14:36:04

Hi Louis,





thanks for the clarification, it did help a lot.





If a crude approximation is sufficient, then what do you think about this much simpler approach:


Instead of the surface, the vdW spheres around each atoms centres are used and projected. This has very little distortion effect, in my opinion it is negligible (only concave curvatures are not taken properly into account but in the projection this has not significant area).


The same can be applied to SASA, is that correct?





With this approach both the development and the using of the program is much faster.


Incorporating largest projected are and all other calculations you referred to are also fairly straightforward.


What do you say?





Regards,


Miklos

User 2477d057f2

09-06-2008 18:06:20

Hi Miklos





That sounds perfect! Thank you very much.





Louis

ChemAxon efa1591b5a

10-06-2008 09:07:47

Hi Louis,





ok, good. I hope this won't take long to implement. I'll let you know when the feature is available for testing.





Miklos

User 2477d057f2

15-07-2008 19:31:09

Hi Miklos





Any progress in the last month?





Cheers


Louis

ChemAxon efa1591b5a

15-07-2008 23:21:51

Hi Louis,





yes! We've got a crude implementation that will be improved within few days. I scheduled a meeting with a developer on Thursday to discuss how to integrate the new algorithm in the geometry calculator plugin and also decide in which version will we deliver this new feature.


You can receive a pre-release for beta testing if you wish.





Regards,


Miklos

ChemAxon efa1591b5a

06-10-2008 14:26:21

Hi Louis,





did you get a chance to test drive the projected surface area calculations at all?





Thanks


Miklos

User 2477d057f2

06-10-2008 14:31:16

Hi Miklos





Please send me the pre-release and I will begin beta testing immediately. Thank you.





Louis

ChemAxon efa1591b5a

07-10-2008 08:51:58

Hi,





apologies, it appears that we have not notified you in time that the calculations you asked for were released in version 5.1.





The projected surface area is part of the GeometryPlugin that you can test various ways.





1, in the MSketch GUI


draw a structure, then Tools->Geometry->Geometry, then it's straightforward





2, via the cxcalc batch tool





Code:
./scripts/cxcalc minimalprojectionarea mols-3d/aciclovir.mol


id      Minimal projection area


1       29.47






Available options are: maximalprojectionarea, maximalprojectionradius, minimalprojectionarea, minimalprojectionradius





3, the API is also available:


http://www.chemaxon.com/marvin/help/developer/beans/api/chemaxon/marvin/calculations/GeometryPlugin.html








Hope this helps.


Apologies for not sending a notification sooner.





Miklos

User 2477d057f2

01-12-2008 17:18:43

Hello Miklos





I finally had a chance to test the new Minimal Projection Area feature of the Geometry plugin. Sorry for taking so long.





The implementation is very nice. This is exactly what I was hoping for. Thank you! Good idea to have control over optimization since the process can be CPU-intensive.





But my limited testing has raised some concerns. For example taking a simple benzene ring, the plugin returns a Min PA of 17.75 square Angstroms. I assume this is with the ring viewed from the side (and if I request Max PA, this will be with the ring viewed from the top or bottom, correct?). Now if I add a methyl substituent, the Min PA actually becomes smaller, to 14.30! The molecule is now bigger, so the Min PA must be equal (if the substituent is completely shielded and invisible in the projection) or bigger (if the substituent increases the thickness of the molecule seen from the side).





Another example is the comparison of flavone (a nearly planar molecule) versus flavonone (almost same molecule, but third ring is out of plane with other two rings due to absence of double bond). I get 32.40 with flavone, and 27.09 with flavonone. Flavonone should give a much larger Min PA since it is nonplanar; in fact it should be bigger by an entire benzene ring viewed from the top (i.e. Max PA of benzene).





Flavone is O=C1C=C(OC2=C1C=CC=C2)C1=CC=CC=C1


Flavonone is O=C1CC(OC2=C1C=CC=C2)C1=CC=CC=C1








Please have a look at my examples. And let me know whether I am not correctly interpreting the algorythm or its output.





Cheers


Louis

ChemAxon efa1591b5a

03-12-2008 07:30:33

Hi Louis,





this sounds bad - we need to thoroughly investigate the optimisation algorithm used in projection. I'm afraid it'll take some time.


You'll be informed.





Miklos