GMOD / jbrowse-components

Source code for JBrowse 2, a modern React-based genome browser
https://jbrowse.org/jb2
Apache License 2.0
206 stars 62 forks source link

Issue when VCF variant's start is 1 #3797

Closed bbimber closed 1 year ago

bbimber commented 1 year ago

This might be a rare situation, but I think there might be a bug here. We have a VCF where a given variant's position is 1. Within the Feature, it seems to get parsed into 0-based, meaning feature.get('start') should return zero.

This falls into:

  get(field: string): any {
    return field === 'samples'
      ? this.variant.SAMPLES
      : this.data[field] || this.variant[field]
  }

https://github.com/GMOD/jbrowse-components/blob/b71dc3d862d4078e93c3d3331c90e37e48d51f3b/plugins/variants/src/VcfFeature/index.ts#L46

while this.data['start'] is zero, it falls back into this.variant[field], which is undefined.

The result is that the downstream code attempting to calculate width here: https://github.com/GMOD/jbrowse-components/blob/b71dc3d862d4078e93c3d3331c90e37e48d51f3b/plugins/svg/src/SvgFeatureRenderer/components/util.ts#L137.

I can side-step this, but wanted to report the potential bug

cmdcolin commented 1 year ago

good catch, I can definitely see this