Skip to content

Conversation

@sanjaysgk
Copy link
Collaborator

@sanjaysgk sanjaysgk commented Jun 30, 2025

Summary by Sourcery

Integrate a real-time progress bar into peptide filtering, refine isoform extraction regex, and streamline ImmunoViz integration.

Enhancements:

  • Add a rich.Progress-based progress bar to the peptide-to-protein alignment loop in filter_and_format_data.
  • Refine the regex in extract_protein_isoforms to correctly handle whitespace delimiters.
  • Streamline the create_immunoviz_object method by updating the ImmunoViz type hint and removing a redundant import.

@sourcery-ai
Copy link

sourcery-ai bot commented Jun 30, 2025

Reviewer's Guide

This PR enhances DataProcessor by adding a real-time progress bar for peptide-to-protein alignment, centralizing key imports at the module level, refining the isoform splitting regex, and simplifying the ImmunoViz object creation signature.

Sequence diagram for peptide-to-protein alignment with progress bar

sequenceDiagram
    participant DataProcessor
    participant ProgressBar as Progress
    participant DataFrame as data
    participant ProteinDB as get_protein_sequence
    participant Output as formatted_rows
    DataProcessor->>ProgressBar: Start progress bar (total = len(data))
    loop For each row in data
        DataProcessor->>DataFrame: Get peptide, accession, intensities
        DataProcessor->>DataProcessor: extract_protein_ids
        alt protein_ids found
            loop For each protein_id
                DataProcessor->>ProteinDB: get_protein_sequence(protein_id)
                alt sequence found
                    DataProcessor->>DataProcessor: find_peptide_position
                else sequence not found
                    DataProcessor->>DataProcessor: Use placeholder positions
                end
                DataProcessor->>Output: Append formatted row if intensity > threshold
            end
        end
        DataProcessor->>ProgressBar: Update progress
    end
    ProgressBar-->>DataProcessor: Complete
Loading

Class diagram for updated PeptideDataProcessor structure

classDiagram
    class PeptideDataProcessor {
        +extract_protein_ids(accession_value: str, protein_pattern=None) List[str]
        +extract_protein_isoforms(accession_value: str, protein_pattern: str = r'[,:;|/\s]+') List[str]
        +filter_and_format_data(...)
        +get_protein_sequence(protein_id: str) Optional[str]
        +create_immunoviz_object() ImmunoViz
        -intensity_cols
        -sample_prefix
        -peptide_df
    }
    class ImmunoViz
    PeptideDataProcessor --> ImmunoViz : creates
Loading

Class diagram for ImmunoViz import and type annotation update

classDiagram
    class PeptideDataProcessor {
        +create_immunoviz_object() ImmunoViz
    }
    class ImmunoViz
    PeptideDataProcessor --> ImmunoViz : returns
Loading

File-Level Changes

Change Details Files
Integrate rich.Progress-based progress bar in filter_and_format_data
  • Wrap peptide-to-protein alignment loop in a Progress context
  • Add and update a progress task for each peptide processed
  • Advance progress after handling each peptide
ProtPeptigram/DataProcessor.py
Centralize module imports for Progress and ImmunoViz
  • Move import of ImmunoViz and rich.Progress to top of the module
  • Remove redundant in-function import of ImmunoViz
ProtPeptigram/DataProcessor.py
Refine protein isoform splitting regex
  • Adjust default regex to correctly include whitespace as a delimiter
ProtPeptigram/DataProcessor.py
Simplify create_immunoviz_object signature and import logic
  • Change return type annotation to use ImmunoViz directly
  • Eliminate circular-import workaround inside the function
ProtPeptigram/DataProcessor.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sanjaysgk sanjaysgk merged commit f20c20c into main Jun 30, 2025
3 checks passed
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

We encountered an error and are unable to review this PR. We have been notified and are working to fix it.

You can try again by commenting this pull request with @sourcery-ai review, or contact us for help.

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