Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Aishwarya Alex
xBELtoCellD
Commits
9347c784
Commit
9347c784
authored
Mar 15, 2017
by
Aishwarya Alex
Browse files
Added reflect-client for Go terms
parent
e51244bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
namespaceTranslator.py
View file @
9347c784
...
...
@@ -11,8 +11,8 @@
##############################################################################################
# Import the modules needed to run the script.
import
MySQLdb
import
MySQLdb
,
reflectclient
from
reflectclient.config
import
EntityType
#LOAD NAMESPACE DICTIONARY
def
getDict
(
filename
):
dict
=
{}
...
...
@@ -30,20 +30,45 @@ def getReactionDict():
reactionDict
[
nspace
[
0
]]
=
nspace
[
1
]
return
reactionDict
#Get GOID from GOOSE
def
termToIdentifier
(
belnamespace
,
term
):
if
"GO"
in
belnamespace
or
belnamespace
is
""
:
term
=
getGoIDfromTerm
(
term
)
if
"CHEM"
in
belnamespace
:
term
=
getChemicalIDfromTerm
(
term
)
return
term
#Get GOID from reflect
def
getGoIDfromTerm
(
term
):
print
"get conn"
cnx
=
MySQLdb
.
connect
(
user
=
'go_select'
,
passwd
=
'amigo'
,
host
=
'spitz.lbl.gov'
,
db
=
'go_latest'
,
port
=
4085
)
cursor
=
cnx
.
cursor
()
print
"connected and querying"
query
=
"SELECT acc FROM term WHERE name='cell migration'"
cursor
.
execute
(
query
)
print
"query done"
row
=
cursor
.
fetchone
()
cnx
.
close
()
print
row
return
row
print
"try"
getGoIDfromTerm
(
"cell migration"
)
print
"done"
\ No newline at end of file
goID
=
term
print
term
reflect_client
=
reflectclient
.
ReflectClient
()
GOresult
=
reflect_client
.
get_entities
(
term
,
[
EntityType
.
biological_process
,
EntityType
.
cellular_component
,
EntityType
.
molecular_function
])
print
GOresult
print
len
(
GOresult
)
if
len
(
GOresult
)
>
0
:
goID
=
GOresult
[
0
][
'entities'
][
0
][
'identifier'
]
print
goID
return
goID
#Get pubchemID from reflect
def
getChemicalIDfromTerm
(
term
):
chemID
=
term
reflect_client
=
reflectclient
.
ReflectClient
()
chemResult
=
reflect_client
.
get_entities
(
term
,
[
EntityType
.
chemicals
])
if
len
(
chemResult
)
>
0
:
chemID
=
chemResult
[
0
][
'entities'
][
0
][
'identifier'
]
return
chemID
#Get meshID from reflect
def
getMeshIDfromTerm
(
term
):
mesh_id
=
term
reflect_client
=
reflectclient
.
ReflectClient
()
meshResult
=
reflect_client
.
get_entities
(
term
,
[
EntityType
.
diseases
])
print
meshResult
if
len
(
meshResult
)
>
0
:
mesh_id
=
meshResult
[
0
][
'entities'
][
0
][
'identifier'
]
return
mesh_id
#getMeshIDfromTerm("Parkinson's Disease")
getGoIDfromTerm
(
"leukotriene production involved in inflammatory response"
)
getGoIDfromTerm
(
"inflammatory response"
)
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