<p>I was wondering if any one has had success merging pre-generated reference index files for BWA, bowtie2 from multiple references? </p>

<p>For a concrete example I have hg19 and a bunch of viral and bacterial genomes that all have been index separately but I want to do a single alignment to all of them.  Is there a way I could say combine hg19, virus_A, virus_D and bacteria_X into a single reference without having to regenerate the indexes?  Since the problem could get combinatorial quickly and indexing anything with hg19 is time consuming I was wondering if there was a way around it.</p>

CC BY-SA 4.0
2019-04-04T15:34:58.960Z
this will likely depend on the tool no? i doubt there is a *generic* why to merge indexes? for `BLAST`, there is `blastdb_aliastool`
Chris_Rands
CC BY-SA 4.0
2019-04-04T16:09:53.620Z
Yeah, I would split this into separate questions for each tool. I don't actually know how the blast index works, but I would be very surprised if the same approach will work for all three tools. It might be the same for bowtie and bwa, but blast will likely be different.
terdon
CC BY-SA 4.0
2019-04-04T19:59:58.160Z
Agreed I wasn't looking for a generic tools but the question does read that way.  I was looking for a way for each of those tools.  Thanks @Chris_Rands ill check out `blastdb_aliastool`
Bioathlete
CC BY-SA 4.0
2019-04-05T08:34:27.670Z
What would you be aligning? Short reads? Why would you want to align the same data against three so different genomes? Surely the time you would save by not re-indexing would be lost again while wasting time aligning to the wrong genome, right?
terdon
CC BY-SA 4.0
2019-04-05T12:12:44.440Z
@terdon I imagine they have metagenomic data or similar where the sample composition is not known a priori (reads could be 90% human, 8% E. coli etc.)
Chris_Rands
CC BY-SA 4.0
2019-04-05T12:28:56.117Z
@Chris_Rands duh, indeed, should have thought of that, thanks.
terdon
CC BY-SA 4.0
2019-04-05T14:17:31.767Z
@terdon Correct we don't know the make up of the sample and want to have the reads complete for alignments
Bioathlete
CC BY-SA 4.0
2019-04-05T14:24:46.527Z
That makes perfect sense for [your BLAST question](https://bioinformatics.stackexchange.com/q/7386/298) but I would be wary of using it for short reads. Even between bacteria and humans there are bound to be regions of homology. I would be very curious to know how well this works if you do manage to do it! Maybe by assigning the viral and bacterial genomes as extra "chromosomes" in a single multi-fasta file along with hg19 and indexing that?
terdon
CC BY-SA 4.0
2019-04-05T14:53:21.283Z
@terdon The multi-fasta is the base case I was hoping not to have to reindex the different combinations but will either do that or create one giant reference
Bioathlete
CC BY-SA 4.0
2019-04-05T14:57:19.690Z
Could some of these help? [1](https://f1000researchdata.s3.amazonaws.com/manuscripts/17815/b3840e4e-8d44-4cf8-891b-2aa7a1c32122_15931_-_steven_wingett_v2.pdf?doi=10.12688/f1000research.15931.2&numberOfBrowsableCollections=15&numberOfBrowsableGateways=23), [2](https://academic.oup.com/bioinformatics/article/29/13/i361/189733), [3](https://genomebiology.biomedcentral.com/articles/10.1186/gb-2009-10-9-r98)?
terdon
<read-mapping><genome-index>
Merging/concatenating index files
# Merging/concatenating index files

(Asked by: username_0 on 2019-04-04)

I was wondering if any one has had success merging pre-generated reference index files for BWA, bowtie2 from multiple references?

For a concrete example I have hg19 and a bunch of viral and bacterial genomes that all have been index separately but I want to do a single alignment to all of them. Is there a way I could say combine hg19, virus\_A, virus\_D and bacteria\_X into a single reference without having to regenerate the indexes? Since the problem could get combinatorial quickly and indexing anything with hg19 is time consuming I was wondering if there was a way around it.

**Tags:** read-mapping, genome-index
> **Comments:**
> **username_1**: this will likely depend on the tool no? i doubt there is a *generic* why to merge indexes? for `BLAST`, there is `blastdb_aliastool`  
> **username_2**: Yeah, I would split this into separate questions for each tool. I don't actually know how the blast index works, but I would be very surprised if the same approach will work for all three tools. It might be the same for bowtie and bwa, but blast will likely be different.  
> **username_0**: Agreed I wasn't looking for a generic tools but the question does read that way.  I was looking for a way for each of those tools.  Thanks @Chris_Rands ill check out `blastdb_aliastool`  
> **username_2**: What would you be aligning? Short reads? Why would you want to align the same data against three so different genomes? Surely the time you would save by not re-indexing would be lost again while wasting time aligning to the wrong genome, right?  
> **username_1**: @terdon I imagine they have metagenomic data or similar where the sample composition is not known a priori (reads could be 90% human, 8% E. coli etc.)  
> **username_2**: @Chris_Rands duh, indeed, should have thought of that, thanks.  
> **username_0**: @terdon Correct we don't know the make up of the sample and want to have the reads complete for alignments  
> **username_2**: That makes perfect sense for [your BLAST question](https://bioinformatics.stackexchange.com/q/7386/298) but I would be wary of using it for short reads. Even between bacteria and humans there are bound to be regions of homology. I would be very curious to know how well this works if you do manage to do it! Maybe by assigning the viral and bacterial genomes as extra "chromosomes" in a single multi-fasta file along with hg19 and indexing that?  
> **username_0**: @terdon The multi-fasta is the base case I was hoping not to have to reindex the different combinations but will either do that or create one giant reference  
> **username_2**: Could some of these help? [1](https://f1000researchdata.s3.amazonaws.com/manuscripts/17815/b3840e4e-8d44-4cf8-891b-2aa7a1c32122_15931_-_steven_wingett_v2.pdf?doi=10.12688/f1000research.15931.2&numberOfBrowsableCollections=15&numberOfBrowsableGateways=23), [2](https://academic.oup.com/bioinformatics/article/29/13/i361/189733), [3](https://genomebiology.biomedcentral.com/articles/10.1186/gb-2009-10-9-r98)?  

---

## 0 answers

