pub struct Record<const N: usize>(/* private fields */);Expand description
A BED record.
Implementations§
Source§impl<const N: usize> Record<N>
impl<const N: usize> Record<N>
Sourcepub const fn standard_field_count(&self) -> usize
pub const fn standard_field_count(&self) -> usize
Returns the number of standard fields.
Sourcepub fn other_fields(&self) -> OtherFields<'_, N>
pub fn other_fields(&self) -> OtherFields<'_, N>
Returns the other fields.
Source§impl Record<3>
impl Record<3>
Sourcepub fn reference_sequence_name(&self) -> &BStr
pub fn reference_sequence_name(&self) -> &BStr
Returns the reference sequence name.
Sourcepub fn feature_start(&self) -> Result<Position>
pub fn feature_start(&self) -> Result<Position>
Returns the feature start.
Examples found in repository?
examples/bed_query.rs (line 39)
13fn main() -> Result<(), Box<dyn std::error::Error>> {
14 let mut args = env::args().skip(1);
15
16 let src = args.next().expect("missing src");
17 let region: Region = args.next().expect("missing region").parse()?;
18
19 let index_src = format!("{src}.tbi");
20 let index = tabix::fs::read(index_src)?;
21
22 let header = index.header().expect("missing tabix header");
23 let reference_sequence_id = header
24 .reference_sequence_names()
25 .get_index_of(region.name())
26 .expect("invalid reference sequence name");
27
28 let mut decoder = File::open(src).map(bgzf::io::Reader::new)?;
29 let chunks = index.query(reference_sequence_id, region.interval())?;
30 let query = csi::io::Query::new(&mut decoder, chunks);
31
32 let mut reader = bed::io::Reader::<3, _>::new(query);
33 let mut record = bed::Record::default();
34
35 let stdout = io::stdout().lock();
36 let mut writer = bed::io::Writer::<3, _>::new(stdout);
37
38 while reader.read_record(&mut record)? != 0 {
39 let start = record.feature_start()?;
40 let end = record.feature_end().expect("missing feature end")?;
41 let interval = (start..=end).into();
42
43 if !region.interval().intersects(interval) {
44 continue;
45 }
46
47 writer.write_record(&record)?;
48 }
49
50 Ok(())
51}Sourcepub fn feature_end(&self) -> Option<Result<Position>>
pub fn feature_end(&self) -> Option<Result<Position>>
Returns the feature end.
Examples found in repository?
examples/bed_query.rs (line 40)
13fn main() -> Result<(), Box<dyn std::error::Error>> {
14 let mut args = env::args().skip(1);
15
16 let src = args.next().expect("missing src");
17 let region: Region = args.next().expect("missing region").parse()?;
18
19 let index_src = format!("{src}.tbi");
20 let index = tabix::fs::read(index_src)?;
21
22 let header = index.header().expect("missing tabix header");
23 let reference_sequence_id = header
24 .reference_sequence_names()
25 .get_index_of(region.name())
26 .expect("invalid reference sequence name");
27
28 let mut decoder = File::open(src).map(bgzf::io::Reader::new)?;
29 let chunks = index.query(reference_sequence_id, region.interval())?;
30 let query = csi::io::Query::new(&mut decoder, chunks);
31
32 let mut reader = bed::io::Reader::<3, _>::new(query);
33 let mut record = bed::Record::default();
34
35 let stdout = io::stdout().lock();
36 let mut writer = bed::io::Writer::<3, _>::new(stdout);
37
38 while reader.read_record(&mut record)? != 0 {
39 let start = record.feature_start()?;
40 let end = record.feature_end().expect("missing feature end")?;
41 let interval = (start..=end).into();
42
43 if !region.interval().intersects(interval) {
44 continue;
45 }
46
47 writer.write_record(&record)?;
48 }
49
50 Ok(())
51}Source§impl Record<4>
impl Record<4>
Sourcepub fn reference_sequence_name(&self) -> &BStr
pub fn reference_sequence_name(&self) -> &BStr
Returns the reference sequence name.
Sourcepub fn feature_start(&self) -> Result<Position>
pub fn feature_start(&self) -> Result<Position>
Returns the feature start.
Sourcepub fn feature_end(&self) -> Option<Result<Position>>
pub fn feature_end(&self) -> Option<Result<Position>>
Returns the feature end.
Source§impl Record<5>
impl Record<5>
Sourcepub fn reference_sequence_name(&self) -> &BStr
pub fn reference_sequence_name(&self) -> &BStr
Returns the reference sequence name.
Sourcepub fn feature_start(&self) -> Result<Position>
pub fn feature_start(&self) -> Result<Position>
Returns the feature start.
Sourcepub fn feature_end(&self) -> Option<Result<Position>>
pub fn feature_end(&self) -> Option<Result<Position>>
Returns the feature end.
Source§impl Record<6>
impl Record<6>
Sourcepub fn reference_sequence_name(&self) -> &BStr
pub fn reference_sequence_name(&self) -> &BStr
Returns the reference sequence name.
Sourcepub fn feature_start(&self) -> Result<Position>
pub fn feature_start(&self) -> Result<Position>
Returns the feature start.
Sourcepub fn feature_end(&self) -> Option<Result<Position>>
pub fn feature_end(&self) -> Option<Result<Position>>
Returns the feature end.
Trait Implementations§
Source§impl Record<3> for Record<3>
impl Record<3> for Record<3>
Source§fn reference_sequence_name(&self) -> &BStr
fn reference_sequence_name(&self) -> &BStr
Returns the reference sequence name.
Source§fn feature_start(&self) -> Result<Position>
fn feature_start(&self) -> Result<Position>
Returns the feature start.
Source§fn other_fields(&self) -> Box<dyn OtherFields + '_>
fn other_fields(&self) -> Box<dyn OtherFields + '_>
Returns the other fields.
Source§fn standard_field_count(&self) -> usize
fn standard_field_count(&self) -> usize
Return the number of standard fields.
Source§impl Record<4> for Record<4>
impl Record<4> for Record<4>
Source§fn reference_sequence_name(&self) -> &BStr
fn reference_sequence_name(&self) -> &BStr
Returns the reference sequence name.
Source§fn feature_start(&self) -> Result<Position>
fn feature_start(&self) -> Result<Position>
Returns the feature start.
Source§fn other_fields(&self) -> Box<dyn OtherFields + '_>
fn other_fields(&self) -> Box<dyn OtherFields + '_>
Returns the other fields.
Source§fn standard_field_count(&self) -> usize
fn standard_field_count(&self) -> usize
Return the number of standard fields.
Source§impl Record<5> for Record<5>
impl Record<5> for Record<5>
Source§fn reference_sequence_name(&self) -> &BStr
fn reference_sequence_name(&self) -> &BStr
Returns the reference sequence name.
Source§fn feature_start(&self) -> Result<Position>
fn feature_start(&self) -> Result<Position>
Returns the feature start.
Source§fn other_fields(&self) -> Box<dyn OtherFields + '_>
fn other_fields(&self) -> Box<dyn OtherFields + '_>
Returns the other fields.
Source§fn standard_field_count(&self) -> usize
fn standard_field_count(&self) -> usize
Return the number of standard fields.
Source§impl Record<6> for Record<6>
impl Record<6> for Record<6>
Source§fn reference_sequence_name(&self) -> &BStr
fn reference_sequence_name(&self) -> &BStr
Returns the reference sequence name.
Source§fn feature_start(&self) -> Result<Position>
fn feature_start(&self) -> Result<Position>
Returns the feature start.
Source§fn other_fields(&self) -> Box<dyn OtherFields + '_>
fn other_fields(&self) -> Box<dyn OtherFields + '_>
Returns the other fields.
Source§fn standard_field_count(&self) -> usize
fn standard_field_count(&self) -> usize
Return the number of standard fields.
impl<const N: usize> Eq for Record<N>
impl<const N: usize> StructuralPartialEq for Record<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for Record<N>
impl<const N: usize> RefUnwindSafe for Record<N>
impl<const N: usize> Send for Record<N>
impl<const N: usize> Sync for Record<N>
impl<const N: usize> Unpin for Record<N>
impl<const N: usize> UnsafeUnpin for Record<N>
impl<const N: usize> UnwindSafe for Record<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.