Fix antitarget crash when --output is omitted (#806)#1124
Open
etal wants to merge 1 commit into
Open
Conversation
The `antitarget` command's default-output-filename branch (taken only when -o/--output is not given) referenced `args.interval`, but the subparser defines the positional argument as `targets` and has no `interval` attribute. Any `antitarget` run without -o therefore raised `AttributeError: 'Namespace' object has no attribute 'interval'`. Use `args.targets` to derive the default output name. Add a regression test exercising `_cmd_antitarget` with output unset, which the existing `do_antitarget` test did not cover.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1124 +/- ##
==========================================
+ Coverage 72.68% 72.75% +0.07%
==========================================
Files 74 74
Lines 8149 8149
Branches 1447 1447
==========================================
+ Hits 5923 5929 +6
+ Misses 1781 1774 -7
- Partials 445 446 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #806.
Problem
cnvkit.py antitarget <targets>raisedAttributeError: 'Namespace' object has no attribute 'interval'whenever-o/--outputwas omitted. The default-output-filename branch of_cmd_antitargetderived the name fromargs.interval, but theantitargetsubparser defines its positional astargetsand has nointervalattribute. (intervalis the positional of the separatetargetcommand; this was a copy-paste from_cmd_target.) Because the branch always failed on that attribute access, the default-output path never worked.Fix
Derive the default name from
args.targets(one token). The handler already readsargs.targetswhen loading the input, so it is now internally consistent.Test
Adds
test/test_preprocessing.py::PreprocessingTests::test_cmd_antitarget_default_output, which exercises_cmd_antitargetwithoutput=Noneand asserts the derived<base>.antitarget.bedis written and parses. This path was previously uncovered (the existingtest_antitargetcallsdo_antitargetdirectly, never the CLI wrapper). Revert-verified: the test fails on the oldargs.intervalline with the exactAttributeErrorand passes on the fix.Note (out of scope)
The fix makes a previously-unreachable branch live. That branch's filename derivation uses
str.rsplit('.', 1), which would raiseValueErroron an extension-less targets filename;os.path.splitextwould handle it gracefully. This is pre-existing and does not affect normal BED/interval inputs (which always carry an extension), so it is left as a possible follow-up rather than folded into this minimal fix.