scverse / genomic-features

Genomic Features in Python from BioConductor's AnnotationHub
https://genomic-features.readthedocs.io
BSD 3-Clause "New" or "Revised" License
18 stars 5 forks source link

Sort output #64

Open thomas-reimonn opened 3 months ago

thomas-reimonn commented 3 months ago

This PR orders the results. By default, it's ordered by chrom, start, and id. Custom ordering can be provided using order_by.

If subsets of columns are selected, then the columns are sorted with available columns and finally by id.

ivirshup commented 3 months ago

I think we could do something like:

        order_cols = []
        if "gene" in tables:
            order_cols += ["seq_name", "gene_seq_start"]
        if "tx" in tables:
            order_cols += ["tx_seq_start"]
        if "exon" in tables:
            order_cols += ["exon_seq_start"]

to have a consistent total order. But idk for sure.

Can this get some tests for expected behavior?

thomas-reimonn commented 3 months ago

I updated it like that. It now sorts in a consistent order. I also added assertions to the tests to validate this functionality.

codecov-commenter commented 3 months ago

Codecov Report

Attention: Patch coverage is 95.23810% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 93.01%. Comparing base (ef33d87) to head (a5cdb15). Report is 1 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #64 +/- ## ========================================== - Coverage 93.09% 93.01% -0.08% ========================================== Files 6 6 Lines 333 358 +25 ========================================== + Hits 310 333 +23 - Misses 23 25 +2 ``` | [Files](https://app.codecov.io/gh/scverse/genomic-features/pull/64?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scverse) | Coverage Δ | | |---|---|---| | [src/genomic\_features/ensembl/ensembldb.py](https://app.codecov.io/gh/scverse/genomic-features/pull/64?src=pr&el=tree&filepath=src%2Fgenomic_features%2Fensembl%2Fensembldb.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scverse#diff-c3JjL2dlbm9taWNfZmVhdHVyZXMvZW5zZW1ibC9lbnNlbWJsZGIucHk=) | `93.02% <95.23%> (-0.14%)` | :arrow_down: |
ivirshup commented 2 months ago

Sorry for the delay on review/ approval but I wanted to dig into the duckdb behaviour we saw a bit more. An ibis maintainer believes this might be a duckdb bug.