repo_name
stringclasses
1 value
path
stringlengths
27
72
content
stringlengths
19
51.7k
license
stringclasses
1 value
rust-bio-tools
./rust-bio-tools/tests/lib.rs
use bio::io::fastq;\nuse rust_htslib::bam;\nuse rust_htslib::bam::Read;\nuse std::fs;\nuse std::process::Command;\n\n/// Compare an output file to the expected output and delete the output file.\nfn test_output(result: &str, expected: &str) {\n assert!(Command::new('cmp')\n .arg(result)\n .arg(expected...
mit
rust-bio-tools
./rust-bio-tools/src/bam/depth.rs
//! Compute the depth of coverage in a BAM file for a list of reference sequences and positions.\n//!\n//! ## Input:\n//! A BAM file and a positions file.\n//! The positions file contains the name of one reference sequence and one position per line (tab separated).\n//! Example:\n//! ```\n//! 16 1\n//! 17 1\n//! ...
mit
rust-bio-tools
./rust-bio-tools/src/bam/plot/plot_bam.rs
use crate::bcf::report::table_report::create_report_table::create_report_data;\nuse crate::bcf::report::table_report::create_report_table::manipulate_json;\nuse crate::common::Region;\nuse anyhow::Result;\nuse chrono::{DateTime, Local};\nuse itertools::Itertools;\nuse std::io;\nuse std::io::Write;\nuse std::path::Path;...
mit
rust-bio-tools
./rust-bio-tools/src/bam/plot/mod.rs
pub mod plot_bam;\n
mit
rust-bio-tools
./rust-bio-tools/src/bam/anonymize_reads.rs
use anyhow::Result;\nuse bio::io::fasta;\nuse rand::prelude::{SliceRandom, ThreadRng};\nuse rand::seq::IteratorRandom;\nuse rust_htslib::bam;\nuse rust_htslib::bam::Read;\nuse std::collections::HashMap;\nuse std::ops::Range;\nuse std::path::Path;\nuse uuid::Uuid;\n\npub fn anonymize_reads<P: AsRef<Path> + std::fmt::Deb...
mit
rust-bio-tools
./rust-bio-tools/src/bam/collapse_reads_to_fragments/calc_consensus.rs
use crate::common::CalcConsensus;\nuse bio::io::fastq;\nuse bio::stats::probs::LogProb;\nuse bio_types::sequence::SequenceRead;\nuse bio_types::sequence::SequenceReadPairOrientation;\nuse derive_new::new;\nuse itertools::Itertools;\nuse rust_htslib::bam;\nuse rust_htslib::bam::record::Aux;\nuse std::collections::{HashM...
mit
rust-bio-tools
./rust-bio-tools/src/bam/collapse_reads_to_fragments/pipeline.rs
use super::calc_consensus::{CalcNonOverlappingConsensus, CalcOverlappingConsensus};\nuse super::unmark_record;\nuse anyhow::Result;\nuse bio::io::fastq;\nuse derive_new::new;\nuse rust_htslib::bam;\nuse rust_htslib::bam::record::Aux;\nuse rust_htslib::bam::Read;\nuse std::cmp::Ordering;\nuse std::collections::{BTreeMap...
mit
rust-bio-tools
./rust-bio-tools/src/bam/collapse_reads_to_fragments/mod.rs
mod calc_consensus;\nmod pipeline;\n\nuse anyhow::Result;\nuse bio::io::fastq;\nuse log::info;\nuse pipeline::CallConsensusRead;\nuse rust_htslib::bam;\nuse rust_htslib::bam::{Format, Header, Read};\nuse std::path::Path;\n\npub fn call_consensus_reads_from_paths<P: AsRef<Path>>(\n bam_in: P,\n fq1: P,\n fq2: P...
mit
rust-bio-tools
./rust-bio-tools/src/bam/mod.rs
//! Tools that work on BAM files\npub mod anonymize_reads;\npub mod collapse_reads_to_fragments;\npub mod depth;\npub mod plot;\n
mit
rust-bio-tools
./rust-bio-tools/src/common.rs
use anyhow::Context;\nuse approx::relative_eq;\nuse bio::stats::probs::{LogProb, PHREDProb};\nuse bio_types::sequence::SequenceRead;\nuse itertools::Itertools;\nuse ordered_float::NotNaN;\nuse std::cmp;\nuse std::collections::HashMap;\nuse std::str::FromStr;\n\nconst PROB_CONFUSION: LogProb = LogProb(-1.098612288668109...
mit
rust-bio-tools
./rust-bio-tools/src/fastq/split.rs
//! Split reads from stdin up into the given files.\n//!\n//! ## Usage:\n//!\n//! Distribute reads from `test.fastq` into the files `A.fastq` and `B.fastq`.\n//! ```bash\n//! $ rbt fastq-split A.fastq B.fastq < test.fastq\n//! ```\n//!\nuse anyhow::Result;\nuse bio::io::fastq;\nuse bio::io::fastq::FastqRead;\nuse log::...
mit
rust-bio-tools
./rust-bio-tools/src/fastq/collapse_reads_to_fragments/calc_consensus.rs
use crate::common::CalcConsensus;\nuse bio::io::fastq;\nuse bio::stats::probs::LogProb;\nuse derive_new::new;\nuse itertools::Itertools;\n\nconst ALLELES: &[u8] = b'ACGT';\n\n/// Compute a maximum likelihood fragment sequence for a collection of FASTQ reads.\n///\n/// For each position, compute the likelihood of each a...
mit
rust-bio-tools
./rust-bio-tools/src/fastq/collapse_reads_to_fragments/pipeline.rs
use anyhow::Result;\nuse bio::io::fastq;\nuse bio::io::fastq::{FastqRead, Record};\nuse bio::stats::probs::LogProb;\nuse derive_new::new;\nuse ordered_float::NotNaN;\nuse rgsl::randist::gaussian::ugaussian_P;\nuse rocksdb::DB;\nuse std::io;\nuse std::io::Write;\nuse std::mem;\nuse std::process::{Command, Stdio};\nuse s...
mit
rust-bio-tools
./rust-bio-tools/src/fastq/collapse_reads_to_fragments/mod.rs
//! Tool to merge sets of reads in paired FASTQ files that share the UMI and have similar read sequence.\n//! The result is a maximum likelihood fragment sequence per set.\n//!\n//! This tool takes two FASTQ files (forward and reverse)\n//! and returns two FASTQ files in which all PCR duplicates\n//! have been merged i...
mit
rust-bio-tools
./rust-bio-tools/src/fastq/mod.rs
//! Tools that work on FASTQ files\npub mod collapse_reads_to_fragments;\npub mod filter;\npub mod split;\n
mit
rust-bio-tools
./rust-bio-tools/src/fastq/filter.rs
//! Filter reads matching names in a text file into a new FASTQ file.\n//!\n//! ## Usage:\n//!\n//! Extract the read with identifier `A` from `test.fastq` into a new file `filtered.fastq`\n//! ```bash\n//! $ cat ids.txt\n//! A\n//!\n//! $ cat test.fastq\n//! @A\n//! ACTCTATCTA\n//! +\n//! !!!!!!!!!!\n//! @B\n//! CTCTAT...
mit
rust-bio-tools
./rust-bio-tools/src/sequences_stats.rs
//! Compute statics on sequences from stdin:\n//! - min: length of shortest sequence\n//! - max: length of longest sequence\n//! - average: average length of sequence\n//! - median: median length of sequence\n//! - nb_reads: number of reads\n//! - nb_bases: number of bases\n//! - n50: N50 of sequences\n//...
mit
rust-bio-tools
./rust-bio-tools/src/cli.rs
use crate::common::Region;\nuse std::path::PathBuf;\nuse structopt::StructOpt;\n\n#[derive(StructOpt)]\n#[structopt(\n about = 'A set of ultra-fast command line utilities for bioinformatics tasks based on Rust-Bio.',\n author = 'Johannes Köster <johannes.koester@tu-dortmund.de>',\n name = 'Rust-Bio-Tools'\n)]\...
mit
rust-bio-tools
./rust-bio-tools/src/csv/report.rs
use crate::bcf::report::oncoprint::WriteErr;\nuse anyhow::Context as AnyhowContext;\nuse anyhow::Result;\nuse chrono::{DateTime, Local};\nuse derive_new::new;\nuse itertools::Itertools;\nuse lz_str::compress_to_utf16;\nuse serde_derive::Serialize;\nuse serde_json::json;\nuse std::collections::{HashMap, HashSet};\nuse s...
mit
rust-bio-tools
./rust-bio-tools/src/csv/mod.rs
//! Tools that work on CSV files.\npub mod report;\n
mit
rust-bio-tools
./rust-bio-tools/src/main.rs
//! Documentation for Rust Bio Tools\nuse anyhow::{Context, Result};\nuse itertools::Itertools;\nuse log::LevelFilter;\nuse rayon::prelude::*;\nuse std::collections::HashMap;\nuse std::fs;\nuse std::path::Path;\nuse structopt::StructOpt;\n\nuse cli::Command::*;\n\npub mod bam;\npub mod bcf;\nmod cli;\npub mod common;\n...
mit
rust-bio-tools
./rust-bio-tools/src/bcf/split.rs
use std::collections::HashMap;\nuse std::path::Path;\n\nuse anyhow::Context;\nuse anyhow::Result;\nuse itertools::Itertools;\nuse rust_htslib::bcf;\nuse rust_htslib::bcf::Read;\n\npub fn split<P: AsRef<Path>>(input_bcf: P, output_bcfs: &[P]) -> Result<()> {\n let n_records = bcf::Reader::from_path(input_bcf.as_ref()...
mit
rust-bio-tools
./rust-bio-tools/src/bcf/report/table_report/alignment_reader.rs
extern crate rust_htslib;\n\nuse self::rust_htslib::bam::FetchDefinition;\nuse crate::bcf::report::table_report::fasta_reader::read_fasta;\nuse crate::common::Region;\nuse anyhow::Result;\nuse itertools::Itertools;\nuse rust_htslib::bam::record::CigarStringView;\nuse rust_htslib::{bam, bam::Read};\nuse serde::Serialize...
mit
rust-bio-tools
./rust-bio-tools/src/bcf/report/table_report/mod.rs
mod alignment_reader;\npub mod create_report_table;\nmod fasta_reader;\nmod static_reader;\n\nuse crate::bcf::report::oncoprint::WriteErr;\nuse crate::bcf::report::table_report::create_report_table::make_table_report;\nuse anyhow::{Context, Result};\nuse std::fs;\nuse std::path::Path;\n\n#[allow(clippy::too_many_argume...
mit
rust-bio-tools
./rust-bio-tools/src/bcf/report/table_report/create_report_table.rs
use crate::bcf::report::table_report::fasta_reader::{get_fasta_lengths, read_fasta};\nuse crate::bcf::report::table_report::static_reader::{get_static_reads, Variant};\nuse crate::common::Region;\nuse anyhow::anyhow;\nuse anyhow::Context as AnyhowContext;\nuse anyhow::Result;\nuse chrono::{DateTime, Local};\nuse iterto...
mit
rust-bio-tools
./rust-bio-tools/src/bcf/report/table_report/fasta_reader.rs
use crate::common::Region;\nuse anyhow::Context;\nuse anyhow::Result;\nuse bio::io::fasta;\nuse itertools::Itertools;\nuse serde::Serialize;\nuse std::collections::HashMap;\nuse std::path::Path;\n\npub fn read_fasta<P: AsRef<Path> + std::fmt::Debug>(\n path: P,\n region: &Region,\n compensate_0_basing: bool,\n...
mit
rust-bio-tools
./rust-bio-tools/src/bcf/report/table_report/static_reader.rs
use crate::bcf::report::table_report::alignment_reader::{\n make_nucleobases, read_indexed_bam, AlignmentMatch, AlignmentNucleobase,\n};\nuse crate::bcf::report::table_report::create_report_table::VariantType;\nuse crate::common::Region;\nuse anyhow::Result;\nuse rand::rngs::StdRng;\nuse rand::seq::IteratorRandom;\n...
mit
rust-bio-tools
./rust-bio-tools/src/bcf/report/oncoprint.rs
use std::collections::HashMap;\nuse std::io::Write;\nuse std::{fs, str};\n\nuse derive_new::new;\nuse itertools::Itertools;\nuse lazy_static::lazy_static;\nuse regex::Regex;\nuse serde_derive::Serialize;\nuse tera::{self, Context, Tera};\n\nuse crate::bcf::report::table_report::create_report_table::get_ann_description;...
mit
rust-bio-tools
./rust-bio-tools/src/bcf/report/mod.rs
use crate::bcf::report::oncoprint::WriteErr;\nuse anyhow::{Context, Result};\nuse itertools::Itertools;\nuse std::fs;\nuse std::fs::File;\nuse std::io::{Read, Write};\nuse std::path::Path;\n\npub mod oncoprint;\npub mod table_report;\n\npub fn embed_js(\n output_path: &str,\n vcf_report: bool,\n custom_table_r...
mit
rust-bio-tools
./rust-bio-tools/src/bcf/match_variants.rs
//! Annotate for each variant in a VCF/BCF at STDIN whether it is contained in a given second VCF/BCF.\n//!\n//! The matching is fuzzy for indels and exact for SNVs.\n//! Results are printed as BCF to STDOUT, with an additional INFO tag MATCHING.\n//! The two vcfs do not have to be sorted.\n//!\n//! ## Usage:\n//! ```b...
mit
rust-bio-tools
./rust-bio-tools/src/bcf/mod.rs
//! Tools that work on VCF and BCF files.\npub mod annotate_dgidb;\npub mod baf;\npub mod fix_iupac_alleles;\npub mod match_variants;\npub mod report;\npub mod split;\npub mod to_txt;\n
mit
rust-bio-tools
./rust-bio-tools/src/bcf/to_txt.rs
//! Create a variant table from a VCF file.\n//!\n//! ## Usage:\n//! ```bash\n//! $ rbt vcf-to-txt --genotypes --fmt S --info T X SOMATIC < tests/test.vcf > tests/variant-table.txt\n//! ```\n//!\nuse anyhow::{bail, Result};\nuse derive_new::new;\nuse itertools::Itertools;\nuse rust_htslib::bcf;\nuse rust_htslib::bcf::r...
mit
rust-bio-tools
./rust-bio-tools/src/bcf/annotate_dgidb.rs
use anyhow::Result;\nuse itertools::Itertools;\nuse regex::Regex;\nuse rust_htslib::bcf;\nuse rust_htslib::bcf::{Format, Read};\nuse serde::{Deserialize, Serialize};\nuse std::collections::{HashMap, HashSet};\nuse std::path::Path;\nuse std::str;\n\n#[derive(Serialize, Deserialize, Debug)]\nstruct Dgidb {\n #[serde(r...
mit
rust-bio-tools
./rust-bio-tools/src/bcf/fix_iupac_alleles.rs
use anyhow::Result;\nuse bio::alphabets::dna::n_alphabet;\nuse itertools::Itertools;\nuse rust_htslib::bcf::{self, Format, Read};\n\npub fn fix_iupac_alleles() -> Result<()> {\n let mut inbcf = bcf::Reader::from_stdin()?;\n let mut outbcf = bcf::Writer::from_stdout(\n &bcf::Header::from_template(inbcf.head...
mit
rust-bio-tools
./rust-bio-tools/src/bcf/baf.rs
//! Compute the B-allele frequencies for a given VCF file.\n//!\n//! ## Usage:\n//! ```bash\n//! $ rbt vcf-baf < tests/test-freebayes.vcf > tests/baf.\n//! ```\n//!\nuse anyhow::Result;\nuse itertools::repeat_n;\nuse itertools::Itertools;\nuse rust_htslib::bcf;\nuse rust_htslib::bcf::record::Numeric;\nuse rust_htslib::...
mit