# ve-bamreader

> object to read bams (forked from shinout/bamreader)

Latest version **0.2.5** (published 2019-04-02) · 0 weekly downloads

## Install

```sh
npm install ve-bamreader
pnpm add ve-bamreader
yarn add ve-bamreader
bun add ve-bamreader
```

Provides the command `ve-bamreader`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.5 |
| Published | 2019-04-02 |
| First published | 2018-04-09 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.8.0 |
| Dependencies | 2 |
| Unpacked size | 323.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Teselagen |
| Maintainers | teselagen-admin, tnrich |
| Keywords | bam, bioinfo, bio, sam, samtools, ngs, sequencer, mapping |

## Links

- npm: https://www.npmjs.com/package/ve-bamreader
- Repository: https://github.com/teselagen/bamreader
- Homepage: http://github.com/teselagen/bamreader
- Issues: http://github.com/teselagen/bamreader/issues
- npm.io page: https://npm.io/package/ve-bamreader

## Dependencies (2)

- [ve-bgzf](https://npm.io/package/ve-bgzf.md) ^0.0.2
- [termcolor](https://npm.io/package/termcolor.md) ^0.2.0

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 0.2.5 (latest) — 2019-04-02
- 0.2.4 — 2018-04-19
- 0.2.3 — 2018-04-09

## README

Note: Forked from shinout bamreader (all credit goes to shinout)

BAMLineReader
==========
BAMLineReader is a reader to parse .bam files.
Uses samtools If exists, otherwise uses a native parser.

installation
----------------
```bash
$ npm install ve-bamreader 
# May require CC and CXX environmental variables on certain distributions pointing to `Nan` compatible GCC version. 
# 4.9.0 has worked in the past
```




usage
-------------
```js
var bamreader = require("ve-bamreader");

bamreader("/path/to/bamfile.bam").then((jsonResult) => {
  //do something with the resulting json :)
})
```


streaming usage (you probably don't need this)
-------------
```js 
var BAMLineReader = require("bamreader").BAMLineReader;
var reader = BAMLineReader.create("/path/to/bamfile.bam");
reader.on("bam", function(bam) {
  // bam: object. see "bam object" section
  console.log(bam.seq, bam.qual);
  console.log(bam.pair); // pair bam object of the bam. To do this, indexing is needed.
});

reader.on("end", function() {
  console.log("all bam alignments have been read.");
});
```

bam object
------------------
- pair          : information of the mate pair. see "bam.pair"
- discordant    : discordant or not. see "bam.discordant"
- qname         : name of the read
- flag          : bitwise flag
- rname         : reference sequence rname
- pos           : 1-based leftmost mapping position
- mapq          : mapping quality
- cigar         : CIGAR string
- rnext         : reference sequence name of the primary alignment of the next read
- next_rname    : the actual reference name of the next read.
- pnext         : position of the primary alignment of the next read
- tlen          : template length
- seq           : segment jsequence
- qual          : ASCII of base quality plus 33
- start         : 0-based leftmost mapping position
- flags         : information of flags
- tagstr        : optional fields as string
- tags          : optional fields as structured data described in "bamdata.tags" section
- multiple      : information from flag: template have multiple segment or not. 
- unmapped      : information from flag: unmapped or not. 
- allmatches    : information from flag: each segment properly aligned or not
- next_unmapped : information from flag: next segment is unmapped or not. 
- reversed      : information from flag: reversely mapped or not.
- next_reversed : information from flag: next segment is reversely mapped or not.
- first         : information from flag: first segment or not.
- last          : information from flag: last segment or not.
- secondary     : information from flag: secondary alignment or not.
- lowquality    : information from flag: not passing quality control or not.
- duplicate     : information from flag: PCR or optic duplicate or not.
- supplementary : information from flag: supplementary alignment or not.
- clipped       : clipped or not.
- soft_clipped  : soft-clipped or not.
- hard_clipped  : hard-clipped or not.
- left_break    : the left position of the breakpoint if clipped.
- right_break   : the right position of the breakpoint if clipped.
- match_len     : length of the matched portion of the read.
- fully_matched : if the whole base of the read is matched or not
- mismatch      : the number of mismatch bases
- unique        : if the read is mapped uniquely or not
- indel         : the mapping result contains insertion/deletion or not.
- different_ref : if both mapped and rname is not rnext or not
- same_strand   : if both mapped and mapped to the same strand or not
- has_n         : the read contains "N" or not
- sam           : SAM formatted string of the bam

bam.pair
-------------------
bamreader can fetch one mate pair of the read using index.

```bash
$ bamreader -c <bamfile>     # creates an index of the bamfile.
```
then you can access bam.pair

bam.pair is also a bam object.

bam.discordant
-------------------
(...)
 
bam.tags
------------------
- (key): tag name (two string character)
- (value): type: data type, value: data

if data type is "B", value[0] is subtype, value.slice(1) is the array of data.

---
_Source: https://npm.io/package/ve-bamreader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
