Formation of molecular templates for fabricating on-chip biosensing devices