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: MtNucRatioCalculator #3496

Merged
merged 63 commits into from
Nov 26, 2024
Merged

Conversation

tdayris
Copy link
Contributor

@tdayris tdayris commented Nov 25, 2024

Add a wrapper for MtNucRatioCalculator.

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

Release Notes

  • New Features

    • Introduced environment.linux-64.pin.txt for easy environment setup on Linux 64-bit.
    • Added a new YAML configuration file for managing project dependencies.
    • Launched the MTNucRatioCalculator with clear input/output specifications and parameters.
    • Implemented a Snakemake wrapper for seamless integration with workflows.
  • Tests

    • Added a new test function to validate the functionality of the MTNucRatioCalculator wrapper.

tdayris and others added 30 commits September 21, 2020 09:16
* perf: update bio/bcftools/index/environment.yaml.

* perf: update bio/bcftools/index/environment.yaml.

* perf: update bio/bcftools/index/environment.yaml.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: snakedeploy-bot[bot] <115615832+snakedeploy-bot[bot]@users.noreply.github.com>
Co-authored-by: snakedeploy-bot[bot] <115615832+snakedeploy-bot[bot]@users.noreply.github.com>
Co-authored-by: snakedeploy-bot[bot] <115615832+snakedeploy-bot[bot]@users.noreply.github.com>
Co-authored-by: snakedeploy-bot[bot] <115615832+snakedeploy-bot[bot]@users.noreply.github.com>
* Add autobump action

* fix paths

* dbg

* dbg branch

* add checkout

* dbg

* trigger rerun

* entity regex and add label

* dbg

* Update autobump.yml

* Update autobump.yml
Co-authored-by: snakedeploy-bot[bot] <115615832+snakedeploy-bot[bot]@users.noreply.github.com>
Co-authored-by: snakedeploy-bot[bot] <115615832+snakedeploy-bot[bot]@users.noreply.github.com>
Co-authored-by: snakedeploy-bot[bot] <115615832+snakedeploy-bot[bot]@users.noreply.github.com>
Co-authored-by: snakedeploy-bot[bot] <115615832+snakedeploy-bot[bot]@users.noreply.github.com>
Co-authored-by: snakedeploy-bot[bot] <115615832+snakedeploy-bot[bot]@users.noreply.github.com>
Co-authored-by: snakedeploy-bot[bot] <115615832+snakedeploy-bot[bot]@users.noreply.github.com>
Co-authored-by: snakedeploy-bot[bot] <115615832+snakedeploy-bot[bot]@users.noreply.github.com>
Co-authored-by: snakedeploy-bot[bot] <115615832+snakedeploy-bot[bot]@users.noreply.github.com>
Co-authored-by: snakedeploy-bot[bot] <115615832+snakedeploy-bot[bot]@users.noreply.github.com>
Co-authored-by: snakedeploy-bot[bot] <115615832+snakedeploy-bot[bot]@users.noreply.github.com>
Co-authored-by: snakedeploy-bot[bot] <115615832+snakedeploy-bot[bot]@users.noreply.github.com>
@tdayris tdayris changed the title Feat: MtNucRatioCalculator feat: MtNucRatioCalculator Nov 25, 2024
Copy link
Contributor

coderabbitai bot commented Nov 25, 2024

📝 Walkthrough

Walkthrough

This pull request introduces several new files and modifications related to the MTNucRatioCalculator project. It creates an environment configuration file (environment.linux-64.pin.txt), a YAML file for managing dependencies (environment.yaml), and a metadata file (meta.yaml). Additionally, a new Snakemake wrapper (wrapper.py) is added to facilitate tool execution, along with a test function for validation in test_wrappers.py. These changes collectively enhance the project's structure for environment management, metadata documentation, and workflow integration.

Changes

File Path Change Summary
bio/mtnucratio/environment.linux-64.pin.txt New file created for Conda environment with specific package URLs and versions.
bio/mtnucratio/environment.yaml New YAML file created specifying channels and dependencies for the environment.
bio/mtnucratio/meta.yaml New metadata file created detailing the calculator's name, URL, authors, input/output, and parameters.
bio/mtnucratio/test/Snakefile New rule test_mtnucratio added for processing BAM files and generating output files.
bio/mtnucratio/wrapper.py New Snakemake wrapper created for executing the MTNucRatioCalculator.
test_wrappers.py New test function test_mtnucratiocalculator added to validate the wrapper functionality.

Possibly related PRs

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: 4

🧹 Outside diff range and nitpick comments (5)
bio/mtnucratio/test/Snakefile (1)

