@@ -6,7 +6,10 @@ use crate::io::file::open_file_or_stdin;
66use crate :: io:: fs:: path_to_str;
77use crate :: pangraph:: pangraph_block:: { BlockId , PangraphBlock } ;
88use crate :: utils:: subprocess:: create_arg_optional;
9+ use crate :: { make_error, vec_of_owned} ;
10+ use color_eyre:: { Section , SectionExt } ;
911use eyre:: { Report , WrapErr } ;
12+ use itertools:: Itertools ;
1013use std:: collections:: BTreeMap ;
1114use std:: io:: Read ;
1215use std:: process:: Command ;
@@ -32,33 +35,32 @@ pub fn align_with_mmseqs(
3235 }
3336
3437 let output_column_names = PafTsvRecord :: fields_names ( ) . join ( "," ) ;
35- let k = create_arg_optional ( "-k" , & params. kmer_length ) ;
3638
37- let cmd_outcome = Command :: new ( "mmseqs" )
38- . arg ( "easy-search" )
39- . arg ( & input_path)
40- . arg ( & input_path)
41- . arg ( & output_path)
42- . arg ( & tmp_path)
43- . arg ( "--threads" )
44- . arg ( "1" )
45- . arg ( "--max-seq-len" )
46- . arg ( "10000" )
47- . arg ( "-a" )
48- . arg ( "--search-type" )
49- . arg ( "3" )
50- . arg ( "--format-output" )
51- . arg ( & output_column_names)
52- . args ( & k)
53- . output ( )
54- . wrap_err ( "When trying to align sequences using mmseqs" ) ?;
39+ let mut args = vec_of_owned ! [
40+ "easy-search" ,
41+ & input_path,
42+ & input_path,
43+ & output_path,
44+ & tmp_path,
45+ "--thread" ,
46+ "1" ,
47+ "--max-seq-len" ,
48+ "10000" ,
49+ "-a" ,
50+ "--search-type" ,
51+ "3" ,
52+ "--format-output" ,
53+ & output_column_names,
54+ ] ;
5555
56- if !cmd_outcome. status . success ( ) {
57- return Err ( Report :: msg ( format ! (
58- "mmseqs command {}\n failed with stderr:\n {}" ,
59- cmd_outcome. status,
60- String :: from_utf8_lossy( & cmd_outcome. stderr) . trim( )
61- ) ) ) ;
56+ args. extend ( create_arg_optional ( "-k" , & params. kmer_length ) ) ;
57+
58+ let cmd = Command :: new ( "mmseqs" ) . args ( & args) . output ( ) ?;
59+
60+ if !cmd. status . success ( ) {
61+ return make_error ! ( "{}" , String :: from_utf8( cmd. stderr) ?. trim( ) )
62+ . wrap_err_with ( || format ! ( "mmseqs failed with exit code {}" , cmd. status. code( ) . unwrap( ) ) )
63+ . with_section ( || format ! ( "mmseqs {}" , args. join( " " ) ) . header ( "Full command line was:" ) ) ;
6264 }
6365
6466 let mut paf_str = String :: new ( ) ;
0 commit comments