33
44## Install
55
6- $ npm install --save @gmod/indexedfasta
6+ ``` bash
7+ npm install @gmod/indexedfasta
8+ ```
79
810## Usage
911
@@ -15,17 +17,16 @@ const t = new IndexedFasta({
1517 faiPath: ' test.fa.fai' ,
1618})
1719// or
18- const t = new BgzipIndexedFasta ({
20+ const t2 = new BgzipIndexedFasta ({
1921 path: ' test.fa.gz' ,
2022 faiPath: ' test.fa.gz.fai' ,
2123 gziPath: ' test.fa.gz.gzi' ,
2224})
2325
24- // get the first 10 bases of a sequence from the file.
26+ // get the first 10 bases of a sequence from the file
2527// coordinates are UCSC standard 0-based half-open
26- //
2728const chr1Region = await t .getSequence (' chr1' , 0 , 10 )
28- // chr1Region is now a string of bases, 'ACTG...'
29+ // chr1Region is a string of bases e.g. 'ACTG...' or undefined if not found
2930
3031// get a whole sequence from the file
3132const chr1Bases = await t .getSequence (' chr1' )
@@ -48,27 +49,27 @@ import { IndexedFasta, BgzipIndexedFasta } from '@gmod/indexedfasta'
4849import { RemoteFile } from ' generic-filehandle2'
4950
5051const t = new IndexedFasta ({
51- fasta: new RemoteFile (' http ://yoursite .com/test.fa' ),
52- fai: new RemoteFile (' http ://yoursite .com/test.fa.fai' ),
52+ fasta: new RemoteFile (' https ://example .com/test.fa' ),
53+ fai: new RemoteFile (' https ://example .com/test.fa.fai' ),
5354})
54- const t = new BgzipIndexedFasta ({
55- fasta: new RemoteFile (' http ://yoursite .com/test.fa.gz' ),
56- fai: new RemoteFile (' http ://yoursite .com/test.fa.gz.fai' ),
57- gzi: new RemoteFile (' http ://yoursite .com/test.fa.gz.gzi' ),
55+ const t2 = new BgzipIndexedFasta ({
56+ fasta: new RemoteFile (' https ://example .com/test.fa.gz' ),
57+ fai: new RemoteFile (' https ://example .com/test.fa.gz.fai' ),
58+ gzi: new RemoteFile (' https ://example .com/test.fa.gz.gzi' ),
5859})
5960```
6061
61- In node .js you can also access remote files with generic-filehandle2, but you
62- would supply a fetch function e.g.
62+ In Node .js you can also access remote files with generic-filehandle2. Node 18+
63+ has native ` fetch ` ; for older versions supply one via e.g. ` cross-fetch ` :
6364
6465``` typescript
6566import { IndexedFasta , BgzipIndexedFasta } from ' @gmod/indexedfasta'
6667import { RemoteFile } from ' generic-filehandle2'
67- import fetch from ' cross-fetch'
68+ import fetch from ' cross-fetch' // only needed for Node < 18
6869
6970const t = new IndexedFasta ({
70- fasta: new RemoteFile (' http ://yoursite .com/test.fa' , { fetch }),
71- fai: new RemoteFile (' http ://yoursite .com/test.fa.fai' , { fetch }),
71+ fasta: new RemoteFile (' https ://example .com/test.fa' , { fetch }),
72+ fai: new RemoteFile (' https ://example .com/test.fa.fai' , { fetch }),
7273})
7374```
7475
@@ -79,6 +80,10 @@ part of the [JBrowse](http://jbrowse.org) project. If you use it in an academic
7980project that you publish, please cite the most recent JBrowse paper, which will
8081be linked from [ jbrowse.org] ( http://jbrowse.org ) .
8182
83+ ## Publishing
84+
85+ Releases are published to npm using [ npm trusted publishing] ( https://docs.npmjs.com/generating-provenance-statements ) via GitHub Actions, so no npm token is stored in the repository secrets.
86+
8287## License
8388
8489MIT © [ Colin Diesh] ( https://github.com/cmdcolin )
0 commit comments