Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SOaAS
psot.repository
Commits
5ea07f52
Commit
5ea07f52
authored
Nov 29, 2017
by
lmueller
Browse files
got resolve_dbxrefs.py working, still unstable
parent
89c7cfc7
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/resolve_dbxrefs.py
View file @
5ea07f52
...
...
@@ -4,24 +4,46 @@ import json
import
argparse
import
os
import
sys
sys
.
path
.
insert
(
0
,
'../../dbxref/dbxref'
)
sys
.
path
.
insert
(
0
,
'../../dbxref'
)
import
retriever
import
subprocess
parser
=
argparse
.
ArgumentParser
(
description
=
'Resolve dbxrefs from json file'
)
parser
.
add_argument
(
'--input'
,
'-i'
,
required
=
True
,
help
=
'The json input document'
)
#parser.add_argument('--output', '-o', required=True, help='The name of the output document')
parser
.
add_argument
(
'--scripts'
,
'-s'
,
required
=
True
,
help
=
'Location of the retriever scripts'
)
parser
.
add_argument
(
'--output'
,
'-o'
,
required
=
True
,
help
=
'Name of the output document'
)
args
=
parser
.
parse_args
()
joined
=
{}
json_file
=
open
(
args
.
input
).
read
()
j
son
=
json
.
loads
(
json_file
)
j
=
json
.
loads
(
json_file
)
for
c
in
json
[
'computations'
]:
li
=
c
[
'results'
][
'informations'
]
di
=
retriever
.
retrieve
(
li
)
def
sort_refs
(
ref_list
):
refs
=
{}
for
ref
in
ref_list
:
ble
=
ref
.
split
(
':'
)
if
ble
[
0
]
in
refs
:
refs
[
ble
[
0
]].
append
(
ble
[
0
]
+
":"
+
ble
[
1
])
else
:
refs
[
ble
[
0
]]
=
[
ble
[
0
]
+
":"
+
ble
[
1
]]
return
(
refs
)
#output_filename = args.output
#with open(output_filename, 'w') as o:
# json.dump(joined, o)
script_dir
=
args
.
scripts
di
=
[]
for
c
in
j
[
'computations'
]:
for
r
in
c
[
'results'
]:
refs
=
sort_refs
(
r
[
'informations'
])
if
'EC'
in
refs
:
di
.
append
(
json
.
loads
(
str
(
subprocess
.
check_output
(
script_dir
+
"retrieve_enzyme.py "
+
" "
.
join
(
refs
[
'EC'
]),
shell
=
True
).
rstrip
())[
2
:
-
1
]))
if
'GO'
in
refs
:
di
.
append
(
json
.
loads
(
str
(
subprocess
.
check_output
(
script_dir
+
"retrieve_gene_ontology.py "
+
" "
.
join
(
refs
[
'GO'
]),
shell
=
True
).
rstrip
())[
2
:
-
1
]))
# if 'PFAM' in refs:
# di = json.loads(str(subprocess.check_output(script_dir + "retrieve_pfam.py " + " ".join(refs['PFAM']), shell=True).rstrip())[2:-1])
if
'SO'
in
refs
:
di
.
append
(
json
.
loads
(
str
(
subprocess
.
check_output
(
script_dir
+
"retrieve_sequence_ontology.py "
+
" "
.
join
(
refs
[
'SO'
]),
shell
=
True
).
rstrip
())[
2
:
-
1
]))
if
'UniProtKB/Swiss-Prot'
in
refs
:
di
.
append
(
json
.
loads
(
str
(
subprocess
.
check_output
(
script_dir
+
"retrieve_uniprot.py "
+
" "
.
join
(
refs
[
'UniProtKB/Swiss-Prot'
]),
shell
=
True
).
rstrip
())[
2
:
-
1
]))
# print (json.dumps(di))
output_filename
=
args
.
output
with
open
(
output_filename
,
'w'
)
as
o
:
json
.
dump
(
di
,
o
)
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