@@ -950,7 +950,42 @@ def update_blanks_in_qiita(self, qclient):
950950 qclient .http_patch (f'/api/v1/study/{ study_id } /samples' ,
951951 data = dumps (data ))
952952
953+ def _project_metadata_check (self , qclient ):
954+ # Let Pipeline() retrieve the needed qiita study ids from the user
955+ # input while this plugin queries for the existing set of column
956+ # names in each project's sample metadata. We'll let Pipeline()
957+ # decide (using its metapool dependency) which column names are
958+ # reserved.
959+ qiita_ids = [x ['qiita_id' ] for x in self .pipeline .get_project_info ()]
960+
961+ results = []
962+
963+ for qiita_id in qiita_ids :
964+ categories = qclient .get (f"/api/v1/study/{ qiita_id } /samples/info" )[
965+ "categories" ]
966+
967+ res = self .pipeline .identify_reserved_words (categories )
968+
969+ # if any reserved words were identified, generate an appropriate
970+ # error message for it and add it to the list of error messages
971+ # to return to the user.
972+ res = [f"'{ x } ' exists in Qiita study { qiita_id } 's sample metadata"
973+ for x in res ]
974+
975+ results += res
976+
977+ if results :
978+ # return any error messages generated across all the projects.
979+ raise PipelineError ("\n " .join (results ))
980+
953981 def precheck (self , qclient ):
982+ # since one of the objectives of SPP is to generate prep-info files
983+ # and automatically load them into Qiita, confirm that all studies
984+ # mentioned in the sample-sheet/pre-prep do not contain sample
985+ # metadata that would cause an error in the pipeline after processing
986+ # has already completed but the results have not yet been loaded.
987+ self ._project_metadata_check (qclient )
988+
954989 # compare sample-ids/tube-ids in sample-sheet/mapping file
955990 # against what's in Qiita. Results are a list of dictionaries, one
956991 # per project.
0 commit comments