2

I would like to run the python script where the input is taken from unix cat function but I also want to give it few additional arguments in sys.argv, it should run in the following way:

cat my_fasta_sequence.txt | get_region.py 193 445

get_region function will take an input from fasta sequence slice from 193 445 and save it as a new file.

I use sys.stdin to take the input from cat function, however I am not sure how to make python to take the numbers (193,445) as an input at the same time.

Ekat Sim
  • 115
  • 6
  • `sys.argv[1]` will be `'193'` and `sys.argv[2]` will be `'445'` in your example – anthony sottile Sep 27 '20 at 20:06
  • In other words, `sys.argv` input is independent of `sys.stdin` arguments. – martineau Sep 27 '20 at 20:09
  • How do you have your incoming args setup in the script, looks the two numbers are passed upon command line execution. Possible solutions within this SO [post](https://stackoverflow.com/questions/1009860/how-to-read-process-command-line-arguments). – de_classified Sep 27 '20 at 20:09
  • Anthony Sottile, when I set it as you say I am getting IndexError: list index out of range – Ekat Sim Sep 27 '20 at 20:16

0 Answers0