Skip to content

Commit

Permalink
Merge pull request #16 from DLBPointon/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
DLBPointon authored May 10, 2024
2 parents 15b499d + 4c28154 commit c0555f2
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fasta_manipulation"
version = "0.1.1"
version = "0.1.2"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
13 changes: 10 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ fn main() -> Result<(), Error> {
)
)
.subcommand(
Command::new("profileONGOING")
Command::new("profile")
.about("Profile an input fasta file and return various statistics")
.arg(
Arg::new("fasta-file")
Expand Down Expand Up @@ -215,9 +215,16 @@ fn main() -> Result<(), Error> {
.default_value("new.fasta")
.help("The output name of the new fasta file")
)
.arg(
Arg::new("n_length")
.aliases(["n_len"])
.value_parser(clap::value_parser!(usize))
.default_value("200")
.help("Length that the N (gap) string should be.")
)
)
.subcommand(
Command::new("subsetONGOING")
Command::new("subset")
.about("Subset a fasta file in a random manner by percentage of file")
.arg(
Arg::new("fasta-file")
Expand Down Expand Up @@ -267,7 +274,7 @@ fn main() -> Result<(), Error> {
)
)
.subcommand(
Command::new("mergehapsONGOING")
Command::new("mergehaps")
.about("Merge haplotypes / multi fasta files together")
.arg(
Arg::new("fasta-1")
Expand Down
14 changes: 10 additions & 4 deletions src/tpf_fasta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,12 @@ pub mod tpf_fasta_mod {
uniques
}

fn save_to_fasta(fasta_data: Vec<NewFasta>, tpf_data: Vec<Tpf>, output: &String) {
fn save_to_fasta(
fasta_data: Vec<NewFasta>,
tpf_data: Vec<Tpf>,
output: &String,
n_length: usize,
) {
//
// TPF is in the input TPF order, this will continue to be the case until
// the script is modified and the Tpf struct gets modified in place for some reason
Expand Down Expand Up @@ -191,9 +196,9 @@ pub mod tpf_fasta_mod {
}

let line_len: usize = 60;

let fixed = data.sequence;
let fixed2 = fixed.join("NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN");
let n_string = "N".repeat(n_length);
let fixed2 = fixed.join(&n_string); //.join required a borrowed str
let fixed3 = fixed2
.as_bytes()
.chunks(line_len)
Expand Down Expand Up @@ -221,6 +226,7 @@ pub mod tpf_fasta_mod {
//
let fasta_file: &String = arguments.unwrap().get_one::<String>("fasta").unwrap();
let tpf_file: &String = arguments.unwrap().get_one::<String>("tpf").unwrap();
let n_length: &usize = arguments.unwrap().get_one::<usize>("n_length").unwrap();
let output: &String = arguments.unwrap().get_one::<String>("output").unwrap();
println!("LET'S GET CURATING THAT FASTA!");
stacker::maybe_grow(32 * 1024, 1024 * 5120, || {
Expand Down Expand Up @@ -262,7 +268,7 @@ pub mod tpf_fasta_mod {
Err(e) => panic!("{:?}", e),
};
}
save_to_fasta(new_fasta_data, tpf_data, output)
save_to_fasta(new_fasta_data, tpf_data, output, n_length.to_owned())
}
Err(e) => panic!("Something is wrong with the file! | {}", e),
}
Expand Down
17 changes: 17 additions & 0 deletions test_data/synthetic/tiny.fa
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
>SG1
AATGGCCGGCGCGTTAAACCCAATGCCCCGGTTAANNGCTCGTCGCTTGCTTCGCAAAA
>ATLANTIS
TGCATGTCAGTAGCTGCGGCCCATAAAAAAACGATCGATGCATGTAAAAATGCATCCAC
ACACATCGATCGATCGAGTAAAACACATAATTATATTATTTTTATATTATACGATCATT
CACACATGTGCATCG
>UNIVERSE
TGCATCGATCGATCGACTAGCTACGATCGATCGATCGACTGTCGCGAGGCGCGCGGCGC
CGGCGCGGGGGCGCCCGCGGGCGCCCCATCACGACTGATAGGCCGCGAGACGGCGAGGG
TCA
>UNSPOKEN_ANIMATED_ONE(CEST TERRIBLE)
CATGCTGTAGCAGCTGTCAGTCGATCGATCACTNNNGCATGCATCGNNNNNNNNGCATC
CATCGTAGTGCGGGCGAGCTATCGGCGATCATCGATCGGGCAGCGATCTACGAGCGGGC
NNNNNNNNNNNNNNNNNNNNNNNNCACACAGTCGATCGAGCTGGCCCACACACACACCA
CACACCACACACACACACACACACACACACACACACACACA
>ERROR
HELLOIMNOTAREALSEQUENCEIMJUSTHERETOTRIPYOUUPUWU

0 comments on commit c0555f2

Please sign in to comment.