-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathgetSingleTax.pl
executable file
·53 lines (48 loc) · 1.37 KB
/
getSingleTax.pl
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
53
#!/usr/bin/perl
# Script: getSingleTax.pl
# Description: Single use to get full taxonomy of a species
# Author: Steven Ahrendt
# email: [email protected]
# Date: 04.04.2014
##################################
use warnings;
use strict;
use lib '/rhome/sahrendt/Scripts';
use Getopt::Long;
use SeqAnalysis;
use Data::Dumper;
#####-----Global Variables-----#####
my $input;
my ($help,$verb);
my $hash_ref;
my $db_form = "flatfile";
my @ranks = qw(Kingdom Phylum Class Order Family Genus Species); # Standard 7 taxonomic rankings
GetOptions ('i|input=s' => \$input,
'h|help' => \$help,
'v|verbose' => \$verb);
my $usage = "Usage: getSingleTax.pl -i input\nOutput to STDOUT\n";
die $usage if $help;
die "No input.\n$usage" if (!$input);
#####-----Main-----#####
my $NCBI_TAX = initNCBI($db_form);
open(my $fh,"<",$input);
while(my $line = <$fh>)
{
if($line =~ /^#/)
{
print $line;
next;
}
chomp $line;
my($abb,$c1,$c2,$spec,$ver,$web) = split(/\t/,$line);
my @data = split(/ /,$spec);
my $newSpec = join(" ",$data[0],$data[1]);
#$hash_ref->{$input} = getTaxonomy($NCBI_TAX,$input,$db_form,$verb);
#print "\"$spec\": ".getTaxIDbySpecies($NCBI_TAX,$spec)."\n";
my $taxID = getTaxIDbySpecies($NCBI_TAX,$newSpec);
print join("\t",$abb,$c1,$c2,$taxID,$spec,$ver,$web),"\n";
}
close($fh);
warn "Done.\n";
exit(0);
#####-----Subroutines-----#####