Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,24 @@ This repository is a work in progress, and still in early development. This repo

## Installation

To install any component of `gtars`, you must have the rust toolchain installed. You can install it by [following the instructions](https://www.rust-lang.org/tools/install).
To install `gtars`, you must first [install the rust toolchain](https://www.rust-lang.org/tools/install).

### Command-line interface

You may build the cli binary locally by navigating to `gtars-cli` and using `cargo build --release`. This will create a binary in `target/release/gtars` at the top level of the workspace. You can then add this to your path, or run it directly.

Alternatively, you can run `cargo install --path gtars-cli` from the top level of the workspace. This will install the binary to your cargo bin directory (usually `~/.cargo/bin`).

We feature-gate binary dependencies maximize compatibility and minimize install size. You can specify features during installation like so:

```
cargo install --path gtars-cli gtars-cli --features "uniwig tokenizers"
```

Finally, you can download precompiled binaries from the [releases page](https://github.com/databio/gtars/releases).

### Python bindings

You can install the Python bindings via pip. First, ensure you have a recent version of pip installed. Then run:

```bash
Expand All @@ -50,6 +58,11 @@ from gtars import __version__
print(__version__)
```

### Dev Python bindings




## Usage

`gtars` provides several useful tools. There are 3 ways to use `gtars`.
Expand Down
4 changes: 3 additions & 1 deletion gtars-core/src/models/region_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ use bigtools::{BedEntry, BigBedWrite};
use crate::models::Region;
#[cfg(feature = "http")]
use crate::utils::get_dynamic_reader_from_url;
use crate::utils::{get_chrom_sizes, get_dynamic_reader};
use crate::utils::get_dynamic_reader;
#[cfg(feature = "bigbed")]
use crate::utils::get_chrom_sizes;

///
/// RegionSet struct, the representation of the interval region set file,
Expand Down
9 changes: 7 additions & 2 deletions gtars-core/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ use std::collections::HashMap;
use std::ffi::OsStr;
use std::fs::File;
use std::io::prelude::*;
use std::io::{BufRead, BufReader, Cursor};
use std::io::{BufRead, BufReader};
#[cfg(feature = "http")]
use std::io::Cursor;
use std::path::{Path, PathBuf};
use std::str::FromStr;

use anyhow::{Context, Result};
use flate2::read::{GzDecoder, MultiGzDecoder};
#[cfg(feature = "http")]
use flate2::read::GzDecoder;
use flate2::read::MultiGzDecoder;
#[cfg(feature = "http")]
use reqwest::blocking::Client;
#[cfg(feature = "http")]
use std::error::Error;

use crate::models::region::Region;
Expand Down
45 changes: 45 additions & 0 deletions gtars-python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# gtars

This is a Python package that wraps the `gtars` crate so you can call gtars code from Python.

Documentation for Python bindings is hosted at: https://docs.bedbase.org/gtars/

## Brief instructions

To install the development version, you'll have to build it locally. The easy way to build/install is to do this, which reads the configuration in `pyproject.toml` for easy building/installing:

```
python -m pip install -e .
```

Or, you can have more control over it in two steps using `maturin` directly.
Build Python bindings like this:

```console
cd gtars-python
python_version=$(python --version | awk '{print $2}' | cut -d '.' -f1-2 )
maturin build --interpreter $python_version --release
```


Then install the local wheel that was just built:

```console
gtars_version=`grep '^version =' Cargo.toml | cut -d '"' -f 2`
python_version_nodot=$(python --version | awk '{print $2}' | cut -d '.' -f1-2 | tr -d '.')
ll ../target/wheels/gtars*
wheel_path=$(find ../target/wheels/gtars-${gtars_version}-cp${python_version_nodot}-cp${python_version_nodot}-manylinux*.whl)
echo $wheel_path
pip install --force-reinstall ${wheel_path}
```


## Importing into python

Once installed, you can import and use the package in Python. For example:

```
from gtars import refget
sc = refget.digest_fasta("../tests/data/fasta/base.fa")
sc2 = refget.load_fasta("../tests/data/fasta/base.fa")
```
Loading