comparison complete_names.pl @ 2:bba379e32116 draft

Uploaded
author dereeper
date Tue, 08 Jan 2019 10:14:49 -0500
parents
children 637ed4e3aa1d
comparison
equal deleted inserted replaced
1:36e5445b7807 2:bba379e32116
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);