Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow global error flag variable to be changed inside function #138

Merged
merged 3 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion workflow/rules/htsinfer.smk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ config.setdefault("records", 100000)


# global variables
samples = pd.read_csv(config["samples"], header=0, index_col=0, sep="\t")
samples = pd.read_csv(config["samples"], header=0, index_col=0, sep="\t", keep_default_na=False)
OUT_DIR = config["outdir"]
LOG_DIR = os.path.join(OUT_DIR, "logs")
CLUSTER_LOG = os.path.join(LOG_DIR, "cluster_logs")
Expand Down
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