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
sciReptor
AIRR CEF Toolbox
Commits
cb803fbd
Commit
cb803fbd
authored
Aug 06, 2021
by
Francisco Arcila Salamanca
Browse files
fix ontology look-up that failed with empty values
parent
81a92183
Changes
1
Hide whitespace changes
Inline
Side-by-side
scirexport/airr_export.py
View file @
cb803fbd
...
...
@@ -450,25 +450,20 @@ def format_id_val_ontologies(meta_dict: dict, ontologies_dic: dict) -> None:
if
ontologies_dic
[
x
][
"preferred_label"
]
==
1
}
missing
=
[
(
x
,
meta_dict
[
x
])
for
x
in
meta_dict
if
meta_dict
[
x
]
not
in
preferred_labels
and
x
in
validate_airr_dic
and
"Ontology"
in
validate_airr_dic
[
x
][
"Format"
]
]
if
missing
:
logger
.
warning
(
f
"WARNING
{
missing
}
not in ontologies table"
)
fix_ontos
=
{
missing
[
0
]:
{
"id"
:
{},
"label"
:
{}}}
# for x in missing}
fix_ontos
=
{}
else
:
fix_ontos
=
{
x
:
{
"id"
:
meta_dict
[
x
],
"label"
:
preferred_labels
[
meta_dict
[
x
]]}
for
x
in
meta_dict
if
x
in
validate_airr_dic
and
"Ontology"
in
validate_airr_dic
[
x
][
"Format"
]
}
for
x
in
meta_dict
:
if
x
in
validate_airr_dic
and
"Ontology"
in
validate_airr_dic
[
x
][
"Format"
]:
if
meta_dict
[
x
]
not
in
preferred_labels
:
logger
.
warning
(
f
"WARNING
{
x
}
not in ontologies table"
)
fix_ontos
[
x
]
=
{
"id"
:
None
,
"label"
:
None
}
elif
meta_dict
[
x
]
in
preferred_labels
:
fix_ontos
[
x
]
=
{
"id"
:
meta_dict
[
x
],
"label"
:
preferred_labels
[
meta_dict
[
x
]],
}
else
:
print
(
x
)
for
x
in
meta_dict
:
if
x
in
fix_ontos
:
...
...
@@ -584,14 +579,21 @@ def process_repertoires(
else
repertoire_dic
[
rep
][
x
]
for
x
in
repertoire_dic
[
rep
]
}
list_reps
.
append
(
sr
.
dump_repertoire
(
format_id_val_ontologies
(
repertoire_dic
[
rep
],
replace_ontos
)
)
rept
=
sr
.
dump_repertoire
(
format_id_val_ontologies
(
repertoire_dic
[
rep
],
replace_ontos
)
)
list_reps
.
append
(
rept
)
essential_validation
(
repertoire_dic
[
rep
],
rep
)
import
airr
try
:
airr
.
RepertoireSchema
.
validate_object
(
rept
)
except
airr
.
ValidationError
as
e
:
print
(
"has repertoire at array position with validation error: %s
\n
"
%
e
)
repertoires_dic
=
{
"Repertoire"
:
list_reps
}
return
repertoires_dic
...
...
Write
Preview
Supports
Markdown
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