-
Notifications
You must be signed in to change notification settings - Fork 0
/
subset_SNPs_all3.pl
executable file
·99 lines (90 loc) · 1.64 KB
/
subset_SNPs_all3.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/perl
#v3.0
# subset_SNPs_all SNPs_all 25
# subset_SNPs_all SNPs_all
# k is optional
no warnings 'deprecated';
my $infile=$ARGV[0]; # probably SNPs_all
my $k=5;
my @bases=qw(A C G T);
if ($ARGV[1]) {
$k=$ARGV[1];
}
if ($k > 5) {
my $count=0;
foreach $w (@bases) {
foreach $x (@bases) {
foreach $y (@bases) {
foreach $m (@bases) {
foreach $n (@bases) {
#foreach $t qw(A C G T) {
#foreach $s qw(A C G T) {
my $z=$w.$x.$y.$m.$n;
$zarray[$count]=$z;
$count++;
#}
#}
}
}
}
}
}
} elsif ($k == 5) {
my $count=0;
foreach $w (@bases) {
foreach $x (@bases) {
foreach $y (@bases) {
foreach $m (@bases) {
#foreach $t qw(A C G T) {
#foreach $s qw(A C G T) {
my $z=$w.$x.$y.$m;
$zarray[$count]=$z;
$count++;
#}
#}
}
}
}
}
} elsif ($k == 4) {
my $count=0;
foreach $w (@bases) {
foreach $x (@bases) {
foreach $y (@bases) {
my $z=$w.$x.$y;
$zarray[$count]=$z;
$count++;
}
}
}
} elsif ($k < 4) {
my $count=0;
foreach $w (@bases) {
my $z=$w;
$zarray[$count]=$z;
$count++;
}
}
$count=0;
open IN,"$infile";
my $out=$zarray[$count].".mers.SNPs_all";
open OUT,">$out";
while (my $line=<IN>){
if ($line =~ /\S+/) {
if ($line =~ /^\d+\t$zarray[$count]/) {
print OUT "$line";
} else {
close OUT;
until ($line =~ /^\d+\t$zarray[$count]/) {
$count++;
$out=$zarray[$count].".mers.SNPs_all";
open OUT,">$out";
close OUT;
}
$out=$zarray[$count].".mers.SNPs_all";
open OUT,">$out";
print OUT "$line";
}
} # if ($line =~ /\S+/) {
}
close OUT;