bio-grumpy 0.1.6__tar.gz → 0.1.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bio_grumpy-0.1.6 → bio_grumpy-0.1.8}/Cargo.lock +1 -1
- {bio_grumpy-0.1.6 → bio_grumpy-0.1.8}/Cargo.toml +1 -1
- {bio_grumpy-0.1.6 → bio_grumpy-0.1.8}/PKG-INFO +2 -1
- {bio_grumpy-0.1.6 → bio_grumpy-0.1.8}/pyproject.toml +1 -0
- {bio_grumpy-0.1.6 → bio_grumpy-0.1.8}/src/difference.rs +13 -4
- {bio_grumpy-0.1.6 → bio_grumpy-0.1.8}/src/genome.rs +6 -0
- {bio_grumpy-0.1.6 → bio_grumpy-0.1.8}/src/lib.rs +8 -1
- {bio_grumpy-0.1.6 → bio_grumpy-0.1.8}/src/main.rs +2 -1
- {bio_grumpy-0.1.6 → bio_grumpy-0.1.8}/src/vcf.rs +22 -13
- {bio_grumpy-0.1.6 → bio_grumpy-0.1.8}/.github/workflows/release.yaml +0 -0
- {bio_grumpy-0.1.6 → bio_grumpy-0.1.8}/.gitignore +0 -0
- {bio_grumpy-0.1.6 → bio_grumpy-0.1.8}/LICENSE +0 -0
- {bio_grumpy-0.1.6 → bio_grumpy-0.1.8}/README-python.md +0 -0
- {bio_grumpy-0.1.6 → bio_grumpy-0.1.8}/README.md +0 -0
- {bio_grumpy-0.1.6 → bio_grumpy-0.1.8}/reference/MN908947.3.gb +0 -0
- {bio_grumpy-0.1.6 → bio_grumpy-0.1.8}/reference/NC_000962.3.gbk +0 -0
- {bio_grumpy-0.1.6 → bio_grumpy-0.1.8}/src/common.rs +0 -0
- {bio_grumpy-0.1.6 → bio_grumpy-0.1.8}/src/gene.rs +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: bio-grumpy
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.8
|
|
4
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
4
5
|
Classifier: Programming Language :: Rust
|
|
5
6
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
7
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
@@ -7,6 +7,7 @@ build-backend = "maturin"
|
|
|
7
7
|
name = "bio-grumpy"
|
|
8
8
|
requires-python = ">=3.8"
|
|
9
9
|
classifiers = [
|
|
10
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
10
11
|
"Programming Language :: Rust",
|
|
11
12
|
"Programming Language :: Python :: Implementation :: CPython",
|
|
12
13
|
"Programming Language :: Python :: Implementation :: PyPy",
|
|
@@ -183,7 +183,7 @@ impl GenomeDifference{
|
|
|
183
183
|
if gene_pos == -1{
|
|
184
184
|
panic!("Failed to find gene position for indel at genome index {} in gene {}", alt_pos.genome_idx, gene.name);
|
|
185
185
|
}
|
|
186
|
-
if alt.alt_type == AltType::INS{
|
|
186
|
+
if alt.alt_type == AltType::INS && gene.reverse_complement{
|
|
187
187
|
gene_pos -= 1;
|
|
188
188
|
if gene_pos == 0{
|
|
189
189
|
// Can't have 0 as a gene position so nudge to promoter start
|
|
@@ -425,6 +425,10 @@ impl GeneDifference{
|
|
|
425
425
|
evidence = Vec::new();
|
|
426
426
|
for e in alt_cd.alts.iter(){
|
|
427
427
|
if e.evidence.is_minor{
|
|
428
|
+
if e.alt_type == AltType::REF{
|
|
429
|
+
//Not sure why we get minor ref calls but skip
|
|
430
|
+
continue;
|
|
431
|
+
}
|
|
428
432
|
if e.alt_type == AltType::SNP || e.alt_type == AltType::HET || e.alt_type == AltType::NULL{
|
|
429
433
|
these_minor_snps.push(e);
|
|
430
434
|
minor_snp_exists = true;
|
|
@@ -476,7 +480,7 @@ impl GeneDifference{
|
|
|
476
480
|
minor_mutations.push(
|
|
477
481
|
GeneDifference::mixed_indel(
|
|
478
482
|
gene_name.clone(),
|
|
479
|
-
|
|
483
|
+
alt_cd.nucleotide_number,
|
|
480
484
|
codes_protein,
|
|
481
485
|
alt_cd.nucleotide_number,
|
|
482
486
|
alt_cd.nucleotide_index,
|
|
@@ -494,7 +498,7 @@ impl GeneDifference{
|
|
|
494
498
|
minor_mutations.push(
|
|
495
499
|
GeneDifference::mixed_indel(
|
|
496
500
|
gene_name.clone(),
|
|
497
|
-
|
|
501
|
+
alt_cd.nucleotide_number,
|
|
498
502
|
codes_protein,
|
|
499
503
|
alt_cd.nucleotide_number,
|
|
500
504
|
alt_cd.nucleotide_index,
|
|
@@ -529,7 +533,7 @@ impl GeneDifference{
|
|
|
529
533
|
mutation: _mutation.clone(),
|
|
530
534
|
gene: gene_name.clone(),
|
|
531
535
|
evidence: evidence.clone(),
|
|
532
|
-
gene_position: Some(
|
|
536
|
+
gene_position: Some(alt_cd.nucleotide_number),
|
|
533
537
|
codes_protein: Some(codes_protein),
|
|
534
538
|
ref_nucleotides: None,
|
|
535
539
|
alt_nucleotides: None,
|
|
@@ -800,6 +804,11 @@ impl GeneDifference{
|
|
|
800
804
|
/// # Returns
|
|
801
805
|
/// - Mutation object for the mixed indel
|
|
802
806
|
fn mixed_indel(gene_name: String, gene_position: i64, codes_protein: bool, nc_num: i64, nc_idx: i64, these_minors: Vec<Alt>, minor_type: MinorType, mutation_name: String) -> Mutation{
|
|
807
|
+
// println!("{} {} -> ", gene_name, mutation_name);
|
|
808
|
+
// for m in these_minors.clone().iter(){
|
|
809
|
+
// println!("{:?}", m);
|
|
810
|
+
// }
|
|
811
|
+
// println!("");
|
|
803
812
|
let mut min_coverage = "".to_string();
|
|
804
813
|
if minor_type == MinorType::COV{
|
|
805
814
|
min_coverage = these_minors.iter().filter(
|
|
@@ -429,6 +429,12 @@ pub fn mutate(reference: &Genome, vcf: VCFFile) -> Genome{
|
|
|
429
429
|
evidence: call.clone()
|
|
430
430
|
});
|
|
431
431
|
|
|
432
|
+
// Mark containing gene as containing a mutation
|
|
433
|
+
// Should make finding genes level mutations easier
|
|
434
|
+
for gene_name in position.genes.iter(){
|
|
435
|
+
new_genome.genes_with_mutations.insert(gene_name.clone());
|
|
436
|
+
}
|
|
437
|
+
|
|
432
438
|
if call.call_type == AltType::DEL{
|
|
433
439
|
position.is_deleted_minor = true;
|
|
434
440
|
for del_idx in 0..call.alt.len(){
|
|
@@ -40,8 +40,15 @@ pub mod gene;
|
|
|
40
40
|
pub mod vcf;
|
|
41
41
|
pub mod difference;
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
#[pymodule]
|
|
45
|
+
/// Grumpy, genetic analysis in Rust.
|
|
46
|
+
///
|
|
47
|
+
/// This library provides a set of tools for genetic analysis, including:
|
|
48
|
+
/// - Genome representation
|
|
49
|
+
/// - Gene representation
|
|
50
|
+
/// - VCF file parsing
|
|
51
|
+
/// - Finding effects of a given VCF file at both genome and gene levels
|
|
45
52
|
fn grumpy(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
46
53
|
m.add_class::<common::AltType>()?;
|
|
47
54
|
m.add_class::<common::MinorType>()?;
|
|
@@ -25,7 +25,7 @@ fn main() {
|
|
|
25
25
|
let vcf_path = &args[2];
|
|
26
26
|
|
|
27
27
|
let vcf_start = SystemTime::now();
|
|
28
|
-
let vcf = VCFFile::new(vcf_path.to_string(), false,
|
|
28
|
+
let vcf = VCFFile::new(vcf_path.to_string(), false, 3);
|
|
29
29
|
let vcf_end = SystemTime::now();
|
|
30
30
|
|
|
31
31
|
let reference_start = SystemTime::now();
|
|
@@ -50,6 +50,7 @@ fn main() {
|
|
|
50
50
|
}
|
|
51
51
|
let gene_end = SystemTime::now();
|
|
52
52
|
|
|
53
|
+
println!("\n-----------------------------------\n");
|
|
53
54
|
println!("VCF took {:?}", vcf_end.duration_since(vcf_start).unwrap());
|
|
54
55
|
println!("Reference took {:?}", reference_end.duration_since(reference_start).unwrap());
|
|
55
56
|
println!("Sample took {:?}", sample_end.duration_since(sample_start).unwrap());
|
|
@@ -136,7 +136,6 @@ impl VCFFile{
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
|
|
139
|
-
|
|
140
139
|
// println!("{:?}\t{:?}\t{:?}\t{:?}\t{:?}", record.position, String::from_utf8_lossy(&record.reference), alts, filters, fields);
|
|
141
140
|
|
|
142
141
|
records.push(VCFRow{
|
|
@@ -148,11 +147,11 @@ impl VCFFile{
|
|
|
148
147
|
is_filter_pass: passed
|
|
149
148
|
});
|
|
150
149
|
|
|
151
|
-
let (record_calls, record_minor_calls) = VCFFile::parse_record_for_calls(records[records.len()-1].clone(), min_dp);
|
|
150
|
+
let (record_calls, mut record_minor_calls) = VCFFile::parse_record_for_calls(records[records.len()-1].clone(), min_dp);
|
|
152
151
|
// println!("Calls {:?}", record_calls);
|
|
153
152
|
// println!("Minor calls {:?}\n", record_minor_calls);
|
|
154
153
|
|
|
155
|
-
for call in record_calls{
|
|
154
|
+
for call in record_calls.iter(){
|
|
156
155
|
let mut added = false;
|
|
157
156
|
if calls_map.contains_key(&call.genome_index){
|
|
158
157
|
println!("Multiple calls at genome position {}! {:?}\n", call.genome_index, calls_map.get(&call.genome_index).unwrap());
|
|
@@ -171,18 +170,13 @@ impl VCFFile{
|
|
|
171
170
|
// Call skipped due to filter fail, so add as a minor call
|
|
172
171
|
let mut c = call.clone();
|
|
173
172
|
c.is_minor = true;
|
|
174
|
-
|
|
175
|
-
minor_calls_map.get_mut(&c.genome_index).unwrap().push(c.clone());
|
|
176
|
-
}
|
|
177
|
-
else{
|
|
178
|
-
minor_calls_map.insert(c.genome_index, vec![c.clone()]);
|
|
179
|
-
}
|
|
173
|
+
record_minor_calls.push(c);
|
|
180
174
|
}
|
|
181
175
|
|
|
182
176
|
}
|
|
183
177
|
// Add minor calls if the filter is passed or ignored, or specifcally just the MIN_FRS has failed
|
|
184
178
|
if (ignore_filter || passed) || (!passed && filters.len() == 1 && filters.contains(&"MIN_FRS".to_string())){
|
|
185
|
-
for call in record_minor_calls{
|
|
179
|
+
for call in record_minor_calls.iter(){
|
|
186
180
|
if minor_calls_map.contains_key(&call.genome_index){
|
|
187
181
|
minor_calls_map.get_mut(&call.genome_index).unwrap().push(call.clone());
|
|
188
182
|
}
|
|
@@ -191,6 +185,19 @@ impl VCFFile{
|
|
|
191
185
|
}
|
|
192
186
|
}
|
|
193
187
|
}
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
// if record.position == 776100{
|
|
191
|
+
// println!("{:?}\t{:?}\t{:?}\t{:?}\t{:?}", record.position, String::from_utf8_lossy(&record.reference), alts, filters, fields);
|
|
192
|
+
// for call in record_calls.iter(){
|
|
193
|
+
// println!("{:?}\n", call);
|
|
194
|
+
// }
|
|
195
|
+
// println!("--");
|
|
196
|
+
// for call in record_minor_calls.iter(){
|
|
197
|
+
// println!("{:?}\n", call);
|
|
198
|
+
// }
|
|
199
|
+
// }
|
|
200
|
+
|
|
194
201
|
// minor_calls.extend(record_minor_calls);
|
|
195
202
|
|
|
196
203
|
// Get the next record
|
|
@@ -305,11 +312,13 @@ impl VCFFile{
|
|
|
305
312
|
alt_allele = record.alternative[alt_idx as usize].clone().to_lowercase();
|
|
306
313
|
let call = VCFFile::simplify_call(ref_allele.clone(), alt_allele.clone());
|
|
307
314
|
let call_cov = cov[(alt_idx + 1) as usize]; // COV should be [ref, alt1, alt2..]
|
|
308
|
-
for (offset,
|
|
315
|
+
for (offset, __alt_type, __base) in call{
|
|
316
|
+
let mut _alt_type = __alt_type;
|
|
317
|
+
let mut _base = __base;
|
|
309
318
|
if call_cov < min_dp{
|
|
310
319
|
// Override calls with null if the coverage is too low
|
|
311
|
-
|
|
312
|
-
|
|
320
|
+
_alt_type = AltType::NULL;
|
|
321
|
+
_base = "x".to_string();
|
|
313
322
|
}
|
|
314
323
|
calls.push(Evidence{
|
|
315
324
|
cov: Some(call_cov),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|