changeset 2:bba379e32116 draft

Uploaded
author dereeper
date Tue, 08 Jan 2019 10:14:49 -0500
parents 36e5445b7807
children 637ed4e3aa1d
files complete_names.pl
diffstat 1 files changed, 35 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/complete_names.pl	Tue Jan 08 10:14:49 2019 -0500
@@ -0,0 +1,35 @@
+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;
+		print "ok"; 
+		my $id = $ids[$numline-2];
+		$line =~s/$reported_id/$id/g;
+		print O $line;
+	}
+	else{
+		print O $line;
+	}
+}
+close(P);
+close(O);