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: bwa-memx-index rule uses correct suffixarray path; fixes #1344 #3303

Merged
merged 1 commit into from
Oct 21, 2024
Merged

fix: bwa-memx-index rule uses correct suffixarray path; fixes #1344 #3303

merged 1 commit into from
Oct 21, 2024

Conversation

tavareshugo
Copy link
Contributor

@tavareshugo tavareshugo commented Oct 21, 2024

The wrapper previously did not allow arbitrary output directory for the files. This was due to how the file defined in the suffixarray variable was being fetched from the input, rather than from the output prefix. I have:

  • made the small change in the code to address this
  • added details to the documentation (meta.yml)
  • ran the test with pytest test.py -v -k test_bwa_memx_index which ran successfully

If someone else could revise and test that would be great.

QC

While the contributions guidelines are more extensive, please particularly ensure that:

  • test.py was updated to call any added or updated example rules in a Snakefile
  • input: and output: file paths in the rules can be chosen arbitrarily
  • wherever possible, command line arguments are inferred and set automatically (e.g. based on file extensions in input: or output:)
  • temporary files are either written to a unique hidden folder in the working directory, or (better) stored where the Python function tempfile.gettempdir() points to
  • the meta.yaml contains a link to the documentation of the respective tool or command under url:
  • conda environments use a minimal amount of channels and packages, in recommended ordering

Summary by CodeRabbit

  • New Features

    • Enhanced input validation to ensure correct file count for processing.
    • Expanded command handling for different BWA variants, improving flexibility and functionality.
    • Added detailed specifications for input, output, and parameters in the index creation process.
  • Bug Fixes

    • Improved error handling for common prefix validation of output files and unexpected parameter values.
  • Documentation

    • Updated authorship and input/output specifications in the meta.yaml file for clarity and accuracy.

Copy link
Contributor

coderabbitai bot commented Oct 21, 2024

Walkthrough

The pull request introduces modifications to the wrapper.py scripts in both bio/bwa-meme and bio/bwa-memx, focusing on improving the construction of the suffixarray variable and enhancing input validation. In meta.yaml for bwa-mem2 index, new sections are added to define input, output, and parameters for index creation. The changes ensure that output files share a common prefix and enhance error handling for input parameters, thereby reinforcing the consistency and robustness of the file naming conventions and command execution.

Changes

File Change Summary
bio/bwa-meme/index/wrapper.py - Updated suffixarray construction to use an interpolated string with prefix.
- Adjusted error handling to raise ValueError if output files do not share a common prefix.
bio/bwa-memx/index/meta.yaml - Added input specification: - fasta file.
- Added output specification: - BWA index files, which should all share a common prefix.
- Added parameter specifications for bwa type and num_models.
bio/bwa-memx/index/wrapper.py - Implemented input validation for the number of input files, raising ValueError for invalid cases.
- Expanded logic for handling BWA variants and constructing command strings based on the selected variant.
- Updated suffixarray construction to use an interpolated string with prefix.
- Added error handling for unexpected bwa parameter values.
- Validated that all output files share a common prefix, raising ValueError if they do not.

Possibly related PRs

  • fix: Correctly handle non str index list for bwa-mem2/mem #3101: Changes in bio/bwa-mem2/mem/wrapper.py involve handling input parameters and constructing command strings, which may relate to the changes in bio/bwa-meme/index/wrapper.py.
  • perf: Update Datavzrd wrapper #3122: Modifications in bio/bwa-mem2/mem/meta.yaml emphasize the expected output files sharing a common prefix, aligning with the main PR's focus on output file naming.
  • feat: Bwameth index #3162: Introduction of bwameth index functionality involves similar concepts of input and output file handling, relating to changes in output validation in the main PR.
  • fix: Gatk filter mutect call typo #3295: Changes in bio/gatk/filtermutectcalls/wrapper.py involve correcting input handling, conceptually similar to error handling adjustments in the main PR regarding output file naming.

Suggested reviewers

  • fgvieira

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
bio/bwa-memx/index/meta.yaml (2)

10-12: LGTM with a minor suggestion: Clear parameter specifications

