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

feat(mask): allow empty mask file, warn not error #1287

Open
wants to merge 1 commit into
base: feat/mask-all-gaps
Choose a base branch
from

Conversation

corneliusroemer
Copy link
Member

@corneliusroemer corneliusroemer commented Aug 19, 2023

Description of proposed changes

This commit adds a warning message when encountering an empty mask file. Now, instead of throwing an error, a warning is printed with the name of the empty mask file.

Reason: When stubbing out a build, one may want to add an empty mask file to future proof the repo even if that list of sites is empty

Also: When one just has one masked site, removes it from the file, one generally doesn't want the workflow to error

Config file changes, e.g. removing mask sites, shouldn't cause workflows to error. This is arguably a bug.

Testing

Tested in a few repos that nothing breaks and no more error when file is empty

Checklist

  • Add a message in CHANGES.md summarizing the changes in this PR that are end user focused. Keep headers and formatting consistent with the rest of the file.

This commit adds a warning message when encountering an empty mask file. Now, instead of throwing an error, a warning is printed with the name of the empty mask file.

Reason: When stubbing out a build, one may want to add an empty mask file
to future proof the repo even if that list of sites is empty

Also: When one just has one masked site, removes it from the file, one generally doesn't want the workflow to error

Config file changes, e.g. removing mask sites, shouldn't cause workflows to error.
This is arguably a bug.
@corneliusroemer corneliusroemer requested a review from a team August 19, 2023 12:31
Comment on lines -234 to -235
print("ERROR: {} is an empty file.".format(args.mask_file))
sys.exit(1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pytest failure isn't very clear, but it fails on this test:

augur/tests/test_mask.py

Lines 257 to 261 in 2810abe

def test_run_handle_empty_mask_file(self, vcf_file, bed_file, argparser):
open(bed_file, "w").close()
args = argparser("-s %s --mask %s" % (vcf_file, bed_file))
with pytest.raises(SystemExit):
mask.run(args)

Failing there makes sense because a SystemExit is no longer raised. However, by warning and letting augur mask continue to run with an empty mask file, there is a new error downstream:

augur/mask.py:244: in run
    mask_sites.update(load_mask_sites(args.mask_file))
augur/utils.py:531: in load_mask_sites
    mask_sites = read_bed_file(mask_file)
augur/utils.py:479: in read_bed_file
    bed = pd.read_csv(bed_file, sep='\t', header=None, usecols=[1,2],
…/site-packages/pandas/util/_decorators.py:211: in wrapper
    return func(*args, **kwargs)
…/site-packages/pandas/util/_decorators.py:331: in wrapper
    return func(*args, **kwargs)
…/site-packages/pandas/io/parsers/readers.py:950: in read_csv
    return _read(filepath_or_buffer, kwds)
…/site-packages/pandas/io/parsers/readers.py:605: in _read
    parser = TextFileReader(filepath_or_buffer, **kwds)
…/site-packages/pandas/io/parsers/readers.py:1442: in __init__
    self._engine = self._make_engine(f, self.engine)
…/site-packages/pandas/io/parsers/readers.py:1753: in _make_engine
    return mapping[engine](f, **self.options)
…/site-packages/pandas/io/parsers/c_parser_wrapper.py:79: in __init__
    self._reader = parsers.TextReader(src, **kwds)

>   ???
E   pandas.errors.EmptyDataError: No columns to parse from file

pandas/_libs/parsers.pyx:554: EmptyDataError

The downstream code should be updated to support empty mask files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

2 participants