-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: unsupported operand type(s) for *: 'NoneType' and 'float' #484
Comments
This is likely arising due to removal of coarse-grained particle names from the For quick reference, the code in question is: MolecularNodes/molecularnodes/io/parse/mda.py Lines 175 to 181 in fba40bd
Do you happen to have any heavy metal atoms in this structure? |
Doesn't look like it. But the atom names listed in the .psf file are certainly not standard atom names and aren't being handled well before the MolecularNodes/molecularnodes/io/parse/mda.py Lines 153 to 166 in fba40bd
Applying this code to the coarse-grained particles in your system returns a set of "elements symbols": elements = [x if x in mn.data.elements.keys() else MDAnalysis.topology.guessers.guess_atom_element(x) for x in all_sel.atoms.names]
print(set(elements))
> {'A', 'AL', 'B', 'C', 'G', 'H', 'I', 'L', 'M', 'P', 'S', 'T'} This is a perfect example of the the MDA guesser failing on us. Related to #452 and #468. Iodine doesn't have a vdw_radii defined in its subdictionary. |
where is this elements dictionary ? in MDAnalysis in python somewhere ?? looks like i have to add the spica cg amino acids to it manually.
no it's a protein with 687 residues, spica coarse grains each amino acids into 1-5 beads:
|
The I'm getting a fix pushed shortly. |
computer is only as dumb as what you tell it, i have to be explicit and provide the cg spica definitions somewhere. ok ill look at those other issues and try to contribute a fix.
there's no iodine anywhere in this file, only the 20 standard amino acids. Since iodine has an atomic weight of ~127, then the code appears to be matching based on weight so a side chain with the backbone of MET say with two cg beads for a total weight of 56+75=131 is getting matched as iodine incorrectly |
Yeah, the MDAnalysis guesser functions get pretty desperate to fill in missing information. The element guesser seems to be doing some strange things. |
i have to merge the spica cg beads information into data.py, this way no guessing required. see attached json: |
@rbdavid i have vdw radii up to 99 from pubchem, and the rest are available in mathematica. ill fork this repo and add all the radii to data.py later tonight. |
I only glanced at the elements data in Wolfram Mathematica; if I recall correctly, I was unable to find the sources for those values. MDAnalysis also includes a table of vdw radii values but its very limited. If you have the time, check the vdw radius values against the papers I link to in the #468. Filling out the But in this case, the vdw_radii values listed in the |
@rbdavid how do you run this python code:
i tried pasting it in the blender python window but i got:
|
TLDR: Coarse-grained particles should never be mapped to elements but they currently are when importing such a structure file into MolecularNodes. Basically, don't trust the assigned Oh shoot. The code snippet that you are trying to use is a part of a small ipython instance that I ran to debug what was happening for this error. It highlights a deeper, fundamental bug in how MN (but really MDAnalysis) fills in missing information about atoms' element labels. Its not something I was doing within blender or the MolecularNodes python API. I'll try to recreate it here in full: import MDAnalysis
import molecularnodes as mn
import pprint
u = MDAnalysis.Universe('4pyg-e.psf','4pyg-20fs-3frames.lammpsdump')
all_sel = u.select_atoms('all')
print(sorted(set(all_sel.atoms.names)))
> ['ABB', 'ABBL', 'ABBS', 'AR1', 'AR2', 'ASN', 'ASP', 'CYS', 'GBB', 'GBBL', 'GBBS', 'GBM', 'GBML', 'GBMS', 'GBTL', 'GLN', 'GLU', 'HI1', 'HI2', 'HI3', 'ILE', 'LEU', 'LY1', 'LY2', 'MET', 'PH1', 'PH2', 'PH3', 'PH4', 'PRO', 'SER', 'THR', 'TR1', 'TR2', 'TR3', 'TY1', 'TY2', 'TY3', 'TY4', 'VAL']
elements = [x if x in mn.data.elements.keys() else MDAnalysis.topology.guessers.guess_atom_element(x) for x in all_sel.atoms.names]
print(sorted(set(elements)))
> ['A', 'AL', 'B', 'C', 'G', 'H', 'I', 'L', 'M', 'P', 'S', 'T']
pprint.pp(list(zip(all_sel.atoms.names, elements))) The But, MDAnalysis nor MN can know that context easily; there are literally too many all-atom and coarse grained force fields out there to have a guesser that covers all that ground without ambiguity/conflicts in name spaces. Like, the atom name Once PR #485 is merged with main, the fatal error you are seeing that stems from all this weirdness should be squashed. You'll be able to load your structure in just fine. But! and this is a big but, none of your elemental data values will be accurate. They shouldn't even be considered. The assigned |
If anyone knows a gpt-like or natural language processing tool that can guess force-field context (all-atom versus coarse-grained, or GROMOS versus AMBER force fields) from a structure file, that might be a great first step to solving this problem. |
where should i add these in data.py ? in elements or coarse_grain_particles ?? when i grep the whole MN repo, "coarse_grain_particles" only shows up in data.py. is it even used somewhere ? |
That You can place the SPICA coarse-grain particle information into that dictionary since, in my opinion, it should not go into the MolecularNodes/molecularnodes/io/parse/mda.py Lines 153 to 166 in fba40bd
|
Alternatively, you posted a json file earlier that contains all relevant information about the SPICA CG force field. It should be feasible/possible to analyze that json file and fill in incorrectly assigned attribute values within the Blender instance so that you're working with the expected set of values. I'm not familiar enough with the SPICA force field to say what those values are or what not. I can help with parsing the json and sending data to attributes but not so much with considering the values associated with that model. |
im working on adding all the spica beads into elements dictionary starting with atomic number 1000, ill make a draft PR when data.py is ready |
added vdv_radii up to 99 and spica cg particles to data.py SOURCES: |
Describe the bug
loading MD lammps cg spica trajectory gives error and does not load.
To Reproduce
Topology: 4ypg-e.psf
Trajectory: 4ypg-20fs.lammpsdump
"Load"
Expected behavior
load md lammps trajectory without error
Error Codes
Desktop (please complete the following information):
Additional context
.psf and .lammpsdump with 3 frames attached as zip
4pyg-mwe.zip
The text was updated successfully, but these errors were encountered: