How to merge set of bam files into one?
1
0
Entering edit mode
8 days ago
mrj ▴ 130

is there a pythonic way to merge a set of bam files?

merge bam python pysam • 306 views
ADD COMMENT
3
Entering edit mode

Why does it need to be pythonic? There are far more straightforward command line ways to do this.

ADD REPLY
1
Entering edit mode

Thanks Ram. I am aware of the straightforward ways. I am just curious if I can do this with python.

ADD REPLY
1
Entering edit mode

Got it. We've seen a lot of users that pick tech first, task later so this sort of awareness is not always present. Glad you figured out a solution, it always helps understand the underlying challenges.

ADD REPLY
3
Entering edit mode
8 days ago
mrj ▴ 130

I figured out the answer to this one. I am writing down it here for future me and all other curious people.

import pysam

list_of_bamfiles = [f.bam,f2.bam]

pysam.merge("-f","-o","output.bam",*list_of_bamfile)
# the * before the list unpack the list of arguments
ADD COMMENT

Login before adding your answer.

Traffic: 2234 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