forked from DiltheyLab/MetaMaps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirstQuartileScore.pl
More file actions
51 lines (45 loc) · 873 Bytes
/
firstQuartileScore.pl
File metadata and controls
51 lines (45 loc) · 873 Bytes
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
use strict;
use warnings;
use Data::Dumper;
if(scalar(@ARGV) == 0)
{
die "Please provide FASTQ as first argument";
}
my $FASTQ = $ARGV[0];
my %Q;
my $totalQ = 0;
open(F, '<', $FASTQ) or die "Cannot open $FASTQ";
while(<F>)
{
my $l = $_;
die unless(substr($l, 0, 1) eq '@');
<F>;
my $ll = <F>;
die unless(substr($ll, 0, 1) eq '+');
my $q = <F>;
chomp($q);
my @Q = split(//, $q);
for(@Q)
{
$Q{$_}++;
$totalQ++;
}
# last if($. > 100);
}
close(F);
my $quartileQ;
my $quantile = 0;
foreach my $q (sort {$a cmp $b} keys %Q)
{
$quantile += ($Q{$q}/$totalQ);
print STDERR join("\t", ord($q), $q, $Q{$q}, $quantile), "\n";
if((not defined $quartileQ) and ($quantile >= 0.25))
{
$quartileQ = $q;
}
}
unless(defined $quartileQ)
{
die "Could not determine quartile quality";
}
print $quartileQ, "\n";