-
Notifications
You must be signed in to change notification settings - Fork 1
/
EblastN.pl
122 lines (120 loc) · 3.63 KB
/
EblastN.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
#!/usr/local/bin/perl -w
#This progrem transfer the BLAST result include the Query sites and Sbject sites to the excel file.
$vision="Vision: 1.0";
use Getopt::Std;
getopts "o:i:e:a:l:s:";
print "*************\n*$vision*\n*************\n";
if ((!defined $opt_i)|| (!defined $opt_o) ) {
die "************************************************************************
Usage:transferall.pl -i filename -o outfile.
-h : help and usage.
-v : vision.
-e : expect value(default 10)
-a : identity% (default 0)
-l : alignment length (default 0)
-s : score (default 0)
************************************************************************\n";
}
$Expect = (defined $opt_e) ? $opt_e : 10;
$Length = (defined $opt_l) ? $opt_l : 0;
$Identity = (defined $opt_a) ? $opt_a : 0;
$Score = (defined $opt_s) ? $opt_s : 0;
open(Ofile,">$opt_o");print "Running.....\n";
open (F,$opt_i) || die"can't open $opt_i:$!\n";
$i=$q=$s=$a=0;
print Ofile "Query name\tLetter\tQueryX\tQueryY\tSbjctX\tSbjctY\tLength\tScore\tE value\tOverlap/total\tIdentity\tSbject Name\tAnontation\n";
while (<F>)
{
if (/Query= (\S+)/)
{
if($i==1)
{
#print Ofile "$query^$letter^Query:$qbegin----$qend^Sbject:$sbegin----$send^$name^$annotation^$length^$score^$expect^$identity^$over\n";
if($score >$Score && $expect<=$Expect && $over>=$Identity && $identity2 >= $Length)
{
$ovalap_total = "$identity1/$identity2";
print Ofile "$query\t$letter\t$qbegin\t$qend\t$sbegin\t$send\t$length\t$score\t$expect\t$ovalap_total\t$over\t$name\t$annotation\n";
}
$i=$q=$s=0;
$query=$letter=$qbegin=$qend=$sbegin=$send=$name=$annotation=$length=$score=$expect=$identity=$over=0;
}
$query=$1;
}
elsif (/\((\S+)\s+letters\)/)
{
$letter=$1;$letter=~s/,//;
}
elsif (/^>(\S*)\s+(.*)/)
{
if($i==1)
{
if($score >$Score && $expect<=$Expect && $over>=$Identity && $identity2 >= $Length)
{
$ovalap_total = "$identity1/$identity2";
print Ofile "$query\t$letter\t$qbegin\t$qend\t$sbegin\t$send\t$length\t$score\t$expect\t$ovalap_total\t$over\t$name\t$annotation\n";
}
$i=$q=$s=0;
$qbegin=$qend=$sbegin=$send=$name=$annotation=$length=$score=$expect=$identity=$over=0;
}
$name=$1;
$annotation=$2;
$a=1;
}
elsif (/Length = (\d+)/)
{
$length=$1;
$a=0;
}
elsif ($a==1)
{
chomp;
$annotation.=$_;
$annotation=~s/\s+/ /g;
} #This sentence could get the very long annotation that is longer than one line;
elsif (/Score = (.+) bits.+Expect =\s+(\S+)\s*/ or /Score = (.+) bits.+Expect\(\d+\) =\s+(\S+)\s*/)
{
if($i==1)
{
if($score >$Score && $expect<=$Expect && $over>=$Identity && $identity2 >= $Length)
{
$ovalap_total = "$identity1/$identity2";
print Ofile "$query\t$letter\t$qbegin\t$qend\t$sbegin\t$send\t$length\t$score\t$expect\t$ovalap_total\t$over\t$name\t$annotation\n";
}
$i=$q=$s=0;
$qbegin=$qend=$sbegin=$send=$score=$expect=$identity=$over=0;
}
$score=$1;$expect=$2;$expect=~s/^e/1e/;
}
elsif (/Identities = (\d+)\/(\d+)\s+\((.{0,4})%\)/)
{
$identity1=$1;
$identity2=$2;
$over=$3;
}
elsif (/Query\:\s+(\d+)\s+\S+\s+(\d+)/)
{
if($q==0)
{
$qbegin=$1;
}
$qend=$2;
$q=1;
}
elsif (/Sbjct\:\s+(\d+)\s+\S+\s+(\d+)/)
{
if($s==0)
{
$sbegin=$1;
}
$send=$2;
$s=$i=1;
}
}
if(($score >$Score && $expect<=$Expect && $over>=$Identity && $identity2 >= $Length)&&($i==1))
{
$ovalap_total = "$identity1/$identity2";
print Ofile "$query\t$letter\t$qbegin\t$qend\t$sbegin\t$send\t$length\t$score\t$expect\t$ovalap_total\t$over\t$name\t$annotation\n";
}
close(F);
close(Ofile);
print "Done!\n";