let topiary ?(configuration=Tools.Topiary.Configuration.default)
vcfs predictor alleles =
let vs = List.map ~f:(fun x -> AF.get_file x |> get_vcf) vcfs in
let refs =
vs |> List.map ~f:(fun v -> v#product#reference_build) |> List.dedup
in
let reference_build =
if List.length refs > 1
then
ksprintf failwith "VCFs do not agree on their reference build: %s"
(String.concat ~sep:", " refs)
else
List.nth_exn refs 0
in
let mhc = get_mhc_alleles (AF.get_file alleles) in
let output_file =
Name_file.in_directory ~readable_suffix:"topiary.tsv" Config.work_dir
([
Hla_utilities.predictor_to_string predictor;
Tools.Topiary.Configuration.name configuration;
Filename.chop_extension (Filename.basename mhc#product#path);
] @ (List.map vs ~f:(fun v -> v#product#path)))
in
Topiary_result (
Tools.Topiary.run
~configuration ~run_with
~reference_build ~vcfs:vs ~predictor
~alleles_file:mhc
~output:(`CSV output_file)
)
|> AF.with_provenance "topiary"
(("alleles", AF.get_provenance alleles)
:: List.mapi vcfs ~f:(fun i v -> sprintf "vcf_%d" i, AF.get_provenance v))
~string_arguments:[
"predictor", Hla_utilities.predictor_to_string predictor;
"configuration-name",
Tools.Topiary.Configuration.name configuration;
]
~json_arguments:[
"configuration",
Tools.Topiary.Configuration.to_json configuration;
]