Inter-chain distance¶
The odist tool computes inter-chain distances between pairs of atoms,
where each atom belongs to a different chain.
It is designed for analyzing LLPS condensates, oligomers, and multi-chain
systems where the distance between representative atoms on different chains is
an important metric.
This tool is implemented in inter_distance.py.
Overview¶
dps odist performs:
Load a trajectory (TPR + XTC + optional NDX).
Select two atom groups: - reference group (one atom per chain) - selection group (one atom per chain)
Split each group into chains (using
splitch).Validate that each chain contributes exactly one atom.
For each frame: - compute distances between all reference–selection atom pairs
Reshape into a time × (reference × selection) matrix
Optionally remove self-pairs (i = j)
Output: - verbose per-pair distances - averaged off-diagonal distances
Usage¶
dps odist -s run.tpr -f run.xtc -ref 0 -sel 1 -ov verbose.xvg
Arguments¶
Required¶
- -s, --run-input TPR¶
TPR file containing topology, residue/chain mapping, atom properties.
- -f, --input XTC¶
XTC trajectory used for distance calculations.
Optional¶
Index file¶
Group selection¶
Exactly one atom per chain must be selected.
If omitted, the program enters interactive selection mode.
Time control¶
- -b, --start-time INT¶
- -e, --end-time INT¶
- -dt, --delta-time INT¶
Determine which frames to evaluate; converted to indices via
trajectory.time2frame.
PBC handling¶
- -pbc, --treat-pbc¶
Apply MDAnalysis
unwraptransformation so distances reflect the real molecular coordinates, not wrapped positions.
Output¶
At least one of:
- -ov, --output-verbose FILE¶
Write all pairwise distances for each time point.
- -oa, --output-average FILE¶
Write the off-diagonal chain-averaged distance vs time.
Program Workflow¶
Load trajectory
trajectory = trajectory_class(tpr, ndx, xtc)
Errors during loading abort execution.
PBC transform
unwrap(trajectory.Universe.atoms)
if --treat-pbc is provided.
Frame indices
start, end, step = trajectory.time2frame(b, e, dt)
frame_list = range(start, end, step)
Group selection
If
--refgiven: group <id>Else: interactive selection
Same for
--sel
Chain splitting
reference_splitchains = trajectory.index.splitch_indices(reference.indices)
selection_splitchains = trajectory.index.splitch_indices(selection.indices)
Validation:
each chain must contribute exactly one atom
reference and selection must have equal chain counts
Errors such as:
“multiple atoms in single chain for reference group”
“Number of atoms in reference and selection groups not match.”
are reported explicitly.
Pair construction
pairs = [[a1, a2] for a1 in reference.indices for a2 in selection.indices]
Distance computation
For each frame:
v = pos1 - pos2
dist = norm(v, axis=1)
All distances stored in a matrix:
distances[time, pair_index]
Matrix reshape
To a 3-D matrix:
distances_matrix[time, ref_chain, sel_chain]
Off-diagonal mask (i != j)
Diagonal entries (chain self-distance) are zeroed:
distances_no_diag[:, i, i] = 0
Output Files¶
Verbose distances¶
Generated when --output-verbose is set.
X-axis: time (ns)
Columns: distance of each pair (j,i)
Legends:
Chain X – Chain Y
A legend for every pair i > j.
Average distances¶
Generated when --output-average is set.
The value written is:
Output units: nanometers.
File created using:
write_xvg(filename, time_list, avg_values)
Example¶
Compute all inter-chain distances between group 0 and group 1:
dps odist \
-s run.tpr \
-f run.xtc \
-n run.ndx \
-ref 0 -sel 1 \
-ov all_pairs.xvg
Compute only the chain-averaged distance:
dps odist \
-s run.tpr \
-f run.xtc \
-ref 5 -sel 5 \
-oa avg_distance.xvg \
-pbc
Error Messages¶
“multiple atoms in single chain for reference group.” Reference selection must contain exactly 1 atom per chain.
“Number of atoms in reference and selection groups not match.” Both groups must span the same number of chains.
“Distance will be calculated without periodic boundary conditions.”
Printed when --treat-pbc is omitted.
“An exception occurred when trying to open trajectory file …” TPR/XTC path invalid or file corrupted.
Summary¶
dps odist computes detailed inter-chain distance matrices for any atom
pairing scheme where each chain contributes one representative atom.
It provides:
full pairwise distances
off-diagonal per-time averages
optional PBC handling
flexible interactive selection
This tool is highly useful for tracking chain-chain separation, oligomerization, and condensate organization during LLPS simulations.