-
Notifications
You must be signed in to change notification settings - Fork 0
/
dom_calling.pl
135 lines (127 loc) · 4.6 KB
/
dom_calling.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
##!/usr/bin/perl -w
#####################################################################
#-this progrome is used to call dominant and codomiant marker
#####################################################################
my $dep1=4;
my $dep2=4;
my $p =0.8;
opendir (DIR, "reads_mapping");
@dire = readdir DIR;
@dire = sort @dire;
my $out ="genotype/all_dom";
my $out1 ="genotype/poly_dom";
parse_command_line();
do_ref();
Do_genotype();
filter();
system("rm genotype/TEMP");
sub do_ref(){
open FIG,"<ref/HQ_ref_dom";
open OUT,">$out";
foreach $word(<FIG>){
chomp($word=$word);
print OUT "$word\n";
}
close FIG;
close OUT;
}
sub filter(){
for($C=1;$C<=200;$C++){
$record[$C][0]=exp(-$C);
$here=0;$tag=0;$bd[$C]=0;
for($j=1;$j<=200;$j++){
$record[$C][$j]=$record[$C][$j-1]*$C/($j);
$here=$here+$record[$C][$j];
if($here<=0.05){$bd[$C]=$j;}
}
}
open FIG,"<$out";
open OUT,">$out1";
$do_m=0;
foreach $word(<FIG>){
chomp($word=$word);
@file=split(/\s+/,$word);
$none=0;$have=0;$sum=0;$num=0;
$len=@file;
for($i=4;$i<$len;$i++){
if(@file[$i]>0){$num++;$sum=$sum+@file[$i];}
}
if($num>0 && @file[2]*@file[3]==0){
$hh=int($sum/$num);
if($hh>$bd[$dep2/2] && $hh>=4){ #.........change 5/9
$ave=int($sum/$num)+1;$str="@file[0] @file[1] @file[2] @file[3]";
for($i=4;$i<$len;$i++){
if($bd[$ave]<-1){
if(@file[$i]>$bd[$ave]){$str=$str." @file[$i]";}
else{$str=$str." --";}
}
else{
if(@file[$i]>$bd[$ave]){$str=$str." @file[$i]";}
elsif(@file[$i]>0){$str=$str." --";}
else{$str=$str." 0";}
}
}
if($d1>=$pro_num*$p){print OUT "$str\n";}
}
}
}
}
sub Do_genotype(){
for($kk=0;$kk<@dire;$kk++){
print "@dire[$kk]\n";
if(@dire[$kk] eq "."|| @dire[$kk] eq ".." || @dire[$kk] eq "P1" || @dire[$kk] eq "P2"){;}
else{
%hash={};
open FIG,"<soap/@dire[$kk]";
foreach $word(<FIG>){
chomp($word=$word);
@file=split(/\s+/,$word);
$hash{@file[7]}++;
}
close FIG;
open FIG,"<$out";
open OUT,">genotype/TEMP";
foreach $word(<FIG>){
chomp($word=$word);
@file=split(/\s+/,$word);
$str=substr(@file[0],1);
$a=0;
if(exists $hash{$str}){$a=$hash{$str};}
print OUT "$word $a\n";
}
close FIG;
close OUT;
open FIG,"<genotype/TEMP";
open OUT,">$out";
foreach $word(<FIG>){
chomp($word=$word);
print OUT "$word\n";
}
}
close FIG;
close OUT;
}
}
sub hashValueDescendingNum {$hello{$b} <=> $hello{$a};}
sub parse_command_line {
while (@ARGV) {
$_ = shift @ARGV;
if ($_ =~ /^-p$/) { $p = shift @ARGV; }
elsif ($_ =~ /^-o1$/) { $out = shift @ARGV; }
elsif ($_ =~ /^-o2$/) { $out1 = shift @ARGV; }
else {
print STDERR "Unknown command line option: '$_'\n";
usage();
}
}
}
sub usage {
print STDERR <<EOQ;
perl dom_calling.pl -p -o1 -o2 [-h]
p :least percentage of genotyped progenies[0.8]
o1 :output file of all dominant genotypes[genotype/all_dom]
o2 :output file of polymorphic dominant markers[genotype/poly_dom]
h :display the help information.
EOQ
exit(0);
}