genomediff
Advanced tools
Comparing version 1.1.4 to 1.2.0
@@ -0,5 +1,12 @@ | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var parser_1 = require('./parser'); | ||
var records_1 = require('./records'); | ||
var GenomeDiff = (function () { | ||
function GenomeDiff(length) { | ||
var GenomeDiff = (function (_super) { | ||
__extends(GenomeDiff, _super); | ||
function GenomeDiff() { | ||
_super.apply(this, arguments); | ||
this.metadata = {}; | ||
@@ -9,6 +16,4 @@ this.mutations = []; | ||
this.validation = []; | ||
this.length = length || 0; | ||
} | ||
// Note that this only works in the browser | ||
GenomeDiff.prototype[Symbol.iterator] = function () { | ||
GenomeDiff.prototype.values = function () { | ||
var items = []; | ||
@@ -35,7 +40,5 @@ var props = Object.keys(this); | ||
GenomeDiff.parse = function (str) { | ||
var records = parser_1.GenomeDiffParser.parse(str); | ||
var length = records.filter(function (record) { return record instanceof records_1.Metadata !== true; }).length; | ||
var gd = new GenomeDiff(length); | ||
for (var _i = 0; _i < records.length; _i++) { | ||
var record = records[_i]; | ||
var gd = new GenomeDiff(); | ||
for (var _i = 0, _a = parser_1.GenomeDiffParser.parse(str); _i < _a.length; _i++) { | ||
var record = _a[_i]; | ||
if (record instanceof records_1.Metadata) { | ||
@@ -64,4 +67,4 @@ gd.metadata[record.name] = record.value; | ||
return GenomeDiff; | ||
})(); | ||
})(Object); | ||
exports.GenomeDiff = GenomeDiff; | ||
//# sourceMappingURL=gd.js.map |
@@ -37,3 +37,17 @@ var records_1 = require('./records'); | ||
}); | ||
describe('#values()', function () { | ||
it('should return an iterable', function () { | ||
var str = '#=GENOME_DIFF 1.0' + '\n' + | ||
'#=AUTHOR test' + '\n' + | ||
'SNP 1 2 NC_000913 223 A' + '\n' + | ||
'RA 2 NC_000913 223 0 G A'; | ||
var gd = gd_1.GenomeDiff.parse(str); | ||
for (var _i = 0, _a = gd.values(); _i < _a.length; _i++) { | ||
var record = _a[_i]; | ||
console.log(record); | ||
expect(record instanceof records_1.Record).toBe(true); | ||
} | ||
}); | ||
}); | ||
}); | ||
//# sourceMappingURL=gd.spec.js.map |
{ | ||
"name": "genomediff", | ||
"version": "1.1.4", | ||
"version": "1.2.0", | ||
"description": "Parses strings from files in the GenomeDiff format generated by the breseq variant caller for haploid microbial organisms.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -16,4 +16,6 @@ # Genomediff | ||
**GenomeDiff** strings are parsed using `GenomeDiff.parse(<string>)`. The **GenomeDiff** object contains a `metadata` dict with the meta data, as well as `mutations`, `evidence` and `validation` lists, each containing records of that type. Records can be accessed through this list or by id using `GenomeDiff.parse(<string>)[<id>]`. **GenomeDiff** is an iterable and iterating will return all records of all types. | ||
**GenomeDiff** strings are parsed using `GenomeDiff.parse(<string>)`. The **GenomeDiff** object contains a `metadata` dict with the meta data, as well as `mutations`, `evidence` and `validation` lists, each containing records of that type. Records can be accessed through this list or by id using `GenomeDiff.parse(<string>)[<id>]`. **GenomeDiff** is an iterable and iterating it will return all properties and records. | ||
For accessing all the records you can use `GenomeDiff.parse('<string>').values()` which returns an iterable but only with the `Record` types. | ||
For accessing the parents of a specific mutation you can use the `.parents(<id>)` method available on the document returned from `GenomeDiff.parse(<string>)`: | ||
@@ -20,0 +22,0 @@ ```js |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
31325
335
63