pub fn bwa_mem_align(ref_name: &str, reads_names: &Reads, result_file: &str, bwa_threads: u16) {
    // first, create the absolute filepaths from the relative filepaths of the ref and reads (throw an error if they don't exist)
    let ref_path: PathFile = absolute_filepath_checked(ref_name);
    let ref_path_os_str: &OsStr = ref_path.as_ref();
    let ref_path_str: &str = ref_path_os_str.to_str().unwrap();

    let absolute_reads: Reads = match reads_names {
        Reads::SingleEnd(filename) => {
            let file_path: PathFile = absolute_filepath_checked(filename);
            let file_path_os_str: &OsStr = file_path.as_ref();
            let file_path_str: &str = file_path_os_str.to_str().unwrap();
            Reads::SingleEnd(file_path_str.to_owned())
        }
        Reads::PairedEnds(file1, file2) => {
            let file1_path: PathFile = absolute_filepath_checked(file1);
            let file1_path_os_str: &OsStr = file1_path.as_ref();
            let file1_path_str: &str = file1_path_os_str.to_str().unwrap();

            let file2_path: PathFile = absolute_filepath_checked(file2);
            let file2_path_os_str: &OsStr = file2_path.as_ref();
            let file2_path_str: &str = file2_path_os_str.to_str().unwrap();

            Reads::PairedEnds(file1_path_str.to_owned(), file2_path_str.to_owned())
        }
    };

    // now do the alignment and store in the result file
    println!("Waiting for bwa mem...");
    match absolute_reads {
        Reads::SingleEnd(filepath) => {
            println!(
                "bwa mem -t {} -o {} {} {}",
                &bwa_threads.to_string()[..],
                &result_file[..],
                ref_path_str,
                &filepath[..]
            );
            let mut child_proc = Command::new("bwa")
                .args(&[
                    "mem",
                    "-t",
                    &bwa_threads.to_string()[..],
                    "-o",
                    &result_file[..],
                    ref_path_str,
                    &filepath[..],
                ])
                .spawn()
                .unwrap();
            let _result = child_proc.wait().unwrap();
        }
        Reads::PairedEnds(file1, file2) => {
            let mut child_proc = Command::new("bwa")
                .args(&[
                    "mem",
                    "-t",
                    &bwa_threads.to_string()[..],
                    "-o",
                    &result_file[..],
                    ref_path_str,
                    &file1[..],
                    &file2[..],
                ])
                .spawn()
                .unwrap();
            let _result = child_proc.wait().unwrap();
        }
    }
    println!("Alignment complete");
}
// does an alignment using BWA MEM
does an alignment using BWA MEM
does an alignment using BWA MEM
pub fn bwa_mem_align(ref_name: &str, reads_names: &Reads, result_file: &str, bwa_threads: u16) {
    // first, create the absolute filepaths from the relative filepaths of the ref and reads (throw an error if they don't exist)
    let ref_path: PathFile = absolute_filepath_checked(ref_name);
    let ref_path_os_str: &OsStr = ref_path.as_ref();
    let ref_path_str: &str = ref_path_os_str.to_str().unwrap();
    let absolute_reads: Reads = match reads_names {
        Reads::SingleEnd(filename) => {
            let file_path: PathFile = absolute_filepath_checked(filename);
            let file_path_os_str: &OsStr = file_path.as_ref();
            let file_path_str: &str = file_path_os_str.to_str().unwrap();
            Reads::SingleEnd(file_path_str.to_owned())
        }
        Reads::PairedEnds(file1, file2) => {
            let file1_path: PathFile = absolute_filepath_checked(file1);
            let file1_path_os_str: &OsStr = file1_path.as_ref();
            let file1_path_str: &str = file1_path_os_str.to_str().unwrap();
            let file2_path: PathFile = absolute_filepath_checked(file2);
            let file2_path_os_str: &OsStr = file2_path.as_ref();
            let file2_path_str: &str = file2_path_os_str.to_str().unwrap();
            Reads::PairedEnds(file1_path_str.to_owned(), file2_path_str.to_owned())
        }
    };
    // now do the alignment and store in the result file
    println!("Waiting for bwa mem...");
    match absolute_reads {
        Reads::SingleEnd(filepath) => {
            println!(
                "bwa mem -t {} -o {} {} {}",
                &bwa_threads.to_string()[..],
                &result_file[..],
                ref_path_str,
                &filepath[..]
            );
            let mut child_proc = Command::new("bwa")
                .args(&[
                    "mem",
                    "-t",
                    &bwa_threads.to_string()[..],
                    "-o",
                    &result_file[..],
                    ref_path_str,
                    &filepath[..],
                ])
                .spawn()
                .unwrap();
            let _result = child_proc.wait().unwrap();
        }
        Reads::PairedEnds(file1, file2) => {
            let mut child_proc = Command::new("bwa")
                .args(&[
                    "mem",
                    "-t",
                    &bwa_threads.to_string()[..],
                    "-o",
                    &result_file[..],
                    ref_path_str,
                    &file1[..],
                    &file2[..],
                ])
                .spawn()
                .unwrap();
            let _result = child_proc.wait().unwrap();
        }
    }
    println!("Alignment complete");
}
pub fn bwa_mem_align ( ref_name : & str , reads_names : & Reads , result_file : & str , bwa_threads : u16 ) { // first, create the absolute filepaths from the relative filepaths of the ref and reads (throw an error if they don't exist) let ref_path : PathFile = absolute_filepath_checked ( ref_name ) ; let ref_path_os_str : & OsStr = ref_path . as_ref ( ) ; let ref_path_str : & str = ref_path_os_str . to_str ( ) . unwrap ( ) ; let absolute_reads : Reads = match reads_names { Reads :: SingleEnd ( filename ) => { let file_path : PathFile = absolute_filepath_checked ( filename ) ; let file_path_os_str : & OsStr = file_path . as_ref ( ) ; let file_path_str : & str = file_path_os_str . to_str ( ) . unwrap ( ) ; Reads :: SingleEnd ( file_path_str . to_owned ( ) ) } Reads :: PairedEnds ( file1 , file2 ) => { let file1_path : PathFile = absolute_filepath_checked ( file1 ) ; let file1_path_os_str : & OsStr = file1_path . as_ref ( ) ; let file1_path_str : & str = file1_path_os_str . to_str ( ) . unwrap ( ) ; let file2_path : PathFile = absolute_filepath_checked ( file2 ) ; let file2_path_os_str : & OsStr = file2_path . as_ref ( ) ; let file2_path_str : & str = file2_path_os_str . to_str ( ) . unwrap ( ) ; Reads :: PairedEnds ( file1_path_str . to_owned ( ) , file2_path_str . to_owned ( ) ) } } ; // now do the alignment and store in the result file println ! ( " " ) ; match absolute_reads { Reads :: SingleEnd ( filepath ) => { println ! ( " " bwa_threads to_string ( ) [ ] result_file [ ] ref_path_str filepath [ ] ) ; let mut child_proc = Command :: new ( " " ) . args ( & [ " " , " " , & bwa_threads . to_string ( ) [ .. ] , " " , & result_file [ .. ] , ref_path_str , & filepath [ .. ] , ] ) . spawn ( ) . unwrap ( ) ; let _result = child_proc . wait ( ) . unwrap ( ) ; } Reads :: PairedEnds ( file1 , file2 ) => { let mut child_proc = Command :: new ( " " ) . args ( & [ " " , " " , & bwa_threads . to_string ( ) [ .. ] , " " , & result_file [ .. ] , ref_path_str , & file1 [ .. ] , & file2 [ .. ] , ] ) . spawn ( ) . unwrap ( ) ; let _result = child_proc . wait ( ) . unwrap ( ) ; } } println ! ( " " ) ; }
does an alignment using BWA MEM
does an alignment using BWA MEM
ref_name
&str
reads_names
&Reads
result_file
&str
bwa_threads
u16
ref_name
&str
reads_names
&Reads
result_file
&str
bwa_threads
u16