-
I have created a new universe from a fully atomistic simulation using a machine-learned force field. universe = mda.Universe.empty(n_atoms=len(atoms), trajectory=True)
...
universe.add_TopologyAttr("bonds", bonds)
reader = H5MDReader(file, convert_units=False)
universe.trajectory = reader I know the composition of the molecules but I don't have a topology file and wanted to compute RDFs and MSDs based on the COM of the residues. In a first attempt I want to compare each fragment to a known list of molecules in the system and assign a resname. (Later on I want to use the connectivity graph to match the molecules more precisely but for now I don't have structures of the same composition in my system.) My attempt to add residues follows https://docs.mdanalysis.org/stable/documentation_pages/core/universe.html#MDAnalysis.core.universe.Universe.add_Residue residues = {k: smiles2atoms(smiles=v) for k, v in self.residues.items()}
mda_residues = {}
for idx, residue in enumerate(residues):
mda_residues[residue] = universe.add_Residue(
segment=universe.segments[0], resid=idx, resname=residue, resnum=idx
)
for mol in universe.atoms.fragments:
for residue in residues:
if sorted(mol.names) == sorted(residues[residue].get_chemical_symbols()):
universe.atoms[mol.indices].residues = mda_residues[residue]
break
else:
raise ValueError With this I can now use
What am I missing? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I was missing a |
Beta Was this translation helpful? Give feedback.
I was missing a
universe.add_TopologyAttr("resnames")
as described here https://userguide.mdanalysis.org/stable/topology_system.html#format-specific-attributes