Affinity purification of proteins using ligands derived from peptide libraries