-
Notifications
You must be signed in to change notification settings - Fork 0
/
uniq_map.pl
46 lines (40 loc) · 1001 Bytes
/
uniq_map.pl
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
#!/usr/bin/perl
use strict;
use warnings;
my $sample = shift;
open SAM, '<', "$sample.hsa.dedup.sam" or die $!;
#open LEFT, '>', 'left.xls' or die $!;
my (%hash, %mapq_of);
while (<SAM>) {
chomp;
my ($id, $mapq) = (split /\t/)[0,4];
$mapq_of{$id} = 0 unless exists $mapq_of{$id};
$mapq_of{$id} += 1 if $mapq < 4;
if (/AS:i:(\d+).*XS:i:(\d+)/) {
if ($1 != 0 && $1 <= $2) {
# print LEFT "$id\t$mapq\n";
$hash{$id} = 1;
}
}
}
#close LEFT;
open HSA, '<', "$sample.hsa.dedup.sam" or die $!;
open VIRUS, '<', "$sample.virus.dedup.sam" or die $!;
open OUT_1, '>', "$sample.hsa.dedup.uniq.sam" or die $!;
open OUT_2, '>', "$sample.virus.dedup.uniq.sam" or die $!;
while (<HSA>) {
chomp;
my $id = (split /\t/)[0];
unless ($mapq_of{$id}>1) {
print OUT_1 "$_\n";
}
}
while (<VIRUS>) {
chomp;
my $id = (split /\t/)[0];
unless ($mapq_of{$id}>1) {
print OUT_2 "$_\n";
}
}
close OUT_1;
close OUT_2;