bfactor_chg¶
Replace the B-factor column of a PDB with residue-summed charges from a .chg file.
Behavior: - Prompts for PDB and CHG filenames. - Verifies:
The total number of non-empty lines in PDB equals the number of data lines in CHG.
The PDB contains NO ‘TER’ lines (will abort if found).
Every non-empty PDB line is ATOM or HETATM (since we expect 1:1 with CHG lines).
Sums charges per residue (chainID, resSeq, iCode) and writes that sum to the B-factor of every atom in the residue.
Writes output as: <pdb_stem>_bfactor_charge.pdb (e.g., B401_B402_bfactor_charge.pdb)
Notes on .chg: - Similar to XYZ but no header. We read the last whitespace-separated token as charge. - The number/order of lines must exactly match the PDB atom order.
Module Contents¶
Functions¶
|
|
|
|
|
|
|
Key residues by (chain_id, resseq, icode). |
|
Return a copy of the PDB ATOM/HETATM line with B-factor (cols 61-66, 1-based) |
|
|
|
|
|
- bfactor_chg.ask_path(prompt, default)¶
- bfactor_chg.die(msg, code=1)¶
- bfactor_chg.is_atom_record(line: str) bool¶
- bfactor_chg.residue_key(line: str)¶
Key residues by (chain_id, resseq, icode).
- bfactor_chg.set_bfactor(line: str, b: float) str¶
Return a copy of the PDB ATOM/HETATM line with B-factor (cols 61-66, 1-based) set to b, preserving occupancy (cols 55-60).
- bfactor_chg.read_charges_from_chg(path: str)¶
- bfactor_chg.count_nonempty_lines(path: str)¶
- bfactor_chg.main()¶