diff rapsodyn/PileupVariant.pl @ 7:3f7b0788a1c4 draft

Uploaded
author mcharles
date Tue, 07 Oct 2014 10:34:34 -0400
parents 442a7c88b886
children 0a6c1cfe4dc8
line wrap: on
line diff
--- a/rapsodyn/PileupVariant.pl	Mon Sep 29 03:02:16 2014 -0400
+++ b/rapsodyn/PileupVariant.pl	Tue Oct 07 10:34:34 2014 -0400
@@ -1,19 +1,41 @@
 #!/usr/bin/perl
+#V1.0.1 added log, option parameters
 use strict;
+use warnings;
+use Getopt::Long;
 
-my $inputfile = $ARGV[0];
-open(IF, $inputfile)  or die("Can't open $inputfile\n");
+my $input_pileup_file;
+my $output_pileup_file;
+my $log_file;
+
+my $nb_base_covered=0;
+my $nb_variant=0;
+GetOptions (
+"input_pileup_file=s" => \$input_pileup_file,
+"log_file=s" => \$log_file
+) or die("Error in command line arguments\n");
+
+open(IN, $input_pileup_file) or die ("Can't open $input_pileup_file\n");
 
 #Extraction des variants
 my $nb_line=0;
-while (my $line=<IF>){
-	my $test = $line;
-	$test =~ s/\$//g; #the read start at this position
-	$test =~ s/\^.//g; #the read end at this position followed by quality char
-	my @field = split(/\s+/,$test);
+while (my $line=<IN>){
+	#print $line;
+	$nb_base_covered++;
+	$line =~ s/\$//g; #the read start at this position
+	$line =~ s/\^.//g; #the read end at this position followed by quality char
+	#print $line;
 	
+	my @field = split(/\s+/,$line);
 	if ($field[4]=~/[ATGCN]/i){
 		print $line;
+		$nb_variant++;
 	}
 }
-close(IF);
+close(IN);
+
+open (LF,">$log_file") or die("Can't open $log_file\n");
+print LF "\n####\t Variant extraction \n";
+print LF "Position covered :\t$nb_base_covered\n";
+print LF "Variant detected :\t$nb_variant\n";
+close (LF);