ProDy icon indicating copy to clipboard operation
ProDy copied to clipboard

System size limitation in writeNMD and/or NMWiz

Open cgseitz opened this issue 3 years ago • 17 comments

Hello,

I am trying to animate a system using ANM in the NMWiz plugin for VMD. I have tried two ways:

  1. Create and save an ANM modes file
writeNMD('anm_modes.nmd', anm[:5], phage.select('calpha'))

but opening this in VMD does not look right. Parts of my system are present in VMD, but maybe half of it seems to have been compressed to a line below the rest of the system in a different plane. I can create an animation with this, but again the structure looks fairly wrong so it isn't really usable. It's my understanding that one cannot create an animation from GNM data; saving my GNM data and opening it in VMD also leads to parts of the system lying on the floor of the VMD window as described above.

  1. Open my system in NMWiz, calculate the ANM modes there and animate. I can load the system without issue in VMD, but calculating the ANM modes from the ProDy interfaces leads to an error:
Info) Executing: /home/cseitz/miniconda3/envs/prody/bin/python /home/cseitz/miniconda3/envs/prody/bin/prody anm --quiet -s all -o /net/gpfs-amarolab/cseitz/from_jam/projects/phage/3_analyses/prody -p /net/gpfs-amarolab/cseitz/from_jam/projects/phage/3_analyses/prody/MOL_dry_anm -n 10 -c 15 -g 1 -u "/net/gpfs-amarolab/cseitz/from_jam/projects/phage/3_analyses/prody/MOL_dry_anm.pdb"
Info) NMWiz: Parsing file /net/gpfs-amarolab/cseitz/from_jam/projects/phage/3_analyses/prody/MOL_dry_anm.nmd
Warning) NMWiz: segnames does not contain any data.
Info) NMWiz: File contains a 3D model.
Info) NMWiz: All segment names are set as "A".
Info) Using plugin pdb for structure file /tmp/.nmdset0.pdb
Info) Using plugin pdb for coordinates from file /tmp/.nmdset0.pdb
Info) Determining bond structure from distance search ...
Info) Analyzing structure ...
Info)    Atoms: 20412
Info)    Bonds: 0
Info)    Angles: 0  Dihedrals: 0  Impropers: 0  Cross-terms: 0
Info)    Bondtypes: 0  Angletypes: 0  Dihedraltypes: 0  Impropertypes: 0
Info)    Residues: 20412
Info)    Waters: 0
Info)    Segments: 1
Info)    Fragments: 20412   Protein: 0   Nucleic: 0
Segmentation fault (core dumped)

Is there a size limit on what writeNMD or NMWiz can handle? As you can see in the error above, my system has >20,000 residues. If there isn't a size limit, do you know what the problem might be?

cgseitz avatar Mar 26 '21 17:03 cgseitz

I don’t know. I can certainly have a look next week

jamesmkrieger avatar Mar 26 '21 17:03 jamesmkrieger

Alright thanks! I dug a bit more and believe this is actually two issues. I don't think that writeNMD can handle this many residues; when I save and then reload modes through writeNMD, it does not list the same number of atoms as when I create the modes initially. This correlates with what I saw in VMD, whereby loading the writeNMD file in VMD didn't show the full structure.

The other issue is NMWiz; even if it cannot create modes for such a large system, perhaps it can simply load large files and create animations provided that writeNMD properly creates the files. Or maybe it can't load such large files.

cgseitz avatar Mar 27 '21 15:03 cgseitz

Hi Christian,

I can't see anything in writeNMD to suggest that there should be a limit on number of atoms that it can write so I'd say it's more likely that this is an NMWiz problem. Have you tried using parseNMD in ProDy to check whether the NMD file contains what it's supposed to?

Best wishes James

jamesmkrieger avatar Apr 12 '21 14:04 jamesmkrieger

Hi James,

Thanks for looking into this. Using writeNMD and then parseNMD gives the expected output - the loaded modes look identical to the previously created modes, both in atom numbers and graphing the modes.

Best, Christian

cgseitz avatar Apr 12 '21 16:04 cgseitz

You're welcome. I'm glad that's figured out. I guess I'll have to wade through NMWiz and see if I can find anything there to explain what's happening then.

Best wishes James

jamesmkrieger avatar Apr 12 '21 17:04 jamesmkrieger

that would be great!! If you make any progress I would surely use an ANM animation in my upcoming publication~

cgseitz avatar Apr 30 '21 00:04 cgseitz

Ok! Sounds good

jamesmkrieger avatar Apr 30 '21 06:04 jamesmkrieger

You could also use traverseMode to make an ensemble and write that to PDB for visualisation in PyMOL or Chimera, but I’ll see what I can do some time next week

jamesmkrieger avatar Apr 30 '21 07:04 jamesmkrieger

