view phyloconversion/raxify_fasta.pl @ 0:5b9a38ec4a39 draft default tip

First commit of old repositories
author osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
date Tue, 11 Mar 2014 12:19:13 -0700
parents
children
line wrap: on
line source

#!/usr/bin/perl -w
use strict;

my $infile = $ARGV[0];
my $outfile = $ARGV[1];

open(IN, "$infile") or exit;
open(OUT, ">$outfile") or exit;

while (<IN>) {
	my $line = $_;
	if($line =~ m/\>/ ){
		$line=raxify($line);
	}
	if($line =~ m/\n/){
		print OUT $line;
	}else{
		print OUT $line."\n";
	}
}
close(IN);
close(OUT);

sub raxify
{
	my $raxline = shift;
	$raxline = substr($raxline,0,51);
	$raxline =~ s/\./_/g;
	$raxline =~ s/\|/_/g;
	$raxline =~ s/ /_/g;
	return $raxline;
}