How to use GW to process ss.xpm file of secondary structures (ss)? #224
Replies: 21 comments
-
You have to import it as import gromacs Reading a xpm file: import gromacs.formats
xpm = gromacs.formats.XPM("./ss.xpm") See the docs for XPM for more details how to work with the class. |
Beta Was this translation helpful? Give feedback.
-
To get the "33th residue at 22th time frame " do resid = 33 # 1-based
frame = 22 # 0-based
resnum = xpm.yvalues[resid-1]
time = xpm.xvalues[frame]
state = xpm.array[frame, resid-1]
print("secondary structure for resid={0} at time {1:.3f} ps: {2}".format(resnum, time, state)) Note that the
|
Beta Was this translation helpful? Give feedback.
-
Thank you, I think GW works for python 2, not python 3. Can I ask if there is an alternative for python 3 as well? Or, can I use python 2 and 3 in the same time? Or, what if I re-write your code into python3? How many files are involved in the xpm processing? I am also interested in batch-processing rmsd/rmsf/gyration files, but I prefer python 3. The following errors are for python 3 only:
|
Beta Was this translation helpful? Give feedback.
-
Can I ask about the I just want to double confirm that. I also asked question on the Gromacs forum. |
Beta Was this translation helpful? Give feedback.
-
We have not ported GW to Python 3 yet, see issue #44 . I'd like to but haven't had enough time. In principle it should not be hard because GW is pure Python. An initial attempt was PR #101, see comments there. If you work on making it work under Python 3 (while still supporting Python 2) I'd be happy to consider your contribution for inclusion – just submit a pull request (PR) on GitHub. |
Beta Was this translation helpful? Give feedback.
-
thank you for the effort, I will write my own python3. |
Beta Was this translation helpful? Give feedback.
-
Regarding >>> import numpy as np
>>> import gromacs.formats
>>> xpm = gromacs.formats.XPM("./ss.xpm")
>>> print(xpm.array.shape)
(10001, 749)
>>> separators = np.all(xpm.array == "Chain_Separator", axis=0)
>>> sep_resnum = xpm.yvalues[separators]
>>> print(sep_resnum)
[375]
>>> # I only have one separator so I am shortcutting and assigning it to
>>> sep_indx = np.where(xpm.yvalues == sep_resnum[0])[0][0]
>>> # data for chain A
>>> ssA = xpm.array[:, :sep_indx]
>>> # data for chain B
>>> ssB = xpm.array[:, sep_indx+1:]
>>> print(ssA.shape, ssB.shape)
((10001, 374), (10001, 374)) |
Beta Was this translation helpful? Give feedback.
-
If you fix the things that allow you to import on Python 3 and submit this as a PR then that could be a start. |
Beta Was this translation helpful? Give feedback.
-
You mean reading the output from the Gromacs commands in the form of XVG files? GW has the You can also run analysis of this kind in MDAnalysis, see |
Beta Was this translation helpful? Give feedback.
-
for the MDAnalysis, I have some problems in installing it, and could not solve it at the moment. So writing my own one might be easier.
|
Beta Was this translation helpful? Give feedback.
-
For MDAnalysis on Windows see https://github.com/MDAnalysis/mdanalysis/wiki/MDAnalysis-on-Windows |
Beta Was this translation helpful? Give feedback.
-
thank you. I do have ubuntu on VMwarePlayer on Win7. But I do not want to frequently use the ubuntu, as I need to copy and paste the files into it. I am writing my own python3 script to process the xvg/xpm files from gromacs. |
Beta Was this translation helpful? Give feedback.
-
Ok – I'll close the issue. Feel free to ask it to be re-opened (or re-open it yourself). |
Beta Was this translation helpful? Give feedback.
-
Hi @orbeckst , I am not sure if I did it correctly. I used
So this should output the first time and the second residue. But what I got is |
Beta Was this translation helpful? Give feedback.
-
I think you're reading the XPM file wrong. The "G" that you are reading at https://github.com/lanselibai/attach/blob/850cc4255e29ead9ef98f14aa655e99992b67057/ss.xpm#L46 belongs to the second but last residue. >>> xpm.array[0, -2]
u'3-Helix' The XPM is a bit map with coordinate origin in the lower left corner.
If you want the original orientation, use xpm = gromacs.formats.XPM("ss.xpm", reverse=False) If you have evidence that suggests that this is wrong for the DSSP files then let me know. EDIT: added output for second but last residue at time step 0. |
Beta Was this translation helpful? Give feedback.
-
Thank you I got it now! But if the last residue shows first, then in my case, the chain separator might be between the two chains, not before the last residue. So is there a solid evidence for the description about the location of chain separator? |
Beta Was this translation helpful? Give feedback.
-
As far as I can tell, your ss.xpm does not contain an explicit chain separator. It is not listed in the legend section and when I load it, I also don't see it: >>> import numpy as np
>>> from gromacs.formats import XPM
>>> ss = XPM("./ss.xpm")
>>> ss.array.shape
(1064, 443)
>>> np.unique(ss.array)
array([u'3-Helix', u'5-Helix', u'A-Helix', u'B-Bridge', u'B-Sheet',
u'Bend', u'Coil', u'Turn'], dtype='<U8') As far as I can tell, your
If its is true what Justin says in his reply to you
then you could get the "separator" by finding the "residue" with number 215: >>> ss.array[:, ss.yvalues == 215]
array([[u'Coil'],
[u'Coil'],
[u'Coil'],
...,
[u'Coil'],
[u'Coil'],
[u'Coil']], dtype='<U8') You could run
All I can say is that in the xpm that I have for my system, the "Chain_separator" is included. My xpm file does not say which version of Gromacs produced it; I think it was 4.6.5 but I am not really sure. |
Beta Was this translation helpful? Give feedback.
-
Thank you @orbeckst , it is a good idea to use only a PDB file. The outputs are here. Still, there are 443 residues, and I do not know which one is the chain separator. You can see from the PDB file that there are only 442 residues. Could you please send me your ss.xpm file? Where can I find the source code for the do_dssp for different versions of Gromacs? |
Beta Was this translation helpful? Give feedback.
-
@orbeckst I got the answer from Carsten now: OK, I found your issue. You are passing your own ss.map over to gmx do_dssp, |
Beta Was this translation helpful? Give feedback.
-
in my case, the chain separator is between the HC and LC. And yes, it is in the order: 442 |
Beta Was this translation helpful? Give feedback.
-
Glad that this was all explained. Closing. |
Beta Was this translation helpful? Give feedback.
-
Sorry I am new to the GW. I have successfully installed it on PyCharm. What next should I do?
I tried
import GromacsWrapper
but gotModuleNotFoundError: No module named 'GromacsWrapper'
I also tried
gromacs.g_hbond(s=TPR, f=XTC, g="hbond.log", hbm="hb.xpm", hbn="hb.ndx")
but gotNameError: name 'gromacs' is not defined
I want to import my ss.xpm file, then I can get an numpy array which contains all the ss records of all the residues for all the time frames. For example,
ss[32][21] = 'E'
means the 33th residue at 22th time frame has beta-sheet structure. Is this doable?@orbeckst
Beta Was this translation helpful? Give feedback.
All reactions