Mercurial > repos > mcharles > rapsosnp
diff rapsodyn/filtersam_mapped_and_unique.pl @ 10:0a6c1cfe4dc8 draft
Uploaded
author | mcharles |
---|---|
date | Mon, 19 Jan 2015 04:33:21 -0500 |
parents | 3f7b0788a1c4 |
children |
line wrap: on
line diff
--- a/rapsodyn/filtersam_mapped_and_unique.pl Mon Oct 20 05:58:31 2014 -0400 +++ b/rapsodyn/filtersam_mapped_and_unique.pl Mon Jan 19 04:33:21 2015 -0500 @@ -1,4 +1,5 @@ #!/usr/bin/perl +#V1.1.0 manage empty files #V1.0.1 added log, option parameters use strict; use warnings; @@ -7,6 +8,7 @@ my $input_sam_file; my $output_sam_file; my $log_file; +my $empty_file=1; my %bitscore_all; my %bitscore_selected; @@ -37,6 +39,7 @@ my @fields_selected = split (/\s+/,$line); if (($fields_selected[1]==83)||($fields_selected[1]==163)||($fields_selected[1]==147)||($fields_selected[1]==99)){ print $line; + $empty_file=0; my $bit = $fields_selected[1]; if ($bitscore_selected{$bit}){ $bitscore_selected{$bit}++; @@ -50,29 +53,30 @@ } close (IN); - open (LF,">$log_file") or die("Can't open $log_file\n"); -print LF "\n####\t Sam filtering \n"; -print LF "## Before filtering\n"; -print LF "bitscore\t:\t"; -foreach my $key (sort {$bitscore_all{$b} <=> $bitscore_all{$a}} keys %bitscore_all) { - print LF $key,"\t*\t"; -} -print LF "\n number \t:\t"; -foreach my $key (sort {$bitscore_all{$b} <=> $bitscore_all{$a}} keys %bitscore_all) { - print LF $bitscore_all{$key},"\t*\t"; +if ($empty_file==0){ + print LF "\n####\t Sam filtering \n"; + print LF "## Before filtering\n"; + print LF "bitscore\t:\t"; + foreach my $key (sort {$bitscore_all{$b} <=> $bitscore_all{$a}} keys %bitscore_all) { + print LF $key,"\t*\t"; + } + print LF "\n number \t:\t"; + foreach my $key (sort {$bitscore_all{$b} <=> $bitscore_all{$a}} keys %bitscore_all) { + print LF $bitscore_all{$key},"\t*\t"; + } + print LF "\n"; + print LF "## After filtering\n"; + print LF "bitscore\t:\t"; + foreach my $key (sort {$bitscore_selected{$b} <=> $bitscore_selected{$a}} keys %bitscore_selected) { + print LF $key,"\t*\t"; + } + print LF "\n number \t:\t"; + foreach my $key (sort {$bitscore_selected{$b} <=> $bitscore_selected{$a}} keys %bitscore_selected) { + print LF $bitscore_selected{$key},"\t*\t"; + } + print LF "\n"; } -print LF "\n"; -print LF "## After filtering\n"; -print LF "bitscore\t:\t"; -foreach my $key (sort {$bitscore_selected{$b} <=> $bitscore_selected{$a}} keys %bitscore_selected) { - print LF $key,"\t*\t"; -} -print LF "\n number \t:\t"; -foreach my $key (sort {$bitscore_selected{$b} <=> $bitscore_selected{$a}} keys %bitscore_selected) { - print LF $bitscore_selected{$key},"\t*\t"; -} -print LF "\n"; close (LF);