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

error in getHeader() #26

Closed
lidaof opened this issue May 1, 2019 · 7 comments
Closed

error in getHeader() #26

lidaof opened this issue May 1, 2019 · 7 comments

Comments

@lidaof
Copy link

lidaof commented May 1, 2019

Hi Colin,

Trying use the getHeader() function but get following error:
image

my code is like:

this.bam = new BamFile({
            bamUrl: url,
            baiUrl: url + '.bai',
        });

const header = await this.bam.getHeader();
        console.log(header);

can you suggest how to fix this? Thanks.

@cmdcolin
Copy link
Collaborator

cmdcolin commented May 1, 2019

I can reproduce this. I think I have a fix and will release a new version shortly, just need to make sure to test!

@cmdcolin
Copy link
Collaborator

cmdcolin commented May 1, 2019

@lidaof Ok I have made two changes that should fix this, mostly with regards to compatibility with the browser's native fetch. If you want to try updating to @gmod/bam@1.0.18 to give it a shot that would be great!

@lidaof
Copy link
Author

lidaof commented May 2, 2019

hi @cmdcolin thanks for fast fix, i can confirm if it's bamUrl, it's fixed. if use a bamPath, a new error raised :)

image

@cmdcolin
Copy link
Collaborator

cmdcolin commented May 2, 2019

I think you can't use bamPath in the browser as that tries to access the filesystem directly via node.js file system calls and this does not exist in the browser.

If you want to access for example a file that a user opened in the browser, you might want to use the BlobFile class in https://github.com/GMOD/generic-filehandle and pass it to the bamFilehandle/baiFilehandle argument. The bamPath/bamUrl are just convenience methods for using the generic-filehandle class directly

@cmdcolin
Copy link
Collaborator

cmdcolin commented May 2, 2019

Note that some of your earlier comments about this topic of opening files actually motivated the creation of generic-filehandle so I hope it is useful :) feel free to provide feedback

@cmdcolin
Copy link
Collaborator

cmdcolin commented May 2, 2019

It's designed hopefully to be usable across multiple modules such as cram-js, bam-js, bbi-js, tabix-js, etc.

@lidaof
Copy link
Author

lidaof commented May 2, 2019

oh...yeah..stupid me....what i was thinking using local path in browser....sorry!
Thank you!! @cmdcolin

@lidaof lidaof closed this as completed May 2, 2019
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