Mercurial > repos > ucsb-phylogenetics > osiris_phylogenetics
diff phyloconversion/fasta2phytab.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 diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phyloconversion/fasta2phytab.pl Tue Mar 11 12:19:13 2014 -0700 @@ -0,0 +1,40 @@ +#!/usr/bin/perl -w + +use strict; + +use FindBin; +use lib "$FindBin::Bin/lib"; +use Bio::DB::Fasta; +use Bio::SeqIO; +use Bio::Seq; + +#inputs +my $infile=shift(@ARGV); +my $species=shift(@ARGV); +my $partition=shift(@ARGV); +my $delpipes=shift(@ARGV); +my $fromfasta; +#for debugging xml input +#print "$infile $species $partition $delpipes\n"; +#exit; + +if($species eq "from fasta"){ + $fromfasta=1; +} +my $seqid; +# open infile fasta file +my $in_obj = Bio::SeqIO->new(-file => $infile, '-format' =>'fasta'); + +#no warnings 'uninitialized'; #Was getting error on one fasta for uninitialized sequences. Never could track down why and used this as a workaround +while (my $seq = $in_obj->next_seq() ) { + my $sequence = $seq->seq; + $seqid = $seq->id; + if($delpipes eq 'yes'){ + $seqid =~ s/\|/_/g; + } + if($fromfasta){ + $species = $seqid; + } + $sequence =~ s/\n//g; + print $species."\t".$partition."\t".$seqid."\t".$sequence."\n"; +}