-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfasta.pl
154 lines (129 loc) · 4.11 KB
/
fasta.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/usr/bin/perl
######## Fuzzy-AllerPred #####################
# Developed by SARAVANAN VIJAYAKUMAR
# Centre for Bioinformatics, Pondicherry University
# Date: 14-2-2013
#
######Required Modules
use List::Util qw[max];
#use CGI qw(:standard);
#use CGI::Carp qw(fatalsToBrowser);
use MIME::Lite; #To be installed
use List::Util qw(first max min);
# Sequence In from argument
$PATH_EXE = "/home/user/Documents/Softwares/FuzzyApp-master/";
my $Seq_In = @ARGV[0];
$Seq_In=~s/\s//g;
#print $Seq_In;
#End !
#Path setting for FASTA36 and others in temp
$Fpath = $PATH_EXE.'fasta36/bin/';
$Fpath=~s/\n//g;
$Seqpath = $PATH_EXE;
$Seqpath =~s/\n//g;
#End!
##FASTA for GLOBAL WITH ALLERGEN DATABASE
my $G_Seq = ">Query\n$Seq_In";
my $G_rand_file = $Seqpath.&generate_random_string(8);
open(TTT,">$G_rand_file");
print TTT $G_Seq;
close(TTT);
$G_result = &Execute_FASTA36($Fpath,$G_rand_file,$Seqpath,'ADB.fasta');
if($G_result ne ''){
$G_result=~s/\s/\@/g;
my @GTemp_array = split('\@',$G_result);
$GQID = @GTemp_array[0];
$GBID = @GTemp_array[1];
$GIDENTITY = @GTemp_array[2];
$GEVALUE = sprintf("%.10g", @GTemp_array[10]);
$G_result = "Global Identity:$GIDENTITY\tGlobal_Evalue:$GEVALUE\tSubject:$GBID";
}else{
$G_result = "Result:NSH";
}
#End !
##FASTA for GLOBAL WITH HOMOLOG NON-ALLERGEN DATABASE
my $HG_Seq = ">Query\n$Seq_In";
my $HG_rand_file = $Seqpath.&generate_random_string(8);
open(TTT,">$HG_rand_file");
print TTT $G_Seq;
close(TTT);
$HG_result = &Execute_FASTA36($Fpath,$HG_rand_file,$Seqpath,'HNA.fasta');
if($HG_result ne ''){
$HG_result=~s/\s/\@/g;
my @HGTemp_array = split('\@',$HG_result);
$HGQID = @HGTemp_array[0];
$HGBID = substr(@HGTemp_array[1],0,6);
$HGIDENTITY = @HGTemp_array[2];
$HGEVALUE = sprintf("%.10g", @HGTemp_array[10]);
$HG_result = "Global Identity:$HGIDENTITY\tGlobal_Evalue:$HGEVALUE\tSubject:$HGBID";
}else{
$HG_result = "Result:NSH";
}
#End !
###FASTA for 80 Window split
$tem_num = int length($Seq_In)-80;
for(my $i=0;$i<$tem_num;$i++){
#Saving sequence in random file
my $random_file = $Seqpath.&generate_random_string(8);
open(TTT,">$random_file");
print TTT ">".($i+1)."-".($i+80)."\n".substr($Seq_In,$i,80);
close(TTT);
#@Eighty_win_res[$i] = &Execute_FASTA36($Fpath,$random_file,$Seqpath);
my $Ding = &Execute_FASTA36($Fpath,$random_file,$Seqpath,'Allergy_DB.fasta');
if($Ding ne ''){
$Ding=~s/\s/\@/g;
my @Temp_array = split('\@',$Ding);
@QID[$i] = @Temp_array[0];
@BID[$i] = @Temp_array[1];
@IDENTITY[$i] = @Temp_array[2];
if(@Temp_array[10] ne ""){
@EVALUE[$i] = sprintf("%.10g", @Temp_array[10]);
}else{
@EVALUE[$i] = 1000;
}
}else{
$F36_OUT = "NSH";
}
}
if($F36_OUT ne "NSH"){
my $search = min(@EVALUE);
my $index = first { $EVALUE[$_] eq $search } 0 .. $#EVALUE;
$F36_OUT = @IDENTITY[$index];
$F36_DOUT = "Window_Pos:".@QID[$index]."\t"."Subject:".@BID[$index]."\t"."Identity:".@IDENTITY[$index]."\t"."E-Value:".@EVALUE[$index];
}else{
$F36_DOUT = "Result:NSH";
}
print $G_result."\n".$F36_DOUT."\n".$HG_result;
#End !
#Executing Fasta sub
sub Execute_FASTA36{
my ($path1,$path2,$path3,$DB) = @_;
#Execution of FASTA36 program
#-m 8 -> format -b ->number of out
# $Execu = $Fpath.'./fasta36'.' -m 8 -b 1'." ".$random_file." $Seqpath".'library.fasta';
#my $Execu = $path1.'./fasta36'.' -m 8 -b 1'." ".$path2." $path3".'Allergy_DB.fasta';
my $Execu = $path1.'fasta36'.' -m 8 -b 2 -f -10 -g -2 -E 0.001 '." ".$path2." $path3"."$DB";
my $Result = `$Execu `;
unlink($path2);
#End !
#Result Parsing
my @Res_line = split('\n',$Result);
return @Res_line[4];
#End !
}
#Random Fiel name generator
sub generate_random_string
{
my $length_of_randomstring=shift;# the length of
# the random string to generate
my @chars=('a'..'z','A'..'Z','0'..'9');
my $random_string;
foreach (1..$length_of_randomstring)
{
# rand @chars will generate a random
# number between 0 and scalar @chars
$random_string.=$chars[rand @chars];
}
return $random_string;
}