-
Notifications
You must be signed in to change notification settings - Fork 0
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: bug with -O being used for gap opening penalty and samtools output directory #3
Conversation
Clone of the PR snakemake/snakemake-wrappers#1450 |
My review is in progress 📖 - I will have feedback for you in a few minutes! |
1 similar comment
My review is in progress 📖 - I will have feedback for you in a few minutes! |
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe changes introduce a new parameter, Changes
Poem
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have reviewed your code and found 1 potential issue.
@@ -15,6 +15,7 @@ | |||
log = snakemake.log_fmt_shell(stdout=False, stderr=True) | |||
sort = snakemake.params.get("sorting", "none") | |||
sort_extra = snakemake.params.get("sort_extra", "") | |||
gap_opening = snakemake.params.get("gap_opening", "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new gap_opening parameter is retrieved without a default value. Consider providing a default value to ensure consistent behavior when the parameter is not explicitly set in the Snakemake rule. For example, you could modify the line to: gap_opening = snakemake.params.get("gap_opening", "10,3")
(using minimap2's default values for gap open and extend penalties).
Chat with Korbit by mentioning @korbit-ai, and give a 👍 or 👎 to help Korbit improve your reviews.
I have reviewed your code and found 3 potential issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The -O {gap_opening}
option is currently being added to the minimap2 command unconditionally. This could potentially cause errors if the gap_opening
parameter is empty or not applicable in certain scenarios. Consider adding a condition to only include this option when gap_opening
is not empty. For example, you could modify the shell command to include this option conditionally:
shell(
"(minimap2"
" -t {snakemake.threads}"
" {extra} "
" {'-O ' + gap_opening if gap_opening else ''}"
" {snakemake.input.target}"
" {snakemake.input.query}"
" {pipe_cmd}"
" > {snakemake.output[0]}"
") {log}"
)
This change will ensure that the -O
option is only included when a gap opening penalty is actually specified.
Chat with Korbit by mentioning @development-korbit-ai-mentor, and give a 👍 or 👎 to help Korbit improve your reviews.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding error handling for the shell command execution. Wrap the shell()
function call in a try-except block to catch and handle any exceptions that may occur during the execution of minimap2 and samtools commands. This will ensure that errors are logged and the script exits gracefully in case of failures.
Chat with Korbit by mentioning @development-korbit-ai-mentor, and give a 👍 or 👎 to help Korbit improve your reviews.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The newly added gap_opening
parameter is a good addition to allow more flexibility in the alignment process. However, it's currently not being validated or handled properly. Consider adding input validation for this parameter and handling cases where it might be empty or invalid. For example, you could use a default value if it's not provided or raise an error if an invalid value is given. Also, it would be helpful to update the documentation to explain the usage and expected format of this new parameter.
Chat with Korbit by mentioning @development-korbit-ai-mentor, and give a 👍 or 👎 to help Korbit improve your reviews.
System configuration at time of review:
|
@coderabbitai full review |
Actions performedFull review triggered. |
There was a problem hiding this 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
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- bio/minimap2/aligner/wrapper.py (2 hunks)
Additional context used
Ruff
bio/minimap2/aligner/wrapper.py
18-18: Undefined name
snakemake
(F821)
Additional comments not posted (2)
bio/minimap2/aligner/wrapper.py (2)
18-18
: Consider providing a default value forgap_opening
.The
gap_opening
parameter is retrieved without a default value. Consider providing a default value to ensure consistent behavior when the parameter is not explicitly set in the Snakemake rule. For example, you could modify the line to:gap_opening = snakemake.params.get("gap_opening", "10,3")(using minimap2's default values for gap open and extend penalties).
Tools
Ruff
18-18: Undefined name
snakemake
(F821)
49-49
: Include the-O
option conditionally.The
-O {gap_opening}
option is currently being added to the minimap2 command unconditionally. This could potentially cause errors if thegap_opening
parameter is empty or not applicable in certain scenarios. Consider adding a condition to only include this option whengap_opening
is not empty. For example, you could modify the shell command to include this option conditionally:shell( "(minimap2" " -t {snakemake.threads}" " {extra} " " {'-O ' + gap_opening if gap_opening else ''}" " {snakemake.input.target}" " {snakemake.input.query}" " {pipe_cmd}" " > {snakemake.output[0]}" ") {log}" )This change will ensure that the
-O
option is only included when a gap opening penalty is actually specified.
/review |
PR Reviewer Guide 🔍
|
/review |
Description
Gap penalty of minimap2 is done via "-O" option and the very same option also exists for samtools, but to indicate output directory. Using "-O" in the "extra" leads to the following error because of using snakemake utils for samtools (https://github.com/snakemake/snakemake-wrapper-utils/blob/f9cba17cb380dc7e6729a845ae37f26972c3d1dd/snakemake_wrapper_utils/samtools.py#LL76C23-L76C23):
The fastest and not over-engineered solution to me was to add the gap_opening variable to params, but I feel that it's also not very elegant especially when it comes to modifying the other penalty scores, but they can still be set in the extra.
QC
For all wrappers added by this PR,
input:
andoutput:
file paths in the resulting rule can be changed arbitrarily,threads: x
statement withx
being a reasonable default,map_reads
for a step that maps reads),environment.yaml
specifications follow the respective best practices,input:
oroutput:
),Snakefile
s and their entries are explained via comments (input:
/output:
/params:
etc.),stderr
and/orstdout
are logged correctly (log:
), depending on the wrapped tool,tempfile.gettempdir()
points to (see here; this also means that using any Pythontempfile
default behavior works),meta.yaml
contains a link to the documentation of the respective tool or command,Snakefile
s pass the linting (snakemake --lint
),Snakefile
s are formatted with snakefmt,Description by Korbit AI
What change is being made?
Fix the bug by adding a parameter for gap opening penalty (
-O
) in the minimap2 aligner wrapper and correct the samtools output directory handling.Why are these changes being made?
The gap opening penalty parameter was previously missing, causing incorrect alignment results. Additionally, the samtools output directory handling needed correction to ensure proper file output locations. These changes ensure accurate alignment and correct file management.
Summary by CodeRabbit
gap_opening
parameter to enhance the configurability of the minimap2 alignment process, allowing users to specify gap opening penalties during alignment.gap_opening
parameter for seamless integration with the minimap2 tool.