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

Cross compatibility with XAM.jl? #24

Open
abhinavsns opened this issue Aug 2, 2024 · 2 comments
Open

Cross compatibility with XAM.jl? #24

abhinavsns opened this issue Aug 2, 2024 · 2 comments

Comments

@abhinavsns
Copy link

I am interested to iterate over BAM records .bam that have supplementary index files .bai using XAM.jl. Now I have a bed file of interesting regions, I want to iterate over all bam records for each interval in the .bed file. Is there an example available for this?

@jonathanBieler
Copy link

jonathanBieler commented Aug 2, 2024

Adapted from XAM docs :

using BED, XAM, GenomicFeatures

# Create an interval collection in memory.
regions = open(BED.Reader, "data.bed") do reader
    IntervalCollection(reader,true)
end

reader = open(BAM.Reader, bamfile)

# Iterate over BAM records.
reader = open(BAM.Reader, bamfile, index = bamfile * ".bai")
for region in regions
    for record in eachoverlap(reader, region)
        # `record` overlaps `region`.
        # ...
    end
end
close(reader)

@abhinavsns
Copy link
Author

Thanks! I was wondering if this is the most efficient way? or maybe there is a while !eof(reader) version where I only allocate the Record once and read it in-place? Also it would be great if the develop branch could be released for easier installation and compatibility with latest XAM.jl release.

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