The params section clearly defines the 'bwa' and 'num_models' parameters. The descriptions are informative and include necessary details like available options and default values.

Consider adding a note that the 'num_models' parameter is only applicable when 'bwa' is set to "bwa-meme". This could prevent confusion for users who might try to use it with other BWA variants.

🧰 Tools
🪛 yamllint

[error] 12-12: no new line character at the end of file

(new-line-at-end-of-file)


12-12: Add a newline at the end of the file

To adhere to common conventions and prevent potential issues with some tools, please add a newline character at the end of the file.

You can do this by adding an empty line at the end of the file.

🧰 Tools
🪛 yamllint

[error] 12-12: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 95b3e05 and be05337.

📒 Files selected for processing (3)
  • bio/bwa-meme/index/wrapper.py (1 hunks)
  • bio/bwa-memx/index/meta.yaml (1 hunks)
  • bio/bwa-memx/index/wrapper.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
bio/bwa-meme/index/wrapper.py (2)

Pattern **/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of the self argument of methods.
Do not suggest type annotation of the cls argument of classmethods.
Do not suggest return type annotation if a function or method does not contain a return statement.


Pattern **/wrapper.py: Do not complain about use of undefined variable called snakemake.

bio/bwa-memx/index/wrapper.py (2)

Pattern **/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of the self argument of methods.
Do not suggest type annotation of the cls argument of classmethods.
Do not suggest return type annotation if a function or method does not contain a return statement.


Pattern **/wrapper.py: Do not complain about use of undefined variable called snakemake.

🪛 yamllint
bio/bwa-memx/index/meta.yaml

[error] 12-12: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (6)
bio/bwa-memx/index/meta.yaml (3)

5-5: LGTM: Author addition

Adding Patrik Smeds to the authors list is appropriate for giving credit to contributors.


6-7: LGTM: Input specification

The input section clearly specifies the requirement for a fasta file, which is correct for BWA index creation.


8-9: LGTM: Comprehensive output description

The output section provides a clear and detailed description of the expected BWA index files. The note about the common prefix and the example of including an output directory path are particularly helpful for users.

bio/bwa-meme/index/wrapper.py (2)

48-48: LGTM! This change improves flexibility and consistency.

The modification to the suffixarray variable construction addresses the issue mentioned in the PR objectives. By using the prefix variable in an f-string, it allows for an arbitrary output directory while ensuring that the suffixarray file shares the same prefix as other output files. This change is consistent with the error checking done earlier in the script and improves the overall flexibility of the wrapper.


Line range hint 1-62: Verify corresponding changes in related file

The change made in this file addresses the issue described in the PR objectives. However, to ensure consistency across the project, we should verify that similar changes have been made in the bio/bwa-memx/index/wrapper.py file, as mentioned in the AI summary.

✅ Verification successful

Changes Verified in Related File

The bio/bwa-memx/index/wrapper.py file contains the necessary updates consistent with the modifications in bio/bwa-meme/index/wrapper.py.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if similar changes have been made in the bwa-memx wrapper

# Test: Look for similar suffixarray construction in bwa-memx wrapper
rg -A 3 'suffixarray =' bio/bwa-memx/index/wrapper.py

Length of output: 261

🧰 Tools
🪛 Ruff

51-51: Undefined name snakemake

(F821)

bio/bwa-memx/index/wrapper.py (1)

77-77: Update to suffixarray variable enhances naming consistency

The construction of suffixarray using the prefix variable ensures consistent file naming for the output files. This change aligns with similar modifications in related wrapper scripts and enhances the robustness of the file handling.

@fgvieira fgvieira merged commit 2256246 into snakemake:master Oct 21, 2024
8 checks passed
@fgvieira fgvieira changed the title fix: bwa-memx-index rule uses correct suffixarray path; fixes #1334 fix: bwa-memx-index rule uses correct suffixarray path; fixes #1344 Oct 21, 2024
@tavareshugo tavareshugo deleted the bwa_memx_index_fix branch October 21, 2024 13:33
@coderabbitai coderabbitai bot mentioned this pull request Oct 22, 2024
7 tasks
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.

2 participants