Commit 9347c784 authored by Aishwarya Alex's avatar Aishwarya Alex
Browse files

Added reflect-client for Go terms

parent e51244bd
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
############################################################################################## ##############################################################################################
# Import the modules needed to run the script. # Import the modules needed to run the script.
import MySQLdb import MySQLdb, reflectclient
from reflectclient.config import EntityType
#LOAD NAMESPACE DICTIONARY #LOAD NAMESPACE DICTIONARY
def getDict(filename): def getDict(filename):
dict={} dict={}
...@@ -30,20 +30,45 @@ def getReactionDict(): ...@@ -30,20 +30,45 @@ def getReactionDict():
reactionDict[nspace[0]]=nspace[1] reactionDict[nspace[0]]=nspace[1]
return reactionDict 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): def getGoIDfromTerm(term):
print "get conn" goID= term
cnx = MySQLdb.connect(user='go_select', passwd='amigo', host='spitz.lbl.gov', db='go_latest', port=4085) print term
cursor=cnx.cursor() reflect_client = reflectclient.ReflectClient()
print"connected and querying" GOresult=reflect_client.get_entities(term, [EntityType.biological_process,EntityType.cellular_component,EntityType.molecular_function])
query="SELECT acc FROM term WHERE name='cell migration'" print GOresult
cursor.execute(query) print len(GOresult)
print "query done" if len(GOresult) >0:
row=cursor.fetchone() goID=GOresult[0]['entities'][0]['identifier']
cnx.close() print goID
print row return goID
return row
#Get pubchemID from reflect
print "try" def getChemicalIDfromTerm(term):
getGoIDfromTerm("cell migration") chemID= term
print "done" reflect_client = reflectclient.ReflectClient()
\ No newline at end of file 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")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment