Skip to content

Conversation

@noamteyssier
Copy link
Collaborator

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello @noamteyssier, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant new utility for converting FASTX files (FASTA/FASTQ) directly into BINSEQ format, leveraging parallel processing for efficiency. It also refines the internal record handling logic within BINSEQ writers to be more robust against records containing extraneous data, while maintaining strictness for missing required data. Furthermore, dependency management has been improved by making certain crates optional, enhancing build flexibility.

Highlights

  • New FASTX to BINSEQ Conversion Utility: A new module src/utils/fastx.rs and an example examples/auto-write.rs have been added to enable direct conversion of FASTX (FASTA/FASTQ) files to BINSEQ format, leveraging the paraseq crate for efficient parallel processing. This significantly simplifies the data ingestion workflow.
  • Improved Record Handling in Writers: The BinseqWriter implementations for BQ, VBQ, and CBQ formats have been refined to handle 'over-specified' records more gracefully. Writers will now ignore extraneous data in records (e.g., quality scores when the writer is not configured for them) instead of erroring, while still enforcing errors for 'under-specified' records (missing data that the writer is configured to store).
  • Flexible Dependency Management: The Cargo.toml file has been updated to make anyhow, paraseq, and parking_lot optional dependencies, controlled by new anyhow and paraseq features. This allows for more modular builds, only including these dependencies when their corresponding features are explicitly enabled.
  • Accurate Record Size Calculation: New methods configured_size_cbq and configured_size_vbq have been introduced in SequencingRecord to calculate the precise size a record will occupy in a block based on the writer's configuration, rather than the record's full content. This improves block capacity management and efficiency.
  • Enhanced Error Reporting for FASTX Encoding: New error types, FastxEncodingError (e.g., EmptyFastxFile, MissingInput), have been added to src/error.rs to provide more specific and informative feedback during the FASTX to BINSEQ conversion process.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a significant and valuable feature for automatically converting FASTX files to BINSEQ format using parallel processing with paraseq. The changes are extensive, including the addition of a new FastxEncoderBuilder, refactoring of record size calculations for better accuracy, and improving validation logic in the writers. The code is well-structured, and the new tests are comprehensive. I've found one critical issue that would prevent compilation and one suggestion for code simplification.

Comment on lines +281 to +305
let (slen, xlen) = if interleaved {
let mut rset_iter = rset.iter();
let Some(Ok(slen)) = rset_iter.next().map(|r| -> Result<usize> {
let rec = r.map_err(IntoBinseqError::into_binseq_error)?;
Ok(rec.seq().len())
}) else {
return Err(FastxEncodingError::EmptyFastxFile.into());
};
let Some(Ok(xlen)) = rset_iter.next().map(|r| -> Result<usize> {
let rec = r.map_err(IntoBinseqError::into_binseq_error)?;
Ok(rec.seq().len())
}) else {
return Err(FastxEncodingError::EmptyFastxFile.into());
};
(slen, xlen)
} else {
let mut rset_iter = rset.iter();
let Some(Ok(slen)) = rset_iter.next().map(|r| -> Result<usize> {
let rec = r.map_err(IntoBinseqError::into_binseq_error)?;
Ok(rec.seq().len())
}) else {
return Err(FastxEncodingError::EmptyFastxFile.into());
};
(slen, 0)
};

Choose a reason for hiding this comment

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

critical

This function has a compilation error and some code duplication.

  1. Compilation Error: The r variable in the map closure is a &paraseq::Result<...>, but map_err is called on it, which takes ownership (self). This will not compile. You need to use as_ref() to work with references inside the Result.

  2. Code Duplication: The logic for extracting the sequence length from a record is repeated.

Here is a suggested refactoring that fixes the bug and improves maintainability by removing the duplication:

    let mut rset_iter = rset.iter();
    let get_len = |r: Option<&paraseq::Result<paraseq::fastx::RefRecord<'_>>>| -> Result<usize> {
        let res = r.ok_or(FastxEncodingError::EmptyFastxFile)?;
        res.as_ref()
            .map(|rec| rec.seq().len())
            .map_err(IntoBinseqError::into_binseq_error)
    };

    let (slen, xlen) = if interleaved {
        (get_len(rset_iter.next())?, get_len(rset_iter.next())?)
    } else {
        (get_len(rset_iter.next())?, 0)
    };

Comment on lines +184 to +188
let nucs_per_byte = if matches!(bitsize, BitSize::Two) {
4
} else {
2
};

Choose a reason for hiding this comment

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

medium

You can simplify this by using the nucs_per_byte() method from the bitnuc::BitSize enum, which makes the code more concise and directly uses the bitnuc crate's API.

        let nucs_per_byte = bitsize.nucs_per_byte();

@noamteyssier noamteyssier merged commit 8847fec into binseq-0.9.0 Jan 22, 2026
28 checks passed
@noamteyssier noamteyssier deleted the auto-convert-fastx-with-paraseq branch January 22, 2026 22:53
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