Skip to content

Conversation

@ChenZiHong-Gavin
Copy link
Collaborator

No description provided.

@github-actions github-actions bot added the core label Feb 6, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ChenZiHong-Gavin, 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 new RfamSearcher client, designed to facilitate comprehensive interaction with the Rfam database. It enables users to retrieve detailed information about RNA families, perform keyword-based searches, and conduct sequence similarity searches against Rfam covariance models through the RNAcentral integration. The client is built with robust error handling and a unified search interface to simplify various types of queries.

Highlights

  • New Rfam Searcher: Introduced a new RfamSearcher class, inheriting from BaseSearcher, to provide a dedicated client for interacting with the Rfam database.
  • Comprehensive Query Capabilities: The searcher supports various query types, including retrieving RNA families by accession (RFXXXXX) or ID, searching families by keywords using EBI search, and performing sequence searches against Rfam covariance models via RNAcentral integration.
  • Data Retrieval Functions: Added methods to retrieve specific data such as covariance models (CMs), seed alignments (in Stockholm or FASTA format), and URLs for secondary structure images of Rfam families.
  • Robust API Interaction: Implemented retry logic using the tenacity library for network requests to handle transient errors (e.g., RequestException, Timeout), ensuring more reliable communication with external APIs.
  • Unified Search Interface: A single search method is provided that intelligently auto-detects the query type (accession, ID, FASTA sequence, raw sequence, or keyword) and dispatches it to the appropriate underlying search function.
Changelog
  • graphgen/models/searcher/db/rfam_searcher.py
    • Added a new Python module containing the RfamSearcher class.
    • Implemented methods for querying Rfam families by accession, ID, and keywords.
    • Integrated sequence search functionality via RNAcentral.
    • Included utilities for retrieving covariance models, alignments, and secondary structure URLs.
    • Developed a unified search method for intelligent query dispatch.
    • Incorporated retry logic for API calls and robust error handling.
Activity
  • No specific human activity (comments, reviews, or progress updates) has been recorded for this pull request yet.
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
Contributor

@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 new RfamSearcher class to interact with the Rfam and RNAcentral APIs. The implementation is well-structured, featuring retry logic, helper methods, and a unified search interface. My review focuses on improving code clarity, addressing a potential performance issue, suggesting a more robust resource management pattern, and removing unused code. Overall, this is a solid addition.

Comment on lines +44 to +54
# RNA molecule type mapping
RNA_TYPES = {
"Gene": "gene",
"snRNA": "snrna",
"snoRNA": "snorna",
"rRNA": "rrna",
"tRNA": "trna",
"miRNA": "mirna",
"ribozyme": "ribozyme",
"riboswitch": "riboswitch",
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The RNA_TYPES dictionary is defined but appears to be unused within the class. To improve code clarity and remove dead code, it's recommended to remove it.

Comment on lines +204 to +210
rna_type = (
types[-1]
if types[-1] != "CD-box"
else types[-2]
if len(types) > 1
else types[0]
)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The nested ternary expression for determining rna_type is difficult to read and maintain. Refactoring this into a more explicit if/elif/else block would improve readability.

Suggested change
rna_type = (
types[-1]
if types[-1] != "CD-box"
else types[-2]
if len(types) > 1
else types[0]
)
if types[-1] != "CD-box":
rna_type = types[-1]
elif len(types) > 1:
rna_type = types[-2]
else:
# Fallback to the first type if it's the only one (even if 'CD-box')
rna_type = types[0]

Comment on lines +362 to +367
for entry in result["entries"]:
accession = entry.get("fields", {}).get("accession", [None])[0]
if accession:
family = self.get_by_accession(accession)
if family:
families.append(family)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This loop makes a separate API call to get_by_accession for each search result. If the search returns many items (e.g., limit=10), this will result in 11 API calls (1 search + 10 get_by_accession), which can be slow and may lead to hitting API rate limits. This is a form of the N+1 query problem.

Consider returning a summarized version of the families using only the information from the initial EBI search to improve performance. If full details are necessary, this behavior should be documented in the method's docstring to make users aware of the performance implications.

Comment on lines +705 to +708
def __del__(self):
"""Cleanup session."""
if hasattr(self, "session"):
self.session.close()
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Using __del__ for resource cleanup (like closing a requests.Session) is not reliable in Python, as its execution is not guaranteed. A more robust and idiomatic approach is to implement the class as a context manager. This ensures that resources are cleaned up properly when the object is used within a with statement.

You can achieve this by adding __enter__ and __exit__ methods and removing __del__.

Example:

def __enter__(self):
    return self

def __exit__(self, exc_type, exc_val, exc_tb):
    self.session.close()

This would allow for usage like with RfamSearcher() as searcher: ....

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant