Skip to content

Commit 6fe39e0

Browse files
authored
Refactor annotation tuple (#536)
* updated to use struct with fN fields * updated fN to real name * fmt * updated enclone_ranger * updated enclone_ranger * update enclone_ranger * update enclone_ranger * update enclone_ranger * set enclone_ranger to follow main
1 parent 98d3b06 commit 6fe39e0

File tree

5 files changed

+52
-51
lines changed

5 files changed

+52
-51
lines changed

Cargo.lock

+30-30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

enclone_paper/src/bin/olga_splice.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::env;
1717
use std::io::{BufRead, Write};
1818
use string_utils::strme;
1919
use string_utils::TextUtils;
20-
use vdj_ann::annotate::{annotate_seq, get_cdr3_using_ann};
20+
use vdj_ann::annotate::{annotate_seq, get_cdr3_using_ann, Annotation};
2121
use vdj_ann::refx::make_vdj_ref_data_core;
2222
use vdj_ann::refx::RefData;
2323
use vdj_ann_ref::human_ref;
@@ -205,11 +205,11 @@ fn main() {
205205
fwriteln!(log, "\ncdr3[{}] = {}\n", i + 1, cdr3[i]);
206206
fwriteln!(log, "seq[{}] = {}\n", i + 1, strme(&seq));
207207
let x = DnaString::from_dna_string(&strme(&seq));
208-
let mut ann = Vec::<(i32, i32, i32, i32, i32)>::new();
208+
let mut ann = Vec::<Annotation>::new();
209209
annotate_seq(&x, &refdata, &mut ann, true, false, true);
210-
let mut annv = Vec::<(i32, i32, i32, i32, i32)>::new();
210+
let mut annv = Vec::<Annotation>::new();
211211
for i in 0..ann.len() {
212-
let t = ann[i].2 as usize;
212+
let t = ann[i].ref_id as usize;
213213
if refdata.is_v(t) {
214214
annv.push(ann[i]);
215215
}
@@ -255,7 +255,7 @@ fn main() {
255255
let mut v_ref_id = None;
256256
let mut j_ref_id = None;
257257
for i in 0..ann.len() {
258-
let t = ann[i].2 as usize;
258+
let t = ann[i].ref_id as usize;
259259
if refdata.is_v(t) {
260260
v_ref_id = Some(t);
261261
} else if refdata.is_j(t) {
@@ -325,8 +325,8 @@ fn main() {
325325
let mut seq_start = vstart as isize;
326326
// probably not exactly right
327327
if annv.len() > 1 {
328-
let q1 = annv[0].0 + ann[0].1;
329-
let q2 = annv[1].0;
328+
let q1 = annv[0].tig_start + ann[0].match_len;
329+
let q2 = annv[1].tig_start;
330330
seq_start += q2 as isize - q1 as isize;
331331
}
332332
let mut seq_end = seq.len() - (jref.len() - jend);

enclone_tail/src/align_n.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,9 @@ pub fn align_n(
339339
let mut seq_start = vstart as isize;
340340
// probably not exactly right
341341
if ex.share[r].annv.len() > 1 {
342-
let q1 = ex.share[r].annv[0].0 + ex.share[r].annv[0].1;
343-
let q2 = ex.share[r].annv[1].0;
342+
let q1 = ex.share[r].annv[0].tig_start
343+
+ ex.share[r].annv[0].match_len;
344+
let q2 = ex.share[r].annv[1].tig_start;
344345
seq_start += q2 as isize - q1 as isize;
345346
}
346347
let mut seq_end = seq.len() - (jref.len() - jend);

enclone_tools/src/bin/annotate_seq.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ fn main() {
142142
fwriteln!(log, "\nFW ANNOTATION VERSUS PLAIN REFERENCE\n");
143143
}
144144
print_annotations(&seq, &refdata, &mut log, false, true, verbose);
145-
let mut ann = Vec::<(i32, i32, i32, i32, i32)>::new();
145+
let mut ann = Vec::<Annotation>::new();
146146
annotate_seq(&seq, &refdata, &mut ann, true, false, true);
147147
print_cdr3_using_ann(&seq, &refdata, &ann, &mut log);
148148
print_start_codon_positions(&seq, &mut log);
@@ -161,20 +161,20 @@ fn main() {
161161
let (mut v, mut j) = (None, None);
162162
let (mut vstart, mut jstop) = (0, 0);
163163
for i in 0..ann.len() {
164-
let t = ann[i].2 as usize;
164+
let t = ann[i].ref_id as usize;
165165
if refdata.rtype[t] == 0 as i32 || refdata.rtype[t] == 4 as i32 {
166166
if refdata.is_v(t) {
167167
v = Some(t);
168168
} else if refdata.is_j(t) {
169169
j = Some(t);
170-
jstop = (ann[i].0 + ann[i].1) as usize;
170+
jstop = (ann[i].tig_start + ann[i].match_len) as usize;
171171
}
172172
}
173173
}
174174
for i in 0..ann.len() {
175-
let t = ann[i].2 as usize;
175+
let t = ann[i].ref_id as usize;
176176
if refdata.is_v(t) {
177-
vstart = ann[i].0 as usize;
177+
vstart = ann[i].tig_start as usize;
178178
break;
179179
}
180180
}

enclone_tools/src/bin/annotate_seqs.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,19 @@ fn main() {
7979
let mut log = Vec::<u8>::new();
8080
fwriteln!(log, ", len = {}", len);
8181
print_annotations(&seq, &refdata, &mut log, false, true, false);
82-
let mut ann = Vec::<(i32, i32, i32, i32, i32)>::new();
82+
let mut ann = Vec::<Annotation>::new();
8383
annotate_seq(&seq, &refdata, &mut ann, true, false, true);
8484
let (valid, _) = is_productive_contig(&seq, &refdata, &ann);
8585
let mut shift = false;
8686
for i in 1..ann.len() {
87-
if ann[i - 1].2 == ann[i].2 {
88-
if ann[i].0 == ann[i - 1].0 + ann[i - 1].1 + 1
89-
&& ann[i].3 == ann[i - 1].3 + ann[i - 1].1
87+
if ann[i - 1].ref_id == ann[i].ref_id {
88+
if ann[i].tig_start == ann[i - 1].tig_start + ann[i - 1].match_len + 1
89+
&& ann[i].ref_start == ann[i - 1].ref_start + ann[i - 1].match_len
9090
{
9191
shift = true;
9292
}
93-
if ann[i].0 == ann[i - 1].0 + ann[i - 1].1
94-
&& ann[i].3 == ann[i - 1].3 + ann[i - 1].1 + 1
93+
if ann[i].tig_start == ann[i - 1].tig_start + ann[i - 1].match_len
94+
&& ann[i].ref_start == ann[i - 1].ref_start + ann[i - 1].match_len + 1
9595
{
9696
shift = true;
9797
}
@@ -102,7 +102,7 @@ fn main() {
102102
}
103103
let mut match_len = 0;
104104
for j in 0..ann.len() {
105-
match_len += ann[j].1;
105+
match_len += ann[j].match_len;
106106
}
107107
let mut log0 = Vec::<u8>::new();
108108
print_cdr3_using_ann(&seq, &refdata, &ann, &mut log0);

0 commit comments

Comments
 (0)