I am writing a program that runs qiime. I need the program to recognize numbers that the user types on the command line, but I think that subprocess.call may not be able to tell that the numbers are integers.
What I have so far:
# Items to import
import subprocess
import argparse
from sys import argv
#Variables
parser=argparse.ArgumentParser()
parser.add_argument('--trim-forward', type=int, required=True)
parser.add_argument('--trim-reverse', type=int, required=True)
parser.add_argument('--truncate-forward', type=int, required=True)
parser.add_argument('--truncate-reverse', type=int, required=True)
parser.add_argument('--max-ee', type=int, required=True)
# Denoise
cmnd = ['qiime', 'dada2', 'denoise-paired', '--i-demultiplexed-seqs', 'paired-end-demux.qza', '--o-table', 'table.qza', '--o-representative-sequences', 'rep-seqs.qza', '--p-trim-left-f {}'.format(argv[2]), '--p-trim-left-r {}'.format(argv[4]), '--p-trunc-len-f {}'.format(argv[6]), '--p-trunc-len-r {}'.format(argv[8]), '--p-max-ee {}'.format(argv[10])]
print('executing {}'.format(''.join(cmnd)))
res = subprocess.call(cmnd)
print('command terminated with status', res)
Running this program returns errors. Any ideas on how I can tell subprocess.call that these are integers, not strings?
Thank you!
This is not really about integers/strings but actually about the parsing of the options with spaces.
In all the places where you have
"--some-option {}".format(some_value)
Change it to:
"--some-option={}".format(some_value)