1616from qiita_db .study import Study
1717from qiita_db .data import RawData
1818from qiita_db .ontology import Ontology
19- from qiita_db .metadata_template import PrepTemplate
19+ from qiita_db .metadata_template import (PrepTemplate , TARGET_GENE_DATA_TYPES ,
20+ PREP_TEMPLATE_COLUMNS_TARGET_GENE )
2021from qiita_db .parameters import (Preprocessed454Params ,
2122 PreprocessedIlluminaParams )
2223from qiita_pet .util import STATUS_STYLER
@@ -166,7 +167,7 @@ def render(self, study, raw_data, full_access):
166167
167168class PrepTemplatePanel (BaseUIModule ):
168169 def render (self , prep , study_id , is_editable , ena_terms ,
169- study_status , user_defined_terms ):
170+ study_status , user_defined_terms , raw_data_files ):
170171 # Check if the request came from a local source
171172 is_local_request = self ._is_local ()
172173
@@ -203,6 +204,23 @@ def render(self, prep, study_id, is_editable, ena_terms,
203204 if 'qiime' in basename (fp ) else "Prep template" )
204205 filepaths = [(id_ , fp , _fp_type (fp )) for id_ , fp in filepaths ]
205206
207+ # Check if the template have all the required columns for preprocessing
208+ if prep .data_type () in TARGET_GENE_DATA_TYPES :
209+ key = ('demultiplex_multiple' if len (raw_data_files ) > 2
210+ else 'demultiplex' )
211+ missing_cols = prep .check_restrictions (
212+ [PREP_TEMPLATE_COLUMNS_TARGET_GENE [key ]])
213+ show_preprocess_btn = len (missing_cols ) == 0
214+ if not show_preprocess_btn :
215+ no_preprocess_msg = (
216+ "Preprocessing disabled due to missing columns in the "
217+ "prep template: %s" % ', ' .join (missing_cols ))
218+ else :
219+ no_preprocess_msg = None
220+ else :
221+ show_preprocess_btn = True
222+ no_preprocess_msg = None
223+
206224 return self .render_string (
207225 "study_description_templates/prep_template_panel.html" ,
208226 prep_id = prep_id ,
@@ -220,7 +238,9 @@ def render(self, prep, study_id, is_editable, ena_terms,
220238 ena_terms = ena_terms ,
221239 study_status = study_status ,
222240 user_defined_terms = user_defined_terms ,
223- preprocess_options = preprocess_options )
241+ preprocess_options = preprocess_options ,
242+ show_preprocess_btn = show_preprocess_btn ,
243+ no_preprocess_msg = no_preprocess_msg )
224244
225245
226246class EditInvestigationType (BaseUIModule ):
0 commit comments