2020-09-23 Wagner Behara Topology Positions Spec

Date

Sep 23, 2020

Participants

  • @Jeffrey Wagner

  • @Pavan Behara

Goals

  • Make OFFTopology.to_file() work, as specified in JW’s comment in

  • Lay out what a Topology class with positions could look like.

Discussion topics

Let's just add the basic functionality now:

Method will probably look something like:

class Topology: ... def to_file(filename, positions, file_format='PDB'): openmm_top = self.to_openmm() openmm_pdbfile = ??? (openmm_top) ??? (something to do with simtk.openmm.app.PDBFile) openmm_pdbfile.writeFile(openmm_top, positions, filename)

Implemented a minimal function that takes in the topology and positions with units (or without, that defaults to angstroms), still need to tackle virtual sites

  • units are handled using openmm Quantity object

  • for virtual sites: checking the no. of atoms in both topology and coords suffice?

  • need to write tests, checked whether units are handled properly or not (and it works)

 

TANGENT: ((I wasted time on this useless diversion))

Openmm outputs positions and topology to pdb by two calls:

PDBFile.writeModel() - that writes coordinates at every step

PDBFile.writeFooter() - that usually writes the topology at the end of simulation

A cheap workaround for openmm simulations is to create a copy of their pdbreporter.py and include the writeFooter() call after every call to PDBFile.writeModel(). Here is the file, https://github.com/openmm/openmm/blob/f9106ddb6a0d72c960c73b23ed0e07cd7190a80f/wrappers/python/simtk/openmm/app/pdbreporter.py, just adding writeFooter() after line 99 would output the topology at each step.

And instead of openmm.app.PDBReporter() we can append something like Topology.off_pdbreporter(), the customized pdbreporter, to the call simulation.reporters.append() and it works fine.

 

 

In the future, we may want to have these positions be optionally stored in an OFFTopology.

Let's spec this out to see whether we can come up with a practical/unsurprising set of behaviors for a OFFTopology object that contains positions:

Ways to make a Topology:

  • Topology.init

  • Topology.from_molecules

    •  

  • Topology.from_dict

    • Load exact position values from dict

  • Topology.from_openmm

    • Do not load – OpenMM Topology objects do not have positions.

  • Topology.from_mdtraj

    • Load positions if available

  • Possible new methods:

    • Topology.from_pdb_and_

Ways to modify a Topology:

  • Topology.add_molecule

Ways to export a Topology:

  • Topology.to_dict

  • Topology.to_openmm

 

Action items

@Pavan Behara will work towards a PR that satisfies the spec in JW’s comment on #502.
@Jeffrey Wagner and @Pavan Behara will discuss how OFFTopology.positions could work after the minimal functionality for #502 is implemented.

Decisions