-
Notifications
You must be signed in to change notification settings - Fork 1
/
RemovePhiHu.pl
79 lines (69 loc) · 1.65 KB
/
RemovePhiHu.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#! /usr/bin/perl -w
use warnings;
use strict;
my ($input, $input2, $output, $counter, $ok, $seqname, $all, $divless) = 0;
my (@ar) = ();
my (%id_Hash) = ();
$input = $ARGV[0];
open(INPUT, "$input") or die "Can't open \"$input\"\n";
$input2 = $ARGV[1];
open(INPUT2, "$input2") or die "Can't open \"$input2\"\n";
$output = "$input.rem.fastq";
open(OUTPUT, ">$output") or die "Can't open \"$output\"\n";
open(INPUT2, "$input2") or die "Can't open \"$input2\"\n";
while(<INPUT2>){
if(/^(\S+)\s+\S+\s+\S+\s+\S+\s+\S+\s+\d+[A-Z]\S*\s+/){
$id_Hash{$1} = 1;
}
}
close INPUT2;
$counter = 0;
$ok = 1;
open(INPUT, "$input") or die "Can't open \"$input\"\n";
while(<INPUT>){
if(/^((\S+).*?)$/){
$counter += 1;
$seqname = $2;
$all = $1;
$divless = $counter % 4;
if($divless == 1){
if($seqname =~ /^\S(\S+)/){
if(exists($id_Hash{$1})){
$ok = 1;
next;
}
else{
$ok = 2;
print OUTPUT "$all\n";
}
}
}
elsif($divless == 2){
if($ok == 2){
print OUTPUT "$all\n";
}
else{
next;
}
}
elsif($divless == 3){
if($ok == 2){
print OUTPUT "$all\n";
}
else{
next;
}
}
elsif($divless == 0){
if($ok == 2){
print OUTPUT "$all\n";
}
else{
next;
}
}
}
}
close INPUT;
close OUTPUT;
exit;