Skip to content

Commit 2ccaf1f

Browse files
committed
slightly prettier chain report
1 parent 159bd95 commit 2ccaf1f

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

moleculekit/tools/preparation.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,18 @@ def _check_chain_and_segid(mol, verbose):
7575
chainatoms = np.where(mol.chain == c)[0]
7676
firstatom = chainatoms[0]
7777
lastatom = chainatoms[-1]
78-
print(f"Chain {c}:")
79-
print(
80-
f" First residue: {_fmt_res(mol.resname[firstatom], mol.resid[firstatom], mol.insertion[firstatom])}"
78+
firstres = _fmt_res(
79+
mol.resname[firstatom], mol.resid[firstatom], mol.insertion[firstatom]
8180
)
82-
print(
83-
f" Final residue: {_fmt_res(mol.resname[lastatom], mol.resid[lastatom], mol.insertion[lastatom])}"
81+
lastres = _fmt_res(
82+
mol.resname[lastatom], mol.resid[lastatom], mol.insertion[lastatom]
8483
)
84+
print(f"Chain {c}:")
85+
if firstres == lastres:
86+
print(f" {'residue:':>14} {firstres}")
87+
else:
88+
print(f" {'First residue:':<16}{firstres}")
89+
print(f" {'Final residue:':<16}{lastres}")
8590
print("---- End of chain report ----\n")
8691

8792
return mol

0 commit comments

Comments
 (0)