-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic iterator trait, range pushing methods, to coitrees, and more!
- tests and test utilies - rough join stuff - interval/range conversion methods - clippy & fmt
- Loading branch information
Showing
10 changed files
with
358 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,45 @@ | ||
use std::rc::Rc; | ||
|
||
use crate::Position; | ||
|
||
pub struct JoinData<DL, DR> { | ||
/// The data index for the left range. | ||
left: usize, | ||
|
||
/// A `Vec` of the indices for the overlapping right ranges. | ||
rights: Vec<usize>, | ||
|
||
/// The length of the left range. | ||
left_length: Position, | ||
|
||
/// The lengths of the right ranges. | ||
right_lengths: Vec<Position>, | ||
|
||
/// The lengths of the overlaps between the left and right ranges. | ||
overlaps: Vec<Position>, | ||
|
||
// TODO: we may want some simple summary of whether something is | ||
// up or downstream. I think the cleanest summary is a signed integer | ||
// representing the side and degree of non-overlap. E.g. a range | ||
// that overlaps another but overhangs the 3' side of the focal left | ||
// range by 10bp is +10; if it were 5', it would be -10. | ||
/// A possible reference to the left data of type `T`. | ||
left_data: Option<Rc<DL>>, | ||
|
||
/// A possible reference to the right data of type `T`. | ||
right_data: Option<Rc<DR>>, | ||
} | ||
|
||
pub struct JoinIterator<DL, DR> { | ||
left_data: Option<Rc<DL>>, | ||
right_data: Option<Rc<DR>>, | ||
} | ||
// | ||
// impl<DL, DR> JoinIterator<DL, DR> { | ||
// | ||
// } | ||
// | ||
// | ||
// pub fn left_join<CL, CR, DL, DR>(left: GRanges<CL, DL>, right: GRanges<CR, DR>) -> JoinIterator<DL, DR> { | ||
// | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,42 @@ | ||
// Copyright (2024) Vince Buffalo | ||
#![crate_name = "granges2"] | ||
#![doc(html_root_url = "https://docs.rs/granges/")] | ||
|
||
pub mod traits; | ||
pub mod ranges; | ||
pub mod granges; | ||
pub mod error; | ||
pub mod granges; | ||
pub mod iterators; | ||
pub mod join; | ||
pub mod ranges; | ||
pub mod test_utilities; | ||
pub mod traits; | ||
|
||
pub type Position = u32; | ||
|
||
pub mod prelude { | ||
pub use crate::granges::GRanges; | ||
pub use crate::error::GRangesError; | ||
pub use crate::granges::GRanges; | ||
pub use crate::iterators::RangesIterable; | ||
|
||
pub use crate::ranges::vec::{VecRangesEmpty, VecRangesIndexed}; | ||
} | ||
|
||
/// Create a new `GRanges<T>` with sequence length information (used primarily for small examples) | ||
#[macro_export] | ||
macro_rules! create_granges_with_seqlens { | ||
($range_type:ty, $data_type:ty, { $($chr:expr => [$(($start:expr, $end:expr, $data:expr)),*]),* }, seqlens: { $($chr_len:expr => $len:expr),* }) => { | ||
{ | ||
let mut seqlens = ::indexmap::IndexMap::new(); | ||
$(seqlens.insert($chr_len.to_string(), $len);)* | ||
|
||
let mut gr: GRanges<$range_type, $data_type> = GRanges::new_vec(&seqlens); | ||
|
||
$( | ||
$( | ||
gr.push_range_with_data(&$chr.to_string(), $start, $end, $data).expect("Failed to push range"); | ||
)* | ||
)* | ||
|
||
gr | ||
} | ||
}; | ||
} |
Oops, something went wrong.