File handling python
0
0
Entering edit mode
5.1 years ago
Jonas.Koch • 0

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 • 648 views
ADD COMMENT
1
Entering edit mode

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 REPLY

Login before adding your answer.

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