One of the few big companies producing a gene therapy, Novartis, recently got approval from the F.D.A. to market a treatment for a rare blood cancer.

But to get the viruses it needed, Novartis signed up years in advance with Oxford BioMedica, agreeing to three contracts starting in 2013 that, with incentives, add up to as much as $195.2 million and that included a provision to pay Oxford a share of the royalties when the drug was approved.

Only a few hundred patients a year might need Novartis’s treatment, and the company is charging $475,000 for the one-time therapy.

Other gene therapy companies are not always able to afford the manufacturing costs or find a manufacturer. Some have taken to buying slots in virus production queues years in advance — like buying a nonrefundable airline ticket long before your vacation and hoping you can get away when the time comes.

Other firms are hedging their bets. Worried that production at one company will fail — as can happen with the finicky viruses — they buy places in line at two contract companies.

Still other biotechs have simply been shut out, unable to get their viruses made.

Then there is BioMarin, one of the larger and more successful biotech companies, which decided to spend several hundred million dollars to build its own virus-manufacturing plant. It does not plan to make viruses for anyone but itself.

“We don’t want to be in a queue, that’s for sure,” said Robert Baffi, head of technical operations at BioMarin. The new facility also will give the company complete control over manufacturing, he added.