Mercurial > repos > ucsb-phylogenetics > osiris_phylogenetics
comparison phyloconversion/gb2phytab.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 use strict; | |
3 | |
4 use Bio::SeqIO; | |
5 | |
6 | |
7 my $datafile = $ARGV[0]; | |
8 my $outfile = $ARGV[1]; | |
9 | |
10 open FILE, ">$outfile" or die "Cannot Write File\n"; | |
11 | |
12 my $seqio_object = Bio::SeqIO->new(-file => $datafile,'-format' => 'genbank'); | |
13 | |
14 while(my $seq_object = $seqio_object->next_seq){ | |
15 my $organism = $seq_object->species->binomial(); | |
16 $organism =~ s/ /_/g; | |
17 my $accession = $seq_object->id; | |
18 for my $feat_object ($seq_object->get_SeqFeatures) { | |
19 if ($feat_object->primary_tag eq "CDS") { | |
20 my $sequence = $feat_object->spliced_seq->seq; | |
21 if ($feat_object->has_tag('gene')) { | |
22 for my $name ($feat_object->get_tag_values('product')){ | |
23 $name =~ s/ /_/g; | |
24 print FILE $organism."\t".$name."\t".$accession."\t".$sequence."\n"; | |
25 } | |
26 } | |
27 }elsif ($feat_object->primary_tag eq "misc_RNA") { | |
28 my $sequence = $feat_object->spliced_seq->seq; | |
29 if ($feat_object->has_tag('product')) { | |
30 for my $name ($feat_object->get_tag_values('product')){ | |
31 $name =~ s/ /_/g; | |
32 print FILE $organism."\t".$name."\t".$accession."\t".$sequence."\n"; | |
33 } | |
34 } | |
35 } | |
36 | |
37 } | |
38 } | |
39 close FILE; | |
40 | |
41 |