Convert Bam file to Fastq
1
0
Entering edit mode
3 months ago
وفاء • 0

I used samtools to convert Bam paired files to Fastq, and I'd like to see if the conversion was successful. I attempted to check the read names with the following commands:

comm -1 -2 bam_read_names.txt (paste fastq1_read_ids.txt fastq2_read_ids.txt | sort) > common_read_names.txt

However, the common_read_names.txt file is empty.

How do you tackle this problem and ensure that the conversion is correct? Is there another way to check?

Fastq Bam • 423 views
ADD COMMENT
0
Entering edit mode

paste fastq1_read_ids.txt fastq2_read_ids.txt is a tabular file with two column. Is it the same for bam_read_names.txt ?

ADD REPLY
0
Entering edit mode

At first, I would trust samtools to do the right thing but of course it doesn't hurt to double check. But I think the crux is what is in fastq1|2_reads_ids.txt and bam read_read_names.txt and how did you get them? The first thing I would do always is look at the files and also the fastq files using head or less. Likely the files are properly sorted already, then you will immediately see what's wrong. If they are not properly sorted you have to do that too. Because for this command to work both files need to be sorted in the same way. comm also has an option --check-order that might help you there.

ADD REPLY
0
Entering edit mode
3 months ago
Michael 53k

I think your code is incorrect bash syntax. I think you want something like this:

sort bam_headers.txt > bam_haeders-sorted.txt # comm can only read one of the input file from STDIN so we need to sort the other file first
paste -d "\n" fq1_headers.txt fq2_headers.txt | sort | comm -1 -2 bam_headers-sorted.txt -
## paste using delimiter "\n" should create an interleaved file of both input files.
ADD COMMENT

Login before adding your answer.

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