Question about atomic distances in a periodic cell

Currently I am trying to use Materials scripting to write a script that  de-hydroxylates a silica or other surface in a 3D periodic cell.  Part  of the algorithm that I am using to do this calculates the distance  between different hydroxide oxygens and selects the pair that is the  closest.

The problem that I am having is that there seems to be no simple way to  calculate the minimum distance between one atom and the periodic copies  of a second atom.  As an example of what I mean, imagine I have a cubic  1000 A^3 simulation cell (ie: 10x10x10) that has two atoms in it.  One  is at Cartesian coordinates (1,1,1) and the other at (9,9,9).  The  minimum distance between the two atoms should be 2.83 Angstroms (ie:  sqrt(2*2*2)).  However because of their positions in the cell the  distance across the cell is 22.63 Angstroms.  Given the two atoms the  distance that is meaningful to me is the 2.83 Angstrom distance, and is  the one I want to calculate.

If you create either a Bond or a Distance object, it is only able to be  defined between the two atoms in the unit cell.  If you calculate close  contacts that will create the minimum distance one, as well as all other  possible contacts within the distance specified.  This means that you have  to sort through all of the created close contacts to find the minimum  distance one.  It also only works if the minimum distance is roughly  less than 20 Angstroms, the maximum allowed distance for close contacts.

Is there a way to simply calculate the minimum distance between two atoms in a periodic cell including translations?  If so, what is it?

Thanks.
Brad.