This issue is a Codex global repository scan finding for deepmodeling/reacnetgenerator at commit 4fa8e2b.
The extxyz detector parses Lattice= only once in _readNfunc() and stores it on self.cell. _readstepfunc() then reuses self.cell for every frame instead of parsing the comment line for the current frame.
Relevant code:
|
if "Lattice=" in line: |
|
lattice_str = line.split("Lattice=")[1].split('"')[1] |
|
lattice_floats = list(map(float, lattice_str.split())) |
|
self.cell = np.array(lattice_floats).reshape((3, 3)) |
|
def _readstepfunc(self, item) -> tuple[list[bytes], tuple[int, int]]: |
|
step, lines = item |
|
step_atoms = [] |
|
timestep = step, step # Use step as timestep fallback |
|
boxsize = self.cell |
|
if self.pbc and boxsize is None: |
|
raise RuntimeError("No cell information is given in extxyz.") |
|
for index, line in enumerate(lines): |
|
if index > 1: |
|
s = line.split() |
|
step_atoms.append( |
|
(index - 1, Atom(s[0], tuple(float(x) for x in s[1:4]))) |
|
) |
|
_, step_atoms = zip(*sorted(step_atoms, key=operator.itemgetter(0))) |
|
step_atoms = Atoms(step_atoms) |
|
bond, level = self._getbondfromcrd(step_atoms, boxsize) |
Impact:
- variable-cell extxyz trajectories, common for NPT/PBC data, use the first frame's cell for all bond detection
- bond perception can become wrong when the box changes over time
- this can alter molecule identity and downstream reaction paths without an explicit error
Suggested fix:
Parse the extxyz metadata/comment line inside _readstepfunc() for each frame and pass that frame-specific lattice to _getbondfromcrd(). Keep the first-frame parsing in _readNfunc() only for atom count/type discovery if needed. Add a regression test with two frames that have different Lattice= values and assert the per-frame cell is used.
This issue is a Codex global repository scan finding for deepmodeling/reacnetgenerator at commit 4fa8e2b.
The extxyz detector parses
Lattice=only once in_readNfunc()and stores it onself.cell._readstepfunc()then reusesself.cellfor every frame instead of parsing the comment line for the current frame.Relevant code:
reacnetgenerator/reacnetgenerator/_detect.py
Lines 653 to 656 in 4fa8e2b
reacnetgenerator/reacnetgenerator/_detect.py
Lines 671 to 686 in 4fa8e2b
Impact:
Suggested fix:
Parse the extxyz metadata/comment line inside
_readstepfunc()for each frame and pass that frame-specific lattice to_getbondfromcrd(). Keep the first-frame parsing in_readNfunc()only for atom count/type discovery if needed. Add a regression test with two frames that have differentLattice=values and assert the per-frame cell is used.