Skip to content

Commit 67b38ba

Browse files
committed
Cleanup
1 parent 45f6eb4 commit 67b38ba

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

notebooks/Preparing the GO Annotation Database for Integration.ipynb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@
184184
}
185185
],
186186
"source": [
187-
"idx = brpd.validate_identifiers(df, column=\"subject_identifier\", prefix_column=\"subject_prefix\", use_tqdm=True)\n",
187+
"idx = brpd.validate_identifiers(\n",
188+
" df, column=\"subject_identifier\", prefix_column=\"subject_prefix\", use_tqdm=True\n",
189+
")\n",
188190
"\n",
189191
"print(f\"{(~idx).sum():,} rows have invalid identifiers\")"
190192
]

src/bioregistry/pandas.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def validate_identifiers(
290290
raise PrefixLocationError
291291
elif prefix is not None:
292292
return _help_validate_identifiers(df, column, prefix)
293-
else: # prefix_column is not None
293+
elif prefix_column is not None:
294294
prefix_column = _norm_column(df, prefix_column)
295295
prefixes = df[prefix_column].unique()
296296
if 0 == len(prefixes):
@@ -319,11 +319,13 @@ def _validate_lambda(_p: str | None, _i: str) -> bool | None:
319319
"pd.Series[bool]",
320320
_multi_column_map(
321321
df,
322-
[cast(str, prefix_column), column],
322+
[prefix_column, column],
323323
_validate_lambda,
324324
use_tqdm=use_tqdm,
325325
),
326326
)
327+
else:
328+
raise RuntimeError
327329
if target_column:
328330
df[target_column] = results
329331
return results
@@ -388,7 +390,7 @@ def identifiers_to_curies(
388390
df = brpd.get_goa_example()
389391
390392
# Use a combination of column 1 (DB) and column 2 (DB Object ID) for conversion
391-
df['subject_curie'] = brpd.identifiers_to_curies(df, column=1, prefix_column=0)
393+
df["subject_curie"] = brpd.identifiers_to_curies(df, column=1, prefix_column=0)
392394
"""
393395
# FIXME do pattern check first so you don't get bananas
394396
column = _norm_column(df, column)
@@ -587,6 +589,7 @@ def pd_collapse_to_curies(
587589
*,
588590
target_column: str,
589591
) -> None:
592+
"""Collapse a prefix and identifier column together into a CURIE column."""
590593
prefix_column = _norm_column(df, prefix_column)
591594
identifier_column = _norm_column(df, identifier_column)
592595
df[target_column] = [

0 commit comments

Comments
 (0)