Capturing molecules with templated materials: analysis and rational design of molecularly imprinted polymers