let vaxrank
?(configuration=Tools.Vaxrank.Configuration.default)
vcfs bam predictor alleles =
let vs = List.map ~f:(fun x -> AF.get_file x |> get_vcf) vcfs in
let b = get_bam (AF.get_file bam) in
let reference_build =
if List.exists vs ~f:(fun v ->
v#product#reference_build <> b#product#reference_build)
then
ksprintf failwith "VCFs and Bam do not agree on their reference build: bam: %s Vs vcfs: %s"
b#product#reference_build
(List.map vs ~f:(fun v -> v#product#reference_build)
|> String.concat ~sep:", ")
else
b#product#reference_build
in
let mhc = get_mhc_alleles (AF.get_file alleles) in
let outdir =
Name_file.in_directory ~readable_suffix:"vaxrank" Config.work_dir
([
Tools.Vaxrank.Configuration.name configuration;
Hla_utilities.predictor_to_string predictor;
(Filename.chop_extension (Filename.basename mhc#product#path));
] @
(List.map vs ~f:(fun v ->
(Filename.chop_extension (Filename.basename v#product#path))))
)
in
Vaxrank_result (
Tools.Vaxrank.run
~configuration ~run_with
~reference_build ~vcfs:vs ~bam:b ~predictor
~alleles_file:mhc
~output_folder:outdir
)
|> AF.with_provenance "vaxrank"
(("alleles", AF.get_provenance alleles)
:: ("bam", AF.get_provenance bam)
:: 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.Vaxrank.Configuration.name configuration;
]
~json_arguments:[
"configuration",
Tools.Vaxrank.Configuration.to_json configuration;
]