11# /// script
2- # requires-python = ">=3.12 "
2+ # requires-python = ">=3.14 "
33# dependencies = [
4- # "bioregistry>=0.13.34 ",
4+ # "bioregistry>=0.14.4 ",
55# "bioversions",
66# "bioontologies",
7- # "pyobo[sources]",
7+ # "pyobo[sources]>=0.14.1 ",
88# "class-resolver",
99# "robot-obo-tool",
1010# ]
@@ -227,7 +227,7 @@ def _prepare_artifact(
227227def _get_summary (obo : Obo ) -> dict :
228228 terms = list (obo ._iter_stanzas (desc = f"[{ obo .ontology } ]" ))
229229 rv = {
230- "terms" : sum (term .prefix == obo .ontology for term in obo ),
230+ "terms" : sum (term .prefix == obo .ontology for term in terms ),
231231 "relations" : sum (len (values ) for term in terms for values in term .relationships .values ()),
232232 "properties" : sum (len (values ) for term in terms for values in term .properties .values ()),
233233 "synonyms" : sum (len (term .synonyms ) for term in terms ),
@@ -366,7 +366,7 @@ def _write(s: str) -> None:
366366 with log_path .open ("a" ) as file :
367367 file .write (f"\n \n { msg } \n \n " )
368368 traceback .print_exc (file = file )
369- obo_path .unlink ()
369+ obo_path .unlink (missing_ok = True )
370370
371371 else :
372372 obo_path , rv ["obo" ] = _prepare_artifact (prefix , obo_path , has_version , ".obo.gz" )
@@ -384,15 +384,15 @@ def _write(s: str) -> None:
384384 with log_path .open ("a" ) as file :
385385 file .write (f"\n \n { msg } \n \n " )
386386 traceback .print_exc (file = file )
387- ofn_path .unlink ()
387+ ofn_path .unlink (missing_ok = True )
388388 else :
389389 ofn_path , rv ["ofn" ] = _prepare_artifact (prefix , ofn_path , has_version , ".ofn.gz" )
390390
391391 _write_nodes (names_path , obo , prefix )
392392 _ , rv ["nodes" ] = _prepare_artifact (prefix , names_path , has_version , ".tsv.gz" )
393393
394394 _write (f"[{ prefix } ] writing SSSOM" )
395- sssom_df = obo .get_mappings_df (use_tqdm = False )
395+ sssom_df = obo .get_mappings_df (progress = False )
396396 sssom_df .to_csv (sssom_path , sep = "\t " , index = False )
397397 _ , rv ["sssom" ] = _prepare_artifact (prefix , sssom_path , has_version , ".sssom.tsv.gz" )
398398
@@ -514,27 +514,27 @@ def _write(s: str) -> None:
514514@click .command ()
515515@verbose_option
516516@click .option ("-m" , "--minimum" )
517- @click .option ("--no-convert" , is_flag = True )
518- @click .option ("-x" , "--xvalue " , help = "Select a specific ontology " , multiple = True )
519- @click .option ("--skip" , help = "Skip a specific ontology " , multiple = True )
517+ @click .option ("--no-convert" , is_flag = True , help = 'If given, do not convert to OWL and OBO Graph JSON' )
518+ @click .option ("-x" , "--resource " , "prefixes" , help = "Select a specific resource " , multiple = True )
519+ @click .option ("--skip" , help = "Skip a specific resource " , multiple = True )
520520@click .option ("--force/--no-force" )
521521@click .option ("--loud" , is_flag = True )
522522@click .option ("--version-override" , nargs = 2 , multiple = True )
523523def main ( # noqa:C901
524524 minimum : str | None ,
525- xvalue : list [str ],
525+ prefixes : list [str ],
526526 no_convert : bool ,
527527 force : bool ,
528528 loud : bool ,
529529 skip : list [str ],
530530 version_override : list [tuple [str , str ]],
531531) -> None :
532532 """Build the PyOBO examples."""
533- if xvalue :
534- for prefix in xvalue :
533+ if prefixes :
534+ for prefix in prefixes :
535535 if prefix != bioregistry .normalize_prefix (prefix ):
536536 raise ValueError (f"invalid prefix: { prefix } " )
537- prefixes = xvalue
537+ prefixes = prefixes
538538 elif minimum :
539539 prefixes = [prefix for prefix in PREFIXES if not (minimum and prefix < minimum .lower ())]
540540 else :
@@ -590,6 +590,7 @@ def main( # noqa:C901
590590 "versions" : _get_build_dependency_versions (),
591591 "resources" : previous_data .get ("resources" , {}),
592592 "errors" : previous_data .get ("errors" , {}),
593+ "disable" : len (it ) <= 1 ,
593594 }
594595
595596 tqdm_kwargs = {"unit" : "ontology" , "total" : len (it ), "desc" : "obo-db-ingest" }
0 commit comments