-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathtaxid2fulltax.pl
More file actions
executable file
·52 lines (47 loc) · 1.27 KB
/
taxid2fulltax.pl
File metadata and controls
executable file
·52 lines (47 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/perl
# Script: test_tax.pl
# Description:
# Author: Steven Ahrendt
# email: sahrendt0@gmail.com
# Date: 11.12.2014
##################################
use warnings;
use strict;
use Getopt::Long;
use lib '/rhome/sahrendt/Scripts';
use SeqAnalysis;
use Data::Dumper;
#####-----Global Variables-----#####
my $input;
my ($help,$verb);
my @ranks = qw(kingdom phylum class order family genus species);
#my @ranks = qw(phylum); # user input for ranks to use
my $user_ranks;
GetOptions ('i|input=s' => \$input,
'h|help' => \$help,
'v|verbose' => \$verb,
'ranks=s' => \$user_ranks);
my $usage = "Usage: test_tax.pl -i input [--ranks]\n\n";
die $usage if $help;
die "No input.\n$usage" if (!$input);
#####-----Main-----#####
@ranks = split(/,/,$user_ranks) if $user_ranks;
warn join("-",@ranks),"\n" if $verb;
my $tax_db = initNCBI("flatfile");
open(IN,"<",$input) or die "Can't open $input: $!\n";
while(my $line = <IN>)
{
chomp $line;
#my @tmp = split(/ /,$line);
#$line = join("\t",@tmp);
my $id = (split(/\t/,$line))[1];
my $hash = getTaxonomybyID($tax_db,$id);
# print Dumper $hash;
$line =~ s/ /\t/;
print $line,"\t";
printTaxonomy($hash,\@ranks,"",$id);
}
close(IN);
warn "Done.\n";
exit(0);
#####-----Subroutines-----#####