Skip to content

Commit 395478f

Browse files
authored
refactor: untangle data flow structs (#547)
* Extract BarcodeFates type and clean up unnecessary mutability. * Remove a bunch of argument unpacking. * Remove more unnecessary types. * Remove the unused MainEncloneOutput type. * Re-scope creation of to_ref_index. * Remove pre-computed is_bcr/is_tcr in favor of a method. * Remove inline h5 file loading debugging code. * Update a regression test that now outputs a newline for some reason.
1 parent 21dbe33 commit 395478f

File tree

9 files changed

+78
-171
lines changed

9 files changed

+78
-171
lines changed

Cargo.lock

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

enclone_exec/src/bin/enclone.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
9090
// Standard run of enclone.
9191

9292
if args.len() < 2 || args[1] != "SERVER" {
93-
let res = main_enclone(&mut args);
94-
9593
// Test for error.
9694

97-
if res.is_err() {
95+
if let Err(err) = main_enclone(&args) {
9896
// TURNED OFF BECAUSE WE GOT EXIT STATUS ZERO SOMETIMES WHEN WE USED THROUGH COMMAND.
9997
//
10098
// If there was an error and we had used the pager, then std::process::exit(1) will
@@ -108,7 +106,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
108106
//
109107
// The kill makes the screen flash. This is pretty horrible.
110108

111-
eprintln!("{}", res.as_ref().err().unwrap());
109+
eprintln!("{err}");
112110
if !no_kill && USING_PAGER.load(SeqCst) && 0 == 1 {
113111
thread::sleep(Duration::from_millis(10));
114112
#[cfg(not(target_os = "windows"))]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

enclone_main/src/main_enclone.rs

+15-20
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ use vector_utils::{bin_member, next_diff, unique_sort};
2828

2929
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
3030

31-
pub fn main_enclone(args: &Vec<String>) -> Result<EncloneState, String> {
31+
pub fn main_enclone(args: &Vec<String>) -> Result<(), String> {
3232
let setup = main_enclone_setup(args)?;
3333
if setup.tall.is_none() {
34-
return Ok(EncloneState::default());
34+
return Ok(Default::default());
3535
}
36-
let inter = main_enclone_start(setup)?;
37-
if inter.setup.tall.is_none() {
38-
return Ok(EncloneState::default());
36+
let (exacts, fate) = main_enclone_start(&setup)?;
37+
if setup.tall.is_none() {
38+
return Ok(Default::default());
3939
}
40-
main_enclone_stop(inter)
40+
main_enclone_stop(&setup, &exacts, fate)
4141
}
4242

4343
pub fn main_enclone_setup(args: &Vec<String>) -> Result<EncloneSetup, String> {
@@ -340,18 +340,15 @@ pub fn main_enclone_setup(args: &Vec<String>) -> Result<EncloneSetup, String> {
340340
let refx2 = &refx;
341341
let mut refdata = RefData::new();
342342
let ext_refx = String::new();
343-
let (mut is_tcr, mut is_bcr) = (true, true);
344-
if ctl.gen_opt.tcr {
345-
is_bcr = false;
346-
}
347-
if ctl.gen_opt.bcr {
348-
is_tcr = false;
349-
}
350-
make_vdj_ref_data_core(&mut refdata, refx2, &ext_refx, is_tcr, is_bcr, None);
351-
let mut to_ref_index = HashMap::<usize, usize>::new();
352-
for i in 0..refdata.refs.len() {
353-
to_ref_index.insert(refdata.id[i] as usize, i);
354-
}
343+
344+
make_vdj_ref_data_core(
345+
&mut refdata,
346+
refx2,
347+
&ext_refx,
348+
ctl.gen_opt.is_tcr(),
349+
ctl.gen_opt.is_bcr(),
350+
None,
351+
);
355352

356353
// Determine if the species is human or mouse or unknown.
357354

@@ -407,7 +404,5 @@ pub fn main_enclone_setup(args: &Vec<String>) -> Result<EncloneSetup, String> {
407404
ann: ann.to_string(),
408405
gex_info,
409406
tall: Some(tall),
410-
is_bcr,
411-
to_ref_index,
412407
})
413408
}

0 commit comments

Comments
 (0)