I’m facing an awkward problem using the subprocess.call operator in python for a script.
I have to run a pipeline program (bowtie) multiple times and then use the output in different ways. For that purpose, I’m using the subprocess.call.
Problem is that bowtie takes in input 2 files, an index and a text file, and I can’t assign both of them to the stdin parameter.
I’ve tried also to include the path to the index in the args, but of course bowtie does not recognize it as index and give me an error. Sincer this index is always the same, is there a way to avoid this problem?
Here’s part of the code i’m working on (very raw):
inpath = "/media/2tbhd/workdata/nanocage_noadapt/zf/fasta/zf_ad_c_r2.fasta"
ind_path = "indexes/zf_gen_topl"
for elem in plist:
cmd = subprocess.call(["bowtie","-f","-v 3", "--best" "--suppress 6,7" "-p 6"], shell = True, stdin = inpath, ind_path)
I don’t know anything about
bowtie, but it seems to me that your call should be something like:Typically, you pass the list of arguments to subprocess exactly as you would have them on the commandline. If you know what the command line would look like, you can use the wonderful
shlexmodule to split the command. e.g.: