Skip to content

Commit 4a44444

Browse files
landesfeindpmarksbrainstorm
authored
Add basic functionality to read indexed FASTA files (continued) (#214)
* Cherry pick the pull request for faidx #165 (review) * Cargo formatting * Update faidx documentation for clarification * Implement faidx_open test * Run actions on faidx branch * Remove faidx from github actions * Activate CI for faidx branch * update osx bindings with faidx support * update linux bindings for faidx * Drop faidx branch from CI actions As requested by @brainstorm (see #214 (comment)) * Migrate faidx to use thiserror instead of snafu (#214 (comment)) * Use i64 in faidx and return byte array Internal C method faidx_fetch_seq64 uses i64 as type to index into large FASTA sequences. The fetch function now returns a byte array instead of a String to be more efficient. A new method was added to automatically convert to a String for convenience. * Formatting using cargo fmt * Use usize-type for position paramter in faidx The return type of the faidx functions is changed to a Result capturing a potential failure in converting the usize into a i64 (hts_pos_t in the C API). * Correct typo in faidx-error: to -> too Co-authored-by: Patrick Marks <pmarks@gmail.com> Co-authored-by: Patrick Marks <patrick@10xgenomics.com> Co-authored-by: Roman Valls Guimera <brainstorm@users.noreply.github.com>
1 parent e979e34 commit 4a44444

File tree

7 files changed

+4426
-766
lines changed

7 files changed

+4426
-766
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,4 @@ jobs:
104104
with:
105105
use-cross: true
106106
command: build
107-
args: --target x86_64-unknown-linux-musl --all-features
107+
args: --target x86_64-unknown-linux-musl --all-features

hts-sys/linux_prebuilt_bindings.rs

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11239,6 +11239,158 @@ fn bindgen_test_layout_kbitset_iter_t() {
1123911239
)
1124011240
);
1124111241
}
11242+
#[repr(C)]
11243+
#[derive(Debug, Copy, Clone)]
11244+
pub struct __faidx_t {
11245+
_unused: [u8; 0],
11246+
}
11247+
pub type faidx_t = __faidx_t;
11248+
pub const fai_format_options_FAI_NONE: fai_format_options = 0;
11249+
pub const fai_format_options_FAI_FASTA: fai_format_options = 1;
11250+
pub const fai_format_options_FAI_FASTQ: fai_format_options = 2;
11251+
pub type fai_format_options = u32;
11252+
extern "C" {
11253+
pub fn fai_build3(
11254+
fn_: *const ::std::os::raw::c_char,
11255+
fnfai: *const ::std::os::raw::c_char,
11256+
fngzi: *const ::std::os::raw::c_char,
11257+
) -> ::std::os::raw::c_int;
11258+
}
11259+
extern "C" {
11260+
pub fn fai_build(fn_: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
11261+
}
11262+
extern "C" {
11263+
pub fn fai_destroy(fai: *mut faidx_t);
11264+
}
11265+
pub const fai_load_options_FAI_CREATE: fai_load_options = 1;
11266+
pub type fai_load_options = u32;
11267+
extern "C" {
11268+
pub fn fai_load3(
11269+
fn_: *const ::std::os::raw::c_char,
11270+
fnfai: *const ::std::os::raw::c_char,
11271+
fngzi: *const ::std::os::raw::c_char,
11272+
flags: ::std::os::raw::c_int,
11273+
) -> *mut faidx_t;
11274+
}
11275+
extern "C" {
11276+
pub fn fai_load(fn_: *const ::std::os::raw::c_char) -> *mut faidx_t;
11277+
}
11278+
extern "C" {
11279+
pub fn fai_load3_format(
11280+
fn_: *const ::std::os::raw::c_char,
11281+
fnfai: *const ::std::os::raw::c_char,
11282+
fngzi: *const ::std::os::raw::c_char,
11283+
flags: ::std::os::raw::c_int,
11284+
format: fai_format_options,
11285+
) -> *mut faidx_t;
11286+
}
11287+
extern "C" {
11288+
pub fn fai_load_format(
11289+
fn_: *const ::std::os::raw::c_char,
11290+
format: fai_format_options,
11291+
) -> *mut faidx_t;
11292+
}
11293+
extern "C" {
11294+
pub fn fai_fetch(
11295+
fai: *const faidx_t,
11296+
reg: *const ::std::os::raw::c_char,
11297+
len: *mut ::std::os::raw::c_int,
11298+
) -> *mut ::std::os::raw::c_char;
11299+
}
11300+
extern "C" {
11301+
pub fn fai_fetch64(
11302+
fai: *const faidx_t,
11303+
reg: *const ::std::os::raw::c_char,
11304+
len: *mut hts_pos_t,
11305+
) -> *mut ::std::os::raw::c_char;
11306+
}
11307+
extern "C" {
11308+
pub fn fai_fetchqual(
11309+
fai: *const faidx_t,
11310+
reg: *const ::std::os::raw::c_char,
11311+
len: *mut ::std::os::raw::c_int,
11312+
) -> *mut ::std::os::raw::c_char;
11313+
}
11314+
extern "C" {
11315+
pub fn fai_fetchqual64(
11316+
fai: *const faidx_t,
11317+
reg: *const ::std::os::raw::c_char,
11318+
len: *mut hts_pos_t,
11319+
) -> *mut ::std::os::raw::c_char;
11320+
}
11321+
extern "C" {
11322+
pub fn faidx_fetch_nseq(fai: *const faidx_t) -> ::std::os::raw::c_int;
11323+
}
11324+
extern "C" {
11325+
pub fn faidx_fetch_seq(
11326+
fai: *const faidx_t,
11327+
c_name: *const ::std::os::raw::c_char,
11328+
p_beg_i: ::std::os::raw::c_int,
11329+
p_end_i: ::std::os::raw::c_int,
11330+
len: *mut ::std::os::raw::c_int,
11331+
) -> *mut ::std::os::raw::c_char;
11332+
}
11333+
extern "C" {
11334+
pub fn faidx_fetch_seq64(
11335+
fai: *const faidx_t,
11336+
c_name: *const ::std::os::raw::c_char,
11337+
p_beg_i: hts_pos_t,
11338+
p_end_i: hts_pos_t,
11339+
len: *mut hts_pos_t,
11340+
) -> *mut ::std::os::raw::c_char;
11341+
}
11342+
extern "C" {
11343+
pub fn faidx_fetch_qual(
11344+
fai: *const faidx_t,
11345+
c_name: *const ::std::os::raw::c_char,
11346+
p_beg_i: ::std::os::raw::c_int,
11347+
p_end_i: ::std::os::raw::c_int,
11348+
len: *mut ::std::os::raw::c_int,
11349+
) -> *mut ::std::os::raw::c_char;
11350+
}
11351+
extern "C" {
11352+
pub fn faidx_fetch_qual64(
11353+
fai: *const faidx_t,
11354+
c_name: *const ::std::os::raw::c_char,
11355+
p_beg_i: hts_pos_t,
11356+
p_end_i: hts_pos_t,
11357+
len: *mut hts_pos_t,
11358+
) -> *mut ::std::os::raw::c_char;
11359+
}
11360+
extern "C" {
11361+
pub fn faidx_has_seq(
11362+
fai: *const faidx_t,
11363+
seq: *const ::std::os::raw::c_char,
11364+
) -> ::std::os::raw::c_int;
11365+
}
11366+
extern "C" {
11367+
pub fn faidx_nseq(fai: *const faidx_t) -> ::std::os::raw::c_int;
11368+
}
11369+
extern "C" {
11370+
pub fn faidx_iseq(
11371+
fai: *const faidx_t,
11372+
i: ::std::os::raw::c_int,
11373+
) -> *const ::std::os::raw::c_char;
11374+
}
11375+
extern "C" {
11376+
pub fn faidx_seq_len(
11377+
fai: *const faidx_t,
11378+
seq: *const ::std::os::raw::c_char,
11379+
) -> ::std::os::raw::c_int;
11380+
}
11381+
extern "C" {
11382+
pub fn fai_parse_region(
11383+
fai: *const faidx_t,
11384+
s: *const ::std::os::raw::c_char,
11385+
tid: *mut ::std::os::raw::c_int,
11386+
beg: *mut hts_pos_t,
11387+
end: *mut hts_pos_t,
11388+
flags: ::std::os::raw::c_int,
11389+
) -> *const ::std::os::raw::c_char;
11390+
}
11391+
extern "C" {
11392+
pub fn fai_set_cache_size(fai: *mut faidx_t, cache_size: ::std::os::raw::c_int);
11393+
}
1124211394
extern "C" {
1124311395
#[link_name = "\u{1}wrap_kbs_init2"]
1124411396
pub fn kbs_init2(ni: size_t, fill: ::std::os::raw::c_int) -> *mut kbitset_t;

0 commit comments

Comments
 (0)