Skip to main content

Record

Struct Record 

Source
pub struct Record<const N: usize>(/* private fields */);
Expand description

A BED record.

Implementations§

Source§

impl<const N: usize> Record<N>

Source

pub const fn standard_field_count(&self) -> usize

Returns the number of standard fields.

Source

pub fn other_fields(&self) -> OtherFields<'_, N>

Returns the other fields.

Source§

impl Record<3>

Source

pub fn reference_sequence_name(&self) -> &BStr

Returns the reference sequence name.

Source

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}
Source

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>

Source

pub fn reference_sequence_name(&self) -> &BStr

Returns the reference sequence name.

Source

pub fn feature_start(&self) -> Result<Position>

Returns the feature start.

Source

pub fn feature_end(&self) -> Option<Result<Position>>

Returns the feature end.

Source

pub fn name(&self) -> Option<&BStr>

Returns the name.

Source§

impl Record<5>

Source

pub fn reference_sequence_name(&self) -> &BStr

Returns the reference sequence name.

Source

pub fn feature_start(&self) -> Result<Position>

Returns the feature start.

Source

pub fn feature_end(&self) -> Option<Result<Position>>

Returns the feature end.

Source

pub fn name(&self) -> Option<&BStr>

Returns the name.

Source

pub fn score(&self) -> Result<u16>

Returns the score.

Source§

impl Record<6>

Source

pub fn reference_sequence_name(&self) -> &BStr

Returns the reference sequence name.

Source

pub fn feature_start(&self) -> Result<Position>

Returns the feature start.

Source

pub fn feature_end(&self) -> Option<Result<Position>>

Returns the feature end.

Source

pub fn name(&self) -> Option<&BStr>

Returns the name.

Source

pub fn score(&self) -> Result<u16>

Returns the score.

Source

pub fn strand(&self) -> Result<Option<Strand>>

Returns the strand.

Trait Implementations§

Source§

impl<const N: usize> Clone for Record<N>

Source§

fn clone(&self) -> Record<N>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Record<3>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Debug for Record<4>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Debug for Record<5>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Debug for Record<6>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Record<3>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Default for Record<4>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Default for Record<5>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Default for Record<6>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<const N: usize> PartialEq for Record<N>

Source§

fn eq(&self, other: &Record<N>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Record<3> for Record<3>

Source§

fn reference_sequence_name(&self) -> &BStr

Returns the reference sequence name.
Source§

fn feature_start(&self) -> Result<Position>

Returns the feature start.
Source§

fn feature_end(&self) -> Option<Result<Position>>

Returns the feature end.
Source§

fn name(&self) -> Option<Option<&BStr>>

Returns the name.
Source§

fn score(&self) -> Option<Result<u16>>

Returns the score.
Source§

fn strand(&self) -> Option<Result<Option<Strand>>>

Returns the strand.
Source§

fn other_fields(&self) -> Box<dyn OtherFields + '_>

Returns the other fields.
Source§

fn standard_field_count(&self) -> usize

Return the number of standard fields.
Source§

impl Record<4> for Record<4>

Source§

fn reference_sequence_name(&self) -> &BStr

Returns the reference sequence name.
Source§

fn feature_start(&self) -> Result<Position>

Returns the feature start.
Source§

fn feature_end(&self) -> Option<Result<Position>>

Returns the feature end.
Source§

fn name(&self) -> Option<Option<&BStr>>

Returns the name.
Source§

fn score(&self) -> Option<Result<u16>>

Returns the score.
Source§

fn strand(&self) -> Option<Result<Option<Strand>>>

Returns the strand.
Source§

fn other_fields(&self) -> Box<dyn OtherFields + '_>

Returns the other fields.
Source§

fn standard_field_count(&self) -> usize

Return the number of standard fields.
Source§

impl Record<5> for Record<5>

Source§

fn reference_sequence_name(&self) -> &BStr

Returns the reference sequence name.
Source§

fn feature_start(&self) -> Result<Position>

Returns the feature start.
Source§

fn feature_end(&self) -> Option<Result<Position>>

Returns the feature end.
Source§

fn name(&self) -> Option<Option<&BStr>>

Returns the name.
Source§

fn score(&self) -> Option<Result<u16>>

Returns the score.
Source§

fn strand(&self) -> Option<Result<Option<Strand>>>

Returns the strand.
Source§

fn other_fields(&self) -> Box<dyn OtherFields + '_>

Returns the other fields.
Source§

fn standard_field_count(&self) -> usize

Return the number of standard fields.
Source§

impl Record<6> for Record<6>

Source§

fn reference_sequence_name(&self) -> &BStr

Returns the reference sequence name.
Source§

fn feature_start(&self) -> Result<Position>

Returns the feature start.
Source§

fn feature_end(&self) -> Option<Result<Position>>

Returns the feature end.
Source§

fn name(&self) -> Option<Option<&BStr>>

Returns the name.
Source§

fn score(&self) -> Option<Result<u16>>

Returns the score.
Source§

fn strand(&self) -> Option<Result<Option<Strand>>>

Returns the strand.
Source§

fn other_fields(&self) -> Box<dyn OtherFields + '_>

Returns the other fields.
Source§

fn standard_field_count(&self) -> usize

Return the number of standard fields.
Source§

impl<const N: usize> Eq for Record<N>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.