Created
June 26, 2024 13:28
-
-
Save apraga/d0328bbb6c6c5f4483ae41d33650d467 to your computer and use it in GitHub Desktop.
PMID to DOI (rust)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use entrez_rs::eutils::{EFetch, Eutils, DB}; | |
use entrez_rs::parser::pubmed::PubmedArticleSet; | |
fn main() { | |
let xml = EFetch::new(DB::Pubmed, vec!["5337378", "33448306"]) | |
.run() | |
.expect("Connection error"); | |
let parsed = PubmedArticleSet::read(&xml).expect("Parsing error"); | |
let data: Vec<_> = parsed | |
.articles | |
.into_iter() | |
.filter_map(|a| a.pubmed_data) | |
.filter_map(|d| d.article_id_list) | |
.flat_map(|l| l.article_ids.into_iter()) | |
.filter(|i| i.id_type == Some("doi".to_string())) | |
.filter_map(|x| x.id) | |
.collect(); | |
println!("{:?}", data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment