[ $# != 3 ] && echo -e "Usage:\n\t$0 KEGG.txt hsa Pathway.txt" && exit 1 kegg_file=$1 org=$2 outfile=$3 database_dir=/Business/psn_company/Work/Transcriptome/Datum/Public/Database/genome_prepare/KEGG if [ -s "$database_dir/pathway/$org" ] then sed "s/^$org/map/;s/^map/map/" $database_dir/pathway/$org | sed 's/ - [^-]\+$//' | \ awk 'BEGIN{FS=OFS="\t"}FNR==NR{a[$1]=$0}FNR!=NR{if(a[$1])print $2,a[$1]}' - $database_dir/pathwayTOKO |sed 's/\tmap/\tko/'|\ sort -k1,1 -V |awk -F"\t" '{a[$1]=$2"("$3");"a[$1]}END{for(i in a)print i"\t"a[i]}' OFS="\t"| sort -k1,1|sed 's/;$//g' |\ awk 'BEGIN{FS=OFS="\t"}FNR==NR{a[$1]=$2}FNR!=NR{if(a[$2])print $1,a[$2]}' - $kegg_file > $outfile else echo "Error:$database_dir/pathway/$org not exists" exit 1 fi