-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from databio/dev
Release `v0.0.13` -- Add fragment file tokenizer
- Loading branch information
Showing
16 changed files
with
456 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .genimtools.models import * # noqa: F403 |
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,9 @@ | ||
from typing import List | ||
|
||
class Region: | ||
chr: str | ||
start: int | ||
end: int | ||
|
||
class RegionSet: | ||
regions: List[Region] |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use pyo3::prelude::*; | ||
|
||
#[pyclass(name = "FragmentTokenizer")] | ||
pub struct PyFragmentTokenizer { | ||
pub tokenizer: genimtools::tokenizers::FragmentTokenizer, | ||
} | ||
|
||
#[pymethods] | ||
impl PyFragmentTokenizer { | ||
#[new] | ||
pub fn new(path: String) -> PyResult<Self> { | ||
let path = std::path::Path::new(&path); | ||
let tokenizer = genimtools::tokenizers::FragmentTokenizer::try_from(path)?; | ||
Ok(PyFragmentTokenizer { tokenizer }) | ||
} | ||
|
||
pub fn tokenize_fragments( | ||
&self, | ||
file: String, | ||
out_path: Option<String>, | ||
filter: Option<Vec<String>>, | ||
) -> PyResult<()> { | ||
let path = std::path::Path::new(&file); | ||
let out_path = out_path.unwrap_or("".to_string()); | ||
let out_path = std::path::Path::new(&out_path); | ||
match filter { | ||
Some(filter) => self | ||
.tokenizer | ||
.tokenize_fragments_with_filter(path, out_path, filter), | ||
None => self.tokenizer.tokenize_fragments(path, out_path), | ||
}?; | ||
Ok(()) | ||
} | ||
} |
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 |
---|---|---|
|
@@ -155,7 +155,6 @@ impl PyTreeTokenizer { | |
|
||
Ok(py_tokenized_region_set) | ||
}) | ||
|
||
} | ||
|
||
// encode returns a list of ids | ||
|
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
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.