0
|
1 #!/usr/bin/perl -w
|
|
2 use strict;
|
|
3 my $fas_file=shift;
|
|
4 my $ann_file=shift;
|
|
5 my $out_file=shift;
|
|
6
|
|
7 open(OUT,">$out_file");
|
|
8
|
|
9 my %seqS=();
|
|
10 my $id="";
|
|
11 open(IN,$fas_file);
|
|
12 while(<IN>)
|
|
13 {
|
|
14 if ($_=~/^>(.*)/)
|
|
15 {
|
|
16 $id=$1;
|
|
17 $id=(split(/\s+/,$id))[0];
|
|
18 }else{
|
|
19 $seqS{$id}.=$_;
|
|
20 }
|
|
21 }
|
|
22
|
|
23 my %decode=();
|
|
24 open(IN,$ann_file);
|
|
25 while(<IN>)
|
|
26 {
|
|
27 last if $_=~/^\#\#FASTA/;
|
|
28 next if $_=~/^\#/;
|
|
29 my ($id1,$id2)=(split(/\t/))[0,-1];
|
|
30 $id2=(split(/\;/,$id2))[0];
|
|
31 my @vl=(split(/\_/,$id1));
|
|
32 $id1="";
|
|
33 foreach my $v (@vl)
|
|
34 {
|
|
35 if ($v eq "length")
|
|
36 {
|
|
37 chop($id1);
|
|
38 last;
|
|
39 }
|
|
40 $id1.="$v\_";
|
|
41 }
|
|
42 $id2=~s/ID=//;
|
|
43 $decode{$id2}=$id1;
|
|
44 }
|
|
45 foreach my $seq (sort keys %seqS)
|
|
46 {
|
|
47 print OUT ">$decode{$seq}\z\z\z$seq\n$seqS{$seq}\n";
|
|
48 }
|
|
49
|