# Efficient fetching of alternative sequences?

**URL:** <https://discuss.hail.is/t/efficient-fetching-of-alternative-sequences/972>\
**Category:** Science\
**Created:** [June 4, 2019, 4:44pm UTC](https://discuss.hail.is/t/efficient-fetching-of-alternative-sequences/972 "2019-06-04T16:44:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hoeze](https://avatars.discourse-cdn.com/v4/letter/h/3d9bf3/32.png) [@Hoeze](https://discuss.hail.is/u/Hoeze)\
**Post date:** [June 4, 2019, 4:44pm UTC](https://discuss.hail.is/t/efficient-fetching-of-alternative-sequences/972/1 "2019-06-04T16:44:49Z")

</div>

Hi, I’m currently searching for an efficient way to fetch alternative sequences from range queries on genomic variants.

Therefore, it is necessary to fetch for one individual all the variants in a certain genomic region.

Is Hail suitable for this kind of query pattern?  
I’d like to use this for 10,000s of samples.

* * *

**[EDIT for better explanation:]**  
For example, some individual might have on position 2 an A-\>G mutation and at position 4 a deletion of three base pairs.

Reference sequence: TATCCCGGG  
Alternative sequence in range [1…6]: TGTGGG

To calculate this alternative sequence, it is necessary to **fetch for one individual all the variants in a certain genomic region.**

---

<div class="post-metadata">

**Author:** ![tpoterba](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/tpoterba/32/61_2.png) [@tpoterba](https://discuss.hail.is/u/tpoterba)\
**Post date:** [June 4, 2019, 4:48pm UTC](https://discuss.hail.is/t/efficient-fetching-of-alternative-sequences/972/2 "2019-06-04T16:48:58Z")

</div>

Sorry, you’re using some lingo I don’t totally understand:

> fetch alternative sequences

Can you give an example of what you would want to get out of this query on VCF-like data?

---

<div class="post-metadata">

**Author:** ![Hoeze](https://avatars.discourse-cdn.com/v4/letter/h/3d9bf3/32.png) [@Hoeze](https://discuss.hail.is/u/Hoeze)\
**Post date:** [June 4, 2019, 5:08pm UTC](https://discuss.hail.is/t/efficient-fetching-of-alternative-sequences/972/3 "2019-06-04T17:08:52Z")

</div>

For example, some individual might have on position 2 an A-\>G mutation and at position 4 a deletion of three bases.

Reference sequence: TATCCCGGG  
Alternative sequence in range [1…6]: TGTGGG

To calculate this alternative sequence, it is necessary to **fetch for one individual all the variants in a certain genomic region.**

---

<div class="post-metadata">

**Author:** ![tpoterba](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/tpoterba/32/61_2.png) [@tpoterba](https://discuss.hail.is/u/tpoterba)\
**Post date:** [June 4, 2019, 6:19pm UTC](https://discuss.hail.is/t/efficient-fetching-of-alternative-sequences/972/4 "2019-06-04T18:19:34Z")

</div>

Wouldn’t this be represented as two different non-overlapping variants, one at position 2, one at position 4?

Do you have a precise definition of an “alternative sequence”?

I still don’t see what you’d want to do with VCF-like data here, sorry.

---

<div class="post-metadata">

**Author:** ![Hoeze](https://avatars.discourse-cdn.com/v4/letter/h/3d9bf3/32.png) [@Hoeze](https://discuss.hail.is/u/Hoeze)\
**Post date:** [June 4, 2019, 6:37pm UTC](https://discuss.hail.is/t/efficient-fetching-of-alternative-sequences/972/5 "2019-06-04T18:37:05Z")

</div>

> [@tpoterba](#):
>
> Wouldn’t this be represented as two different non-overlapping variants, one at position 2, one at position 4?

Yes. Given some individual, I need to know all its variants in a certain region.

Variant == difference to reference genome, i.e. if I know the reference genome + the variants in the region, I can calculate the individual’s DNA sequence in the region. That’s the alternative sequence I try to obtain for each individual.

So, in short I need to execute range queries for single individuals. Does this make sense to you?

---

<div class="post-metadata">

**Author:** ![tpoterba](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/tpoterba/32/61_2.png) [@tpoterba](https://discuss.hail.is/u/tpoterba)\
**Post date:** [June 4, 2019, 6:43pm UTC](https://discuss.hail.is/t/efficient-fetching-of-alternative-sequences/972/6 "2019-06-04T18:43:52Z")

</div>

Yes, got it. Hail’s typical representation of VCF-like data stores a variant-major matrix, which does not make it easy to do rapid single-sample lookups. If you want to execute a query like this for all samples, Hail can probably do that efficiently.

---

<div class="post-metadata">

**Author:** ![Hoeze](https://avatars.discourse-cdn.com/v4/letter/h/3d9bf3/32.png) [@Hoeze](https://discuss.hail.is/u/Hoeze)\
**Post date:** [June 5, 2019, 3:00pm UTC](https://discuss.hail.is/t/efficient-fetching-of-alternative-sequences/972/7 "2019-06-05T15:00:34Z")

</div>

Thanks for explaining. Yes, I’d like to do this for all samples in the end, but I’d need to get this batch-wise.
