Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
API scripts
Commits
082970b7
Commit
082970b7
authored
Mar 18, 2020
by
Marek Ostaszewski
Browse files
Update API_find_drug_targets.R
parent
06577b80
Changes
1
Hide whitespace changes
Inline
Side-by-side
R/API_find_drug_targets.R
View file @
082970b7
...
...
@@ -33,3 +33,37 @@ map_hits <- sapply(aspirin_targets$targets[[1]]$targetElements, nrow) > 0
### Extract HGNC symbols from the 'targetParticipants' part of the results
aspirin_map_hgncs
<-
sapply
(
aspirin_targets
$
targets
[[
1
]]
$
targetParticipants
[
map_hits
],
function
(
x
)
x
[,
"resource"
])
### Query for the drugs targetting given
### Uniprot identifiers
#Define UniProt identifiers to be matched in model elements
uniprot_examples
<-
c
(
"Q92793"
,
"P16220"
)
### Request identifiers of models for a given project (main map and submaps)
models
<-
ask_GET
(
base_url
,
"models/"
)
models
<-
fromJSON
(
models
,
flatten
=
F
)
### For each model, retrieve elements with columns including references
model_elements
<-
lapply
(
models
$
idObject
,
function
(
x
)
fromJSON
(
ask_GET
(
paste0
(
base_url
,
"models/"
,
x
,
"/"
),
"bioEntities/elements/?columns=id,name,type,references"
),
flatten
=
F
))
### For results in each model, find element identifiers that have the selected uniprot id
identifiers
<-
c
()
for
(
m
in
1
:
length
(
model_elements
))
{
### In "resources" of each element, find those which have requested UniProt identifiers
hits
<-
sapply
(
model_elements
[[
m
]]
$
references
,
function
(
x
)
any
(
uniprot_examples
%in%
x
$
resource
[
x
$
type
==
"UNIPROT"
]))
### Identifiers of the elements matching the search criteria
identifiers
<-
c
(
identifiers
,
unlist
(
model_elements
[[
m
]]
$
id
[
hits
]))
}
### For each identifier, request fo its drug targets, select 'name' from results
drugs
<-
sapply
(
identifiers
,
function
(
x
)
fromJSON
(
ask_GET
(
base_url
,
paste0
(
"drugs:search?target=ALIAS:"
,
x
)))
$
name
)
### Display unique results
unique
(
drugs
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment