From 9c6e4ea2d28d4770315474be26e0e2a755255fc0 Mon Sep 17 00:00:00 2001 From: bedro Date: Mon, 30 Sep 2019 17:46:13 +0200 Subject: [PATCH] MIAPPE compliance improvements --- brapi_to_isa.py | 2 +- brapi_to_isa_converter.py | 21 ++++++--------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/brapi_to_isa.py b/brapi_to_isa.py index ce1338f..0825c93 100755 --- a/brapi_to_isa.py +++ b/brapi_to_isa.py @@ -181,7 +181,7 @@ def create_study_sample_and_assay(client, brapi_study_id, isa_study, growth_pro phenotyping_process = Process(executes_protocol=phenotyping_protocol) phenotyping_process.inputs.append(this_isa_sample) - phenotyping_process.name = obs_unit["observationUnitDbId"] + phenotyping_process.name = att_test(obs_unit, 'observationLevel', PAR_defaultObsLvl).lower() # Adding Parameter Value[Collection Date] column # col_date_pp = ProtocolParameter(parameter_name=OntologyAnnotation(term="Collection Date")) diff --git a/brapi_to_isa_converter.py b/brapi_to_isa_converter.py index 3e61b27..b436c57 100644 --- a/brapi_to_isa_converter.py +++ b/brapi_to_isa_converter.py @@ -191,7 +191,7 @@ def create_isa_study(self, brapi_study_id, investigation, obs_levels_in_study): affiliation=att_test(brapicontact, 'institutionName', PAR_NAinData), email=att_test(brapicontact, 'email'), address=PAR_NAinBrAPI, roles=[role]) this_study.contacts.append(contact) - # Adding dataLinks inforamtion + # Adding dataLinks information if att_test(brapi_study,'dataLinks'): for brapidata in brapi_study['dataLinks']: this_study.comments.append(Comment(name="Study Data File Link",value=brapidata['url'])) @@ -205,14 +205,10 @@ def create_isa_study(self, brapi_study_id, investigation, obs_levels_in_study): self.logger.info("The observation level " + level + " is not supported by MIAPPE at this moment and will not be validated.") self.logger.info("Following observation levels are supported: " + str(PAR_suppObsLvl) + ".") - oref_mt = OntologySource( - name="OBI", description=self.ontologies["obi"][0], file=self.ontologies["obi"][1]) oa_mt = OntologyAnnotation( - term="phenotyping", term_accession="", term_source=oref_mt) - oref_tt = OntologySource( - name="OBI", description=self.ontologies["obi"][0], file=self.ontologies["obi"][1]) + term="phenotyping", term_accession="", term_source="") oa_tt = OntologyAnnotation( - term=level + " level analysis", term_accession="", term_source=oref_tt) + term=level + " level analysis", term_accession="", term_source="") isa_assay_file = "a_" + str(brapi_study_id) + "_" + level + ".txt" new_assay = Assay(measurement_type=oa_mt, @@ -221,11 +217,6 @@ def create_isa_study(self, brapi_study_id, investigation, obs_levels_in_study): this_study.assays.append(new_assay) - if oref_mt not in investigation.ontology_source_references: - investigation.ontology_source_references.append(oref_mt) - if oref_tt not in investigation.ontology_source_references: - investigation.ontology_source_references.append(oref_tt) - self.logger.info("Number of ISA assays: " + str(len(this_study.assays))) return this_study, investigation @@ -270,9 +261,9 @@ def create_isa_tdf_from_obsvars(self, obsvars): else: if att_test(obs_var, 'synonyms'): - elements['Variable Name'].append('; '.join(obs_var['synonyms']) + ' (BrAPI variableDbId: ' + att_test(obs_var, 'observationVariableDbId', 'NA') + ')') + elements['Variable Name'].append('; '.join(obs_var['synonyms']) + ' (BrAPI variableDbId: ' + att_test(obs_var, 'observationVariableDbId', PAR_NAinData) + ')') else: - elements['Variable Name'].append('(BrAPI variableDbId: ' + att_test(obs_var, 'observationVariableDbId', 'NA') + ')') + elements['Variable Name'].append('(BrAPI variableDbId: ' + att_test(obs_var, 'observationVariableDbId', PAR_NAinData) + ')') elements['Trait'].append(att_test(obs_var['trait'], 'name')) @@ -314,7 +305,7 @@ def create_isa_obs_data_from_obsvars(self, obs_units, obs_variables, level, germ for obslvl in obs_levels[level]: obs_levels_header.append("observationLevels[{}]".format(obslvl)) # headers belonging observation unit - obs_unit_header = ["observationUnitDbId", "observationUnitXref", + obs_unit_header = ["observationUnitName", "observationUnitXref", "X", "Y", "germplasmDbId", "germplasmName"] # headers belonging germplasm germpl_header = ["accessionNumber"]