18 个版本 (10 个重大更改)
使用旧 Rust 2015
0.10.0 | 2016 年 9 月 4 日 |
---|---|
0.9.0 | 2016 年 5 月 19 日 |
0.8.1 | 2016 年 4 月 12 日 |
0.7.0 | 2016 年 3 月 17 日 |
0.2.1 | 2015 年 12 月 23 日 |
#25 in #rna
用于 rosalind-cli
41KB
740 行
rosalind
罗莎琳德问题解决方案库
lib.rs
:
rosalind
提供了解决来自 Rosalind 网站问题的函数。
计算 DNA 核苷酸
示例
use rosalind::RosalindError::UnknownNucleotide;
use rosalind::dna::*;
let dna = "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC";
let dna_nucleotides = DNANucleotides {A: 20, C: 12, G: 17, T: 21};
assert_eq!(count_dna_nucleotides(dna).unwrap(), dna_nucleotides);
assert_eq!(dna_nucleotides.to_string(), "20 12 17 21");
assert_eq!(count_dna_nucleotides("\n").unwrap(), DNANucleotides {A: 0, C: 0, G: 0, T: 0});
assert_eq!(count_dna_nucleotides("Z").unwrap_err(), UnknownNucleotide('Z'));
将 DNA 转录为 RNA
示例
use rosalind::RosalindError::UnknownNucleotide;
use rosalind::rna::*;
let dna = "GATGGAACTTGACTACGTAAATT";
assert_eq!(transcribe_dna_into_rna(dna).unwrap(), "GAUGGAACUUGACUACGUAAAUU");
assert_eq!(transcribe_dna_into_rna("\n").unwrap(), "");
assert_eq!(transcribe_dna_into_rna("Z").unwrap_err(), UnknownNucleotide('Z'));
互补 DNA 链
示例
use rosalind::RosalindError::UnknownNucleotide;
use rosalind::revc::*;
let dna = "AAAACCCGGT";
assert_eq!(reverse_complement_dna(dna).unwrap(), "ACCGGGTTTT");
assert_eq!(reverse_complement_dna("\n").unwrap(), "");
assert_eq!(reverse_complement_dna("Z").unwrap_err(), UnknownNucleotide('Z'));
兔子与递归关系
示例
use rosalind::fib::*;
use num::{BigUint};
use num::bigint::{ToBigUint};
let mut expected_relation: BigUint = 19.to_biguint().unwrap();
assert_eq!(recurrence_relation(5, 3).unwrap(), expected_relation);
expected_relation = 4.to_biguint().unwrap();
assert_eq!(recurrence_relation_with_stop(6, 3).unwrap(), expected_relation);
将 RNA 转译为蛋白质,推断 mRNA 从蛋白质,计算蛋白质质量
示例
use rosalind::RosalindError::{CodonParseError, UnknownCodon, UnknownAminoAcid};
use rosalind::prot::*;
let rna = "AUGGCCAUGGCGCCCAGAACUGAGAUCAAUAGUACCCGUAUUAACGGGUGA";
assert_eq!(translate_rna_into_protein(rna).unwrap(), "MAMAPRTEINSTRING");
assert_eq!(translate_rna_into_protein("AUGUGA\n").unwrap(), "M");
assert_eq!(translate_rna_into_protein("Z").unwrap_err(), CodonParseError);
assert_eq!(translate_rna_into_protein("ZZZ").unwrap_err(), UnknownCodon("ZZZ".to_string()));
assert_eq!(get_number_of_rna_from_protein("MA").unwrap(), 12);
assert_eq!(get_number_of_rna_from_protein("").unwrap(), 0);
assert_eq!(get_number_of_rna_from_protein("\n").unwrap(), 3);
assert_eq!(get_number_of_rna_from_protein("B").unwrap_err(), UnknownAminoAcid('B'));
assert_eq!(get_protein_mass("SKADYEK\n").unwrap(), 821.392f64);
assert_eq!(get_protein_mass("AB").unwrap_err(), UnknownAminoAcid('B'));
计算点突变
示例
use rosalind::RosalindError::HammingStringsLengthError;
use rosalind::hamm::*;
let s = "GAGCCTACTAACGGGAT";
let t = "CATCGTAATGACGGCCT";
assert_eq!(hamming_distance(s, t).unwrap(), 7);
assert_eq!(hamming_distance("G", "").unwrap_err(), HammingStringsLengthError);
在 DNA 中找到基序
示例
use rosalind::RosalindError::MotifStringsLengthError;
use rosalind::subs::*;
let s = "GATATATGCATATACTT";
let t = "ATAT";
assert_eq!(motif_lookup(s, t).unwrap(), vec![2, 4, 10]);
assert_eq!(motif_lookup(t, s).unwrap_err(), MotifStringsLengthError);
计算 GC 含量
示例
use rosalind::gc::*;
assert_eq!(gc_content("").unwrap(), 0f32);
assert_eq!(gc_content("AGCTATAG").unwrap(), 37.5f32);
let dataset = ">Rosalind_6404
CCTGCGGAAGATCGGCACTAGAATAGCCAGAACCGTTTCTCTGAGGCTTCCGGCCTTCCC
TCCCACTAATAATTCTGAGG
>Rosalind_5959
CCATCGGTAGCGCATCCTTAGTCCAATTAAGTCCCTATCCAGGCGCTCCGCCGAAGGTCT
ATATCCATTTGTCAGCAGACACGC
>Rosalind_0808
CCACCCTCGTGGTATGGCTAGGCATTCAGGAACCGGAGAACGCTTCAGACCAGCCCGGAC
TGGGAACCTGCGGGCAGTAGGTGGAAT";
assert_eq!(best_gc_content_in_dataset(dataset).unwrap(),
GCcontent {string_id: "Rosalind_0808".to_string(), gc_content: 60.919540f32});
孟德尔的第一个定律
示例
use rosalind::RosalindError::InvalidInputParameters;
use rosalind::iprb::*;
assert_eq!(dominant_allele_probability(0, 1, 1).unwrap_err(), InvalidInputParameters);
assert_eq!(dominant_allele_probability(1, 0, 1).unwrap_err(), InvalidInputParameters);
assert_eq!(dominant_allele_probability(1, 1, 0).unwrap_err(), InvalidInputParameters);
assert_eq!(dominant_allele_probability(2, 2, 2).unwrap(), 0.7833333);
共识和轮廓
示例
use rosalind::cons::*;
let prof = Profile {
A: vec![5, 1, 0, 0, 5, 5, 0, 0],
C: vec![0, 0, 1, 4, 2, 0, 6, 1],
G: vec![1, 1, 6, 3, 0, 1, 0, 0],
T: vec![1, 5, 0, 0, 0, 1, 1, 6],
};
assert_eq!(consensus(prof).unwrap(), "ATGCAACT");
实用工具
将 Fasta 数据集解析为字符串列表
use rosalind::utils::*;
let fasta_dataset = ">Rosalind_1
CCTGCGGAAG
TCCCACTAAT
>Rosalind_2
CCATCGGTAG
ATATCCATTT
>Rosalind_3
CCACCCTCGT
TGGGAACCTG";
let expected_dataset = vec![
"CCTGCGGAAGTCCCACTAAT",
"CCATCGGTAGATATCCATTT",
"CCACCCTCGTTGGGAACCTG",
];
assert_eq!(parse_fasta_dataset(fasta_dataset).unwrap(), expected_dataset);
依赖项
~240KB