Skip to content

Commit

Permalink
Update xrefs.py
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Aug 18, 2023
1 parent 2abc322 commit eec4353
Showing 1 changed file with 28 additions and 33 deletions.
61 changes: 28 additions & 33 deletions src/pyobo/api/xrefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,46 +133,41 @@ def get_sssom_df(
rows = []
with logging_redirect_tqdm():
for source_id, target_prefix, target_id in tqdm(df.values, unit="mapping", unit_scale=True):
row = (
bioregistry.curie_to_str(prefix, source_id),
bioregistry.curie_to_str(target_prefix, target_id),
predicate_id,
justification,
)
if names:
row = (*row, get_name(prefix, source_id) or "", get_name(target_prefix, target_id))
rows.append(row)

if not names:
return pd.DataFrame(
rows,
columns=[
"subject_id",
"object_id",
"predicate_id",
"mapping_justification",
],
)

df = pd.DataFrame(
rows,
columns=[
rows.append(
(
bioregistry.curie_to_str(prefix, source_id),
bioregistry.curie_to_str(target_prefix, target_id),
predicate_id,
justification,
)
)
else:
rows.append(
(
bioregistry.curie_to_str(prefix, source_id),
get_name(prefix, source_id) or "",
bioregistry.curie_to_str(target_prefix, target_id),
get_name(target_prefix, target_id),
predicate_id,
justification,
)
)

if names:
columns = [
"subject_id",
"subject_label",
"object_id",
"object_label",
"predicate_id",
"mapping_justification",
"subject_label",
"object_label",
],
)
# reorder columns
return df[
[
]
else:
columns = [
"subject_id",
"subject_label",
"object_id",
"object_label",
"predicate_id",
"mapping_justification",
]
]
return pd.DataFrame(rows, columns=columns)

0 comments on commit eec4353

Please sign in to comment.