From 47b1e0b999fcab86f908610c160db825bdb0df5a Mon Sep 17 00:00:00 2001 From: "Michael G. Campana" Date: Wed, 17 May 2023 16:04:53 -0400 Subject: [PATCH] Site skip fix --- CHANGELOG.md | 3 +++ vcf2aln.rb | 14 +++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b358673..ee1d36b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ Michael G. Campana & Jacob A. West-Roberts, 2017-2023 Smithsonian's National Zoo and Conservation Biology Institute Contact: campanam@si.edu +### Version 0.13.1 +Fixed bug in reference-inclusion if missing sites are not skipped + ### Version 0.13.0 Added option to output reference sequence as part of the alignment diff --git a/vcf2aln.rb b/vcf2aln.rb index cc940b5..a59af31 100644 --- a/vcf2aln.rb +++ b/vcf2aln.rb @@ -2,7 +2,7 @@ #----------------------------------------------------------------------------------------------- # vcf2aln -VCF2ALNVER = "0.13.0" +VCF2ALNVER = "0.13.1" # Michael G. Campana, Jacob A. West-Roberts, 2017-2023 # Smithsonian's National Zoo and Conservation Biology Institute #----------------------------------------------------------------------------------------------- @@ -619,11 +619,15 @@ def vcf_to_alignment(line, index, previous_index, previous_endex, previous_name, end current_base = line_arr[1].to_i # Set starting base position if current_base > previous_endex - for i in 0...$samples.size - unless $options.skip # Adjust for missing bases + unless $options.skip # Adjust for missing bases + for i in 0...$samples.size current_locus.seqs[i] << "?" * (current_base - 1 - previous_endex) current_locus.alts[i] << "?" * (current_base - 1 - previous_endex) end + if $options.includeref + current_locus.seqs[-1] << "?" * (current_base - 1 - previous_endex) + current_locus.alts[-1] << "?" * (current_base - 1 - previous_endex) + end end if write_cycle >= $options.write_cycle current_locus.write_seqs @@ -637,6 +641,10 @@ def vcf_to_alignment(line, index, previous_index, previous_endex, previous_name, current_locus.seqs[i] << "?" * lengths.max * (current_base - previous_endex) if current_base > previous_endex current_locus.alts[i] << "?" * lengths.max * (current_base - previous_endex) if current_base > previous_endex end + if $options.includeref + current_locus.seqs[-1] << "?" * lengths.max * (current_base - previous_endex) if current_base > previous_endex + current_locus.alts[-1] << "?" * lengths.max * (current_base - previous_endex) if current_base > previous_endex + end index += current_base - previous_index endex = index + lengths.max - 1 # Sequence end index unless $options.hap_flag #Accounting for ploidy