using python to write bioinformatics pipelines tutorial I was wondering if there is a tutorial or a small code snippet to understand how to write bioinformatics pipeline using python, for example


use a aligner (say hisat) 
get the output and process it using samtools 


I was able to use subprocess from python2.7 for this purpose using samtools but i am not able to link both the processes.i.e given path(which I can use argparse) for directory with fastq files output would be processed bam. 

sample code for samtools sam to bam :

import subprocess
subprocess.run(['samtools','view', '-bS',
                '../some.sam',
                '&gt;',
                '../some.bam'])
Taking a different tack from other answers, there's lots of tools for pipelines in Python. Note: there was a time when people would use "pipeline" to refer to a shell script. I'm talking about something more sophisticated that helps you decompose an analysis into parts and  runs it robustly.


Snakemake is my favourite. It's (nearly) pure Python and can generate reports.
Nextflow is growing in popularity and is pretty straightforward
Ruffus used to be reasonably popular, seemed fine when I used it
Bpipe is for bioinformatics
Airflow is a more industrial "big" solution but in wide use
See this big list of pipeline systems


I'm sure you can find something there.