rmgpy.molecule.pathfinder

This module provides functions for searching paths within a molecule. The paths generally consist of alternating atoms and bonds.

rmgpy.molecule.pathfinder.add_allyls(list path) list

Find all the (3-atom, 2-bond) patterns “X=X-X” starting from the last atom of the existing path.

The bond attached to the starting atom should be non single. The second bond should be single.

rmgpy.molecule.pathfinder.add_inverse_allyls(list path) list

Find all the (3-atom, 2-bond) patterns “start~atom2=atom3” starting from the last atom of the existing path.

The second bond should be non-single.

rmgpy.molecule.pathfinder.add_unsaturated_bonds(list path) list

Find all the (2-atom, 1-bond) patterns “X=X” starting from the last atom of the existing path.

The bond attached to the starting atom should be non single.

rmgpy.molecule.pathfinder.compute_atom_distance(list atom_indices, Graph mol) dict

Compute the distances between each pair of atoms in the atom_indices.

The distance between two atoms is defined as the length of the shortest path between the two atoms minus 1, because the start atom is part of the path.

The distance between multiple atoms is defined by generating all possible combinations between two atoms and storing the distance between each combination of atoms in a dictionary.

The parameter ‘atom_indices’ is a list of 1-based atom indices.

rmgpy.molecule.pathfinder.find_N5dc_radical_delocalization_paths(Vertex atom1) list

Find all the resonance structures of an N5dc nitrogen atom with a single bond to a radical N/O/S site, another single bond to a negatively charged N/O/S site, and one double bond (not participating in this transformation)

Example:

  • N=[N+]([O])([O-]) <=> N=[N+]([O-])([O]), these structures are isomorphic but not identical, the transition is important for correct degeneracy calculations

In this transition atom1 is the middle N+ (N5dc), atom2 is the radical site, and atom3 is negatively charged A “if atom1.atomtype.label == ‘N5dc’” check should be done before calling this function

rmgpy.molecule.pathfinder.find_adj_lone_pair_multiple_bond_delocalization_paths(Vertex atom1) list

