How to sort a FASTA file and (its) BAM file in the same order?
1
0
Entering edit mode
3.2 years ago
Dunois ★ 2.5k

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 • 956 views
ADD COMMENT
1
Entering edit mode
3.2 years ago
GenoMax 141k

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: 2789 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