Skip to content

HYDRONMR

run

run(pdb_path: Union[str, Path], config_path: Union[str, Path] = DEFAULT_CONFIG_PATH, csv_path: Optional[Union[str, Path]] = None) -> Result

Run the mode-25 pipeline (PDB -> diffusion tensor -> per-residue T1/T2/NOE) for pdb_path, using parameters from config_path (default: python_port/config.yml).

If csv_path is given, also write per-residue results there (columns: resseq, T1, T2, T1_over_T2, NOE).

Source code in makeshift/hydronmr/engine.py
def run(
    pdb_path: Union[str, Path],
    config_path: Union[str, Path] = DEFAULT_CONFIG_PATH,
    csv_path: Optional[Union[str, Path]] = None,
) -> Result:
    """Run the mode-25 pipeline (PDB -> diffusion tensor -> per-residue
    T1/T2/NOE) for `pdb_path`, using parameters from `config_path`
    (default: `python_port/config.yml`).

    If `csv_path` is given, also write per-residue results there
    (columns: resseq, T1, T2, T1_over_T2, NOE).
    """
    cfg = Config.from_yaml(config_path)

    g = HydronmrState()
    g.modehyd = 25
    g.pdb_path = str(pdb_path)
    g.aer = cfg.aer_angstrom
    g.temperature = cfg.temperature_k
    g.viscosity = cfg.viscosity_poise

    structure_pro(g)

    ct, cr, cc, c, cod = tensors.hydro(
        g.bead_positions, g.bead_radii, g.viscosity,
        center=g.center_of_mass, ind=cfg.ind,
    )
    g.friction_translation = ct
    g.friction_rotation = cr
    g.friction_coupling = cc
    g.friction_full = c
    g.center_of_diffusion = cod

    tensors.generdif66_state(g)
    rotani(g)
    dipolesnmr(
        g,
        b0_tesla=cfg.fields_tesla[0],
        gamma_x=cfg.gamma_x_e7 * 1.0e7,
        r_nh_angstrom=cfg.r_nh_angstrom,
        csa_ppm=cfg.csa_ppm,
    )

    atoms = parse_pdb_atoms(g.pdb_path)
    nh_vectors = nh_bond_vectors(atoms)

    per_residue = per_residue_results(g, nh_vectors)

    written = None
    if csv_path is not None:
        written = write_t1t2_csv(g, nh_vectors, csv_path)

    return Result(state=g, per_residue=per_residue, csv_path=written)

Result dataclass

Result(state: HydronmrState, per_residue: dict, csv_path: Optional[Path] = None)

to_dataframe

to_dataframe()

Per-residue results as a tidy DataFrame, one row per residue with columns: chain, seqpos, T1, T2, T1_over_T2, NOE.

Source code in makeshift/hydronmr/engine.py
def to_dataframe(self):
    """Per-residue results as a tidy DataFrame, one row per residue with
    columns: chain, seqpos, T1, T2, T1_over_T2, NOE."""
    rows = [
        dict(chain=chain, seqpos=resseq,
             T1=t1, T2=t2, T1_over_T2=ratio, NOE=noe)
        for (chain, resseq), (t1, t2, ratio, noe) in self.per_residue.items()
    ]
    return (pd.DataFrame(rows)
            .sort_values(["chain", "seqpos"])
            .reset_index(drop=True))

to_csv

to_csv(path)

Write per-residue results to path (columns: resseq, T1, T2, T1_over_T2, NOE) and return the path written.

Source code in makeshift/hydronmr/engine.py
def to_csv(self, path):
    """Write per-residue results to ``path`` (columns: resseq, T1, T2,
    T1_over_T2, NOE) and return the path written."""
    from .physics.output import write_t1t2_csv
    from .physics.pdb import nh_bond_vectors, parse_pdb_atoms
    nh_vectors = nh_bond_vectors(parse_pdb_atoms(self.state.pdb_path))
    return write_t1t2_csv(self.state, nh_vectors, path)