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 while parsing a custom-format bigbed file #56

Closed
azangru opened this issue Jul 29, 2023 · 4 comments · Fixed by #57
Closed

Error while parsing a custom-format bigbed file #56

azangru opened this issue Jul 29, 2023 · 4 comments · Fixed by #57

Comments

@azangru
Copy link

azangru commented Jul 29, 2023

Hi,

I am getting an error when trying to parse a custom bigbed file that contains 21 columns (bed4+17). I am running bbi-js thus:

import  { BigBed } from '@gmod/bbi';
import { LocalFile } from 'generic-filehandle';

const test = async () => {
  try {
    const file = new BigBed({
      filehandle: new LocalFile(require.resolve('<path-to-the-bigbed-file>')),
    });
    const { autoSql } = await file.getHeader(); // <-- this errors
  } catch (error) {
    console.log('error', error);
  }
};

The error message is: RangeError: Offset is outside the bounds of the DataView

I could trace the code execution down to this line in bbi.ts

const sum = ret.totalSummaryParser.parse(tail)

image

but then it calls the binary parser, at which point I get lost.

I am providing the problematic bigbed, as well as the source files from which the bigbed was generated. I am not sure whether the problem is with the bigbed file itself or with the bbi-js library; but would like to point out that the bigbed file can be parsed back into bed by the bigbedToBed tool, and can also be read by the pyBigWig python library.

Attachments:

  • bigbed.zip — the bigbed that causes the error
  • input.zip — an archived directory with source files from which the bigbed was generated by running the command bedToBigBed -as=transcripts.as -type=bed4+17 transcripts.bed chrom.sizes transcripts.bb
@cmdcolin
Copy link
Collaborator

@azangru thanks much for the detailed issue report. I came up with a improved fix here #57

I can probably create a quick bugfix release for it :)

@cmdcolin
Copy link
Collaborator

published fix as 4.0.2! the pr autoclosed this but let me know if that helps

@cmdcolin cmdcolin reopened this Jul 30, 2023
@azangru
Copy link
Author

azangru commented Jul 30, 2023

@cmdcolin thank you so much such a quick response! I am happy to report that 4.0.2 fixes the issue for me.

BTW, while checking that the fix works, I noticed a couple of typos in a code snippet in the readme:

image

There's a closing backtick missing (first red arrow), and a backslash where it shouldn't be (second red arrow).

@cmdcolin
Copy link
Collaborator

excellent, glad that worked. that syntax should be fixed in the github readme now too

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

Successfully merging a pull request may close this issue.

2 participants