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

ignore case in original extension #183

Merged
merged 3 commits into from
Oct 27, 2024
Merged

ignore case in original extension #183

merged 3 commits into from
Oct 27, 2024

Conversation

daichengxin
Copy link
Collaborator

@daichengxin daichengxin commented Oct 27, 2024

PR Type

enhancement, documentation


Description

  • Enhanced the _removesuffix function to handle suffixes in a case-insensitive manner.
  • Updated the logic for file extension conversion to be case-insensitive.
  • Revised the help text in parse_sdrf.py to reflect the case-insensitive nature of extension conversion.
  • Bumped the version from 0.0.31 to 0.0.32.

Changes walkthrough 📝

Relevant files
Configuration changes
__init__.py
Bump version to 0.0.32                                                                     

sdrf_pipelines/init.py

  • Updated the version from 0.0.31 to 0.0.32.
+1/-1     
Enhancement
openms.py
Implement case-insensitive extension handling                       

sdrf_pipelines/openms/openms.py

  • Modified _removesuffix function to ignore case when checking suffix.
  • Updated logic to handle case-insensitive extension conversion.
  • +4/-3     
    Documentation
    parse_sdrf.py
    Update documentation for case-insensitive extension conversion

    sdrf_pipelines/parse_sdrf.py

  • Updated help text to indicate case-insensitive extension conversion.
  • +1/-1     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link

    coderabbitai bot commented Oct 27, 2024

    Important

    Review skipped

    Auto reviews are disabled on base/target branches other than the default branch.

    Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

    You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


    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

    PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Performance Concern
    The new implementation of _removesuffix uses regex, which might be less efficient than the previous string slicing approach. Consider benchmarking to ensure no significant performance impact.

    Potential Bug
    The case-insensitive comparison is implemented inconsistently. While endswith is made case-insensitive, the _removesuffix function still uses case-sensitive regex replacement. This might lead to unexpected behavior.

    Copy link

    PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Enhancement
    Use a more robust method for case-insensitive string comparison

    Consider using the casefold() method instead of lower() for more robust
    case-insensitive string comparison, especially for Unicode strings.

    sdrf_pipelines/openms/openms.py [45-47]

    -if suffix and x.lower().endswith(suffix.lower()):
    +if suffix and x.casefold().endswith(suffix.casefold()):
         res = re.sub(suffix + "$", "", x, flags=re.I)
         return res
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: The suggestion to use casefold() instead of lower() provides a more robust solution for case-insensitive comparisons, especially with Unicode strings. This enhances the reliability of the code without altering its logic.

    7
    Use a more concise and efficient method to create a dictionary from a list of strings

    Consider using a dictionary comprehension to create extension_convert_dict for
    improved readability and potentially better performance.

    sdrf_pipelines/openms/openms.py [56-59]

    -extension_convert_dict = {}
    -for extension_convert in extension_convert_list:
    -    current_extension, new_extension = extension_convert.split(":")
    -    extension_convert_dict[current_extension] = new_extension
    +extension_convert_dict = {current_ext: new_ext for current_ext, new_ext in 
    +                          (ext.split(":") for ext in extension_convert_list)}
    • Apply this suggestion
    Suggestion importance[1-10]: 6

    Why: The suggestion to use a dictionary comprehension improves code readability and conciseness. While it may not significantly impact performance, it simplifies the code structure, making it easier to understand and maintain.

    6

    💡 Need additional feedback ? start a PR chat

    @ypriverol ypriverol merged commit d87d22c into bigbio:dev Oct 27, 2024
    7 checks passed
    @@ -59,7 +60,7 @@ def _removesuffix(x: str, suffix: str, /) -> str:

    raw_bkp = raw
    for current_extension, target_extension in extension_convert_dict.items():
    if raw.endswith(current_extension):
    if raw.lower().endswith(current_extension.lower()):
    raw = _removesuffix(raw, current_extension)
    raw += target_extension
    if not any(raw.endswith(x) for x in possible_extension):
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    I think you will need to change this,too in case the user uses RAW and does no conversion of it.

    Copy link
    Collaborator Author

    Choose a reason for hiding this comment

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

    Here I assume that the final openms experimental design file has the same suffix. Is that right? For example
    Example 1: raw:mzML:
    1.raw -> 1.mzML
    2.Raw -> 2.mzML
    3.RAW -> 3.mzML

    Example 2: raw:RAW:
    1.raw -> 1.RAW
    2.Raw -> 2.RAW
    3. RAW -> 3.RAW

    Copy link
    Collaborator Author

    @daichengxin daichengxin Oct 27, 2024

    Choose a reason for hiding this comment

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

    And also we assumed only suppoted four format in the ending file: "raw", "mzML", "mzml", "d"

    if not any(raw.endswith(x) for x in possible_extension):
    raise RuntimeError(

    Copy link
    Collaborator

    @jpfeuffer jpfeuffer Oct 27, 2024

    Choose a reason for hiding this comment

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

    If I am not mistaken your example raw:RAW will fail.
    If you only allow ".raw" as possible extension you have to add RAW:raw or raw:raw as a default conversion to the pipeline which is a bit weird.

    Copy link
    Collaborator

    @jpfeuffer jpfeuffer Oct 27, 2024

    Choose a reason for hiding this comment

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

    Why not allow the possible extensions case-insensitive then? (i.e. "raw", "mzml", "d" in any possible casing)
    Would solve a lot of problems.

    Copy link
    Collaborator

    @jpfeuffer jpfeuffer Oct 27, 2024

    Choose a reason for hiding this comment

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

    It depends a bit on if downstream tools allow different cases. (e.g. does DIANN allow .D?)
    Is this conversion to openms experimental design even used in the DIA branch of the pipeline?

    Copy link
    Collaborator Author

    @daichengxin daichengxin Oct 27, 2024

    Choose a reason for hiding this comment

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

    Good ideas. I need to test it. Wait a while. Also is ProteomicsLFQ allowed different cases? For example input .mzML file, but in the experimental design file it's mzml

    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    ProteomicLFQ expects exact matches of the full filename of the files that you pass as -in and what is written in the experimental design (including extension, excluding paths).

    Copy link
    Collaborator Author

    Choose a reason for hiding this comment

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

    DIA-NN don't support .D format. So I suggest the possible extensions is case-sensitive. What do you think?

    Copy link
    Collaborator Author

    Choose a reason for hiding this comment

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

    Is this conversion to openms experimental design even used in the DIA branch of the pipeline?

    Yes. It also used in DIA branch https://github.com/bigbio/quantms/blob/b7c9b6a416723c4210effd3889dadce3d9032938/workflows/quantms.nf#L55

    @jpfeuffer
    Copy link
    Collaborator

    @ypriverol I think this was too quick

    @daichengxin
    Copy link
    Collaborator Author

    Another related question: Do we need to support this format ? bigbio/quantms#430

    @ypriverol
    Copy link
    Member

    @daichengxin I have asked how the .dia is obtained. Let's see what they say.

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

    Successfully merging this pull request may close these issues.

    3 participants