Skip to content

foyer.forcefield.apply does not carry over atomic_number information from the input structure #466

@jennyfothergill

Description

@jennyfothergill

Bug summary

I am using mbuild/foyer in a workflow in planckton. We have a couple older input mol2 files which were typed with antechamber, and for these the particle name will match the type name in a gaff (custom) forcefield. The element in the compound is manually set, and this transfers to the parmed structure, but when the apply function is used, the atomic number is not carried over from the input structure.

Code to reproduce the behavior

I'm using the example I described from planckton--if needed, I can work up a simpler example.

from planckton.compounds import COMPOUND
from planckton.forcefields import FORCEFIELD
from planckton.init import Compound

p3ht = Compound(COMPOUND["P3HT-16-gaff"])
gaff = FORCEFIELD["gaff-custom"]
residues = [p3ht.name]
pmd = p3ht.to_parmed(residues=residues)
s = gaff.apply(pmd, assert_dihedral_params=False)

p0 = [p for p in p3ht.particles()][0]
a0 = [a for a in pmd.atoms][0]
s0 = [a for a in s.atoms][0]
print(p0.name, p0.element.atomic_number)
print(a0.name, a0.atomic_number)
print(s0.name, s0.atomic_number)

output:

_cc 6
_cc 6
_cc 0

Software versions

NOTE: The below template should have dunder around version:

  • Which version of Foyer are you using? (python -c "import foyer; print(foyer.__version__)")
    0.9.4
  • Which version of Python (python --version)?
    Python 3.7.11
  • Which operating system?
    CentOS Linux release 7.8.2003 (Core)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions