Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gmod/bam

Package Overview
Dependencies
Maintainers
5
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gmod/bam

Parser for BAM and BAM index (bai) files

  • 1.0.17
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.2K
decreased by-14.35%
Maintainers
5
Weekly downloads
 
Created
Source

Generated with nod NPM version Build Status Coverage Status

Install

$ npm install --save @gmod/bam

Usage

const {BamFile} = require('@gmod/bam');

const t = new BamFile({
    bamPath: 'test.bam',
});

var header = await t.getHeader()

var records = await t.getRecordsForRange('ctgA', 1, 50000)

Input are 0-based half-open coordinates (note: not the same as samtools view coordinate inputs!)

Documentation

BAM constructor

The BAM class constructor accepts arguments

  • bamPath/baiUrl/bamFilehandle - a string file path to a local file or a class object with a read method
  • csiPath/csiUrl/csiFilehandle - a CSI index for the BAM file, required for long chromosomes greater than 2^29 in length
  • baiPath/baiUrl/baiFilehandle - a BAI index for the BAM file
  • fetchSizeLimit - total size of the number of chunks being fetched at once. default: ~50MB
  • chunkSizeLimit - size limit on any individual chunk. default: ~10MB
  • cacheSize - limit on number of chunks to cache. default: 50

Note: filehandles implement the Filehandle interface from https://www.npmjs.com/package/generic-filehandle. This module offers the path and url arguments as convenience methods for supplying the LocalFile and RemoteFile

Documentation

getRecordsForRange(refName, start, end, opts)
  • refName - a string for the chrom to fetch from
  • start - a 0 based half open start coordinate
  • end - a 0 based half open end coordinate
  • opts.signal - an AbortSignal to indicate stop processing
  • opts.viewAsPairs - re-dispatches requests to find mate pairs. default: false
  • opts.pairAcrossChr - control the viewAsPairs option behavior to pair across chromosomes. default: false
  • opts.maxInsertSize - control the viewAsPairs option behavior to limit distance within a chromosome to fetch. default: 200kb

indexCov(refName, start, end)

  • refName - a string for the chrom to fetch from
  • start - a 0 based half open start coordinate (optional, will fetch whole chromosome without)
  • end - a 0 based half open end coordinate (optional, will fetch whole chromosome without even if start is specified)

Returns features of the form {start, end, score} containing estimated feature density across 16kb windows in the genome

Returned features

The returned features from BAM are lazy features meaning that it delays processing of all the feature tags until necessary.

You can access data feature.get('field') to get the value of a feature attribute

Example

feature.get('seq_id') // numerical sequence id corresponding to position in the sam header
feature.get('start') // 0 based half open start coordinate
feature.get('end') // 0 based half open end coordinate

Fields

feature.get('name') // QNAME
feature.get('seq') // feature sequence
feature.get('qual') // qualities
feature.get('cigar') // cigar string
feature.get('MD') // MD string
feature.get('SA') // supplementary alignments
feature.get('template_length') // TLEN
feature.get('length_on_ref') // derived from CIGAR using standard algorithm

Flags

feature.get('seq_reverse_complemented')
feature.get('unmapped')
feature.get('qc_failed')
feature.get('duplicate')
feature.get('secondary_alignment')
feature.get('supplementary_alignment')

The feature format may change in future versions to be more raw records but will be a major version bump

License

MIT © Colin Diesh

Keywords

FAQs

Package last updated on 28 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc