How to sort a FASTA file and (its) BAM file in the same order?
1
0
Entering edit mode
3 months ago
Dunois ▴ 740

Exactly what the title says.

I'd like to sort the FASTA and BAM files in the same order (for reasons). Can samtools do this or would this need some scripting (e.g., sorting an intermediate SAM file and subsequently converting it to BAM)?

I do apologize if this a simple question that is already answered elsewhere.

fasta bam samtools • 166 views
ADD COMMENT
0
Entering edit mode
3 months ago
GenoMax 100k

You should be able to name sort your BAM (use samtools sort -n). Linearize your fasta file and then sort it based on first column (which will contain the fasta header). They should be in the same order then.

You could usebbmap.sh to do the alignments in first place with the following option.

ordered=f               Set to true to output reads in same order as input.
                        Slower and uses more memory.
ADD COMMENT

Login before adding your answer.

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