annotate PGAP-1.2.1/Blast_Filter.pl @ 6:c43a55b28d06 draft

Uploaded
author dereeper
date Fri, 25 Jun 2021 16:25:53 +0000
parents 83e62a1aeeeb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
1 #!/usr/bin/perl
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
2 use strict;
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
3 use warnings;
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
4
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
5
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
6 my $BLASTResult=$ARGV[0];
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
7 my $SEQFile=$ARGV[1];
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
8 my $coverage=$ARGV[2];
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
9 my $identity=$ARGV[3]*100;#percents
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
10 my $score=$ARGV[4];
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
11 my %hash;
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
12 my @row;
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
13 my $line;
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
14
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
15 #my $coverage=0.5;
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
16 #my $identity=50;#percents
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
17 #my $score=50;
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
18
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
19 &ReadSeqLength("$SEQFile",\%hash);
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
20
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
21 open(F,$BLASTResult);
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
22 while ($line=<F>)
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
23 {
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
24 if ($line!~/\#/)
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
25 {
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
26 @row=split(/\t/,$line);
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
27 if ($row[2]>=$identity and $row[11]>=$score)
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
28 {
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
29 if ((($row[7]-$row[6]+1)/$hash{$row[0]})>=$coverage)
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
30 {
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
31 if ((($row[9]-$row[8]+1)/$hash{$row[1]})>=$coverage)
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
32 {
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
33 print "$row[0]\t$row[1]\t$row[11]";
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
34 }
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
35 }
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
36 }
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
37 }
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
38 }
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
39 close(F);
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
40
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
41 sub ReadSeqLength()
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
42 {
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
43 use Bio::SeqIO;
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
44 (my $file,my $hash)=@_;
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
45 my $seq;
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
46 my $in=Bio::SeqIO->new(-file=>"$file",-format=>"fasta");
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
47 while ($seq=$in->next_seq())
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
48 {
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
49 $$hash{$seq->id}=length($seq->seq());
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
50 }
83e62a1aeeeb Uploaded
dereeper
parents:
diff changeset
51 }