Optical and electronic properties of functional polythiophenes