Ab initio computation of molecular similarity