marrink-lab / polyply_1.0

Generate input parameters and coordinates for atomistic and coarse-grained simulations of polymers, ssDNA, and carbohydrates
Apache License 2.0
122 stars 21 forks source link

Error message for undefined atom/bead types #299

Open ricalessandri opened 1 year ago

ricalessandri commented 1 year ago

Not a bug but possible enhancement.

This is the error one gets if the [ atoms ] contains a atom/bead type S4 that is not defined in the [atomtypes] section:

Traceback (most recent call last):
  File "/Users/alessandri/miniconda3/envs/polyply/bin/polyply", line 258, in <module>
    main()
  File "/Users/alessandri/miniconda3/envs/polyply/bin/polyply", line 254, in main
    subprogram(**args_dict)
  File "/Users/alessandri/miniconda3/envs/polyply/lib/python3.10/site-packages/polyply/src/gen_coords.py", line 246, in gen_coords
    GenerateTemplates(topology=topology, max_opt=10).run_system(topology)
  File "/Users/alessandri/miniconda3/envs/polyply/lib/python3.10/site-packages/polyply/src/processor.py", line 31, in run_system
    mols.append(self.run_molecule(molecule))
  File "/Users/alessandri/miniconda3/envs/polyply/lib/python3.10/site-packages/polyply/src/generate_templates.py", line 366, in run_molecule
    self.gen_templates(meta_molecule)
  File "/Users/alessandri/miniconda3/envs/polyply/lib/python3.10/site-packages/polyply/src/generate_templates.py", line 353, in gen_templates
    self.volumes[resname] = compute_volume(block,
  File "/Users/alessandri/miniconda3/envs/polyply/lib/python3.10/site-packages/polyply/src/generate_templates.py", line 180, in compute_volume
    rad = float(nonbond_params[frozenset([atom_key, atom_key])]["nb1"])
KeyError: frozenset({'S4'})

This error message for this could be improved. Opening this issue to hear your opinion and in case I can try to add an error message.

(P.S. Sorry I need to catch up with a couple of PRs but I'm planning to schedule some closing-open-PRs hackathon soon :))

fgrunewald commented 1 year ago

@ricalessandri for sure this can become an error message. The only question is from where to raise it. There are several functions that require the beads types to be present. Anyways, let's start with this one and then I'll think about of other places would benefit from the same error message.