Pathway.sh 765 B

12345678910111213141516
  1. [ $# != 3 ] && echo -e "Usage:\n\t$0 KEGG.txt hsa Pathway.txt" && exit 1
  2. kegg_file=$1
  3. org=$2
  4. outfile=$3
  5. database_dir=/Business/psn_company/Work/Transcriptome/Datum/Public/Database/genome_prepare/KEGG
  6. if [ -s "$database_dir/pathway/$org" ]
  7. then
  8. sed "s/^$org/map/;s/^map/map/" $database_dir/pathway/$org | sed 's/ - [^-]\+$//' | \
  9. 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/'|\
  10. 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' |\
  11. awk 'BEGIN{FS=OFS="\t"}FNR==NR{a[$1]=$2}FNR!=NR{if(a[$2])print $1,a[$2]}' - $kegg_file > $outfile
  12. else
  13. echo "Error:$database_dir/pathway/$org not exists"
  14. exit 1
  15. fi