r/IPython • • Oct 12 '23

Embedding iPython Shell Commands into Regular Python Script

I have developed a bioinformatics pipeline within a Jupyter notebook (iPython) allowing me to easily validate results along the way with graphs etc.

Many of the key processing steps use shell commands and third-party unix programs called with iPython ! Moreover, I’ve made extensive use of variable interpolation, i.e., {var}, to use Python defined values within system shell calls. Everything works as expected.

What I would like to do now is simply convert this to a Python script. Any advice on how to do this without re-writing all the system calls using subprocess module?

Best I can think of is to strip down notebook to key cells and then run with nbconvert. I believe this would work, however, ideally, I would like this pipeline to live in ordinary Python.

Thanks in advance for any advice.

2 Upvotes

2 comments sorted by

View all comments

Show parent comment

1

u/prairie-guy Oct 13 '23

Thank you. I will post here if I find anyway of doing this with out of subprocess.