Bowtie2 and subprocess issue
1
0
Entering edit mode
20 months ago
robjohn70000 ▴ 150

Hi,

I tried running bowtie2 in python using subprocess without any success.

Codes:

REFGENOME='/path-to-genome/genome.fasta'

P1='/path-to-fastq/P1.fastq.bz2'
P2='/path-to-fastq/P2.fastq.bz2'

cmd=['bowtie2','--quiet','-p','10','--dovetail','--no-head','--no-sq','-x',REFGENOME,'-1',P1,'-2',P2,'-S', 'out.sam']

subprocess.Popen(cmd, shell=True)

Error:

No index, query, or output file specified!

Does anyone know how to set up subprocess properly to get the code working?

subprocess python • 742 views
ADD COMMENT
2
Entering edit mode
20 months ago
Dave Carlson ★ 1.7k

I typically use subprocess.run for this sort of thing. The following works (tested with python 3.7):

#!/usr/bin/env python

import subprocess

REFGENOME='path/to/indexed/genome.fasta'

P1='/path/to/r1.fq.gz'
P2='path/to/r2.fq.gz'

cmd=['bowtie2','--quiet','-p','10','--dovetail','--no-head','--no-sq','-x',REFGENOME,'-1',P1,'-2',P2,'-S', 'out.sam']

subprocess.run(cmd)
ADD COMMENT
1
Entering edit mode

@Dave Carlson your solution worked for me. Many thanks!

ADD REPLY

Login before adding your answer.

Traffic: 2996 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6