Skip to content

Commit

Permalink
check for covariates only when DEanalyses is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
borauyar committed Mar 29, 2022
1 parent 74858dd commit 7314e34
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions scripts/validate_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ def validate_config(config):
sample_sheet = read_sample_sheet(config['locations']['sample-sheet'])

# Check if the required fields are found in the sample sheet
# also add the list of covariates from the DE analyses
covariates = [config['DEanalyses'][x]['covariates'] for x in config['DEanalyses'].keys()]
# cleanup and get the set of unique covariates
covariates = [y.strip() for y in itertools.chain(*[x.split(',') for x in covariates])]
# remove empty strings
covariates = [x for x in covariates if x]
required_fields = set(['name', 'reads', 'reads2', 'sample_type'] + covariates)
required_fields = ['name', 'reads', 'reads2', 'sample_type']

if 'DEanalyses' in config:
# also add the list of covariates from the DE analyses if available
covariates = [config['DEanalyses'][x]['covariates'] for x in config['DEanalyses'].keys() if 'covariates' in config['DEanalyses'][x]]
# cleanup and get the set of unique covariates
covariates = [y.strip() for y in itertools.chain(*[x.split(',') for x in covariates])]
# remove empty strings
covariates = [x for x in covariates if x]
required_fields = required_fields + covariates
required_fields = set(required_fields)
not_found = required_fields.difference(set(sample_sheet[0].keys()))
if len(not_found) > 0:
raise Exception("ERROR: Required field(s) {} could not be found in the sample sheet file '{}'".format(not_found, config['locations']['sample-sheet']))
Expand Down

0 comments on commit 7314e34

Please sign in to comment.