-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path15.parse_NCBI_name_to_get_strain_name.pl
More file actions
50 lines (45 loc) · 1.01 KB
/
Copy path15.parse_NCBI_name_to_get_strain_name.pl
File metadata and controls
50 lines (45 loc) · 1.01 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
#!/usr/bin/perl -w
my %rank = ();
$rank{"d"} = "Domain";
$rank{"p"} = "Phylum";
$rank{"c"} = "Class";
$rank{"o"} = "Order";
$rank{"f"} = "Family";
$rank{"g"} = "Genus";
$rank{"s"} = "Species";
%GnTax = ();
open IN, "Bin2Curated_tax.result.txt";
while (<IN>){
chomp;
my @tmp = split (/\t/,$_);
$GnTax{$tmp[0]} = $tmp[1];
}
close IN;
%out = ();
foreach my $key (sort keys %GnTax){
my $strain_name = "";
my $tail = ""; my $BorA = "";
my @tmp = split (/\;/, $GnTax{$key});
foreach my $rank_info (@tmp){
if ($rank_info =~ /^\S\_\_\S/){
$tail = $rank_info;
}
}
if ($GnTax{$key} =~ /^d\_\_Bacteria/){
$BorA = "bacterium";
}else{
$BorA = "archaeon";
}
my ($rank_letter, $tail_name) = $tail =~ /^(\S)\_\_(.+)/;
if ($rank_letter eq "g"){
$strain_name = "$tail_name sp\. $key \[Genus\]";
}else{
$strain_name = "$tail_name $BorA $key \[$rank{$rank_letter}\]";
}
$out{$key} = $strain_name;
}
open OUT, ">strain_name.xls";
foreach my $key (sort keys %out){
print OUT "$key\t$out{$key}\n";
}
close OUT;