Greetings Rustaceans!,
I have been trying to write a shell pipeline for the past couple of days.
This is what I would like to have,
'cmd1 args[...] <inp1> | cmd2 args[...] out_from_cmd1 <inp2> ' | 'cmd3 args <inp3> out_from_pipe1'
Please note the quotes around pipe1 and pipe2.
what I have tried:
let pipe1 = { Exec::cmd("samtools").args(&["fasta", "-f", "0x4", &sam_path]) | Exec::cmd("fasta").args(&["spl it", "interleaved", "-", &anchor_len.to_string()])}.stream_stdout().unwrap();
Hyphen ("-") in the second command is a placeholder for output from the first command. That worked so far!. Now to extend it to the third part, I have added
let test = { Exec::cmd("samtools").args(&["fasta", "-f", "0x4", &sam_path]) | Exec::cmd("fasta").args(&["split ", "interleaved", "-", &anchor_len.to_string()])| Exec::cmd("bowtie").args(&["-f", "-p1", "-v0", "-m1", "-B1", "-- suppress", "5,6,7,8", &genome_path, "-"])};
Well it compiles, no error. But the third command is not receiving any input. I have tried adding .stream_stdout().unwrap()
after the second command, that doesn't compile.
I have same pipeline written in python:
testout = shell_stdout(
'samtools fasta -f 0x4 %s | fasta split interleaved - %d | '
'bowtie -f -p1 -v0 -m1 -B1 --suppress 5,6,7,8 %s -'
% (sam_path, anchor_len, genome_path))
def shell_stdout(command):
return subprocess.Popen(command, stdout=subprocess.PIPE, shell=True, executable='/bin/bash', bufsize=-1).stdout
Any help will be greatly appreciated. This is my first post in any forum. Please bear with me, If I have written anything stupid.