Shire plc agreed to buy ViroPharma Inc. for about $4.2 billion to gain treatments for rare diseases and ease dependence on its best-selling Vyvanse pill for attention deficit hyperactivity disorder. Shire will pay $50 a share in cash, 27 percent more than the closing price of ViroPharma on Nov. 8, the Dublin-based drugmaker said today in a statement. The acquisition gives Shire access to Cinryze, a medicine for the inflammatory condition hereditary angioedema, which complements Shire’s Firazyr for the same malady, the company said. The purchase marks the company’s third this year under Flemming Ornskov, who became chief executive officer in April, and is Shire’s biggest, topping the $3.6 billion takeover of Canada’s BioChem Pharma Inc. in 2001. “This is the big deal the market had been waiting for,” Savvas Neophytou, an analyst at Panmure Gordon & Co., said in a note to investors today. The purchase is “clearly at an eye- watering multiple but strategically very sound.” Based on the price of $4.2 billion, Shire is paying about 58 times earnings before interest, tax, depreciation and amortization for ViroPharma, according to data compiled by Bloomberg. Buyers paid a median of 23 times Ebitda for biotechnology companies in transactions valued at more than $100 million in the past five years.