10-13: Consider improvements for parameters and wrapper versioning

A few suggestions to enhance maintainability and reliability:

  1. Move the chromosome parameter to a config file for better configurability
  2. Use a specific version tag instead of "master" for the wrapper to ensure stability

Consider these improvements:

     params:
-        chrom="ref2",
+        chrom=lambda wildcards, config: config["mtnucratio"].get("chromosome", "ref2"),
     wrapper:
-        "master/bio/mtnucratio"
+        "v3.3.3/bio/mtnucratio"

Add to your config.yaml:

mtnucratio:
    chromosome: "ref2"  # default value, can be overridden
bio/mtnucratio/wrapper.py (3)

10-11: Document the significance of the 'MT' default value.

Consider adding a comment explaining why 'MT' is chosen as the default chromosome name (e.g., if it's a standard convention for mitochondrial DNA).

-# Default mito chromosome name is set to 'MT'
+# Default mitochondrial chromosome name is set to 'MT' as per human genome convention
🧰 Tools
🪛 Ruff (0.7.0)

11-11: Undefined name snakemake

(F821)


17-17: Validate input BAM file existence.

The input BAM file path is used without validation. Consider adding a check to ensure the file exists and is accessible.

 bam = str(snakemake.input)
+if not os.path.isfile(bam):
+    raise FileNotFoundError(f"Input BAM file not found: {bam}")
🧰 Tools
🪛 Ruff (0.7.0)

17-17: Undefined name snakemake

(F821)


1-37: Consider enhancing logging for better debugging.

The wrapper could benefit from additional logging to help users track the process flow and debug issues.

Consider adding log messages for key steps:

  1. Input file validation
  2. Temporary directory creation
  3. Symlink creation
  4. Command execution
  5. Output file movement

This can be achieved by using Snakemake's logging functionality or Python's logging module.

🧰 Tools
🪛 Ruff (0.7.0)

11-11: Undefined name snakemake

(F821)


12-12: Undefined name snakemake

(F821)


17-17: Undefined name snakemake

(F821)


31-31: Undefined name snakemake

(F821)


35-35: Undefined name snakemake

(F821)

test_wrappers.py (1)

3420-3425: Consider adding more test cases

The current test only verifies basic functionality with a single output file. Consider adding test cases for:

  • Different input file formats/types
  • Multiple output files if supported
  • Various parameter combinations
  • Edge cases and error conditions
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 50980f1 and 85e5a2b.

📒 Files selected for processing (6)
  • bio/mtnucratio/environment.linux-64.pin.txt (1 hunks)
  • bio/mtnucratio/environment.yaml (1 hunks)
  • bio/mtnucratio/meta.yaml (1 hunks)
  • bio/mtnucratio/test/Snakefile (1 hunks)
  • bio/mtnucratio/wrapper.py (1 hunks)
  • test_wrappers.py (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • bio/mtnucratio/environment.linux-64.pin.txt
  • bio/mtnucratio/environment.yaml
  • bio/mtnucratio/meta.yaml
🧰 Additional context used
📓 Path-based instructions (2)
bio/mtnucratio/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.

test_wrappers.py (1)

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.

🪛 Ruff (0.7.0)
bio/mtnucratio/wrapper.py

11-11: Undefined name snakemake

(F821)


12-12: Undefined name snakemake

(F821)


17-17: Undefined name snakemake

(F821)


31-31: Undefined name snakemake

(F821)


35-35: Undefined name snakemake

(F821)

🔇 Additional comments (2)
bio/mtnucratio/wrapper.py (1)

1-9: LGTM! Imports and docstring are appropriate.

The imports cover all necessary functionality for file operations and Snakemake integration.

test_wrappers.py (1)

3420-3425: LGTM: Test function follows established patterns

The test function follows the standard pattern used throughout the test suite, with proper use of the run fixture and standard snakemake parameters.

bio/mtnucratio/test/Snakefile Show resolved Hide resolved
bio/mtnucratio/wrapper.py Show resolved Hide resolved
bio/mtnucratio/wrapper.py Show resolved Hide resolved
bio/mtnucratio/wrapper.py Show resolved Hide resolved
@fgvieira fgvieira merged commit b221057 into snakemake:master Nov 26, 2024
9 checks passed
@tdayris tdayris deleted the MTNucRatioCalculator branch November 27, 2024 07:44
@coderabbitai coderabbitai bot mentioned this pull request Nov 27, 2024
7 tasks
@coderabbitai coderabbitai bot mentioned this pull request Jan 27, 2025
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.

5 participants