npm package: @gmod/nclist
Description: Read features from JBrowse 1 format nested containment list JSON
Author: Robert Buels
Latest version: 3.0.6

# nclist-js

Read legacy JBrowse 1 nested containment list JSON.

## Status

[![Build Status](https://img.shields.io/github/actions/workflow/status/GMOD/nclist-js/push.yml?branch=master)](https://github.com/GMOD/nclist-js/actions)
[![Coverage Status](https://img.shields.io/codecov/c/github/GMOD/nclist-js/master.svg?style=flat-square)](https://codecov.io/gh/GMOD/nclist-js/branch/master)
[![NPM version](https://img.shields.io/npm/v/@gmod/nclist.svg?logo=npm&style=flat-square)](https://npmjs.org/package/@gmod/nclist)

## Usage

```javascript
import { RemoteFile } from 'generic-filehandle2'
import NCList from '@gmod/nclist'
;(async () => {
  const store = new NCList({
    baseUrl: `http://my.server/path/to/data/dir/`,
    urlTemplate: 'volvox_genes/{refseq}/trackData.json',
    readFile: url => new RemoteFile(url).readFile(),
  })

  for await (const feature of store.getFeatures({
    refName: 'ctgA',
    start: 0,
    end: 50000,
  })) {
    console.log(
      `got feature at ${feature.get('seq_id')}:${feature.get(
        'start',
      )}-${feature.get('end')}`,
    )
  }
})()
```

## API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

#### Table of Contents

- [NCListStore](#ncliststore)
  - [Parameters](#parameters)
  - [getRegionFeatureDensities](#getregionfeaturedensities)
    - [Parameters](#parameters-1)
  - [getFeatures](#getfeatures)
    - [Parameters](#parameters-2)

### NCListStore

Sequence feature store using nested containment lists held in JSON files that
are lazily read.

#### Parameters

- `args`
  **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
  constructor args
  - `args.baseUrl`
    **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
    base URL for resolving relative URLs
  - `args.urlTemplate`
    **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
    Template string for the root file of each reference sequence. The reference
    sequence name will be interpolated into this string where `{refseq}`
    appears.
  - `args.readFile`
    **[function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)**
    function to use for reading remote from URLs.
  - `args.cacheSize` (optional, default `10`)

#### getRegionFeatureDensities

fetch binned counts of feature coverage in the given region.

##### Parameters

- `query`
  **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;
  - `query.refName`
    **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
    reference sequence name
  - `query.start`
    **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
    region start
  - `query.end`
    **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
    region end
  - `query.numBins`
    **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
    number of bins desired in the feature counts
  - `query.basesPerBin`
    **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
    number of bp desired in each feature counting bin

Returns
**[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
as: `{ bins: hist, stats: statEntry }`

#### getFeatures

Fetch features in a given region. This method is an asynchronous generator
yielding feature objects.

##### Parameters

- `args`
  **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;
  - `args.refName`
    **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
    reference sequence name
  - `args.start`
    **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
    start of region. 0-based half-open.
  - `args.end`
    **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
    end of region. 0-based half-open.