#!/usr/bin/perl -w =head Title : apt_SNPCall_report Function : To combine the results from the different reports based on the batch list. =cut #------------------------------------------------------------------------------- # use and library files use strict; use Getopt::Long; #------------------------------------------------------------------------------- # Get options my ($help, $batch, $list); my $output = "genotyping_results.txt"; my ($good_batch, $out_name, $out_dir_name); my (@list_files, %sample); sub help { print < \$help, 'batch=s' => \$batch, 'list=s' => \$list, 'output=s' => \$output ); if ((! $batch) or (! $list) or $help){ &help(); } # File opening: open (BATCH, $batch) || die "Cannot open input file $batch: $!\n"; open (LIST, $list) || die "Cannot open input file $list: $!\n"; open (W, ">$output") || die "Error to open $!"; #------------------------------------------------------------------------------- # Script #print W "SampleName\tcall_rate\tpm_mean\n"; print "SampleName\tcall_rate\tpm_mean\n"; while () { chomp; my ($path, $file) = ($_ =~ /(.*\/)(.*)/); push (@list_files, $file); } close LIST; while () { chomp; s/\r//; my $filename = $_; $out_name = $filename; $out_name =~ s/\.txt//; $out_dir_name = "apt_SNPCall_".$out_name; foreach my $lf (@list_files){ open (SAMPLE, "$out_dir_name/birdseed-v2.report.txt") || die "Error to open: $!"; while () { chomp; my @tab = split("\t", $_); if ($tab[0] eq $lf){ my $sample = $lf; $sample =~ s/\.CEL//; print $sample."\t".$tab[2]."\t".$tab[22]."\n"; #I get problems here # print W $sample."\t".$tab[2]."\t".$tab[22]."\n"; } } } } close SAMPLE; close W; close BATCH; ################################### # Functions