https://github.com/cmdcolin/gff-nostream
https://github.com/cmdcolin/gff-nostream
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/cmdcolin/gff-nostream
- Owner: cmdcolin
- License: mit
- Created: 2024-09-04T15:16:53.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2025-02-09T20:40:56.000Z (over 1 year ago)
- Last Synced: 2025-04-12T09:54:02.211Z (about 1 year ago)
- Language: TypeScript
- Size: 2.9 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gff-nostream
[](https://github.com/cmdcolin/gff-nostream/actions?query=branch%3Amaster+workflow%3APush+)
Parse GFF3 data. This is a simplified version of
[@gmod/gff](https://github.com/GMOD/gff-js) with just basic parsing and no
node.js stream module usage
## Install
$ npm install --save gff-nostream
## Usage
```js
const { parseStringSync } = require('gff-nostream')
// or in ES6 (recommended)
import { parseStringSync } from 'gff-nostream'
const fs = require('fs')
// parse a string of gff3 synchronously
const stringOfGFF3 = fs.readFileSync('my_annotations.gff3', 'utf8')
const arrayOfThings = gff.parseStringSync(stringOfGFF3)
```
## Object format
### features
In GFF3, features can have more than one location. We parse features as
arrayrefs of all the lines that share that feature's ID. Values that are `.` in
the GFF3 are `null` in the output.
A simple feature that's located in just one place:
```json
[
{
"seq_id": "ctg123",
"source": null,
"type": "gene",
"start": 1000,
"end": 9000,
"score": null,
"strand": "+",
"phase": null,
"attributes": {
"ID": ["gene00001"],
"Name": ["EDEN"]
},
"child_features": [],
"derived_features": []
}
]
```
A CDS called `cds00001` located in two places:
```json
[
{
"seq_id": "ctg123",
"source": null,
"type": "CDS",
"start": 1201,
"end": 1500,
"score": null,
"strand": "+",
"phase": "0",
"attributes": {
"ID": ["cds00001"],
"Parent": ["mRNA00001"]
},
"child_features": [],
"derived_features": []
},
{
"seq_id": "ctg123",
"source": null,
"type": "CDS",
"start": 3000,
"end": 3902,
"score": null,
"strand": "+",
"phase": "0",
"attributes": {
"ID": ["cds00001"],
"Parent": ["mRNA00001"]
},
"child_features": [],
"derived_features": []
}
]
```
## API
#### Table of Contents
- [ParseOptions](#parseoptions)
- [disableDerivesFromReferences](#disablederivesfromreferences)
- [encoding](#encoding)
- [parseFeatures](#parsefeatures)
- [parseDirectives](#parsedirectives)
- [parseComments](#parsecomments)
- [parseSequences](#parsesequences)
- [parseAll](#parseall)
### ParseOptions
Parser options
#### disableDerivesFromReferences
Whether to resolve references to derives from features
Type:
[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
#### encoding
Text encoding of the input GFF3. default 'utf8'
Type: BufferEncoding
#### parseFeatures
Whether to parse features, default true
Type:
[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
#### parseDirectives
Whether to parse directives, default false
Type:
[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
#### parseComments
Whether to parse comments, default false
Type:
[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
#### parseSequences
Whether to parse sequences, default true
Type:
[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
#### parseAll
Parse all features, directives, comments, and sequences. Overrides other parsing
options. Default false.
Type:
[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)