I can confirm that I can reproduce the same problem of the initial atoms being placed stretched along a line using a structure in the PDB (4v8r), which has two CCT hexadecamers in the asymmetric unit. When I make the movies, however, the atoms get placed back in their original positions.

I haven't yet found code that could explain this, but this finding should help pinpoint it.

jamesmkrieger avatar May 03 '21 19:05 jamesmkrieger

Actually, the problem may be with writeNMD after all as using parseNMD then writePDB and then opening up the file in PyMOL also gave an elongated set of beads.

jamesmkrieger avatar May 06 '21 12:05 jamesmkrieger

Sorry for the delay. I've tried to make an ensemble through traverseMode. From there I could use setAtoms and then writePDB and the load this pdb in pymol or chimera to see the animation (but correct me if I'm wrong). However, my GNM modes are not 3D modes, as seen through gnm.is3d(). I was assuming these would be 3D modes as I can create 3D images of them through showProtein(calphas, mode=gnm[0]); what simple thing am I missing here? I built my modes as follows:

phage = parsePDB('MOL_dry.pdb')
phage
calphas = phage.select('calpha')
calphas
gnm = GNM('Phage')
gnm.buildKirchhoff(calphas)
gnm.getKirchhoff()
gnm.calcModes(n_modes=10, zeros=False, turbo=True)

And my error is this:

traverseMode(gnm[0], calphas)
ValueError                                Traceback (most recent call last)
<ipython-input-33-b6b607ae135e> in <module>
----> 1 traverseMode(gnm[0], calphas)
      2 #setAtoms(calphas)

~/.local/lib/python3.7/site-packages/prody/dynamics/sampling.py in traverseMode(mode, atoms, n_steps, rmsd, **kwargs)
    199                         'not {0}'.format(type(mode)))
    200     if not mode.is3d():
--> 201         raise ValueError('mode must be from a 3-dimensional model.')
    202     n_atoms = mode.numAtoms()
    203     initial = None

ValueError: mode must be from a 3-dimensional model.

cgseitz avatar May 11 '21 02:05 cgseitz

That’s right. GNM modes are not 3D so you can’t animate them with either NMWiz or traverseMode. What NMWiz and showProtein give are structures coloured by the mode instead. The easiest way to get that into chimera or pymol is to writePDB with beta=gnm[0] for example.

The function traverseMode only works with 3D modes from ANM, PCA, etc.

jamesmkrieger avatar May 11 '21 08:05 jamesmkrieger

Hi James,

Sorry for another silly question, but can you tell me what I'm doing wrong here? I have selected the alpha carbons and created GNM modes from those. I can write a pdb structure of just the alpha carbons, but when I try to add a mode, containing the same number of atoms, it says that the atoms numbers differ. I did create some animations of the ANM modes with traverseMode, it was interesting...

writePDB('test.pdb', calphas) #this works
print(len(gnm[0]))
print(len(calphas))
writePDB('test.pdb', calphas, beta=gnm[0]) #says len() of unsized object
@> WARNING Resnums are exceeding 9999 and hexadecimal format is being used for resnums

20412
20412

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-54-87b3524e4480> in <module>
      2 print(len(gnm[0]))
      3 print(len(calphas))
----> 4 writePDB('test.pdb', calphas, beta=gnm[0]) #says len() of unsized object

~/.local/lib/python3.7/site-packages/prody/proteins/pdbfile.py in writePDB(filename, atoms, csets, autoext, **kwargs)
   1453         filename += '.pdb'
   1454     out = openFile(filename, 'wt')
-> 1455     writePDBStream(out, atoms, csets, **kwargs)
   1456     out.close()
   1457     return filename

~/.local/lib/python3.7/site-packages/prody/proteins/pdbfile.py in writePDBStream(stream, atoms, csets, **kwargs)
   1226     else:
   1227         bfactors = np.array(beta)
-> 1228         if len(bfactors) != n_atoms:
   1229             raise ValueError('len(beta) must be equal to number of atoms')
   1230 

TypeError: len() of unsized object

cgseitz avatar May 12 '21 06:05 cgseitz

Oh sorry, yes. I forgot you need to use getArray so it would be writePDB('test.pdb', calphas, beta=gnm[0].getArray())

jamesmkrieger avatar May 12 '21 08:05 jamesmkrieger

thanks, that works now!

cgseitz avatar May 19 '21 04:05 cgseitz

You’re welcome.

There’s still the issue with the NMD file so this still open.

jamesmkrieger avatar May 19 '21 08:05 jamesmkrieger

Actually, the problem may be with writeNMD after all as using parseNMD then writePDB and then opening up the file in PyMOL also gave an elongated set of beads.

Actually, this isn't happening now, but I still get the elongated set in VMD from the nmd file

jamesmkrieger avatar Feb 01 '23 14:02 jamesmkrieger