Find all the delocalization paths of atom1 which either

  • Has a lonePair and is bonded by a single/double bond (e.g., [::NH-]-[CH2+], [::N-]=[CH+]) – direction 1

  • Can obtain a lonePair and is bonded by a double/triple bond (e.g., [:NH]=[CH2], [:N]#[CH]) – direction 2

Giving the following resonance transitions, for example:

  • [::NH-]-[CH2+] <=> [:NH]=[CH2]

  • [:N]#[CH] <=> [::N-]=[CH+]

  • other examples: S#N, N#[S], O=S([O])=O

Direction “1” is the direction <increasing> the bond order as in [::NH-]-[CH2+] <=> [:NH]=[CH2] Direction “2” is the direction <decreasing> the bond order as in [:NH]=[CH2] <=> [::NH-]-[CH2+] (where ‘:’ denotes a lone pair, ‘.’ denotes a radical, ‘-’ not in [] denotes a single bond, ‘-‘/’+’ denote charge) (In direction 1 atom1 <losses> a lone pair, in direction 2 atom1 <gains> a lone pair)

rmgpy.molecule.pathfinder.find_adj_lone_pair_radical_delocalization_paths(Vertex atom1) list

Find all the delocalization paths of lone electron pairs next to the radical center indicated by atom1. Used to generate resonance isomers in adjacent N/O/S atoms. Two adjacent O atoms are not allowed since (a) currently RMG has no good thermo/kinetics for R[:O+.][:::O-] which could have been generated as a resonance structure of R[::O][::O.].

The radical site (atom1) could be either:

  • N u1 p0, eg O=[N.+][:::O-]

  • N u1 p1, eg R[:NH][:NH.]

  • O u1 p1, eg [:O.+]=[::N-]; not allowed when adjacent to another O atom

  • O u1 p2, eg O=N[::O.]; not allowed when adjacent to another O atom

  • S u1 p0, eg O[S.+]([O-])=O

  • S u1 p1, eg O[:S.+][O-]

  • S u1 p2, eg O=N[::S.]

  • any of the above with more than 1 radical where possible

The non-radical site (atom2) could respectively be:

  • N u0 p1

  • N u0 p2

  • O u0 p2

  • O u0 p3

  • S u0 p1

  • S u0 p2

  • S u0 p3

(where ‘:’ denotes a lone pair, ‘.’ denotes a radical, ‘-’ not in [] denotes a single bond, ‘-‘/’+’ denote charge) The bond between the sites does not have to be single, e.g.: [:O.+]=[::N-] <=> [::O]=[:N.]

rmgpy.molecule.pathfinder.find_adj_lone_pair_radical_multiple_bond_delocalization_paths(Vertex atom1) list

Find all the delocalization paths of atom1 which either

  • Has a lonePair and is bonded by a single/double bond to a radical atom (e.g., [::N]-[.CH2])

  • Can obtain a lonePair, has a radical, and is bonded by a double/triple bond (e.g., [:N.]=[CH2])

Giving the following resonance transitions, for example:

  • [::N]-[.CH2] <=> [:N.]=[CH2]

  • O[:S](=O)[::O.] <=> O[S.](=O)=[::O]

Direction “1” is the direction <increasing> the bond order as in [::N]-[.CH2] <=> [:N.]=[CH2] Direction “2” is the direction <decreasing> the bond order as in [:N.]=[CH2] <=> [::N]-[.CH2] (where ‘:’ denotes a lone pair, ‘.’ denotes a radical, ‘-’ not in [] denotes a single bond, ‘-‘/’+’ denote charge) (In direction 1 atom1 <losses> a lone pair, gains a radical, and atom2 looses a radical. In direction 2 atom1 <gains> a lone pair, looses a radical, and atom2 gains a radical)

rmgpy.molecule.pathfinder.find_allyl_delocalization_paths(Vertex atom1) list

Find all the delocalization paths allyl to the radical center indicated by atom1.

rmgpy.molecule.pathfinder.find_allyl_end_with_charge(Vertex start) list

Search for a (3-atom, 2-bond) path between start and end atom that consists of alternating non-single and single bonds and ends with a charged atom.

Returns a list with atom and bond elements from start to end, or an empty list if nothing was found.

rmgpy.molecule.pathfinder.find_butadiene(Vertex start, Vertex end) list

Search for a path between start and end atom that consists of alternating non-single and single bonds.

Returns a list with atom and bond elements from start to end, or None if nothing was found.

rmgpy.molecule.pathfinder.find_butadiene_end_with_charge(Vertex start) list

Search for a (4-atom, 3-bond) path between start and end atom that consists of alternating non-single and single bonds and ends with a charged atom.

Returns a list with atom and bond elements from start to end, or None if nothing was found.

rmgpy.molecule.pathfinder.find_lone_pair_multiple_bond_paths(Vertex atom1) list

Find all the delocalization paths between lone electron pair and multiple bond in a 3-atom system atom1 indicates the localized lone pair site. Currently carbenes are excluded from this path.

Examples:

  • N2O (N#[N+][O-] <-> [N-]=[N+]=O)

  • Azide (N#[N+][NH-] <-> [N-]=[N+]=N <-> [N-2][N+]#[NH+])

  • N#N group on sulfur (O[S-](O)[N+]#N <-> OS(O)=[N+]=[N-] <-> O[S+](O)#[N+][N-2])

  • N[N+]([O-])=O <=> N[N+](=O)[O-], these structures are isomorphic but not identical, this transition is important for correct degeneracy calculations

rmgpy.molecule.pathfinder.find_shortest_path(Vertex start, Vertex end, list path=None) list
rmgpy.molecule.pathfinder.is_atom_able_to_gain_lone_pair(Vertex atom) bool

Helper function Returns True if atom is N/O/S and is able to <gain> an additional lone pair, False otherwise We don’t allow O to remain with no lone pairs

rmgpy.molecule.pathfinder.is_atom_able_to_lose_lone_pair(Vertex atom) bool

Helper function Returns True if atom is N/O/S and is able to <loose> a lone pair, False otherwise We don’t allow O to remain with no lone pairs