Skip to content

Fix antitarget crash when --output is omitted (#806)#1124

Open
etal wants to merge 1 commit into
masterfrom
fix/806-antitarget-default-output
Open

Fix antitarget crash when --output is omitted (#806)#1124
etal wants to merge 1 commit into
masterfrom
fix/806-antitarget-default-output

Conversation

@etal

@etal etal commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Fixes #806.

Problem

cnvkit.py antitarget <targets> raised AttributeError: 'Namespace' object has no attribute 'interval' whenever -o/--output was omitted. The default-output-filename branch of _cmd_antitarget derived the name from args.interval, but the antitarget subparser defines its positional as targets and has no interval attribute. (interval is the positional of the separate target command; 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 reads args.targets when loading the input, so it is now internally consistent.

Test

Adds test/test_preprocessing.py::PreprocessingTests::test_cmd_antitarget_default_output, which exercises _cmd_antitarget with output=None and asserts the derived <base>.antitarget.bed is written and parses. This path was previously uncovered (the existing test_antitarget calls do_antitarget directly, never the CLI wrapper). Revert-verified: the test fails on the old args.interval line with the exact AttributeError and 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 raise ValueError on an extension-less targets filename; os.path.splitext would 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.

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

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.75%. Comparing base (6acfbc7) to head (e85ee3b).

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     
Flag Coverage Δ
unittests 72.75% <100.00%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CNVkit antitarget AttributeError: 'Namespace' object has no attribute 'interval' BUG

1 participant