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
3e7bd674
Commit
3e7bd674
authored
May 03, 2016
by
Aishwarya Alex
Browse files
update 8 : add input files for dictionary : namespace map and entities and reactions
parent
4cc24cf0
Changes
5
Hide whitespace changes
Inline
Side-by-side
inputs/EntityDictFile.txt
View file @
3e7bd674
proteinAbundance PROTEIN
pathology PHENOTYPE
biologicalProcess PHENOTYPE
rnaAbundance RNA
microRNAAbundance RNA
\ No newline at end of file
inputs/namespaceDictFile.txt
View file @
3e7bd674
...
...
@@ -3,4 +3,5 @@ PubMed urn:miriam:pubmed
GO urn:miriam:go
MESHPP urn:miriam:mesh.2012
MESHCL urn:miriam:mesh.2012
MESHD urn:miriam:mesh.2012
\ No newline at end of file
MESHD urn:miriam:mesh.2012
CHEBIID urn:miriam:chebi:CHEBI
\ No newline at end of file
inputs/reactionDictFile.txt
0 → 100644
View file @
3e7bd674
increases UNKNOWKN_POSTIVE_INFLUENCE
directlyIncreases POSTIVE_INFLUENCE
\ No newline at end of file
namespaceTranslator.py
View file @
3e7bd674
...
...
@@ -21,6 +21,25 @@ def getNamespaceDict():
namespaceDict
[
nspace
[
0
]]
=
nspace
[
1
]
return
namespaceDict
#LOAD NAMESPACE DICTIONARY
def
getEntityDict
():
entityDict
=
{}
for
line
in
open
(
"inputs/EntityDictFile.txt"
,
'r'
):
nspace
=
line
.
split
()
entityDict
[
nspace
[
0
]]
=
nspace
[
1
]
return
entityDict
#LOAD reaction DICTIONARY
def
getReactionDict
():
reactionDict
=
{}
for
line
in
open
(
"inputs/reactionDictFile.txt"
,
'r'
):
nspace
=
line
.
split
()
reactionDict
[
nspace
[
0
]]
=
nspace
[
1
]
return
reactionDict
#Get GOID from GOOSE
def
getGoIDfromTerm
(
term
):
cnx
=
MySQLdb
.
connect
(
user
=
'go_select'
,
passwd
=
'amigo'
,
host
=
'mysql-amigo.ebi.ac.uk'
,
db
=
'go_latest'
,
port
=
4085
)
...
...
@@ -29,4 +48,4 @@ def getGoIDfromTerm(term):
cursor
.
execute
(
query
)
row
=
cursor
.
fetchone
()
cnx
.
close
()
return
row
return
row
\ No newline at end of file
xBEL2CellD.py
View file @
3e7bd674
...
...
@@ -66,10 +66,23 @@ def get_details_from_element(node, index, statement_num, evidence, expStatementF
elementName
=
""
# function@TERM
elementAnnotation
=
""
# ns@PARAMETER+text
details
=
"EMPTY"
entityDict
=
NT
.
getEntityDict
()
if
term
is
not
None
:
element
Name
=
term
.
get
(
ns_tag
(
'function'
))
element
=
term
.
get
(
ns_tag
(
'function'
))
parameter
=
term
.
find
(
ns_tag
(
"parameter"
))
if
element
in
entityDict
.
keys
():
elementName
=
entityDict
[
element
]
else
:
elementName
=
element
#LOAD entity DIctionary
alreadyIn
=
[
line
.
strip
()
for
line
in
open
(
"outputs/additional/toMapEntities.txt"
,
"r"
)]
if
element
not
in
alreadyIn
:
f
=
open
(
"outputs/additional/toMapEntities.txt"
,
"a"
)
f
.
write
(
element
+
"
\n
"
)
f
.
close
()
if
parameter
is
not
None
:
belnamespace
=
parameter
.
get
(
ns_tag
(
"ns"
))
namespaceDict
=
NT
.
getNamespaceDict
()
...
...
@@ -101,8 +114,7 @@ def get_details_from_element(node, index, statement_num, evidence, expStatementF
details
=
get_details_from_element
(
term
,
index
,
statement_num
,
evidence
,
expStatementFile
)
return
details
else
:
print
remove_ns_tag
(
node
.
tag
).
upper
()
+
" is nested WITH A STATEMENT ## add as modifier to nested statement(reaction)"
print
remove_ns_tag
(
node
.
tag
).
upper
()
+
" is nested WITH A STATEMENT ## add as modifier to nested statement(reaction)"
print
"----PRINTING NODE INFO RECURSIVELY"
entry
=
str
(
index
+
1
)
+
"|"
+
str
(
statement_num
+
1
)
+
"|"
+
str
(
elementName
+
" :"
+
elementAnnotation
)
+
"|"
+
str
(
get_node_info_recursive
(
term
)).
replace
(
'|'
,
' '
)
+
"|"
+
str
(
evidence
.
encode
(
'utf-8'
).
replace
(
"
\r\n
"
,
""
)
+
"
\n
"
)
...
...
@@ -127,10 +139,13 @@ def convertXBEL(filepath):
tree
=
ET
.
parse
(
filepath
)
root
=
tree
.
getroot
()
#
LOAD namespace DIctionary
f
=
open
(
"outputs/additional/to
AddNamespac
es.txt"
,
"w"
)
#
create new files
f
=
open
(
"outputs/additional/to
MapEntiti
es.txt"
,
"w"
)
f
.
close
()
#LOAD namespace DIctionary
namespaceDict
=
NT
.
getNamespaceDict
()
reactionDict
=
NT
.
getReactionDict
()
# get all statement nodes, annotation and sub nodes (complex, or composite structures)
reactionIdentifier
=
0
...
...
@@ -175,6 +190,14 @@ def convertXBEL(filepath):
nFile
.
write
(
nodeEntry
)
nFile
.
close
()
print
"
\n
-----REACTION-----
\n
"
if
relationship
in
reactionDict
.
keys
():
relationship
=
reactionDict
[
relationship
]
else
:
alreadyIn
=
[
line
.
strip
()
for
line
in
open
(
"outputs/additional/toMapReactions.txt"
,
"r"
)]
if
element
not
in
alreadyIn
:
f
=
open
(
"outputs/additional/toMapReactions.txt"
,
"a"
)
f
.
write
(
element
+
"
\n
"
)
f
.
close
()
reactionEntry
=
"r"
+
str
(
reactionIdentifier
)
+
"
\t
"
+
relationship
+
"
\t
"
+
reactant
+
"
\t
"
+
modifier
+
"
\t
"
+
product
+
"
\t
"
+
namespaceDict
[
referenceType
]
+
":"
+
reference
+
"
\n
"
print
reactionEntry
rFile
=
open
(
reactionFile
,
"a"
)
...
...
@@ -185,6 +208,6 @@ def convertXBEL(filepath):
print
"TO DO : Nested statement: Add as modifier"
#C
O
nvert file
#C
o
nvert file
#/home/alex/PhD/Bel2CellD/full_abstract3.xbel
convertXBEL
(
'/home/alex/PhD/Bel2CellD/small_corpus.xbel'
)
\ 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