Skip to content

Commit a0f05a0

Browse files
authored
Merge pull request #145 from dvitale199/warnings
updated warnings to stacklevel=2
2 parents 005f6cb + f404dbf commit a0f05a0

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

genotools/pipeline.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def execute_pipeline(steps, steps_dict, geno_path, out_path, samp_qc, var_qc, an
135135
else:
136136
# if warn is True and step input doesn't exist print error and reset step input
137137
if args['warn'] and (not os.path.isfile(f'{step_input}.pgen')) and (len(step_paths) > 1):
138-
warnings.warn(f'{step_input}.pgen was not created. Continuing to next step...')
138+
warnings.warn(f'{step_input}.pgen was not created. Continuing to next step...', stacklevel=2)
139139
step_input = f'{step_paths[-2]}' if step != steps[1] else geno_path
140140

141141
# very rare edge case when multiple steps fail

genotools/utils.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def upfront_check(geno_path, args):
112112

113113
# if no pgen present, but bed is present, and skip fails is True, convert to pgen
114114
if not os.path.isfile(f'{geno_path}.pgen') and os.path.isfile(f'{geno_path}.bed') and (not args['skip_fails']):
115-
warnings.warn(f'{geno_path} exists but it is in PLINK1.9 binary format. Converting to PLINK2 binaries...')
115+
warnings.warn(f'{geno_path} exists but it is in PLINK1.9 binary format. Converting to PLINK2 binaries...', stacklevel=2)
116116
bfiles_to_pfiles(bfile_path=geno_path)
117117

118118
sam = pd.read_csv(f'{geno_path}.psam', sep = '\s+')
@@ -155,25 +155,25 @@ def upfront_check(geno_path, args):
155155
# skip sex check when no sex in fam or no X chromosome
156156
if args['sex'] is not None:
157157
if (1 not in sex_counts.keys()) and (2 not in sex_counts.keys()):
158-
warnings.warn('You tried calling sex prune but no sample sex data is available. Skipping...')
158+
warnings.warn('You tried calling sex prune but no sample sex data is available. Skipping...', stacklevel=2)
159159
args['sex'] = None
160160
elif ('23' not in chr_counts.keys()) and ('X' not in chr_counts.keys()):
161-
warnings.warn('You tried calling sex prune but no X chromosome data is available. Skipping...')
161+
warnings.warn('You tried calling sex prune but no X chromosome data is available. Skipping...', stacklevel=2)
162162
args['sex'] = None
163163

164164
# change hwe prune to be run without controls filtered when no controls present
165165
if (args['hwe'] is not None) and (args['filter_controls'] == True) and (1 not in pheno_counts.keys()):
166-
warnings.warn('You tried calling hwe prune with controls filtered but no controls are available. Skipping...')
166+
warnings.warn('You tried calling hwe prune with controls filtered but no controls are available. Skipping...', stacklevel=2)
167167
args['filter_controls'] = False
168168

169169
# skip case control when called without cases or controls present
170170
if (args['case_control'] is not None) and ((1 not in pheno_counts.keys()) or (2 not in pheno_counts.keys())):
171-
warnings.warn('You tried calling case-control prune but only cases or controls are available, not both. Skipping...')
171+
warnings.warn('You tried calling case-control prune but only cases or controls are available, not both. Skipping...', stacklevel=2)
172172
args['case_control'] = None
173173

174174
# skip het prune if less than 50 samples are present
175175
if (args['het'] is not None) and (var.shape[0] < 50):
176-
warnings.warn('You tried calling het prune with less than 50 samples. Skipping...')
176+
warnings.warn('You tried calling het prune with less than 50 samples. Skipping...', stacklevel=2)
177177
args['het'] = None
178178

179179
return args

0 commit comments

Comments
 (0)