2
|
1 use strict;
|
|
2
|
|
3 my $fasta = $ARGV[0];
|
|
4 my $phylip = $ARGV[1];
|
|
5 my $out = $ARGV[2];
|
|
6
|
|
7 my @ids;
|
|
8 open(F,$fasta) or die "Can not open file $fasta";
|
|
9 while(<F>){
|
|
10 if (/>(.*)/){
|
|
11 my $id = $1;
|
|
12 push(@ids,$id);
|
|
13 }
|
|
14 }
|
|
15 close(F);
|
|
16
|
|
17 open(O,">$out") or die "Can not open and write into file $out";
|
|
18 open(P,$phylip) or die "Can not open file $phylip";
|
|
19 my $numline = 0;
|
|
20 while(<P>){
|
|
21 my $line = $_;
|
|
22 $numline++;
|
|
23 if (/^([\w\-]+)\s+/ && $numline > 1){
|
|
24 my $reported_id = $1;
|
|
25 print "ok";
|
|
26 my $id = $ids[$numline-2];
|
|
27 $line =~s/$reported_id/$id/g;
|
|
28 print O $line;
|
|
29 }
|
|
30 else{
|
|
31 print O $line;
|
|
32 }
|
|
33 }
|
|
34 close(P);
|
|
35 close(O);
|