#!/usr/bin/perl -w #################################################### ### Huang He ### ### put taxonomy information to summary file ### #################################################### ($silva,$summary)=@ARGV; open(File,"$silva")||die "can't open the $silva\n"; while(){ chomp; s/\c@*//g; s/\cM*$//; if(/^>/){ $line=$_; @temp=split; $id=$temp[0]; $id=~s/\>//g; $id_taxo{$id}=$line; } } close File; open(File,"$summary")||die "can't open the $summary\n"; $b=0; print"ID\tCount\tAvg.% Identity\tGenome\tTaxonomy\n"; while(){ chomp; s/\c@*//g; s/\cM*$//; if(/Identity/){ next; } @temp=(); @temp_taxo=(); $line=$_; @temp=split(/\s+/,$line); $name=$temp[0]; if(! exists $id_taxo{$name}){ print"$line\tunknown\n"; $b=$b+$temp[1]; next; } # $name=~s/\>//g; $b=$b+$temp[1]; $taxo=$id_taxo{$name}; @temp_taxo=split(/\;/,$taxo); @temp_fir=split(/\s+/,$temp_taxo[0]); $first=$temp_fir[1]; print"$line\t$first\t"; for($a=1;$a<@temp_taxo;$a++){ print"$temp_taxo[$a]\t"; } print"\n"; } #print"\t$b"; close File;