#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Citation {
pub tool: &'static str,
pub text: &'static str,
pub doi: &'static str,
}
impl Citation {
#[must_use]
pub fn render(&self) -> String {
format!("{} doi:{}", self.text, self.doi)
}
}
pub const KNOWN: &[Citation] = &[
Citation {
tool: "minimap2",
text: "Li H (2018) Minimap2: pairwise alignment for nucleotide sequences. \
Bioinformatics 34(18):3094-3100.",
doi: "10.1093/bioinformatics/bty191",
},
Citation {
tool: "samtools",
text: "Danecek P, Bonfield JK, Liddle J, Marshall J, Ohan V, Pollard MO, \
Whitwham A, Keane T, McCarthy SA, Davies RM, Li H (2021) Twelve years \
of SAMtools and BCFtools. GigaScience 10(2):giab008.",
doi: "10.1093/gigascience/giab008",
},
Citation {
tool: "hivdb",
text: "Rhee SY, Gonzales MJ, Kantor R, Betts BJ, Ravela J, Shafer RW (2003) \
Human immunodeficiency virus reverse transcriptase and protease \
sequence database. Nucleic Acids Research 31(1):298-303.",
doi: "10.1093/nar/gkg100",
},
Citation {
tool: "bcftools",
text: "Danecek P, Bonfield JK, Liddle J, Marshall J, Ohan V, Pollard MO, \
Whitwham A, Keane T, McCarthy SA, Davies RM, Li H (2021) Twelve years \
of SAMtools and BCFtools. GigaScience 10(2):giab008.",
doi: "10.1093/gigascience/giab008",
},
Citation {
tool: "bwa",
text: "Li H (2013) Aligning sequence reads, clone sequences and assembly \
contigs with BWA-MEM. arXiv:1303.3997 [q-bio.GN].",
doi: "10.48550/arXiv.1303.3997",
},
];
#[must_use]
pub fn of(tool: &str) -> Option<&'static Citation> {
KNOWN.iter().find(|citation| citation.tool == tool)
}
#[cfg(test)]
mod tests {
#![allow(clippy::expect_used)]
use super::*;
#[test]
fn a_known_tool_has_a_reference_with_a_doi() {
let citation = of("minimap2").expect("minimap2 is in the table");
assert!(citation.text.contains("Li H"));
assert!(
citation
.render()
.contains("doi:10.1093/bioinformatics/bty191")
);
}
#[test]
fn samtools_and_bcftools_share_their_paper() {
let samtools = of("samtools").expect("in the table");
let bcftools = of("bcftools").expect("in the table");
assert_eq!(samtools.doi, bcftools.doi);
}
#[test]
fn the_aligner_a_library_step_runs_is_the_one_cited() {
let citation = of("bwa").expect("bwa is in the table");
assert!(
citation.text.contains("BWA-MEM"),
"`ligase.steps.bwa.mem` runs BWA-MEM, and that is the algorithm \
bwa asks to be cited for: {}",
citation.text
);
assert!(citation.render().contains("doi:10.48550/arXiv.1303.3997"));
}
#[test]
fn every_reference_carries_a_doi() {
for citation in KNOWN {
assert!(
citation.doi.starts_with("10."),
"{} has no resolvable DOI",
citation.tool
);
}
}
#[test]
fn an_unknown_tool_has_no_reference() {
assert!(
of("minimap3").is_none(),
"the engine does not invent a reference from a name"
);
}
}