Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order of VariantCollection with sort_key=None #220

Open
iskandr opened this issue Apr 1, 2017 · 1 comment
Open

Order of VariantCollection with sort_key=None #220

iskandr opened this issue Apr 1, 2017 · 1 comment

Comments

@iskandr
Copy link
Contributor

iskandr commented Apr 1, 2017

Issue raised by @tuomastik in a PR:

In the following example, shouldn't a==b and c==d on each loop?

import varcode

variants = [varcode.Variant(contig='1', start=4, ref='', alt=''),
            varcode.Variant(contig='1', start=1, ref='', alt=''),
            varcode.Variant(contig='1', start=3, ref='', alt=''),
            varcode.Variant(contig='1', start=2, ref='', alt='')]

for a, b, c, d in zip(
        varcode.VariantCollection(variants=variants),
        varcode.VariantCollection(variants=variants).variants,
        varcode.VariantCollection(variants=variants, sort_key=None),
        varcode.VariantCollection(variants=variants, sort_key=None).variants):
    print("%s\n%s\n%s\n%s" % (a, b, c, d))
    print("---------------------------------")

Output:

Variant(contig='1', start=1, ref='', alt='', reference_name='GRCh38')
Variant(contig='1', start=4, ref='', alt='', reference_name='GRCh38')
Variant(contig='1', start=1, ref='', alt='', reference_name='GRCh38')
Variant(contig='1', start=4, ref='', alt='', reference_name='GRCh38')
---------------------------------
Variant(contig='1', start=2, ref='', alt='', reference_name='GRCh38')
Variant(contig='1', start=1, ref='', alt='', reference_name='GRCh38')
Variant(contig='1', start=2, ref='', alt='', reference_name='GRCh38')
Variant(contig='1', start=1, ref='', alt='', reference_name='GRCh38')
---------------------------------
Variant(contig='1', start=3, ref='', alt='', reference_name='GRCh38')
Variant(contig='1', start=3, ref='', alt='', reference_name='GRCh38')
Variant(contig='1', start=3, ref='', alt='', reference_name='GRCh38')
Variant(contig='1', start=3, ref='', alt='', reference_name='GRCh38')
---------------------------------
Variant(contig='1', start=4, ref='', alt='', reference_name='GRCh38')
Variant(contig='1', start=2, ref='', alt='', reference_name='GRCh38')
Variant(contig='1', start=4, ref='', alt='', reference_name='GRCh38')
Variant(contig='1', start=2, ref='', alt='', reference_name='GRCh38')
@joaoe
Copy link

joaoe commented Apr 20, 2017

I had this issue. VariantCollection always sorts. In some cases, I'd want for the order in the input file to be kept. Would also skip some sorting overhead with really big files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants