annotate phyloconversion/uniprotfasta2phytab.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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
1 #!/usr/bin/perl -w
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
2
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
3 use strict;
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
4
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
5 use FindBin;
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
6 use lib "$FindBin::Bin/lib";
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
7 use Bio::DB::Fasta;
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
8 use Bio::SeqIO;
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
9 use Bio::Seq;
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
10
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
11 #inputs
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
12 my $infile=shift(@ARGV);
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
13 my $partition=shift(@ARGV);
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
14 #my $delpipes=shift(@ARGV);
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
15 my $species;
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
16
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
17 my $seqid;
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
18 # open infile fasta file
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
19 my $in_obj = Bio::SeqIO->new(-file => $infile, '-format' =>'fasta');
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
20
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
21 while (my $seq = $in_obj->next_seq() ) {
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
22 my $sequence = $seq->seq;
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
23 my @rawid = split(/\|/, $seq->id);
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
24 $seqid = $rawid[1];
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
25 # $seqid = $seq->id;
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
26
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
27 $sequence =~ s/\n//g;
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
28 $species = $seq->desc;
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
29 #species Name is after OS=
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
30 $species =~ s/.+OS\=//;
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
31 $species =~ s/.+OS\=//;
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
32 #species Name is before GN= sometimes PE=
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
33 $species =~ s/ GN\=.+//;
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
34 $species =~ s/ PE\=.+//;
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
35 $species =~ s/ /_/g;
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
36
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
37 print $species."\t".$partition."\t".$seqid."\t".$sequence."\n";
5b9a38ec4a39 First commit of old repositories
osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
parents:
diff changeset
38 }