wheretrue / biobear

Work with bioinformatic files using Arrow, Polars, and/or DuckDB
https://www.wheretrue.dev/docs/exon/biobear/
MIT License
163 stars 8 forks source link

Why different handling between GFF and mzml/genbank in polars. #93

Open tshauck opened 9 months ago

tshauck commented 9 months ago

All have maps, but GFF is converted ok into a polars df, but not the latter to.

abearab commented 8 months ago

@tshauck have you seen https://github.com/BiocPy?

tshauck commented 8 months ago

@abearab I've seen it, but not used it. I am a fan of those packages in R (e.g. granges). I also know there's some other analogues in Python for some of those bioconductor packages (e.g. AnnData).

abearab commented 8 months ago

I've seen it, but not used it. I am a fan of those packages in R (e.g. granges). I also know there's some other analogues in Python for some of those bioconductor packages (e.g. AnnData).

Yeah, I do like AnnData and scverse ecosystem a lot. However, a good implementation of granges for python has been missing for long time! I thought considering this granges can be very relevant to your implementation of annotation file formats (i.e. GTF, GFF, BED, BAM, etc.). This is just another suggestion, feel free to ignore it :)

tshauck commented 8 months ago

100% -- you can actually do a little of granges stuff via SQL joins, but it's not quite as intuitive or as specialized to genomic intervals. E.g. say you ran bakta, and wanted to get CDSs where a spacer annotation is within 100bp of a CDS

WITH cds AS (
  SELECT *
  FROM gff_scan('bakta.gff')
  WHERE type = 'cds'
), spacers AS (
  SELECT *
  FROM gff_scan('bakta.gff')
  WHERE type = 'crispr-spacer'
)

SELECT *
FROM cds
  JOIN spacers
    ON spacers.start > (cds.start - 100) OR spacers.end < (cds.end - 100)

I would certainly like to make it easier to do more complex granges stuff.