biojs-io-fasta
v0.1.17
Published
Parses FASTA files
Downloads
225
Readme
biojs-io-fasta
npm install biojs-io-fasta
Use in your browser
<script src="http://wzrd.in/bundle/biojs-io-fasta@latest"></script>
- You can find a JSBin to play around with it.
- Remember that you need CORS to download files from other servers on the web
Methods
var Fasta = require('biojs-io-fasta');
read(url)
Parses an url an calls your parse
method with the returned body.
Fasta.read("https://raw.githubusercontent.com/biojs-io/biojs-io-fasta/master/test/foo.fasta", function(err, model) {
// model is the parsed url
});
If callback is undefined, read
returns a promise.
var p = Fasta.read("https://raw.githubusercontent.com/biojs-io/biojs-io-fasta/master/test/foo.fasta");
// ...
p.then(function(model) {
// model is the parsed url
}, function(err){
console.error("err happened during downloading", err);
});
parse(str)
var seqs = Fasta.parse(str);
export(model)
var text = Fasta.export(seqs);
extend(customParser)
Thanks to @sillitoe you can provide a custom parser if your FASTA header is formatted "in weird and wonderful ways".
var customGetMeta = function(header) {
return {
id: "id",
name: "name",
// optional
details: {
foo: "bar"
},
// optional
ids: {
customId: "bar"
}
};
}
var altFasta = Fasta.extend(customGetMeta);
Take a look at tests for a better example of such a parser;
Sequence object
{
seq: "ABC",
name: "awesome seq",
id: "unique id"
}
Develop
Install dependencies and execute the tests:
npm install
npm script compile && npm test
To build a JS file for the browser, execute:
npm run build-browser
License
Apache 2