Protostars accrete their material from the natal cloud through accretion disks. These disks are progressively dispersed by the recently formed star to form protoplanetary discs in which planets are born. Although this process takes a few million years, now we think that the final chemical composition of the gas and dust in the proto-planetary disk is to a large extent determined by the chemical evolution in the natal cloud. Determining the chemical composition of molecular clouds and young stellar objects at different evolutionary stages is therefore of paramount importance to discern the origin of the material from which planets are formed. In this talk we will give an overview of our work on the chemistry in star forming regions. In particular we will focus on the results of the IRAM Large Program “Gas phase Elemental abundancesin Molecular cloudS” (GEMS) and our long-term study of the transition disk AB Aurigae.