diff --git a/src/data_structures/fmindex.rs b/src/data_structures/fmindex.rs index 810506ed9..d51b883f8 100644 --- a/src/data_structures/fmindex.rs +++ b/src/data_structures/fmindex.rs @@ -382,13 +382,21 @@ impl, DLess: Borrow, DOcc: Borrow> FMDIndex Vec<(BiInterval, usize, usize)> { diff --git a/src/io/fasta.rs b/src/io/fasta.rs index 32342a4bc..399cc7bc6 100644 --- a/src/io/fasta.rs +++ b/src/io/fasta.rs @@ -116,12 +116,14 @@ //! const FAI_FILE: &[u8] = b"chr1\t16\t6\t12\t13"; //! //! let seq_name = "chr1"; -//! let start: u64 = 0; // start is 0-based, inclusive -//! let stop: u64 = 10; // stop is 0-based, exclusive -//! // load the index +//! let start: u64 = 0; // start is 0-based, inclusive +//! let stop: u64 = 10; // stop is 0-based, exclusive +//! // load the index //! let mut faidx = IndexedReader::new(std::io::Cursor::new(FASTA_FILE), FAI_FILE).unwrap(); //! // move the pointer in the index to the desired sequence and interval -//! faidx.fetch(seq_name, start, stop).expect("Couldn't fetch interval"); +//! faidx +//! .fetch(seq_name, start, stop) +//! .expect("Couldn't fetch interval"); //! // read the subsequence defined by the interval into a vector //! let mut seq = Vec::new(); //! faidx.read(&mut seq).expect("Couldn't read the interval"); @@ -458,12 +460,14 @@ impl IndexedReader { /// const FAI_FILE: &[u8] = b"chr1\t16\t6\t12\t13"; /// /// let seq_name = "chr1"; - /// let start: u64 = 0; // start is 0-based, inclusive - /// let stop: u64 = 10; // stop is 0-based, exclusive - /// // load the index + /// let start: u64 = 0; // start is 0-based, inclusive + /// let stop: u64 = 10; // stop is 0-based, exclusive + /// // load the index /// let mut faidx = IndexedReader::new(std::io::Cursor::new(FASTA_FILE), FAI_FILE).unwrap(); /// // move the pointer in the index to the desired sequence and interval - /// faidx.fetch(seq_name, start, stop).expect("Couldn't fetch interval"); + /// faidx + /// .fetch(seq_name, start, stop) + /// .expect("Couldn't fetch interval"); /// // read the subsequence defined by the interval into a vector /// let mut seq = Vec::new(); /// faidx.read(&mut seq).expect("Couldn't read the interval"); @@ -472,7 +476,6 @@ impl IndexedReader { /// /// # Errors /// If the `seq_name` does not exist within the index. - /// pub fn fetch(&mut self, seq_name: &str, start: u64, stop: u64) -> io::Result<()> { let idx = self.idx(seq_name)?; self.start = Some(start); @@ -494,12 +497,14 @@ impl IndexedReader { /// const FAI_FILE: &[u8] = b"chr1\t16\t6\t12\t13"; /// /// let rid: usize = 0; - /// let start: u64 = 0; // start is 0-based, inclusive - /// let stop: u64 = 10; // stop is 0-based, exclusive - /// // load the index + /// let start: u64 = 0; // start is 0-based, inclusive + /// let stop: u64 = 10; // stop is 0-based, exclusive + /// // load the index /// let mut faidx = IndexedReader::new(std::io::Cursor::new(FASTA_FILE), FAI_FILE).unwrap(); /// // move the pointer in the index to the desired sequence and interval - /// faidx.fetch_by_rid(rid, start, stop).expect("Couldn't fetch interval"); + /// faidx + /// .fetch_by_rid(rid, start, stop) + /// .expect("Couldn't fetch interval"); /// // read the subsequence defined by the interval into a vector /// let mut seq = Vec::new(); /// faidx.read(&mut seq).expect("Couldn't read the interval"); @@ -508,7 +513,6 @@ impl IndexedReader { /// /// # Errors /// If `rid` does not exist within the index. - /// pub fn fetch_by_rid(&mut self, rid: usize, start: u64, stop: u64) -> io::Result<()> { let idx = self.idx_by_rid(rid)?; self.start = Some(start); diff --git a/src/stats/bayesian/model.rs b/src/stats/bayesian/model.rs index 803f01453..6760374e4 100644 --- a/src/stats/bayesian/model.rs +++ b/src/stats/bayesian/model.rs @@ -166,6 +166,14 @@ where .max_by_key(|(_, prob)| NotNan::new(***prob).unwrap()) .map(|(event, _)| event) } + + /// Event posteriors sorted in descending order. + pub fn event_posteriors(&self) -> impl Iterator { + self.joint_probs + .iter() + .map(|(event, prob)| (event, prob - self.marginal)) + .sorted_by_key(|(_, prob)| -NotNan::new(**prob).unwrap()) + } } impl ModelInstance, PosteriorEvent>