@@ -55,7 +55,11 @@ def iter_to_upper(x: Iterable[str]) -> Iterable[str]:
5555
5656
5757def build_vcf_header (
58- sample_id : str , reference_file : str , partial_phasing : bool , num_loci : int , loci_hash : str
58+ command : str , sample_ids : tuple [str , ...],
59+ reference_file : Path | str , # if Path, turn into file URI. Otherwise, treat "as-is".
60+ partial_phasing : bool ,
61+ num_loci : int ,
62+ loci_hash : str
5963) -> VariantHeader :
6064 vh = VariantHeader () # automatically sets VCF version to 4.2
6165
@@ -70,17 +74,23 @@ def build_vcf_header(
7074 if partial_phasing :
7175 vh .add_meta ("phasing" , "partial" )
7276
73- # Add an absolute path to the reference genome
74- vh .add_meta ("reference" , f"file://{ str (Path (reference_file ).resolve ().absolute ())} " )
77+ # Add an absolute path to the reference genome. If we're passed a string (from merge), assume this is already a file
78+ # URI.
79+ vh .add_meta (
80+ "reference" ,
81+ f"file://{ str (reference_file .resolve ().absolute ())} " if isinstance (reference_file , Path ) else reference_file
82+ )
7583
7684 # Add all contigs from the reference genome file + lengths
77- with FastaFile (reference_file ) as rf :
85+ with FastaFile (str ( reference_file ) ) as rf :
7886 for contig in rf .references :
7987 vh .contigs .add (contig , length = rf .get_reference_length (contig ))
8088
8189 # Add STRkit-specific fields:
8290 # - marking version
8391 vh .add_meta ("strkitVersion" , str (__version__ ))
92+ # - the subcommand being used to generate this VCF (call|merge)
93+ vh .add_meta ("strkitCommand" , command )
8494 # - indicating number of loci provided (i.e., catalogue size)
8595 vh .add_meta ("strkitCatalogNumLoci" , str (num_loci ))
8696 # - indicating hash of STRkitLocus objects (for checking catalogue sameness)
@@ -128,8 +138,9 @@ def build_vcf_header(
128138 # for iv in VCF_TR_INFO_RECORDS:
129139 # vh.info.add(*iv)
130140
131- # Add the sample
132- vh .add_sample (sample_id )
141+ # Add the sample(s)
142+ for sample_id in sample_ids :
143+ vh .add_sample (sample_id )
133144
134145 return vh
135146
0 commit comments