Infinite DNA (across boundary conditions)

Hi,
I get a little lost in the number. you have to look each strand independently. Assuming your strand is going from resid 1 to resid 12 and you have the following atoms numbering in the strand
…-P(31-resid2)…O(352-resid11)-P(353-resid12)
Then what you wrote is correct.

If you visualize the gro file with VMD (and one of the drawing options) it occurs that you see a long bond going through the box from the first strand residue to the last strand residue. That is due to the fact that vmd think that it is one molecule and do not know that it is a continuum system.
I hope that makes thing more clear.
Best regards
Alessandra