code: def _topology_from_residue(res):
      
      topology = app.Topology()
      chain = topology.addChain()
      new_res = topology.addResidue(res.name, chain)
  
      atoms = dict()  # { omm.Atom in res : omm.Atom in *new* topology }
  
      for res_atom in res.atoms():
          topology_atom = topology.addAtom(name=res_atom.name,
                           element=res_atom.element,
                           residue=new_res)
          atoms[res_atom] = topology_atom
          topology_atom.bond_partners = []
  
      for bond in res.bonds():
          atom1 = atoms[bond.atom1]
          atom2 = atoms[bond.atom2]
          topology.addBond(atom1, atom2)
          atom1.bond_partners.append(atom2)
          atom2.bond_partners.append(atom1)
  
      return topology
docs: Converts a openmm.app.Topology.Residue to openmm.app.Topology.
  
      Parameters
      ----------
      res : openmm.app.Topology.Residue
          An individual residue in an openmm.app.Topology
  
      Returns
      -------
      topology : openmm.app.Topology
          The generated topology