gff-nostream 3.0.6 → 3.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -11
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Parse GFF3 data. A simplified version of
|
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
|
-
$
|
|
11
|
+
$ pnpm add gff-nostream
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
@@ -16,15 +16,25 @@ Parse GFF3 data. A simplified version of
|
|
|
16
16
|
import { parseStringSync } from 'gff-nostream'
|
|
17
17
|
import fs from 'fs'
|
|
18
18
|
|
|
19
|
-
const
|
|
20
|
-
|
|
19
|
+
const features = parseStringSync(fs.readFileSync('my_annotations.gff3', 'utf8'))
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
For browser or other non-Node environments, pass any GFF3 string directly — for
|
|
23
|
+
example from `fetch`:
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
import { parseStringSyncJBrowse } from 'gff-nostream'
|
|
27
|
+
|
|
28
|
+
const text = await fetch('my_annotations.gff3').then(r => r.text())
|
|
29
|
+
const features = parseStringSyncJBrowse(text)
|
|
21
30
|
```
|
|
22
31
|
|
|
23
32
|
## Object format
|
|
24
33
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
### GFF3 format
|
|
35
|
+
|
|
36
|
+
Features are returned as arrays of all lines sharing the same ID (to represent
|
|
37
|
+
multi-location features). Values that are `.` in GFF3 are `null` in the output.
|
|
28
38
|
|
|
29
39
|
A simple feature located in one place:
|
|
30
40
|
|
|
@@ -88,31 +98,68 @@ A CDS called `cds00001` located in two places:
|
|
|
88
98
|
]
|
|
89
99
|
```
|
|
90
100
|
|
|
101
|
+
### JBrowse format
|
|
102
|
+
|
|
103
|
+
The `JBrowse` variants return flat objects with coordinates converted to 0-based
|
|
104
|
+
half-open, `strand` as a number (`1`/`-1`/`0`), attributes spread as lowercase
|
|
105
|
+
top-level keys, and `subfeatures` instead of `child_features`.
|
|
106
|
+
|
|
107
|
+
The same gene feature in JBrowse format:
|
|
108
|
+
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"refName": "ctg123",
|
|
112
|
+
"source": null,
|
|
113
|
+
"type": "gene",
|
|
114
|
+
"start": 999,
|
|
115
|
+
"end": 9000,
|
|
116
|
+
"strand": 1,
|
|
117
|
+
"subfeatures": [],
|
|
118
|
+
"id": "gene00001",
|
|
119
|
+
"name": "EDEN"
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Note: multi-location features (same ID on multiple lines) are not merged in
|
|
124
|
+
JBrowse format — only the first occurrence is kept.
|
|
125
|
+
|
|
91
126
|
## API
|
|
92
127
|
|
|
93
128
|
### `parseStringSync(str: string): GFF3Feature[]`
|
|
94
129
|
|
|
95
|
-
Synchronously parse a GFF3 string and return an array of features.
|
|
130
|
+
Synchronously parse a GFF3 string and return an array of features. Comments,
|
|
131
|
+
directives, and `##FASTA` sections are ignored.
|
|
96
132
|
|
|
97
133
|
### `parseStringSyncJBrowse(str: string): JBrowseFeature[]`
|
|
98
134
|
|
|
99
|
-
Synchronously parse a GFF3 string and return features in JBrowse format
|
|
100
|
-
objects with `subfeatures` instead of `child_features`).
|
|
135
|
+
Synchronously parse a GFF3 string and return features in JBrowse format.
|
|
101
136
|
|
|
102
137
|
### `parseRecords(records: LineRecord[]): GFF3Feature[]`
|
|
103
138
|
|
|
104
139
|
Parse an array of `LineRecord` objects. Useful when managing raw line data
|
|
105
|
-
directly (e.g. from
|
|
140
|
+
directly (e.g. from a tabix-indexed file with byte offsets).
|
|
106
141
|
|
|
107
142
|
### `parseRecordsJBrowse(records: LineRecord[]): JBrowseFeature[]`
|
|
108
143
|
|
|
109
144
|
Same as `parseRecords` but returns JBrowse-format features.
|
|
110
145
|
|
|
146
|
+
### `LineRecord`
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
interface LineRecord {
|
|
150
|
+
line: string
|
|
151
|
+
hasEscapes: boolean // set true when line contains '%' to enable URL-decoding
|
|
152
|
+
lineHash?: string | number // propagated to attributes._lineHash on the parsed feature
|
|
153
|
+
start?: number // byte offset passthrough (not used by the parser)
|
|
154
|
+
end?: number // byte offset passthrough (not used by the parser)
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
111
158
|
## Publishing
|
|
112
159
|
|
|
113
160
|
[Trusted publishing](https://docs.npmjs.com/about-trusted-publishing) via GitHub
|
|
114
161
|
Actions.
|
|
115
162
|
|
|
116
163
|
```bash
|
|
117
|
-
|
|
164
|
+
pnpm version patch # or minor/major
|
|
118
165
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gff-nostream",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.8",
|
|
4
4
|
"description": "utilities to read GFF3 data",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -48,13 +48,13 @@
|
|
|
48
48
|
],
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@eslint/js": "^10.0.1",
|
|
51
|
-
"@types/node": "^25.
|
|
52
|
-
"eslint": "^10.
|
|
51
|
+
"@types/node": "^25.8.0",
|
|
52
|
+
"eslint": "^10.4.0",
|
|
53
53
|
"eslint-plugin-import-x": "^4.16.2",
|
|
54
54
|
"prettier": "^3.8.3",
|
|
55
55
|
"rimraf": "^6.1.3",
|
|
56
56
|
"typescript": "^6.0.3",
|
|
57
|
-
"typescript-eslint": "^8.59.
|
|
58
|
-
"vitest": "^4.1.
|
|
57
|
+
"typescript-eslint": "^8.59.3",
|
|
58
|
+
"vitest": "^4.1.6"
|
|
59
59
|
}
|
|
60
60
|
}
|