Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SOaAS
dbxref
Commits
d76fd38d
Commit
d76fd38d
authored
Mar 04, 2020
by
Lukas Jelonek
Browse files
Fix failing test. Adapt to general dbxref requirements
parent
d17d7f0a
Changes
2
Hide whitespace changes
Inline
Side-by-side
dbxref/retrieve/cdd.py
View file @
d76fd38d
...
...
@@ -43,7 +43,7 @@ def main():
print
(
json
.
dumps
(
documents
,
sort_keys
=
True
,
indent
=
4
))
def
retrieve
(
dbxrefs
,
basics
,
abstract
,
dat
e
,
pssmlength
,
structure
,
status
):
def
retrieve
(
dbxrefs
,
basics
=
True
,
abstract
=
False
,
date
=
Fals
e
,
pssmlength
=
False
,
structure
=
False
,
status
=
False
):
"""Retrieve json document from InterPro REST api, filter information by selected Options and parse into new json"""
resolved
=
dbxref
.
resolver
.
resolve
(
dbxrefs
,
check_existence
=
False
)
documents
=
[]
...
...
@@ -56,22 +56,24 @@ def retrieve(dbxrefs, basics, abstract, date, pssmlength, structure, status):
cdd_json
=
json
.
loads
(
r
.
text
)
# parse retrieved json file by selected options
output
=
{}
output
=
{
"id"
:
entry
[
"dbxref"
]
}
acc_id
=
str
(
resolved
[
0
][
"dbxref"
][
4
:])
if
basics
:
try
:
output
.
update
({
"dbxref
_id
"
:
"CDD:"
+
acc_id
,
"accession
_id
"
:
cdd_json
[
"result"
][
acc_id
][
"accession"
],
output
.
update
({
"dbxref"
:
"CDD:"
+
acc_id
,
"accession"
:
cdd_json
[
"result"
][
acc_id
][
"accession"
],
"scientific_name"
:
cdd_json
[
"result"
][
acc_id
][
"title"
],
"database"
:
cdd_json
[
"result"
][
acc_id
][
"database"
],
"associated_organism"
:
cdd_json
[
"result"
][
acc_id
][
"organism"
]
})
except
KeyError
:
print
(
"One or more basic information were not available for the given entry. Please check your data."
)
raise
if
abstract
:
try
:
output
.
update
({
"abstract"
:
cdd_json
[
"result"
][
acc_id
][
"abstract"
]})
except
KeyError
:
print
(
"An abstract was not available for the given entry."
)
raise
if
date
:
try
:
output
.
update
({
"publication_date"
:
cdd_json
[
"result"
][
acc_id
][
"pubdate"
],
...
...
@@ -79,21 +81,25 @@ def retrieve(dbxrefs, basics, abstract, date, pssmlength, structure, status):
except
KeyError
:
print
(
"The date of publishment and/or day of addition to Entrez were not available for the given "
"entry."
)
raise
if
pssmlength
:
try
:
output
.
update
({
"pssmlength"
:
cdd_json
[
"result"
][
acc_id
][
"pssmlength"
]})
except
KeyError
:
print
(
"Information about PSSM was not available for the given entry."
)
raise
if
structure
:
try
:
output
.
update
({
"representative_structure"
:
cdd_json
[
"result"
][
acc_id
][
"structurerepresentative"
]})
except
KeyError
:
print
(
"There was no representative structure available for the given entry."
)
raise
if
status
:
try
:
output
.
update
({
"status"
:
cdd_json
[
"result"
][
acc_id
][
"status"
]})
except
KeyError
:
print
(
"Status information was not available for the given entry. Please check your data."
)
raise
documents
.
append
(
output
)
return
documents
...
...
tests/test_cdd.py
View file @
d76fd38d
...
...
@@ -4,7 +4,7 @@ from dbxref.retrieve import cdd
class
TestCDD
(
unittest
.
TestCase
):
def
test_output
(
self
):
documents
=
cdd
.
retrieve
({
"db"
:
"CDD"
,
"id"
:
"351793"
},
basics
=
True
,
abstract
=
True
,
date
=
True
,
pssmlength
=
True
,
documents
=
cdd
.
retrieve
(
[
{
"db"
:
"CDD"
,
"id"
:
"351793"
}
]
,
basics
=
True
,
abstract
=
True
,
date
=
True
,
pssmlength
=
True
,
status
=
True
,
structure
=
True
)
self
.
assertTrue
(
documents
)
...
...
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