Similarity between element x and y was calculated as the degree of replaceability for one another in molecular formulas (MFs). For a given set of MFs, a similarity matrix (S t ) collecting all pair-wise similarities among chemical elements is obtained. For the calculation, every MF of the form A a ...Q q ...Z z was rewritten as A a ...Q q-n ...Z z -Q n , with n ≤ q. A set of templates R-X n is obtained, with X being any element in the MF. In this case, it is said that element Q holds the template R-X n , as the compound R-Q n exists in the dataset.