A biomimetic molecular switch at work: coupling photoisomerization dynamics to peptide structural rearrangement