use crate::error::FerroError;
use crate::reference::transcript::Transcript;
pub trait ReferenceProvider {
fn get_transcript(&self, id: &str) -> Result<Transcript, FerroError>;
fn get_sequence(&self, id: &str, start: u64, end: u64) -> Result<String, FerroError>;
fn has_transcript(&self, id: &str) -> bool {
self.get_transcript(id).is_ok()
}
fn get_genomic_sequence(
&self,
contig: &str,
start: u64,
end: u64,
) -> Result<String, FerroError> {
Err(FerroError::GenomicReferenceNotAvailable {
contig: contig.to_string(),
start,
end,
})
}
fn has_genomic_data(&self) -> bool {
false
}
fn get_protein_sequence(
&self,
accession: &str,
start: u64,
end: u64,
) -> Result<String, FerroError> {
Err(FerroError::ProteinReferenceNotAvailable {
accession: accession.to_string(),
start,
end,
})
}
fn has_protein_data(&self) -> bool {
false
}
}
impl ReferenceProvider for Box<dyn ReferenceProvider> {
fn get_transcript(&self, id: &str) -> Result<Transcript, FerroError> {
(**self).get_transcript(id)
}
fn get_sequence(&self, id: &str, start: u64, end: u64) -> Result<String, FerroError> {
(**self).get_sequence(id, start, end)
}
fn has_transcript(&self, id: &str) -> bool {
(**self).has_transcript(id)
}
fn get_genomic_sequence(
&self,
contig: &str,
start: u64,
end: u64,
) -> Result<String, FerroError> {
(**self).get_genomic_sequence(contig, start, end)
}
fn has_genomic_data(&self) -> bool {
(**self).has_genomic_data()
}
fn get_protein_sequence(
&self,
accession: &str,
start: u64,
end: u64,
) -> Result<String, FerroError> {
(**self).get_protein_sequence(accession, start, end)
}
fn has_protein_data(&self) -> bool {
(**self).has_protein_data()
}
}