new file: cell2loc.py
[GalaxyCodeBases.git] / perl / etc / justonce / countmsam.pl
blob12c00cfa7163b2d33051504fc8bde554bacb5259
1 #!/bin/env perl
2 =pod
3 Author: Hu Xuesong @ BIOPIC <galaxy001@gmail.com>
4 Version: 1.0.0 @ 20120330
5 =cut
6 use strict;
7 use warnings;
8 #use Data::Dump qw(ddx);
10 die "Usage: $0 <fq_base_list> <genome_list> <sam_path> <out>\n" if @ARGV<1;
11 my $fqlst=shift;
12 my $reflst=shift;
13 my $sampath=shift;
14 my $outf=shift;
16 sub openfile($) {
17 my ($filename)=@_;
18 my $infile;
19 if ($filename=~/.xz$/) {
20 open( $infile,"-|","xz -dc $filename") or die "Error opening $filename: $!\n";
21 } elsif ($filename=~/.gz$/) {
22 open( $infile,"-|","gzip -dc $filename") or die "Error opening $filename: $!\n";
23 } else {open( $infile,"<",$filename) or die "Error opening $filename: $!\n";}
24 return $infile;
27 open L,'<',$fqlst or die;
28 my @fqpres;
29 while (<L>) {
30 chomp;
31 push @fqpres,$_;
33 close L;
35 open L,'<',$reflst or die;
36 my @refs;
37 while (<L>) {
38 chomp;
39 push @refs,$_;
41 close L;
43 my %FH;
44 for my $fq (@fqpres) {
45 for my $ref (@refs) {
46 my $fh = openfile("$sampath/${fq}_$ref.sam.gz");
47 push @{$FH{$fq}},$fh;
48 #$FH{$fq}{$ref}=$fh;
53 __END__
54 ./countmsam.pl fqbase.lst genomes.lst ./check pigv2.stat