Question: File handling python
gravatar for Jonas.Koch
8 days ago by
Jonas.Koch0 wrote:


I extracted mapped and unmapped reads of different BAM files using a bash script. Now, I want to compare which reads are in which BAM files in python.

I imagined to use python sets (union, intersection) to do that. Unfortunately, I have only little python experience. I already could write a script that does the job, but without using loops etc for automation.

I tried this:

import glob

path = "/path/to/files/*.txt"   

Now, I want to read in all lines of the files using readlines(), and store the output in separate variables to create sets using the .update() function. Do you have an idea how to do that?


file handling python • 76 views
ADD COMMENTlink modified 8 days ago by finswimmer11k • written 8 days ago by Jonas.Koch0

While your desire to learn python is commendable this may be a bit of a heavy lift to tackle as the first python coding challenge.

In this specific instance you may be able to use the solution @Pierre has in this thread: Find common reads between two bam files

ADD REPLYlink written 7 days ago by genomax64k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2219 users visited in the last hour