code: public static Atom[] findNearestAtomLinkage(final Group group1, final Group group2,
  			List<String> potentialNamesOfAtomOnGroup1, List<String> potentialNamesOfAtomOnGroup2,
  			final boolean ignoreNCLinkage, double bondLengthTolerance) {
  
  
  		List<Atom[]> linkages = findAtomLinkages(group1, group2,
  				potentialNamesOfAtomOnGroup1, potentialNamesOfAtomOnGroup2,
  				ignoreNCLinkage, bondLengthTolerance);
  
  		Atom[] ret = null;
  		double minDistance = Double.POSITIVE_INFINITY;
  
  		for (Atom[] linkage : linkages) {
  			double distance;
  
  			distance = Calc.getDistance(linkage[0], linkage[1]);
  
  
  			if (distance < minDistance) {
  				minDistance = distance;
  				ret = linkage;
  			}
  		}
  
  		return ret;
  	}
docs: Find a linkage between two groups within tolerance of bond length,
  from potential atoms.
  @param group1 the first {@link Group}.
  @param group2 the second {@link Group}.
  @param potentialNamesOfAtomOnGroup1 potential names of the atom on the first group.
  If null, search all atoms on the first group.
  @param potentialNamesOfAtomOnGroup2 potential names of the atom on the second group.
  If null, search all atoms on the second group.
  @param ignoreNCLinkage true to ignore all N-C linkages
  @param bondLengthTolerance bond length error tolerance.
  @return an array of two Atoms that form bond between each other
  if found; null, otherwise.