Question: File handling python
0
gravatar for Jonas.Koch
5 months ago by
Jonas.Koch0
Jonas.Koch0 wrote:

Hi!

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"   
list_of_files=glob.glob(path)

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?

Greetings

file handling python • 156 views
ADD COMMENTlink modified 5 months ago by finswimmer12k • written 5 months 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 5 months ago by genomax70k
Please log in to add an answer.

Help
Access

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