Skip to main content
added 148 characters in body
Source Link
Bioathlete
  • 2.6k
  • 13
  • 30

BioPython has some good tools for processing reads and alignments. http://biopython.org/DIST/docs/tutorial/Tutorial.html

There is a python library wrapping samtools so many of the samtools calls can be used directly as python objects and calls https://pysam.readthedocs.io/en/latest/

I would use subprocess to call the aligner and specify the output to a bam file that you have named and then read that bam file with pysam to do the analysis that you are interested in.

If you provide more specifics about the analysis or aligners I can help you more but you are in the right track just need to connect the two calls together.

example:

import subprocess
import pysam
import os 

for root, dirs, files in os.walk(rootPath):
    for filename in fnmatch.filter(files, ".fastq"):

        subprocess.run([`hisat`, `some options``-f`, filename `-o`, `some.bam`])

        #get depth
        depth = pysam.depth('some.bam')

BioPython has some good tools for processing reads and alignments. http://biopython.org/DIST/docs/tutorial/Tutorial.html

There is a python library wrapping samtools so many of the samtools calls can be used directly as python objects and calls https://pysam.readthedocs.io/en/latest/

I would use subprocess to call the aligner and specify the output to a bam file that you have named and then read that bam file with pysam to do the analysis that you are interested in.

If you provide more specifics about the analysis or aligners I can help you more but you are in the right track just need to connect the two calls together.

example:

import subprocess
import pysam

subprocess.run([`hisat`, `some options`, `-o`, `some.bam`])

#get depth
depth = pysam.depth('some.bam')

BioPython has some good tools for processing reads and alignments. http://biopython.org/DIST/docs/tutorial/Tutorial.html

There is a python library wrapping samtools so many of the samtools calls can be used directly as python objects and calls https://pysam.readthedocs.io/en/latest/

I would use subprocess to call the aligner and specify the output to a bam file that you have named and then read that bam file with pysam to do the analysis that you are interested in.

If you provide more specifics about the analysis or aligners I can help you more but you are in the right track just need to connect the two calls together.

example:

import subprocess
import pysam
import os 

for root, dirs, files in os.walk(rootPath):
    for filename in fnmatch.filter(files, ".fastq"):

        subprocess.run([`hisat`, `-f`, filename `-o`, `some.bam`])

        #get depth
        depth = pysam.depth('some.bam')
Source Link
Bioathlete
  • 2.6k
  • 13
  • 30

BioPython has some good tools for processing reads and alignments. http://biopython.org/DIST/docs/tutorial/Tutorial.html

There is a python library wrapping samtools so many of the samtools calls can be used directly as python objects and calls https://pysam.readthedocs.io/en/latest/

I would use subprocess to call the aligner and specify the output to a bam file that you have named and then read that bam file with pysam to do the analysis that you are interested in.

If you provide more specifics about the analysis or aligners I can help you more but you are in the right track just need to connect the two calls together.

example:

import subprocess
import pysam

subprocess.run([`hisat`, `some options`, `-o`, `some.bam`])

#get depth
depth = pysam.depth('some.bam')