comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:5b9a38ec4a39
1 #!/usr/bin/perl -w
2
3 use strict;
4
5 use FindBin;
6 use lib "$FindBin::Bin/lib";
7 use Bio::DB::Fasta;
8 use Bio::SeqIO;
9 use Bio::Seq;
10
11 #inputs
12 my $infile=shift(@ARGV);
13 my $species=shift(@ARGV);
14 my $partition=shift(@ARGV);
15 my $delpipes=shift(@ARGV);
16 my $fromfasta;
17 #for debugging xml input
18 #print "$infile $species $partition $delpipes\n";
19 #exit;
20
21 if($species eq "from fasta"){
22 $fromfasta=1;
23 }
24 my $seqid;
25 # open infile fasta file
26 my $in_obj = Bio::SeqIO->new(-file => $infile, '-format' =>'fasta');
27
28 #no warnings 'uninitialized'; #Was getting error on one fasta for uninitialized sequences. Never could track down why and used this as a workaround
29 while (my $seq = $in_obj->next_seq() ) {
30 my $sequence = $seq->seq;
31 $seqid = $seq->id;
32 if($delpipes eq 'yes'){
33 $seqid =~ s/\|/_/g;
34 }
35 if($fromfasta){
36 $species = $seqid;
37 }
38 $sequence =~ s/\n//g;
39 print $species."\t".$partition."\t".$seqid."\t".$sequence."\n";
40 }