-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatic_gene_length.pl
51 lines (44 loc) · 935 Bytes
/
static_gene_length.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
#!/usr/bin/perl
use strict;
use warnings;
open(IN1,"$ARGV[0]") or die $!;
open(IN2,"$ARGV[1]") or die $!;
open(IN3,"$ARGV[2]") or die $!;
open(OUT,">blastn_result_m8.list");
my %query=();
my %subject=();
$/=">";
while(<IN1>){
chomp;
next if(/^$/);
my ($gene_id,$seq)=(split /\n+/,$_)[0,1];
my $length=length($seq);
#print $gene_id,"\n";
$query{$gene_id}=$length;
}
while(<IN2>){
chomp;
next if(/^$/);
my ($gene_id,$seq)=(split /\n+/,$_)[0,1];
my $length=length($seq);
#print $gene_id;
$subject{$gene_id}=$length;
}
$/="\n";
close IN1;
close IN2;
while(<IN3>){
chomp;
if(/subject/){
print OUT "$_","sub_id","\t","sublength","\t","query","\t","query_length","\n";
next;
}
my ($sub,$quer)=(split /\s+/,$_)[0,1];
#print $sub,"\n";
#print $quer,"\n";
if(exists $query{$quer} && exists $subject{$sub}){
print OUT $_,"\t",$sub,":",$subject{$sub},"\t",$quer,":",$query{$quer},"\n";
}
}
close IN3;
close OUT;