A structural study for the optimisation of functional motifs encoded in protein sequences