Mercurial > repos > dereeper > readseq
view complete_names.pl @ 3:637ed4e3aa1d draft default tip
Uploaded
author | dereeper |
---|---|
date | Tue, 08 Jan 2019 10:17:16 -0500 |
parents | bba379e32116 |
children |
line wrap: on
line source
use strict; my $fasta = $ARGV[0]; my $phylip = $ARGV[1]; my $out = $ARGV[2]; my @ids; open(F,$fasta) or die "Can not open file $fasta"; while(<F>){ if (/>(.*)/){ my $id = $1; push(@ids,$id); } } close(F); open(O,">$out") or die "Can not open and write into file $out"; open(P,$phylip) or die "Can not open file $phylip"; my $numline = 0; while(<P>){ my $line = $_; $numline++; if (/^([\w\-]+)\s+/ && $numline > 1){ my $reported_id = $1; my $id = $ids[$numline-2]; $line =~s/$reported_id/$id/g; print O $line; } else{ print O $line; } } close(P); close(O);