Skip to content

feat: split get_reads in two rules #125

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

Closed
wants to merge 3 commits into from
Closed

Conversation

BiancaStoecker
Copy link
Collaborator

@BiancaStoecker BiancaStoecker commented May 15, 2025

Separate download of bam file and splitting the bam into reads in two rules.

Summary by CodeRabbit

  • New Features
    • Introduced a dedicated step for downloading BAM files, with improved reliability and concurrency.
  • Improvements
    • The process for extracting reads now works from locally downloaded BAM files, enhancing workflow clarity and control.
    • Log file locations and naming have been updated for better organization.
    • Added checksum verification for BAM files in benchmark configurations to ensure data integrity.

Copy link
Contributor

coderabbitai bot commented May 15, 2025

Walkthrough

A new Snakemake rule, get_bams, was introduced to handle downloading BAM files from URLs, with concurrency and retry logic. The get_reads rule was updated to process these locally downloaded BAM files, removing direct URL access and retry logic. Log file paths and input sources were also adjusted to reflect the new workflow.

Changes

File(s) Change Summary
workflow/rules/download.smk Added get_bams rule for downloading BAM files with retries and threading; updated get_reads rule to use local BAMs, changed log paths, removed retries and direct URL handling.
workflow/resources/presets.yaml Added bam-md5 checksum entries to four benchmark configurations (giab-na12878-exome, seqc2-wes, seqc2-wgs, seqc2-ffpe).

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Snakemake
    participant get_bams
    participant get_reads

    User->>Snakemake: Trigger workflow
    Snakemake->>get_bams: Download BAM file from URL
    get_bams->>Snakemake: BAM file saved locally
    Snakemake->>get_reads: Process local BAM file to extract reads
    get_reads->>Snakemake: Reads extracted
Loading

Poem

In the warren of code, a new path appears,
BAMs are fetched with hops and cheers!
No more chasing URLs in the night—
Now local files make things right.
With logs in new places and retries in tow,
This bunny’s workflow is ready to go!
🐇✨

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 862f871 and 6f4e1e7.

📒 Files selected for processing (1)
  • workflow/resources/presets.yaml (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • workflow/resources/presets.yaml
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Testing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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

🧹 Nitpick comments (1)
workflow/rules/download.smk (1)

1-15: Well-structured new rule for downloading BAM files.

The new get_bams rule looks good and follows Snakemake best practices. It:

  • Properly outputs to a consistent location in resources/bams/
  • Uses parameters to get the BAM URL dynamically
  • Includes appropriate logging
  • Sets a reasonable thread count (32) for concurrent downloads
  • Includes retry logic (3 attempts) which is essential for handling network issues
  • Uses curl for downloading, with proper output redirection

One potential improvement would be to add validation of the downloaded file:

 rule get_bams:
     output:
         bam="resources/bams/{benchmark}.bam",
     params:
         bam_url=get_benchmark_bam_url,
     log:
         "logs/download-bams/{benchmark}.log",
     conda:
         "../envs/tools.yaml"
     resources:
         sort_threads=lambda _, threads: max(threads - 2, 1),
     threads: 32
     retries: 3
     shell:
-        "curl {params.bam_url} --output {output.bam} 2> {log}"
+        "(curl {params.bam_url} --output {output.bam} && samtools quickcheck {output.bam}) 2> {log}"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 6dc4dca and 33aeff4.

📒 Files selected for processing (1)
  • workflow/rules/download.smk (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Formatting
🔇 Additional comments (1)
workflow/rules/download.smk (1)

18-38: Cleanly refactored read extraction rule.

The modifications to the get_reads rule are logically correct and complete the separation of concerns between downloading BAM files and extracting reads:

  1. Now properly takes the downloaded BAM file as input
  2. Log file path has been appropriately renamed to split-into-reads to reflect its current purpose
  3. Shell command correctly uses the input BAM file instead of downloading from URL
  4. Removed the retry logic as it's no longer needed (handled by upstream rule)

The changes improve the workflow by:

  • Making each step more focused and easier to debug
  • Avoiding redundant downloads if extraction fails
  • Allowing for clearer monitoring of each process

@famosab famosab changed the title feat: split get_reads in two rules a feat: split get_reads in two rules May 16, 2025
@famosab
Copy link
Collaborator

famosab commented May 21, 2025

Closed in favor of #126

@famosab famosab closed this May 21, 2025
@famosab famosab deleted the fix/split-get-reads branch June 18, 2025 14:17
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