Skip to content

Commit

Permalink
feat: add generation function for fast[a|q] format
Browse files Browse the repository at this point in the history
  • Loading branch information
natir committed Feb 2, 2024
1 parent 97d1959 commit 707fcba
Show file tree
Hide file tree
Showing 13 changed files with 483 additions and 82 deletions.
2 changes: 1 addition & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ forge_namespace: natir
forge_repo_name: biotest
msrv: '1.75'
proc_macro: true
project_description: Many function to generate test data for bioinformatics data
project_description: Generate random test data for bioinformatics
project_name: biotest
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
args: --all-features -- -D warnings
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: check
args: --all-features

test:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -56,7 +57,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test
args: --no-fail-fast
args: --no-fail-fast --all-features

coverage:
runs-on: ubuntu-latest
Expand All @@ -79,6 +80,6 @@ jobs:
run: cargo tarpaulin --all-features --timeout 600 --out Xml -- --test-threads 1

- name: Upload coverage to codecov
uses: codecov/codecov-action@v1.0.3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
15 changes: 11 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "biotest"
version = "0.1.0"
authors = ["Pierre Marijon <[email protected]>"]
edition = "2021"
description = "Many function to generate test data for bioinformatics data"
description = "Generate random test data for bioinformatics"
rust-version = "1.75"

homepage = "https://github.com/natir/biotest"
Expand All @@ -14,13 +14,17 @@ readme = "Readme.md"
license-file = "LICENSE"


[dependencies]
[features]
fasta = []
fastq = []
derive = ["dep:biotest_derive"]

[dependencies]
rand = { version = "0.8" }

# Error management
thiserror = { version = "1" }


# Logging and error management
log = { version = "0.4" }

Expand All @@ -30,12 +34,15 @@ biotest_derive = { path = "biotest_derive", optional = true }

[dev-dependencies]
criterion = { version = "0.5" }
tempfile = { version = "3" }

# CLI management
clap = { version = "4", features = ["derive"] }

# Logging management
stderrlog = { version = "0.5" }


[profile.release]
lto = 'thin'
opt-level = 3
Expand All @@ -46,4 +53,4 @@ incremental = false

[profile.profiling]
inherits = "release"
debug = true
debug = true
23 changes: 11 additions & 12 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
<h1 style="text-align: center;">biotest</h1>

[![License](https://img.shields.io/badge/license-MIT-green)](https:///natir/biotest/blob/master/LICENSE)
[![License](https://img.shields.io/badge/license-MIT-green)](https://github.com/natir/biotest/blob/master/LICENSE)
![Test](https://github.com/natir/natir/workflows/Test/badge.svg)
![Lints](https://github.com/natir/natir/workflows/Lints/badge.svg)
![MSRV](https://github.com/natir/natir/workflows/MSRV/badge.svg)
[![CodeCov](https://codecov.io/gh/natir/natir/branch/master/graph/badge.svg)](https://codecov.io/gh/natir/natir)
[![Documentation](https://github.com/natir/natir/workflows/Documentation/badge.svg)](https://natir.github.io/natir/natir)

Generate random test data for bioinformatics

Many function to generate test data for bioinformatics data

## Installation

### From source
## Usage

```bash
git clone https:///natir/biotest.git
cd biotest
cargo install --path .
In your Cargo.toml add
```toml
biotest = { url = "https:///natir/biotest.git" }
```

## Usage

## Minimum supported Rust version

Currently the minimum supported Rust version is 1.75.
2 changes: 1 addition & 1 deletion biotest_derive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Many function to generate test data for bioinformatics data procedural macro crate
//! Generate random test data for bioinformatics"
#![warn(missing_docs)]

Expand Down
50 changes: 0 additions & 50 deletions examples/biotest.rs

This file was deleted.

70 changes: 70 additions & 0 deletions src/constants.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//! Declarations of some constants value
/* std use */

/* crates use */

/* projet use */

const fn gen_array<const N: usize, const B: usize>() -> [u8; N] {
let mut array = [0; N];

let mut i = 0;
while i < N {
array[i] = (B + i) as u8;
i += 1;
}

array
}

/// Fixed random seed
pub const SEED: [u8; 32] = [42; 32];

/// Nucleotides with any case
pub const NUCLEOTIDES: [u8; 8] = *b"ACTGactg";

/// Nucleotides lower
pub const NUCLEOTIDES_LOWER: [u8; 4] = *b"actg";

/// Nucleotides upper
pub const NUCLEOTIDES_UPPER: [u8; 4] = *b"ACTG";

/// All possible phred 33 value
pub const PHRED33: [u8; 40] = gen_array::<40, 33>();

/// All possible phred 64 value
pub const PHRED64: [u8; 40] = gen_array::<40, 64>();

/// Alphabets with [ \ ] ^ _ `
pub const ALPHABETS: [u8; 58] = gen_array::<58, 65>();

#[cfg(test)]
mod tests {
/* project use */
use super::*;

#[test]
fn phred33() {
assert_eq!(
gen_array::<40, 33>().to_vec(),
b"!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGH".to_vec()
);
}

#[test]
fn phred64() {
assert_eq!(
gen_array::<40, 64>().to_vec(),
b"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefg".to_vec()
);
}

#[test]
fn alphapets() {
assert_eq!(
gen_array::<58, 65>().to_vec(),
b"ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz".to_vec()
);
}
}
5 changes: 4 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ use thiserror;
/// Enum to manage error
#[derive(std::fmt::Debug, thiserror::Error)]
pub enum Error {
}
/// std::io::Error error
#[error(transparent)]
StdIo(#[from] std::io::Error),
}

/// Alias of result
pub type Result<T> = core::result::Result<T, Error>;
14 changes: 14 additions & 0 deletions src/format.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//! Format data generation
/* std use */

/* crates use */

/* module declaration */
#[cfg(feature = "fasta")]
pub mod fasta;

#[cfg(feature = "fastq")]
pub mod fastq;

/* projet use */
Loading

0 comments on commit 707fcba

Please sign in to comment.