{"id":739,"date":"2024-07-05T21:04:32","date_gmt":"2024-07-05T13:04:32","guid":{"rendered":"https:\/\/linguopeng.top\/?p=739"},"modified":"2024-07-05T21:07:50","modified_gmt":"2024-07-05T13:07:50","slug":"%e7%88%ac%e5%8f%96hmdb%e4%bb%a3%e8%b0%a2%e7%89%a9%e5%8f%8a%e5%85%b6%e5%af%b9%e5%ba%94pathway%ef%bc%8c-smpdb_id-kegg_id","status":"publish","type":"post","link":"https:\/\/linguopeng.top\/?p=739","title":{"rendered":"\u722c\u53d6HMDB\u4ee3\u8c22\u7269\u53ca\u5176\u5bf9\u5e94Pathway,SMPDB_ID, KEGG_ID"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>#1.\u6279\u91cf\u722c\u53d6HMDB\u6bcf\u9875\u7684\u7f51\u9875\uff1a\nfor i in {1..46}; \ndo     \n   curl -s  https:\/\/hmdb.ca\/hml\/metabolites?page=${i} -o page${i};\n   sleep 15;\ndone\n#2.\u89e3\u6790\u672c\u5730\u7684page\u7f51\u9875\uff0c\u5f97\u5230\u4ee3\u8c22\u7269id-name\u5b57\u5178\nfor i in {1..46};\ndo\n    cat page${i} \\\n        | grep HMDB \\\n        | sed 's#class=\"metabolite-name\\\">#\\n#g' \\\n        | grep HMDB \\\n        | sed 1d|sed '$d' \\\n\t    | sed 's\/&lt;strong>\/\/g' \\\n        | awk '{match($0, \/HMDB&#91;0-9]{7}\/, arr);\n          \t\thmdb_id = arr&#91;0];\n\t\t\t\tmatch($0, \/&#91;^>]*>(&#91;^&lt;]+)\/, arr);\n\t\t\t\tcompound_name = arr&#91;1];\n\t\t\t\tif (length(hmdb_id) &amp;&amp; length(compound_name)) print hmdb_id\"\\t\"compound_name}'  > page${i}.dict;\ndone\n#3.\u5728\u4e0a\u4e00\u6b65\u7684\u57fa\u7840\u4e0a\uff0c\u6279\u91cf\u722c\u53d6\u6bcf\u4e2a\u4ee3\u8c22\u7269\u7684\u8be6\u7ec6\u4fe1\u606f\ncat page*.dict |while IFS=$'\\t' read -r id name \ndo\n    curl -s https:\/\/hmdb.ca\/metabolites\/${id}.xml -o ${id}.xml\n    sleep 10 # \u7761\u4e00\u4f1a\uff0c\u4e0d\u8981\u592a\u75b2\u60eb\ndone\n#\u6279\u91cf\u89e3\u6790xml\u6587\u4ef6\uff0c\u5f97\u5230\u3010\u4ee3\u8c22\u7269-\u901a\u8def\u3011\u5b57\u5178\ncat page*.dict |while IFS=$'\\t' read -r id name\ndo\n    if test -z \"$(cat ${id}.xml|xmllint --xpath \"\/\/pathway\/name\" - 2>\/dev\/null)\"; then\n        echo \"# ${id} skiped.\"\n    else\n        echo \"# ${id} running\" &amp;&amp;\\\n        cat ${id}.xml \\\n            | xmllint --xpath \"\/\/pathway\/name | \/\/pathway\/smpdb_id | \/\/pathway\/kegg_map_id\" - \\\n            | awk -F'&#91;&lt;>]' -v HMDB_ID=\"$id\" -v HMDB_NM=\"$name\" '{\n                 if (FNR % 3 == 1) name = ($3 ? $3 : \"NA\");\n                 if (FNR % 3 == 2) smpdb_id = ($3 ? $3 : \"NA\");\n                 if (FNR % 3 == 0) kegg_map_id = ($3 ? $3 : \"NA\");\n                 if (FNR % 3 == 0) printf(\"%s\\t%s\\t%s\\t%s\\t%s\\n\", HMDB_ID, HMDB_NM, name, smpdb_id, kegg_map_id);\n}' >> Meta2Pathway.tsv\n    fi\ndone<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/linguopeng.top\/wp-content\/uploads\/2024\/07\/hmdb1.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1863\" height=\"277\" data-original=\"https:\/\/linguopeng.top\/wp-content\/uploads\/2024\/07\/hmdb1.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-741\"  sizes=\"auto, (max-width: 1863px) 100vw, 1863px\" \/><\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-739","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/linguopeng.top\/index.php?rest_route=\/wp\/v2\/posts\/739","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linguopeng.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linguopeng.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linguopeng.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linguopeng.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=739"}],"version-history":[{"count":4,"href":"https:\/\/linguopeng.top\/index.php?rest_route=\/wp\/v2\/posts\/739\/revisions"}],"predecessor-version":[{"id":744,"href":"https:\/\/linguopeng.top\/index.php?rest_route=\/wp\/v2\/posts\/739\/revisions\/744"}],"wp:attachment":[{"href":"https:\/\/linguopeng.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=739"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linguopeng.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=739"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linguopeng.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=739"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}