pestifer.charmmff.graphhelpers module

pestifer.charmmff.graphhelpers.anchor_paths(sub: Graph, anchor_adj: int, element_attr: str = 'element')[source]

One path per terminal leaf within the connected piece containing anchor_adj.

pestifer.charmmff.graphhelpers.carbon_component_from_neighbor(G: Graph, start: int, S: set[int], element_attr: str = 'element')[source]

Carbon-only connected component reachable from ‘start’ without entering S. Hydrogens are ignored implicitly since we require is_C.

pestifer.charmmff.graphhelpers.carbon_neighbors_outside_S(G: Graph, node: int, S: set[int], element_attr: str = 'element')[source]

Immediate carbon neighbors not in S.

pestifer.charmmff.graphhelpers.count_unsats_cc(G: Graph, path: list[int], element_attr: str = 'element') int[source]

Count C=C along a carbon path using ‘order’ if present; otherwise 0.

pestifer.charmmff.graphhelpers.cycle_atoms_heavy(G: Graph, element_attr: str = 'element')[source]

Return nodes on any cycle, computed on heavy-atom induced subgraph.

pestifer.charmmff.graphhelpers.elem(G: Graph, n: int, element_attr: str = 'element')[source]
pestifer.charmmff.graphhelpers.head_tail_pairs(G: Graph, chains: list[dict], element_attr: str = 'element')[source]
For each chain in chains, return:

{‘chain_id’, ‘head’, ‘tail’, ‘head_element’, ‘head_distance’}

where:

tail = last node of the chain’s path head = heaviest hetero atom at the minimum heavy-graph distance from the chain’s anchor

pestifer.charmmff.graphhelpers.heavy_degree(G: Graph, n: int, element_attr: str = 'element')[source]
pestifer.charmmff.graphhelpers.heavy_neighbors(G: Graph, n: int, element_attr: str = 'element')[source]
pestifer.charmmff.graphhelpers.heavy_only_nodes(G: Graph, element_attr: str = 'element')[source]
pestifer.charmmff.graphhelpers.is_C(G: Graph, n: int, element_attr: str = 'element')[source]
pestifer.charmmff.graphhelpers.is_H(G: Graph, n: int, element_attr: str = 'element')[source]
pestifer.charmmff.graphhelpers.is_N(G: Graph, n: int, element_attr: str = 'element')[source]
pestifer.charmmff.graphhelpers.is_O(G: Graph, n: int, element_attr: str = 'element')[source]
pestifer.charmmff.graphhelpers.is_P(G: Graph, n: int, element_attr: str = 'element')[source]
pestifer.charmmff.graphhelpers.is_S(G: Graph, n: int, element_attr: str = 'element')[source]
pestifer.charmmff.graphhelpers.label_lipid_chains_heavy_aware(G: Graph, min_len=6, split_branches=True, include_carbonyl_C_as_seed=True, element_attr: str = 'element')[source]

Identify lipid tails robustly when hydrogens are present.

Seeds:
  • hetero heavy atoms (O,N,P,S),

  • heavy-graph ring atoms,

  • heavy-branch carbons (heavy_degree >= 3),

  • (optionally) carbonyl carbons are naturally included via heavy_degree rule.

Returns:

dict node -> int or None chains: list of dicts {id, anchor, nodes, path, length, unsaturations}

Return type:

node_to_chain_id

pestifer.charmmff.graphhelpers.leafs_in(sub: Graph, avoid: int = None, element_attr: str = 'element')[source]

Degree-1 nodes within sub; optionally ignore ‘avoid’.

pestifer.charmmff.graphhelpers.mark_cc_doubles_by_degree(G: Graph, element_attr: str = 'element', set_other_cc_single: bool = True)[source]
Set bond ‘order’ on C-C edges using node degrees only:
  • C-C with both endpoints degree==3 -> order=2

  • (optional) all other C-C -> order=1

Non-C-C edges are untouched. Returns the list of edges marked as double.

pestifer.charmmff.graphhelpers.seed_set(G: Graph, branch_deg_threshold: int = 3, element_attr: str = 'element')[source]

Seeds = hetero heavy atoms, ring atoms (heavy graph), and heavy-branch carbons (heavy_degree>=3). Hydrogens are never seeds.