mod attributes;
mod bounds;
mod position;
mod strand;
pub(crate) use self::bounds::Bounds;
use self::{attributes::Attributes, position::Position, strand::Strand};
const MISSING: &str = ".";
pub struct Record {
pub(crate) buf: String,
pub(crate) bounds: Bounds,
}
impl Record {
pub fn reference_sequence_name(&self) -> &str {
&self.buf[self.bounds.reference_sequence_name_range()]
}
pub fn source(&self) -> &str {
&self.buf[self.bounds.source_range()]
}
pub fn ty(&self) -> &str {
&self.buf[self.bounds.type_range()]
}
pub fn start(&self) -> Position<'_> {
let buf = &self.buf[self.bounds.start_range()];
Position::new(buf)
}
pub fn end(&self) -> Position<'_> {
let buf = &self.buf[self.bounds.end_range()];
Position::new(buf)
}
pub fn score(&self) -> &str {
&self.buf[self.bounds.score_range()]
}
pub fn strand(&self) -> Strand<'_> {
let buf = &self.buf[self.bounds.strand_range()];
Strand::new(buf)
}
pub fn phase(&self) -> &str {
&self.buf[self.bounds.phase_range()]
}
pub fn attributes(&self) -> Attributes<'_> {
match &self.buf[self.bounds.attributes_range()] {
MISSING => Attributes::new(""),
buf => Attributes::new(buf),
}
}
}
impl From<Record> for String {
fn from(record: Record) -> Self {
record.buf
}
}