Skip to content

fix: Add more FASTA extensions #49

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

fgvieira
Copy link
Contributor

@fgvieira fgvieira commented May 28, 2025

Fixes #48

Summary by CodeRabbit

  • New Features

    • Expanded support for recognizing additional file extensions as "fasta" format, including .ffn, .faa, .mpfa, and .frn.
    • Added support for .xz compression extension alongside existing ones.
  • Documentation

    • Added a reference comment for the FASTA format to improve clarity.

Copy link
Contributor

coderabbitai bot commented May 28, 2025

📝 Walkthrough

Walkthrough

The get_format function in the snakemake_wrapper_utils/snakemake.py file was updated to recognize additional FASTA file extensions and handle .xz compression. A comment referencing the FASTA format Wikipedia page was added above the extended list of recognized FASTA extensions.

Changes

File(s) Change Summary
snakemake_wrapper_utils/snakemake.py Expanded recognized FASTA file extensions in get_format; added .xz compression support; added reference comment.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant get_format
    User->>get_format: Call with file path
    get_format->>get_format: Check file extension against updated FASTA extensions list and compression types
    get_format-->>User: Return "fasta" if match, else other format or error
Loading

Assessment against linked issues

Objective Addressed Explanation
Update get_format to recognize all FASTA extensions (.fasta, .fas, .fa, .fna, .ffn, .faa, .mpfa, .frn) (#48)

Possibly related PRs

Suggested reviewers

  • johanneskoester

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ef951de and 3d37a26.

📒 Files selected for processing (1)
  • snakemake_wrapper_utils/snakemake.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.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 `s...

**/*.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.

  • snakemake_wrapper_utils/snakemake.py
🪛 Ruff (0.11.9)
snakemake_wrapper_utils/snakemake.py

38-41: Use ternary operator ext = exts[-2] if exts[-1] in (".gz", ".bgz", ".bz2", ".xz") else exts[-1] instead of if-else-block

Replace if-else-block with ext = exts[-2] if exts[-1] in (".gz", ".bgz", ".bz2", ".xz") else exts[-1]

(SIM108)

🔇 Additional comments (3)
snakemake_wrapper_utils/snakemake.py (3)

37-37: LGTM! Grammar improvement.

Good catch adding the period for consistency with error message formatting.


38-38: LGTM! Enhanced compression support.

Adding .xz compression support is a valuable enhancement that extends the function's capability to handle more compressed file formats commonly used in bioinformatics.

🧰 Tools
🪛 Ruff (0.11.9)

38-41: Use ternary operator ext = exts[-2] if exts[-1] in (".gz", ".bgz", ".bz2", ".xz") else exts[-1] instead of if-else-block

Replace if-else-block with ext = exts[-2] if exts[-1] in (".gz", ".bgz", ".bz2", ".xz") else exts[-1]

(SIM108)


45-46: LGTM! Successfully addresses the PR objective.

The addition of .ffn, .faa, .mpfa, and .frn extensions properly expands FASTA format recognition as intended by the PR. The Wikipedia reference comment is helpful documentation. These are legitimate FASTA format extensions commonly used in bioinformatics:

  • .ffn: FASTA nucleotide sequences of genes
  • .faa: FASTA amino acid sequences
  • .mpfa: Multi-FASTA file
  • .frn: FASTA formatted sequence file
✨ Finishing Touches
  • 📝 Generate Docstrings

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)
snakemake_wrapper_utils/snakemake.py (1)

45-47: Improve maintainability with constants and case-insensitive matching
To simplify updates and avoid missing uppercase variants (e.g. .FA), normalize ext to lowercase and extract FASTA/FASTQ extension sets to module‐level constants. For example:

@@ get_format(path)
-    if exts[-1] in (".gz", ".bgz", ".bz2"):
+    if exts[-1] in (".gz", ".bgz", ".bz2"):
         ext = exts[-2]
     else:
         ext = exts[-1]
+    ext = ext.lower()

-    if ext in (".fq", ".fastq"):
+    if ext in FASTQ_EXTS:
         return "fastq"
-    elif ext in (".fa", ".fas", ".fna", ".ffn", ".faa", ".fasta", ".mpfa", ".frn"):
-        # https://en.wikipedia.org/wiki/FASTA_format
-        return "fasta"
+    elif ext in FASTA_EXTS:
+        return "fasta"

And at the top of the file:

# Supported file extensions for FASTA/FASTQ formats:
FASTA_EXTS = {".fa", ".fas", ".fna", ".ffn", ".faa", ".fasta", ".mpfa", ".frn"}  # https://en.wikipedia.org/wiki/FASTA_format
FASTQ_EXTS = {".fq", ".fastq"}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2469d4d and ef951de.

📒 Files selected for processing (1)
  • snakemake_wrapper_utils/snakemake.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.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 `s...

**/*.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.

  • snakemake_wrapper_utils/snakemake.py
🔇 Additional comments (1)
snakemake_wrapper_utils/snakemake.py (1)

45-47: Extended FASTA extensions added
The new extensions .ffn, .faa, .mpfa, and .frn accurately reflect the FASTA variants, and the Wikipedia URL comment provides valuable context for future maintainers.

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.

feature update: Make the get_format function of snakemake module cater more fasta file extension types
1 participant