view 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 source

#!/usr/bin/perl
#V1.0.1 added log, option parameters
use strict;
use warnings;
use Getopt::Long;

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=<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(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);