-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathextract_run_tallies
executable file
·56 lines (39 loc) · 970 Bytes
/
extract_run_tallies
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env perl
use strict;
use Getopt::Long;
my $print_usage = 0;
my $usage = <<USAGE;
This script tabulates Illumina flow cell serial numbers from mapped reads
in a SAM file
Reads from stdin writes to stdout
Mark Stenglein, 10/5/2023
Usage: $0 [-h] [-r regex]
[-h] print this message
[-r regex] optional regex to search for in refseq names
USAGE
if ((scalar @ARGV == 0) and -t STDIN) { print $usage and exit; }
my $regex = undef;
GetOptions ("h" => \$print_usage,
"r=s" => \$regex);
my %run_tally = ();
while (<>)
{
chomp;
my @fields = split "\t";
my $read = $fields[0];
my @read_parts = split ":", $read;
my $run = $read_parts[2];
my $refseq = $fields[2];
if (defined $regex and ($refseq =~ /$regex/))
{
$run_tally{$run} += 1;
}
elsif (!defined $regex)
{
$run_tally{$run} += 1;
}
}
foreach my $run (keys %run_tally)
{
print "$run\t$run_tally{$run}\n";
}