Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
$ npm install --save @gmod/bam
const { BamFile } = require('@gmod/bam') // or import {BamFile} from '@gmod/bam'
const t = new BamFile({
bamPath: 'test.bam',
})
var header = await t.getHeader()
// this would get same records as samtools view ctgA:1-50000
var records = await t.getRecordsForRange('ctgA', 0, 49999)
Input are 0-based half-open coordinates (note: not the same as samtools view coordinate inputs!)
Since 1.0.41 we support htsget!
Here is a small code snippet for this
const { HtsgetFile } = require('@gmod/bam')
const ti = new HtsgetFile({
baseUrl: 'http://htsnexus.rnd.dnanex.us/v1/reads',
trackId: 'BroadHiSeqX_b37/NA12878',
})
await ti.getHeader()
const records = await ti.getRecordsForRange(1, 2000000, 2000001)
The BAM class constructor accepts arguments
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
This is a async generator function that takes the same signature as getRecordsForRange but results can be processed using
for await(const chunk of file.streamRecordsForRange(refName, start, end, opts)) {
}
The getRecordsForRange simply wraps this process by concatenating chunks into an array
This obtains the header from HtsgetFile or BamFile. Retrieves BAM file and BAI/CSI header if applicable, or API request for refnames from htsget
Returns features of the form {start, end, score} containing estimated feature density across 16kb windows in the genome
Returns number of features on refName, uses special pseudo-bin from the BAI/CSI index (e.g. bin 37450 from bai, returning n_mapped from SAM spec pdf) or -1 if refName not exist in sample
Returns whether we have this refName in the sample
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
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
feature.get('flags') // see https://broadinstitute.github.io/picard/explain-flags.html
BAM tags such as MD can be obtained via
feature.get('MD')
A full list of tags that can be obtained can be obtained via
feature._tags()
The feature format may change in future versions to be more raw data records, but this will be a major version bump
MIT © Colin Diesh
1.1.17 (2022-07-18)
FAQs
Parser for BAM and BAM index (bai) files
The npm package @gmod/bam receives a total of 1,219 weekly downloads. As such, @gmod/bam popularity was classified as popular.
We found that @gmod/bam demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.