-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: annotation of structural variants (#46)
- Loading branch information
Showing
4 changed files
with
245 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
//! Annotation of VCF files. | ||
pub mod seqvars; | ||
pub mod strucvars; |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//! UCSC binning scheme. | ||
// Offsets for UCSC binning. | ||
// | ||
// cf. http://genomewiki.ucsc.edu/index.php/Bin_indexing_system | ||
static BIN_OFFSETS: &[i32] = &[512 + 64 + 8 + 1, 64 + 8 + 1, 8 + 1, 1, 0]; | ||
|
||
const BIN_FIRST_SHIFT: i32 = 17; | ||
|
||
const BIN_NEXT_SHIFT: i32 = 3; | ||
|
||
// Compute UCSC bin from 0-based half-open interval. | ||
pub fn bin_from_range(begin: i32, end: i32) -> Result<i32, anyhow::Error> { | ||
let mut begin_bin = begin >> BIN_FIRST_SHIFT; | ||
let mut end_bin = std::cmp::max(begin, end - 1) >> BIN_FIRST_SHIFT; | ||
|
||
for offset in BIN_OFFSETS { | ||
if begin_bin == end_bin { | ||
return Ok(offset + begin_bin); | ||
} | ||
begin_bin >>= BIN_NEXT_SHIFT; | ||
end_bin >>= BIN_NEXT_SHIFT; | ||
} | ||
|
||
anyhow::bail!( | ||
"begin {}, end {} out of range in bin_from_range (max is 512M", | ||
begin, | ||
end | ||
); | ||
} |
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
Oops, something went wrong.