Ligand Pharmaceuticals to buy Pfenex for up to $516m