From b2cec9d0e931461b1be327733ef4001a01226757 Mon Sep 17 00:00:00 2001 From: Surya Saha Date: Mon, 13 Jul 2015 09:03:32 -0400 Subject: [PATCH] record insertion event and modify if that line was already inserted at, issue #53 --- lib/Bio/GenomeUpdate/TPF.pm | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/Bio/GenomeUpdate/TPF.pm b/lib/Bio/GenomeUpdate/TPF.pm index f4b7068..2e5fd56 100644 --- a/lib/Bio/GenomeUpdate/TPF.pm +++ b/lib/Bio/GenomeUpdate/TPF.pm @@ -2011,7 +2011,29 @@ Returns the length of the accession. Added for use in switchover and trim files } $line_key++; } - #print STDERR Dumper \%sequence_accessions_to_remove; + + #record insertion event and modify $insert_line_number if that line was already inserted at, issue #53 + if ( $insert_before_or_after eq 'before'){ + if (!exist $before_insertion_counter{$insert_line_number}){ + $before_insertion_counter{$insert_line_number} = 1 ; + } + else{ + my $old_insert_line_number = $insert_line_number; + $insert_line_number = $insert_line_number - $before_insertion_counter{$insert_line_number}; + $before_insertion_counter{$old_insert_line_number}++ ; + } + } + elsif ( $insert_before_or_after eq 'after'){ + if (!exist $after_insertion_counter{$insert_line_number}){ + $after_insertion_counter{$insert_line_number} = 1 ; + } + else{ + my $old_insert_line_number = $insert_line_number; + $insert_line_number = $insert_line_number + $after_insertion_counter{$insert_line_number}; + $after_insertion_counter{$old_insert_line_number}++ ; + } + } + my $accession = $tpfline_accession[$insert_line_number]; my $tpf_line_arr_ref = $accession_tpflines{$accession}; my @temp_arr = @$tpf_line_arr_ref;