-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExtractKEGGPathways_from_UniprotKB.rtf
37 lines (36 loc) · 1.39 KB
/
ExtractKEGGPathways_from_UniprotKB.rtf
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
{\rtf1\ansi\ansicpg1252\cocoartf2580
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\paperw11900\paperh16840\margl1440\margr1440\vieww11520\viewh8400\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0
\f0\fs24 \cf0 ## Write function to extract KEGG terms\
library(KEGGREST)\
extractKEGGPathways_from_UNIPROTKBs <- function(uniprotkb = uniprotkb, org="mmu")\{\
\
# initiate output vector\
v_KEGGPathways <- character(length(uniprotkb))\
\
# go over loop\
for (i in 1:length(uniprotkb))\{\
uniprotkb_i <- uniprotkb[i]\
uniprot_entry <- paste0("uniprot:",uniprotkb_i) \
tryCatch(\{\
keggID <- keggConv(org, uniprot_entry) # convert uniprotKB to kegg id\
keggENTRY <- keggGet(keggID) # extract kegg pathways for kegg id\
if (is.null(keggENTRY[[1]]$PATHWAY))\{\
v_KEGGPathways[i] <<- ""\
\} else \{\
kegg_entry_collapse <- paste0("KEGG: ", keggENTRY[[1]]$PATHWAY)\
kegg_entry_collapse <- paste(kegg_entry_collapse, collapse="; ")\
v_KEGGPathways[i] <- kegg_entry_collapse\
\
\}\
\}, error = function(err) \{\
v_KEGGPathways[i] <<- ""\
\})\
\}\
\
# return pathway vector separated by ";"\
return(v_KEGGPathways)\
\}}