def setUpClass(cls) -> None: json_metrics = getMetrics() factory = FAIRMetricsFactory() # for i in range(1,3): try: # metrics.append(factory.get_metric("test_f1")) # metrics.append(factory.get_metric("test_r2")) for metric in json_metrics: # remove "FAIR Metrics Gen2" from metric name name = metric["name"].replace("FAIR Metrics Gen2- ", "") # same but other syntax because of typo name = name.replace("FAIR Metrics Gen2 - ", "") principle = metric["principle"].rsplit("/", 1)[-1] cls.metrics.append( factory.get_metric( name, metric["@id"], metric["description"], metric["smarturl"], principle, metric["creator"], metric["created_at"], metric["updated_at"], ) ) except ValueError as e: print(f"no metrics implemention for {e}")
def test_identifiers_dataverse(self): dataverse = WebResource( "https://data.inrae.fr/dataset.xhtml?persistentId=doi:10.15454/P27LDX" ) res = FAIRMetricsFactory.get_F1B(web_resource=dataverse).evaluate() print(res) self.assertEqual(res.get_score(), str(Result.NO.value))
def test_R13_workflowhub(self): wf = ReuseTestCase.wf res = FAIRMetricsFactory.get_R13( web_resource=wf, impl=Implem.FAIR_CHECKER ).evaluate() logging.info(res) self.assertEqual(res.get_score(), str(Result.WEAK.value))
def test_R13_biotools(self): biotools = ReuseTestCase.tool res = FAIRMetricsFactory.get_R13( web_resource=biotools, impl=Implem.FAIR_CHECKER ).evaluate() logging.info(res) self.assertEqual(res.get_score(), str(Result.WEAK.value))
def test_F1A_biotools_none(self): metric_f1a = FAIRMetricsFactory.get_F1A(impl=Implem.FAIR_CHECKER) web_resource = WebResource("https://bio.tools/bwa") metric_f1a.set_web_resource(web_resource) print(metric_f1a) res = metric_f1a.evaluate() logging.info(res) self.assertEqual(res.get_score(), str(Result.STRONG.value))
def test_R11_biotools(self): biotools = ReuseTestCase.tool res = FAIRMetricsFactory.get_R11( web_resource=biotools, impl=Implem.FAIR_CHECKER ).evaluate() logging.info(res) self.assertEqual( res.get_score(), str(Result.NO.value) ) # TODO to be fixed with Thomas use the Result enum rather than int values
def test_F1A_dataverse(self): dataverse = WebResource( # "https://data.inrae.fr/dataset.xhtml?persistentId=doi:10.15454/P27LDX" "https://data.inrae.fr/dataset.xhtml?persistentId=doi:10.15454/DOMEHB" # "https://data.inrae.fr/api/datasets/export?exporter=schema.org&persistentId=doi%3A10.15454/DOMEHB" ) res = FAIRMetricsFactory.get_F1A(web_resource=dataverse, impl=Implem.FAIR_CHECKER).evaluate() logging.info(res) self.assertEqual(res.get_score(), str(Result.STRONG.value))
def test_cached_F2B_biotools(self): biotools = FindabilityTestCase.tool res4 = FAIRMetricsFactory.get_R11(web_resource=biotools, impl=Implem.FAIR_CHECKER).evaluate() logging.info(res4) self.assertEqual(res4.get_score(), str(Result.NO.value)) res1 = FAIRMetricsFactory.get_F2B(web_resource=biotools, impl=Implem.FAIR_CHECKER).evaluate() logging.info(res1) self.assertEqual(res1.get_score(), str(Result.WEAK.value)) res2 = FAIRMetricsFactory.get_F2B(web_resource=biotools, impl=Implem.FAIR_CHECKER).evaluate() logging.info(res2) self.assertEqual(res2.get_score(), str(Result.WEAK.value)) res3 = FAIRMetricsFactory.get_I2(web_resource=biotools, impl=Implem.FAIR_CHECKER).evaluate() logging.info(res3) self.assertEqual(res3.get_score(), str(Result.WEAK.value))
def eval_metrics(web_res): metrics_collection = [] # metrics_collection.append(FAIRMetricsFactory.get_F1A(web_res)) metrics_collection.append(FAIRMetricsFactory.get_F1B(web_res)) metrics_collection.append(FAIRMetricsFactory.get_F2A(web_res)) metrics_collection.append(FAIRMetricsFactory.get_F2B(web_res)) metrics_collection.append(FAIRMetricsFactory.get_I1(web_res)) metrics_collection.append(FAIRMetricsFactory.get_I2(web_res)) metrics_collection.append(FAIRMetricsFactory.get_I3(web_res)) metrics_collection.append(FAIRMetricsFactory.get_R11(web_res)) metrics_collection.append(FAIRMetricsFactory.get_R12(web_res)) metrics_collection.append(FAIRMetricsFactory.get_R13(web_res)) row = {"ID": web_res.get_url()} row_time = {"ID": web_res.get_url()} for m in metrics_collection: ts1 = time.time() e = m.evaluate() duration = round((time.time() - ts1), 2) if e is not None: row[m.get_principle_tag()] = e.get_score() row_time[m.get_principle_tag()] = duration return row, row_time
def test_F2A_biotools(self): biotools = FindabilityTestCase.tool res = FAIRMetricsFactory.get_F2A(web_resource=biotools, impl=Implem.FAIR_CHECKER).evaluate() logging.info(res) self.assertEqual(res.get_score(), str(Result.STRONG.value))
def test_identifiers_datacite(self): datacite = WebResource( "https://search.datacite.org/works/10.7892/boris.108387") res = FAIRMetricsFactory.get_F1B(web_resource=datacite).evaluate() print(res) self.assertEqual(res.get_score(), str(Result.NO.value))
def test_EDAM(self): EDAM_KG = ConjunctiveGraph() # EDAM_KG.parse("https://edamontology.org/EDAM.owl") EDAM_KG.parse( "/Users/gaignard-a/Documents/Dev/edamverify/src/EDAM.owl") print(f"Loaded {len(EDAM_KG)} triples.") edam = WebResource( "file:///Users/gaignard-a/Documents/Dev/edamverify/src/EDAM.owl", rdf_graph=EDAM_KG, ) print(len(edam.get_rdf())) self.assertGreater(len(edam.get_rdf()), 36000) web_res = edam metrics_collection = [] metrics_collection.append(FAIRMetricsFactory.get_2(web_res)) metrics_collection.append(FAIRMetricsFactory.get_F1B(web_res)) metrics_collection.append(FAIRMetricsFactory.get_F2A(web_res)) metrics_collection.append(FAIRMetricsFactory.get_F2B(web_res)) metrics_collection.append(FAIRMetricsFactory.get_I1(web_res)) metrics_collection.append(FAIRMetricsFactory.get_I1A(web_res)) metrics_collection.append(FAIRMetricsFactory.get_I1B(web_res)) metrics_collection.append(FAIRMetricsFactory.get_I2(web_res)) metrics_collection.append(FAIRMetricsFactory.get_I2A(web_res)) metrics_collection.append(FAIRMetricsFactory.get_I2B(web_res)) metrics_collection.append(FAIRMetricsFactory.get_I3(web_res)) metrics_collection.append(FAIRMetricsFactory.get_R11(web_res)) metrics_collection.append(FAIRMetricsFactory.get_R12(web_res)) metrics_collection.append(FAIRMetricsFactory.get_R13(web_res)) row = {"ID": web_res.get_url()} row_time = {"ID": web_res.get_url()} for m in metrics_collection: ts1 = time.time() e = m.evaluate() duration = round((time.time() - ts1), 2) if e is not None: row[m.get_principle_tag()] = e.get_score() row_time[m.get_principle_tag()] = duration print(row)
def test_I3_biotools(self): biotools = WebResource("http://bio.tools/bwa") res = FAIRMetricsFactory.get_I3(web_resource=biotools, impl=Implem.FAIR_CHECKER).evaluate() logging.info(res) self.assertEqual(res.get_score(), str(Result.STRONG.value))