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

How to get a value of a attribute from gtf file by using the key #316

Closed
zhengxinchang opened this issue Jan 13, 2025 · 1 comment
Closed
Assignees
Labels
enhancement New feature or request gtf

Comments

@zhengxinchang
Copy link

Dear Developer,

I hope you are doing well! I am working on a project using the noodle-gtf file. I have been unable to find a way to retrieve an attribute value by providing a key. Although it provides a 'get' method, this method only accepts index value. I would appreciate if you could provide a solution that allows me to input a key and retrieve its corresponding value.

Best regards,
Xinchang

@zaeleus zaeleus added the gtf label Jan 13, 2025
@zaeleus
Copy link
Owner

zaeleus commented Jan 13, 2025

gff::record::Attributes is a list of entries. You can currently use Iterator::find to search for a value by tag, e.g.,

let value = record
    .attributes()
    .iter()
    .find(|entry| entry.key() == key)
    .map(|entry| entry.value());

@zaeleus zaeleus self-assigned this Jan 19, 2025
@zaeleus zaeleus added the enhancement New feature or request label Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request gtf
Projects
None yet
Development

No branches or pull requests

2 participants