def topology_to_numpy(top):
    """Convert this topology into a pandas dataframe

    Returns
    -------
    atoms : np.ndarray dtype=[("serial", 'i4'), ("name", 'S4'), ("element", 'S3'),
                              ("resSeq", 'i4'), ("resName",'S4'), ("chainID", 'i4'), ("segmentID", 'S4')]
        The atoms in the topology, represented as a data frame.
    bonds : np.ndarray
        The bonds in this topology, represented as an n_bonds x 2 array
        of the indices of the atoms involved in each bond.
    """
    data = [(atom.serial, atom.name, atom.element.symbol,
             atom.residue.resSeq, atom.residue.name,
             atom.residue.chain.index, atom.segment_id) for atom in top.atoms]
    atoms = np.array(data,
                     dtype=[("serial", 'i4'), ("name", 'S4'), ("element", 'S3'),
                            ("resSeq", 'i4'), ("resName", 'S4'), ("chainID", 'i4'), ("segmentID", 'S4')])

    bonds = np.fromiter(((a.index, b.index) for (a, b) in top.bonds), dtype='i4,i4', count=top.n_bonds)
    return atoms, bonds
def topology_to_numpy ( top ) : data = [ ( atom . serial , atom . name , atom . element . symbol , atom . residue . resSeq , atom . residue . name , atom . residue . chain . index , atom . segment_id ) for atom in top . atoms ] atoms = np . array ( data , dtype = [ ( "serial" , 'i4' ) , ( "name" , 'S4' ) , ( "element" , 'S3' ) , ( "resSeq" , 'i4' ) , ( "resName" , 'S4' ) , ( "chainID" , 'i4' ) , ( "segmentID" , 'S4' ) ] ) bonds = np . fromiter ( ( ( a . index , b . index ) for ( a , b ) in top . bonds ) , dtype = 'i4,i4' , count = top . n_bonds ) return atoms , bonds
Convert this topology into a pandas dataframe

    Returns
    -------
    atoms : np.ndarray dtype=[("serial", 'i4'), ("name", 'S4'), ("element", 'S3'),
                              ("resSeq", 'i4'), ("resName",'S4'), ("chainID", 'i4'), ("segmentID", 'S4')]
        The atoms in the topology, represented as a data frame.
    bonds : np.ndarray
        The bonds in this topology, represented as an n_bonds x 2 array
        of the indices of the atoms involved in each bond.