Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Python utilities to handle NUVA ====== A [[https://github.com/fkaag71/nuva-utils/tree/master/NUVA%20Utils|library available on GitHub]] allows to retrieve and explore NUVA. It is a work in progress, that will be progressively enriched to provide metrics on code systems based upon their mapping to NUVA codes. The supported functions are so far: <code python> get_nuva_version() </code> Returns the version index for the last publication of NUVA. <code python> get_nuva(version) </code> Uploads in the current directory the referenced version in RDF/XML format as **nuva_ans.rdf**, and creates a rebased version **nuva_ivci.rdf**. <code python> split_nuva() </code> From the uploaded **nuva_ivci.rdf** file, creates a split version as a collection of files in RDF/Turtle format: * **nuva_core.ttl** including the concepts for vaccines, valences, target diseases and their labels in English * **nuva_lang_XX.ttl** includes all translations for language XX * **nuva_refcode_YYY.ttl** includes the concepts and the NUVA alignments for code system YYY <code python> refturtle_to_map(code) </code> Starting from the **nuva_refcode_YYY.ttl** file for the given code, creates a simple CSV file **nuva_refcode_YYY.csv** with alignments between the given code and NUVA. <code python> map_to_turtle(code) </code> Assuming that the **nuva_refcode_YYY.csv** file has been copied to work file **nuva_code_YYY.csv**, then edited for enhancing the alignments, creates a Turtle work file **nuva_code_YYY.ttl** for further processing. Note that the refcode file contains the NUVA English labels of vaccines for convenience, but these are not required nor processed from the work code file. <code python> query_core(q) </code> Runs a SPARQL query q against the core graph loaded from **nuva_core.ttl** <code python> query_code(q,code) </code> Runs a SPARQL query q against a graph formed by merging **nuva_core.ttl** and the work file **nuva_code_YYY.ttl**, thus allowing to run checks and measures on the alignment. <code> eval_code(code) </code> Produces the metrics for a code system, given a **nuva_code_YYY.csv** file for alignments. Subproducts are: * **nuva_reverse_YYY.csv** : file with all NUVA codes matching a given external code * **nuva_best_YYY.csv**: file with the best possible external code for a given NUVA code An example use sequence is included in the file: <code python> # Here the main program - Adapt the work directory to your environment os.chdir(str(Path.home())+"/Documents/NUVA") get_nuva(get_nuva_version()) split_nuva() refturtle_to_map("CVX") shutil.copyfile("nuva_refcode_CVX.csv","nuva_code_CVX.csv") map_to_turtle("CVX") q = """ # All vaccines against smallpox SELECT ?vcode ?vl WHERE { ?dis rdfs:subClassOf nuva:Disease . ?dis rdfs:label "Smallpox-Monkeypox"@en . ?vac rdfs:subClassOf nuva:Vaccine . ?vac rdfs:label ?vl . ?vac skos:notation ?vcode . ?vac nuvs:containsValence ?val . ?val nuvs:prevents ?dis } """ res = query_core(q) for row in res: print (f"{row.vcode} - {row.vl}") res = eval_code("CVX") print ("Completeness {:.1%} ".format(res['Completeness'])) print ("Precision {:.1%} ".format(res['Precision'])) </code> ivci/nuva-utils.txt Last modified: 2024/03/20 13:21by fkaag