1D and 2D density calculation

43 views
Skip to first unread message

znjadore zheng

unread,
Oct 8, 2024, 11:38:18 PM10/8/24
to Tools from yuxiangwang321
Dear Professor:
I get an error when using dc.tcl. The command I entered is: dc prod_fixed.xtc prod_fixed.xtc number_z 100000 100000 1 10 155 1 ​​10 100 1 -6 68 232 {MOL}, and the error message is: atomselect: cannot parse selection text: x>10.000 and x<155.000 and y>10.000 and y<100.000 and z>-6.000 and z<-5.681 and {MOL}


微信图片_20241009113051.png
I want to study the density distribution of these peptides on this slab, including number density and mass density, but every time I run DC, no matter whether I choose MOL molecules or slab molecules, I get the same error. If I choose all, dat will be generated. file, but all densities are 0.

I want to show this effect in other people's literature, please give me some advice.1.png
2.png

Y. Wang

unread,
Oct 9, 2024, 7:21:34 PM10/9/24
to znjadore zheng, Tools from yuxiangwang321
Hi Znjadore,

Thank you for using our code. I am sure DC is capable of the job. It looks like you used the wrong atomSelection parameter. Is MOL the atom type or name or resname or restype? You should put one of the VMD atomselection keyword before MOL, for example {resname MOL}. To check what MOL is, you can go to VMD, and follow the way shown in the picture.

2024-10-10_101745.png

Enjoy,
Yuxiang

--
You received this message because you are subscribed to the Google Groups "Tools from yuxiangwang321" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tools-from-yuxiang...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tools-from-yuxiangwang321/b49d9cf4-5b17-4b83-9f6e-0890d6a0ee3en%40googlegroups.com.

znjadore zheng

unread,
Oct 9, 2024, 10:39:42 PM10/9/24
to Tools from yuxiangwang321
Thanks to Professor Wang for his guidance, the previous problem has been solved. Currently I have a new doubt. I want to make a 2D density map. The command used is: dc prod.xtc prod.xtc mass_xy 1 100000 1000 0 130 65 1 90 45 1 68 1 {z<15 and z>8}, but The calculated density values ​​are all 0, I don’t know why. Screenshot to give you my selection interval and calculation results.
2.png
3.png

1.png

Y. Wang

unread,
Oct 9, 2024, 11:01:57 PM10/9/24
to znjadore zheng, Tools from yuxiangwang321
Hi Znjadore,

