Skip to content

Commit

Permalink
2024/10/24-10:50:00 (Linux cray unknown)
Browse files Browse the repository at this point in the history
  • Loading branch information
pbenner committed Oct 24, 2024
1 parent 53acd0d commit 60a011a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,32 @@ Please find the API documentation [here](https://docs.rs/rustynetics/latest/rust

## Examples

### Import genes from UCSC

```rust
use crate::genes::Genes;

if let Ok(genes) = Genes::import_genes_from_ucsc("hg19", "knownGene") {

println!("{}", genes);
}
```
The result is:
```bash
seqnames ranges strand | names cds
1 chr1 [ 11868, 14409) + | ENST00000456328.2_1 [11868, 11868)
2 chr1 [ 29553, 31097) + | ENST00000473358.1_5 [29553, 29553)
3 chr1 [ 30266, 31109) + | ENST00000469289.1_1 [30266, 30266)
4 chr1 [ 34553, 36081) - | ENST00000417324.1_4 [34553, 34553)
5 chr1 [ 35244, 36073) - | ENST00000461467.1_3 [35244, 35244)
... ... | ... ...
254531 chrY [ 59161253, 59162245) - | ENST00000711258.1_1 [59161253, 59161253)
254532 chrY [ 59208304, 59208554) + | ENST00000711259.1_1 [59208304, 59208304)
254533 chrY [ 59311662, 59311996) - | ENST00000711266.1_1 [59311662, 59311662)
254534 chrY [ 59318040, 59318920) - | ENST00000711267.1_1 [59318040, 59318040)
254535 chrY [ 59358334, 59360548) - | ENST00000711270.1_1 [59358334, 59358334)
```
### Read a BAM file into a GRanges object
```rust
Expand Down
17 changes: 17 additions & 0 deletions src/genes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

use std::fmt;
use std::collections::HashMap;
use std::error::Error;

Expand Down Expand Up @@ -134,3 +135,19 @@ impl Genes {
}

}

/* -------------------------------------------------------------------------- */

impl PartialEq for Genes {
fn eq(&self, other: &Self) -> bool {
self.granges == other.granges
}
}

/* -------------------------------------------------------------------------- */

impl fmt::Display for Genes {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.pad(&format!("{}", self.granges))
}
}

0 comments on commit 60a011a

Please sign in to comment.