|
1 | 1 | # gff-nostream |
2 | 2 |
|
3 | 3 | [](https://npmjs.org/package/gff-nostream) |
4 | | -[](https://github.com/cmdcolin/gff-nostream/actions?query=branch%3Amain+workflow%3APush+) |
| 4 | +[](https://github.com/GMOD/gff-nostream/actions?query=branch%3Amain+workflow%3APush+) |
5 | 5 |
|
6 | | -Parse GFF3 data. This is a simplified version of |
7 | | -[@gmod/gff](https://github.com/cmdcolin/gff-js) with just basic parsing and no |
8 | | -node.js stream module usage |
| 6 | +Parse GFF3 data. A simplified version of [@gmod/gff](https://github.com/GMOD/gff-js) with no Node.js stream dependency. |
9 | 7 |
|
10 | 8 | ## Install |
11 | 9 |
|
12 | | - $ npm install --save gff-nostream |
| 10 | + $ npm install gff-nostream |
13 | 11 |
|
14 | 12 | ## Usage |
15 | 13 |
|
16 | 14 | ```js |
17 | 15 | import { parseStringSync } from 'gff-nostream' |
18 | 16 | import fs from 'fs' |
19 | 17 |
|
20 | | -// parse a string of gff3 synchronously |
21 | 18 | const stringOfGFF3 = fs.readFileSync('my_annotations.gff3', 'utf8') |
22 | | -const arrayOfThings = gff.parseStringSync(stringOfGFF3) |
| 19 | +const features = parseStringSync(stringOfGFF3) |
23 | 20 | ``` |
24 | 21 |
|
25 | 22 | ## Object format |
26 | 23 |
|
27 | | -### features |
| 24 | +In GFF3, features can have more than one location. Features are returned as arrays of all lines sharing the same ID. Values that are `.` in GFF3 are `null` in the output. |
28 | 25 |
|
29 | | -In GFF3, features can have more than one location. We parse features as |
30 | | -arrayrefs of all the lines that share that feature's ID. Values that are `.` in |
31 | | -the GFF3 are `null` in the output. |
32 | | - |
33 | | -A simple feature that's located in just one place: |
| 26 | +A simple feature located in one place: |
34 | 27 |
|
35 | 28 | ```json |
36 | 29 | [ |
@@ -94,68 +87,18 @@ A CDS called `cds00001` located in two places: |
94 | 87 |
|
95 | 88 | ## API |
96 | 89 |
|
97 | | -<!-- Generated by documentation.js. Update this documentation by updating the source code. --> |
98 | | - |
99 | | -#### Table of Contents |
100 | | - |
101 | | -- [ParseOptions](#parseoptions) |
102 | | - - [disableDerivesFromReferences](#disablederivesfromreferences) |
103 | | - - [encoding](#encoding) |
104 | | - - [parseFeatures](#parsefeatures) |
105 | | - - [parseDirectives](#parsedirectives) |
106 | | - - [parseComments](#parsecomments) |
107 | | - - [parseSequences](#parsesequences) |
108 | | - - [parseAll](#parseall) |
109 | | - |
110 | | -### ParseOptions |
111 | | - |
112 | | -Parser options |
113 | | - |
114 | | -#### disableDerivesFromReferences |
115 | | - |
116 | | -Whether to resolve references to derives from features |
117 | | - |
118 | | -Type: |
119 | | -[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean) |
120 | | - |
121 | | -#### encoding |
122 | | - |
123 | | -Text encoding of the input GFF3. default 'utf8' |
124 | | - |
125 | | -Type: BufferEncoding |
126 | | - |
127 | | -#### parseFeatures |
128 | | - |
129 | | -Whether to parse features, default true |
130 | | - |
131 | | -Type: |
132 | | -[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean) |
133 | | - |
134 | | -#### parseDirectives |
135 | | - |
136 | | -Whether to parse directives, default false |
137 | | - |
138 | | -Type: |
139 | | -[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean) |
140 | | - |
141 | | -#### parseComments |
142 | | - |
143 | | -Whether to parse comments, default false |
| 90 | +### `parseStringSync(str: string): GFF3Feature[]` |
144 | 91 |
|
145 | | -Type: |
146 | | -[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean) |
| 92 | +Synchronously parse a GFF3 string and return an array of features. |
147 | 93 |
|
148 | | -#### parseSequences |
| 94 | +### `parseStringSyncJBrowse(str: string): JBrowseFeature[]` |
149 | 95 |
|
150 | | -Whether to parse sequences, default true |
| 96 | +Synchronously parse a GFF3 string and return features in JBrowse format (flat objects with `subfeatures` instead of `child_features`). |
151 | 97 |
|
152 | | -Type: |
153 | | -[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean) |
| 98 | +### `parseRecords(records: LineRecord[]): GFF3Feature[]` |
154 | 99 |
|
155 | | -#### parseAll |
| 100 | +Parse an array of `LineRecord` objects. Useful when managing raw line data directly (e.g. from an indexed file with byte offsets). |
156 | 101 |
|
157 | | -Parse all features, directives, comments, and sequences. Overrides other parsing |
158 | | -options. Default false. |
| 102 | +### `parseRecordsJBrowse(records: LineRecord[]): JBrowseFeature[]` |
159 | 103 |
|
160 | | -Type: |
161 | | -[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean) |
| 104 | +Same as `parseRecords` but returns JBrowse-format features. |
0 commit comments