I can see two problems in the command. First, you are using an old version, please go to my github (https://github.com/yuxiangwang321/DensityCalculator) to have a try of the new version dc_20240617.tcl, don't forget to change the name to dc.tcl, and note that the parameter set is a little different; then, the frame index should start from 0 in VMD. But these two problems cannot result in the strange result.So can you send me a frame of your trajectory file? I can do a test to see what is wrong with the code or command.

Thank you,
Yuxiang

znjadore zheng

unread,
Oct 10, 2024, 12:25:30 AM10/10/24
to Tools from yuxiangwang321

This is the trajectory file of one of my frames. Please check it, Professor.

znjadore zheng

unread,
Oct 10, 2024, 12:28:41 AM10/10/24
to Tools from yuxiangwang321
thanks

Y. Wang

unread,
Oct 10, 2024, 1:40:59 AM10/10/24
to znjadore zheng, Tools from yuxiangwang321
This file is empty. Please send me a correct one.

znjadore zheng

unread,
Oct 10, 2024, 3:41:32 AM10/10/24
to Tools from yuxiangwang321

This is a trajectory file with water removed. Please check it.
prod_fixed_1frame.xyz

Y. Wang

unread,
Oct 10, 2024, 7:52:08 PM10/10/24
to znjadore zheng, Tools from yuxiangwang321
Hi Znjadore,

I tested your file and found the problem. You have no pbc boundary in the .xyz file. If you still want to use the code on this file, you should do one of the two treatments: either setting pbc in you file before running the code (in VMD, you can do this by command "pbc set {x y z}", and save in a file with format that includes pbc boundaries, i.e. .pdb, I think .xyz doesn't include pbc boundaries); or, you can simply comment this line "pbc wrap -all" in the code to avoid using pbc. The latter way should be used carefully, in case of the atoms moving out of the cell in trajectory file.

I used the second way by commenting on the pbc setting for your .xyz file.  But if you still have problems in other format, let me know.

Here is the command I used:
source dc.tcl; dc prod_fixed_1frame.xyz prod_fixed_1frame.xyz test mass_xy 0 100000 1000 0 130 65 1 90 45 1 68 1 {z<15 and z>8}

Here is the test result.

2024-10-11_103956.jpg
2024-10-11_104257.jpg

Here is the code with commenting pbc setting:


dc.tcl

znjadore zheng

unread,
Oct 10, 2024, 9:30:27 PM10/10/24
to Tools from yuxiangwang321
Thank you very much, I will try it now

znjadore zheng

unread,
Oct 11, 2024, 5:19:53 AM10/11/24
to Tools from yuxiangwang321
Professor Wang, I tried to use your suggestion to create a 2D density map. No matter whether I used the new dc.tcl script you provided or modified the periodicity of pbc, the density value obtained was still 0. I used the trajectory file sent to you and copied the same instructions, but it still didn't work. This time, I would like to send you my trajectory file (in xtc format) and the test file I got again for you to take a look at. Please give me your guidance. Your help is greatly appreciated.
5-7-20frame.xtc
test.dat

Y. Wang

unread,
Oct 11, 2024, 7:56:43 AM10/11/24
to znjadore zheng, Tools from yuxiangwang321
Hi Znjadore,

I can load your .xtc file, but cannot see anything in VMD. I searched the file format online found one possible reason for the error, you only loaded the .xtc file, this is a compressed gromacs format, it should be paried with a reference file, just like a .psf file paired with a .dcd file. Check details here:
https://www.ks.uiuc.edu/Research/vmd/vmd-1.7.1/ug/node21.html
https://www.compchems.com/how-to-load-gromacs-trajectories-in-vmd/

In your case, you need load both the .xtc file and your reference file, please try their sequence in the command, I think the reference file should go first since it corresponds to the .psf file in the examples of the paper.

Cheers,
Yuxiang

znjadore zheng

unread,
Oct 11, 2024, 10:07:42 AM10/11/24
to Tools from yuxiangwang321
With your continuous help, I finally solved it. The command of the gromacs trajectory is:
dc prod.gro prod.xtc test mass_xy 10000 10000 1 0 155 65 0 90 45 0 68 1 {z<15 and z>8}

znjadore zheng

unread,
Oct 11, 2024, 10:47:35 AM10/11/24
to Tools from yuxiangwang321
Professor Wang, I got the 2D test.dat file. What software should I use to draw the 2D diagram? Which module should be used to use origin? I have tried several, but none of them are the same as those in your document.
2.png

I followed the following steps in origin:
3.png

4.png

Thank you very much for your advice.

znjadore zheng

unread,
Oct 11, 2024, 10:48:31 AM10/11/24
to Tools from yuxiangwang321

this is my file of dat
test.dat

Y. Wang

unread,
Oct 11, 2024, 10:54:11 PM10/11/24
to znjadore zheng, Tools from yuxiangwang321
Hi Znjadore,

Congratulations, you got the density results!

How to plot a beautiful 2D density map is now out of the usage of code, you should search the answers online. You can use software or create a python script to do that.

But, yes, you can use Origin, I also used it in the paper. You should choose the first one (Contour, color fill); then, you need to adjust the parameters in the following settings, here, you have to find the answer online yourself (sorry). I am pretty sure you will finally draw an amazing picture.

Good luck!
Yuxiang

Reply all
Reply to author
Forward
0 new messages