Skip to content

Commit

Permalink
fix: allow global error flag variable to be changed inside function (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ninsch3000 authored May 17, 2023
1 parent 7642eb9 commit b608864
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions workflow/scripts/htsinfer_to_tsv.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def parse_arguments():


def main():
global e_flag
# input parameters
file_list = options.file_list

Expand All @@ -49,7 +50,7 @@ def main():
samples_df = samples_df.replace(r'^\s*$', np.nan, regex=True)
# replace None
samples_df = samples_df.fillna(value=np.nan)

LOGGER.debug(f"samples_df: {samples_df}")
outfile = options.output

params_df = pd.DataFrame(columns=[
Expand Down Expand Up @@ -106,20 +107,22 @@ def main():

def should_i_flag(df, sample, param):
'''Only RAISE error if user hasn't specified value either'''

global e_flag
LOGGER.debug(f"flag before: {e_flag}")
try:
user_param = df.loc[sample,param]
except KeyError:
user_param = np.nan
if user_param is np.nan:
if np.isnan(user_param):
e_flag = True

LOGGER.debug(f"flag after: {e_flag}")
return e_flag


def htsinfer_to_zarp(sample,jparams, samples_df):
'''Translate htsinfer json output to zarp compatible row.'''

global e_flag
# need to swap filepaths?
swap_paths = False

Expand Down

0 comments on commit b608864

Please sign in to comment.