Giter Club home page Giter Club logo

Comments (4)

brentp avatar brentp commented on June 16, 2024 1

That's great to hear that it's getting use!
Just yesterday, I added fai.chrom_len() which exposes faidx_seq_len and I just now pushed a way to expose faidx_iseq by using []. You can see the tests in the commit for an example.

with these changes you can write something like:

for x in 0..fai.len-1:
  var L = fai.chrom_len(fai[i])
  ...

For why/how it is slow, can you show an example so I can test? It should be similar speed to pysam, but it does have to make a copy of the string because (as you know) a cstring is not the same as a string in nim.

Please let me know any additional issues you encounter.

from hts-nim.

brentp avatar brentp commented on June 16, 2024

and also re the performance, you are compiling with -d:release yes?

from hts-nim.

kmhernan avatar kmhernan commented on June 16, 2024

Thanks I just saw the chrom_len() after I posted. My test was just chr1 from GRCh38 (https://api.gdc.cancer.gov/data/62f23fad-0f24-43fb-8844-990d531947cf). so fa.get("chr1") in nim and fa.fetch(region="chr1") in pysam...

Ok after doing a much better "test" i actually see similar stats:

  • python: 169.11user 41.20system 3:30.34elapsed 99%CPU (0avgtext+0avgdata 990340maxresident)k
import pysam

fa = pysam.FastaFile("/mnt/SCRATCH/refdata/GRCh38.d1.vd1.fa")

for i in range(100):
    seq = fa.fetch(region="chr1")

fa.close()
  • nim: 168.89user 17.64system 3:06.55elapsed 99%CPU (0avgtext+0avgdata 493344maxresident)k
import hts

when isMainModule:
  var
    fafil = "/mnt/SCRATCH/refdata/GRCh38.d1.vd1.fa"
    fa: Fai
    chrom = "chr1"

  discard open(fa, fafil)
  for i in 0..<100:
    var bases = fa.get(chrom)

So, I think you can ignore that statement

from hts-nim.

brentp avatar brentp commented on June 16, 2024

great! let me know if you hit any more issues.

from hts-nim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.