1818from tqdm .contrib .logging import logging_redirect_tqdm
1919
2020import bioontologies
21+ from bioontologies .robot import ROBOTError
2122
2223
2324@click .command ()
@@ -27,19 +28,29 @@ def main() -> None:
2728 resource .prefix
2829 for resource in bioregistry .resources ()
2930 if resource .get_download_owl () or resource .get_download_obograph ()
30- ][ 282 :]
31+ ]
3132 for prefix in tqdm (prefixes , desc = "Parsing OWL ontologies" , unit = "ontology" ):
32- tqdm .write (click .style ("\n " + prefix , fg = "green" ))
33+ tqdm .write (click .style (f "\n [ { prefix } ]" , fg = "green" ))
3334 with logging_redirect_tqdm ():
34- document = bioontologies .get_obograph_by_prefix (prefix , cache = False )
3535 try :
36- graph = document .squeeze (standardize = True , prefix = prefix )
37- except ValueError :
38- tqdm .write (f"[{ prefix } ] failed to parse" )
39- else :
40- tqdm .write (
41- click .style (f"[{ prefix } ] parsed { graph .title } - v{ graph .version } " , fg = "red" )
36+ document = bioontologies .get_obograph_by_prefix (prefix , cache = False , reason = False )
37+ except ROBOTError as e :
38+ tqdm .write (click .style (f"[{ prefix } ] { e } " , fg = "red" ))
39+ continue
40+
41+ try :
42+ graph = document .squeeze (
43+ standardize = True , prefix = prefix , tqdm_kwargs = {"leave" : False }
4244 )
45+ except ValueError as e :
46+ tqdm .write (click .style (f"[{ prefix } ] failed to parse\n \n { e } " , fg = "red" ))
47+ else :
48+ if graph .version :
49+ msg = f"[{ prefix } ] parsed { graph .title } - v{ graph .version } "
50+ else :
51+ msg = f"[{ prefix } ] parsed { graph .title } "
52+
53+ tqdm .write (click .style (msg , fg = "green" ))
4354
4455
4556if __name__ == "__main__" :
0 commit comments