1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
/// An instance of a Fastx Record.
/// This is a two attribute object containing the sequence
/// ID and the Sequence.
#[derive(Debug)]
pub struct Record {
id: String,
seq: String
}
impl Record {
/// # Usage
/// Creates a new instance of a `[Record]`
/// ```
/// let record = fxread::Record::new();
/// assert!(record.empty());
/// ```
pub fn new() -> Self {
Self {
id: String::new(),
seq: String::new()
}
}
/// Checks if `[Record]` is empty
pub fn empty(&self) -> bool {
self.id.is_empty() & self.seq.is_empty()
}
/// # Usage
/// Sets the ID of the record
/// ```
/// let mut record = fxread::Record::new();
/// record.set_id("some_id".to_string());
/// assert_eq!(record.id(), "some_id");
/// ```
pub fn set_id(&mut self, token: String) {
self.id = token;
}
/// # Usage
/// Sets the Sequence of the record
/// ```
/// let mut record = fxread::Record::new();
/// record.set_seq("ACGT".to_string());
/// assert_eq!(record.seq(), "ACGT");
/// ```
pub fn set_seq(&mut self, token: String) {
self.seq = token;
}
/// Returns a reference of the sequence ID
pub fn id(&self) -> &str {
&self.id
}
/// Returns a reference of the sequence
pub fn seq(&self) -> &str {
&self.seq
}
}