Knowledge based method for building molecular models