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

@gmod/bed

Package Overview
Dependencies
Maintainers
5
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gmod/bed - npm Package Compare versions

Comparing version 1.0.4 to 2.0.0

13

CHANGELOG.md

@@ -0,1 +1,14 @@

# [2.0.0](https://github.com/GMOD/bed-js/compare/v1.0.4...v2.0.0) (2019-04-15)
### Major changes
- API now processes just text lines with the parseLine method
- Remove snake case of results
- Returned values match autoSql very faithfully and uses the naming from UCSC e.g. exact strings from autoSql {chrom, chromStart, chromEnd}
- Accepts a opts.uniqueId for the parseLine method which adds this to the featureData
- Parses the default BED schema with a defaultBedSchema.as autoSql definition instead of a separate method
## [1.0.4](https://github.com/GMOD/bed-js/compare/v1.0.3...v1.0.4) (2019-04-14)

@@ -2,0 +15,0 @@

2

package.json
{
"name": "@gmod/bed",
"version": "1.0.4",
"version": "2.0.0",
"description": "A BED file format parser with autoSql support",

@@ -5,0 +5,0 @@ "main": "dist/main.js",

@@ -21,35 +21,14 @@ # bed-js

### BED parser with default schema
The default instantiation of the parser with new BED() simply parses lines assuming the fields come from the standard BED schema.
## API
```js
const p = new BED()
const feature = p.parseLine('chr1\t0\t100')
```
### Constructor
The default schema is the same 12 fields as UCSC
The BED constructor accepts an opts object with options
chrom
chromStart
chromEnd
name
score
strand
thickStart
thickEnd
itemRgb
blockCount
blockSizes
blockStarts
- opts.autoSql - a optional autoSql schema for parsing lines
- opts.type - a string representing one of a list of predefined types
If only a subset of those are used, it just parses up to that, e.g. your line can just contain chrom, chromStart, chromEnd, name, score.
The predefined types can include
### BED parser with alternative schema
If you have a BED format that corresponds to a different schema, you can specify from a list of default built in alternate schemas or specify an autoSql as a string
The alternative types by default include
bigInteract

@@ -65,5 +44,38 @@ bigMaf

Specify this in the type for the BED constructor
If neither autoSql or type is specified, the default BED schema is used (see [here](src/as/defaultBedSchema.as))
### parseLine(line, opts)
Parses a BED line according to the currently loaded schema
* line: string|Array<string> - is a tab delimited line with fields from the schema, or an array of fields with fields from the schema
* opts: Options - an options object
An Options object can contain
* opts.uniqueId - an indication of a uniqueId that is not encoded by the BED line itself
The default instantiation of the parser with new BED() simply parses lines assuming the fields come from the standard BED schema.
Your line can just contain just a subset of the fields e.g. `chrom, chromStart, chromEnd, name, score`
## Examples
### Parsing BED with default schema
```js
const p = new BED()
p.parseLine('chr1\t0\t100')
// outputs { chrom: 'chr1', chromStart: 0, chromEnd: 100, strand: 0 }
```
### Parsing BED with a built in schema e.g. bigGenePred
If you have a BED format that corresponds to a different schema, you can specify from the list of default built in schemas
Specify this in the opts.type for the BED constructor
```js
const p = new BED({ type: 'bigGenePred' })

@@ -73,32 +85,36 @@ const line = 'chr1\t11868\t14409\tENST00000456328.2\t1000\t+\t11868\t11868\t255,128,0\t3\t359,109,1189,\t0,744,1352,\tDDX11L1\tnone\tnone\t-1,-1,-1,\tnone\tENST00000456328.2\tDDX11L1\tnone'

// above line outputs
{ refID: 'chr1',
start: 11868,
end: 14409,
{ chrom: 'chr1',
chromStart: 11868,
chromEnd: 14409,
name: 'ENST00000456328.2',
score: 1000,
strand: 1,
thick_start: 11868,
thick_end: 11868,
thickStart: 11868,
thickEnd: 11868,
reserved: '255,128,0',
block_count: 3,
block_sizes: [ 359, 109, 1189 ],
chrom_starts: [ 0, 744, 1352 ],
blockCount: 3,
blockSizes: [ 359, 109, 1189 ],
chromStarts: [ 0, 744, 1352 ],
name2: 'DDX11L1',
cds_start_stat: 'none',
cds_end_stat: 'none',
exon_frames: [ -1, -1, -1 ],
cdsStartStat: 'none',
cdsEndStat: 'none',
exonFrames: [ -1, -1, -1 ],
type: 'none',
gene_name: 'ENST00000456328.2',
gene_name2: 'DDX11L1',
gene_type: 'none' }
geneName: 'ENST00000456328.2',
geneName2: 'DDX11L1',
geneType: 'none' }
```
### BED parser with autoSql
### Parsing BED with a supplied autoSql
If you have a BED format with a custom alternative schema with autoSql, or if you are using a BigBed file that contains autoSql (e.g. with [@gmod/bbi](https://github.com/gmod/bbi-js) then you can get it from header.autoSql)
If you have a BED format with a custom alternative schema with autoSql, or if you are using a BigBed file that contains autoSql (e.g. with [@gmod/bbi](https://github.com/gmod/bbi-js) then you can get it from header.autoSql) then you initialize the schema in the constructor and then use parseLine as normal
```
const p = new BED({ autoSql: /* your autosql formatted string here */ })
const {BigBed} = require('@gmod/bbi')
const bigbed = new BigBed({path: 'yourfile'})
const {autoSql} = await bigbed.getHeader()
const p = new BED({ autoSql })
p.parseLine(line)
// etc.
```

@@ -110,6 +126,5 @@

* Does not do any conversion of types beyond just converting known int/float values
* Does not convert blockStarts/blockEnds to gene features
* Does not parse header or track lines
* Does not handle files that use spaces instead of tabs even though this is allowed by UCSC
* Does not parse "browser" or "track" lines and will throw an error if parseLine receives one of these
* By default, parseLine parses only tab delimited text, if you want to use spaces as is allowed by UCSC then pass an array to `line` for parseLine
* Converts strand from {+,-,.} to {1,-1,0} and also sets strand 0 even if no strand is in the autoSql

@@ -116,0 +131,0 @@

Sorry, the diff of this file is too big to display

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