@gmod/bed 2.0.8 → 2.1.0
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/CHANGELOG.md +6 -0
- package/dist/as/autoSqlSchemas.d.ts +10 -10
- package/dist/as/autoSqlSchemas.js.map +1 -1
- package/dist/defaultTypes.d.ts +3 -2
- package/dist/defaultTypes.js +4 -1
- package/dist/defaultTypes.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/parser.d.ts +10 -10
- package/dist/parser.js +1 -7
- package/dist/parser.js.map +1 -1
- package/dist/util.d.ts +18 -1
- package/dist/util.js +1 -14
- package/dist/util.js.map +1 -1
- package/esm/as/autoSqlSchemas.d.ts +10 -10
- package/esm/as/autoSqlSchemas.js.map +1 -1
- package/esm/defaultTypes.d.ts +3 -2
- package/esm/defaultTypes.js +4 -3
- package/esm/defaultTypes.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.js.map +1 -1
- package/esm/parser.d.ts +10 -10
- package/esm/parser.js +2 -8
- package/esm/parser.js.map +1 -1
- package/esm/util.d.ts +18 -1
- package/esm/util.js +9 -14
- package/esm/util.js.map +1 -1
- package/package.json +11 -11
- package/src/as/{autoSqlSchemas.js → autoSqlSchemas.ts} +0 -0
- package/src/defaultTypes.ts +10 -0
- package/src/{index.js → index.ts} +0 -0
- package/src/{parser.js → parser.ts} +14 -19
- package/src/util.ts +27 -0
- package/src/defaultTypes.js +0 -8
- package/src/util.js +0 -26
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export const bigChain
|
|
2
|
-
export const bigGenePred
|
|
3
|
-
export const bigInteract
|
|
4
|
-
export const bigLink
|
|
5
|
-
export const bigMaf
|
|
6
|
-
export const bigNarrowPeak
|
|
7
|
-
export const bigPsl
|
|
8
|
-
export const defaultBedSchema
|
|
9
|
-
export const mafFrames
|
|
10
|
-
export const mafSummary
|
|
1
|
+
export declare const bigChain = "table bigChain\n\"bigChain pairwise alignment\"\n (\n string chrom; \"Reference sequence chromosome or scaffold\"\n uint chromStart; \"Start position in chromosome\"\n uint chromEnd; \"End position in chromosome\"\n string name; \"Name or ID of item, ideally both human readable and unique\"\n uint score; \"Score (0-1000)\"\n char[1] strand; \"+ or - for strand\"\n uint tSize; \"size of target sequence\"\n string qName; \"name of query sequence\"\n uint qSize; \"size of query sequence\"\n uint qStart; \"start of alignment on query sequence\"\n uint qEnd; \"end of alignment on query sequence\"\n uint chainScore; \"score from chain\"\n )";
|
|
2
|
+
export declare const bigGenePred = "table bigGenePred\n\"bigGenePred gene models\"\n (\n string chrom; \"Reference sequence chromosome or scaffold\"\n uint chromStart; \"Start position in chromosome\"\n uint chromEnd; \"End position in chromosome\"\n string name; \"Name or ID of item, ideally both human readable and unique\"\n uint score; \"Score (0-1000)\"\n char[1] strand; \"+ or - for strand\"\n uint thickStart; \"Start of where display should be thick (start codon)\"\n uint thickEnd; \"End of where display should be thick (stop codon)\"\n uint reserved; \"RGB value (use R,G,B string in input file)\"\n int blockCount; \"Number of blocks\"\n int[blockCount] blockSizes; \"Comma separated list of block sizes\"\n int[blockCount] chromStarts; \"Start positions relative to chromStart\"\n string name2; \"Alternative/human readable name\"\n string cdsStartStat; \"Status of CDS start annotation (none, unknown, incomplete, or complete)\"\n string cdsEndStat; \"Status of CDS end annotation (none, unknown, incomplete, or complete)\"\n int[blockCount] exonFrames; \"Exon frame {0,1,2}, or -1 if no frame for exon\"\n string type; \"Transcript type\"\n string geneName; \"Primary identifier for gene\"\n string geneName2; \"Alternative/human readable gene name\"\n string geneType; \"Gene type\"\n )";
|
|
3
|
+
export declare const bigInteract = "table interact\n\"interaction between two regions\"\n (\n string chrom; \"Chromosome (or contig, scaffold, etc.). For interchromosomal, use 2 records\"\n uint chromStart; \"Start position of lower region. For interchromosomal, set to chromStart of this region\"\n uint chromEnd; \"End position of upper region. For interchromosomal, set to chromEnd of this region\"\n string name; \"Name of item, for display. Usually 'sourceName/targetName/exp' or empty\"\n uint score; \"Score (0-1000)\"\n double value; \"Strength of interaction or other data value. Typically basis for score\"\n string exp; \"Experiment name (metadata for filtering). Use . if not applicable\"\n string color; \"Item color. Specified as r,g,b or hexadecimal #RRGGBB or html color name, as in //www.w3.org/TR/css3-color/#html4. Use 0 and spectrum setting to shade by score\"\n string sourceChrom; \"Chromosome of source region (directional) or lower region. For non-directional interchromosomal, chrom of this region.\"\n uint sourceStart; \"Start position in chromosome of source/lower/this region\"\n uint sourceEnd; \"End position in chromosome of source/lower/this region\"\n string sourceName; \"Identifier of source/lower/this region\"\n string sourceStrand; \"Orientation of source/lower/this region: + or -. Use . if not applicable\"\n string targetChrom; \"Chromosome of target region (directional) or upper region. For non-directional interchromosomal, chrom of other region\"\n uint targetStart; \"Start position in chromosome of target/upper/this region\"\n uint targetEnd; \"End position in chromosome of target/upper/this region\"\n string targetName; \"Identifier of target/upper/this region\"\n string targetStrand; \"Orientation of target/upper/this region: + or -. Use . if not applicable\"\n\n )";
|
|
4
|
+
export declare const bigLink = "table bigLink\n\"bigLink pairwise alignment\"\n (\n string chrom; \"Reference sequence chromosome or scaffold\"\n uint chromStart; \"Start position in chromosome\"\n uint chromEnd; \"End position in chromosome\"\n string name; \"Name or ID of item, ideally both human readable and unique\"\n uint qStart; \"start of alignment on query sequence\"\n )";
|
|
5
|
+
export declare const bigMaf = "table bedMaf\n\"Bed3 with MAF block\"\n (\n string chrom; \"Reference sequence chromosome or scaffold\"\n uint chromStart; \"Start position in chromosome\"\n uint chromEnd; \"End position in chromosome\"\n lstring mafBlock; \"MAF block\"\n )";
|
|
6
|
+
export declare const bigNarrowPeak = "table bigNarrowPeak\n\"BED6+4 Peaks of signal enrichment based on pooled, normalized (interpreted) data.\"\n(\n string chrom; \"Reference sequence chromosome or scaffold\"\n uint chromStart; \"Start position in chromosome\"\n uint chromEnd; \"End position in chromosome\"\n string name;\t \"Name given to a region (preferably unique). Use . if no name is assigned\"\n uint score; \"Indicates how dark the peak will be displayed in the browser (0-1000) \"\n char[1] strand; \"+ or - or . for unknown\"\n float signalValue; \"Measurement of average enrichment for the region\"\n float pValue; \"Statistical significance of signal value (-log10). Set to -1 if not used.\"\n float qValue; \"Statistical significance with multiple-test correction applied (FDR -log10). Set to -1 if not used.\"\n int peak; \"Point-source called for this peak; 0-based offset from chromStart. Set to -1 if no point-source called.\"\n)";
|
|
7
|
+
export declare const bigPsl = "table bigPsl\n\"bigPsl pairwise alignment\"\n (\n string chrom; \"Reference sequence chromosome or scaffold\"\n uint chromStart; \"Start position in chromosome\"\n uint chromEnd; \"End position in chromosome\"\n string name; \"Name or ID of item, ideally both human readable and unique\"\n uint score; \"Score (0-1000)\"\n char[1] strand; \"+ or - indicates whether the query aligns to the + or - strand on the reference\"\n uint thickStart; \"Start of where display should be thick (start codon)\"\n uint thickEnd; \"End of where display should be thick (stop codon)\"\n uint reserved; \"RGB value (use R,G,B string in input file)\"\n int blockCount; \"Number of blocks\"\n int[blockCount] blockSizes; \"Comma separated list of block sizes\"\n int[blockCount] chromStarts; \"Start positions relative to chromStart\"\n\n uint oChromStart;\"Start position in other chromosome\"\n uint oChromEnd; \"End position in other chromosome\"\n char[1] oStrand; \"+ or -, - means that psl was reversed into BED-compatible coordinates\"\n uint oChromSize; \"Size of other chromosome.\"\n int[blockCount] oChromStarts; \"Start positions relative to oChromStart or from oChromStart+oChromSize depending on strand\"\n\n lstring oSequence; \"Sequence on other chrom (or empty)\"\n string oCDS; \"CDS in NCBI format\"\n\n uint chromSize;\"Size of target chromosome\"\n\n uint match; \"Number of bases matched.\"\n uint misMatch; \" Number of bases that don't match \"\n uint repMatch; \" Number of bases that match but are part of repeats \"\n uint nCount; \" Number of 'N' bases \"\n uint seqType; \"0=empty, 1=nucleotide, 2=amino_acid\"\n )";
|
|
8
|
+
export declare const defaultBedSchema = "table defaultBedSchema\n\"BED12\"\n (\n string chrom; \"The name of the chromosome (e.g. chr3, chrY, chr2_random) or scaffold (e.g. scaffold10671).\"\n uint chromStart; \"The starting position of the feature in the chromosome or scaffold. The first base in a chromosome is numbered 0.\"\n uint chromEnd; \"The ending position of the feature in the chromosome or scaffold. The chromEnd base is not included in the display of the feature. For example, the first 100 bases of a chromosome are defined as chromStart=0, chromEnd=100, and span the bases numbered 0-99.\"\n string name; \"Defines the name of the BED line.\"\n float score; \"Feature score, doesn't care about the 0-1000 limit as in bed\"\n char strand; \"Defines the strand. Either '.' (=no strand) or '+' or '-'\"\n uint thickStart; \"The starting position at which the feature is drawn thickly (for example, the start codon in gene displays). When there is no thick part, thickStart and thickEnd are usually set to the chromStart position.\"\n uint thickEnd; \"The ending position at which the feature is drawn thickly (for example the stop codon in gene displays).\"\n string itemRgb; \"An RGB value of the form R,G,B (e.g. 255,0,0). \"\n uint blockCount; \" The number of blocks (exons) in the BED line.\"\n uint[blockCount] blockSizes; \" A comma-separated list of the block sizes. The number of items in this list should correspond to blockCount.\"\n uint[blockCount] blockStarts; \"A comma-separated list of block starts. All of the blockStart positions should be calculated relative to chromStart. The number of items in this list should correspond to blockCount.\"\n )";
|
|
9
|
+
export declare const mafFrames = "table mafFrames\n\"codon frame assignment for MAF components\"\n (\n string chrom; \"Reference sequence chromosome or scaffold\"\n uint chromStart; \"Start range in chromosome\"\n uint chromEnd; \"End range in chromosome\"\n string src; \"Name of sequence source in MAF\"\n ubyte frame; \"frame (0,1,2) for first base(+) or last bast(-)\"\n char[1] strand; \"+ or -\"\n string name; \"Name of gene used to define frame\"\n int prevFramePos; \"target position of the previous base (in transcription direction) that continues this frame, or -1 if none, or frame not contiguous\"\n int nextFramePos; \"target position of the next base (in transcription direction) that continues this frame, or -1 if none, or frame not contiguous\"\n ubyte isExonStart; \"does this start the CDS portion of an exon?\"\n ubyte isExonEnd; \"does this end the CDS portion of an exon?\"\n )";
|
|
10
|
+
export declare const mafSummary = "table mafSummary\n\"Positions and scores for alignment blocks\"\n (\n string chrom; \"Reference sequence chromosome or scaffold\"\n uint chromStart; \"Start position in chromosome\"\n uint chromEnd; \"End position in chromosome\"\n string src; \"Sequence name or database of alignment\"\n float score; \"Floating point score.\"\n char[1] leftStatus; \"Gap/break annotation for preceding block\"\n char[1] rightStatus; \"Gap/break annotation for following block\"\n )";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autoSqlSchemas.js","sourceRoot":"","sources":["../../src/as/autoSqlSchemas.
|
|
1
|
+
{"version":3,"file":"autoSqlSchemas.js","sourceRoot":"","sources":["../../src/as/autoSqlSchemas.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG,wvBAelB,CAAA;AAEO,QAAA,WAAW,GAAG,42CAuBtB,CAAA;AAEQ,QAAA,WAAW,GAAG,y4DAsBrB,CAAA;AAEO,QAAA,OAAO,GAAG,gZAQjB,CAAA;AAEO,QAAA,MAAM,GAAG,kRAOhB,CAAA;AACO,QAAA,aAAa,GAAG,w+BAa3B,CAAA;AACW,QAAA,MAAM,GAAG,qwDAgChB,CAAA;AAEO,QAAA,gBAAgB,GAAG,wqDAe1B,CAAA;AAEO,QAAA,SAAS,GAAG,07BAcnB,CAAA;AAEO,QAAA,UAAU,GAAG,wgBAUpB,CAAA"}
|
package/dist/defaultTypes.d.ts
CHANGED
package/dist/defaultTypes.js
CHANGED
|
@@ -27,6 +27,9 @@ var autoSql_1 = require("./autoSql");
|
|
|
27
27
|
var types = __importStar(require("./as/autoSqlSchemas"));
|
|
28
28
|
exports.default = Object.fromEntries(Object.entries(types).map(function (_a) {
|
|
29
29
|
var key = _a[0], val = _a[1];
|
|
30
|
-
return [
|
|
30
|
+
return [
|
|
31
|
+
key,
|
|
32
|
+
(0, autoSql_1.parse)(val.trim()),
|
|
33
|
+
];
|
|
31
34
|
}));
|
|
32
35
|
//# sourceMappingURL=defaultTypes.js.map
|
package/dist/defaultTypes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultTypes.js","sourceRoot":"","sources":["../src/defaultTypes.
|
|
1
|
+
{"version":3,"file":"defaultTypes.js","sourceRoot":"","sources":["../src/defaultTypes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAiC;AAEjC,yDAA4C;AAE5C,kBAAe,MAAM,CAAC,WAAW,CAC/B,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,UAAC,EAAU;QAAT,GAAG,QAAA,EAAE,GAAG,QAAA;IAAM,OAAA;QACxC,GAAG;QACH,IAAA,eAAK,EAAC,GAAG,CAAC,IAAI,EAAE,CAAqB;KACtC;AAHyC,CAGzC,CAAC,CACH,CAAA"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,oDAA0B;AAE1B,kBAAe,gBAAG,CAAA"}
|
package/dist/parser.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export default class BED {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
private autoSql;
|
|
3
|
+
private attemptDefaultBed?;
|
|
4
|
+
constructor(args?: {
|
|
5
|
+
autoSql?: string;
|
|
6
|
+
type?: string;
|
|
7
|
+
});
|
|
8
|
+
parseLine(line: string | string[], opts?: {
|
|
9
|
+
uniqueId?: string;
|
|
10
|
+
}): {
|
|
11
|
+
[key: string]: any;
|
|
12
12
|
};
|
|
13
13
|
}
|
package/dist/parser.js
CHANGED
|
@@ -42,13 +42,7 @@ var BED = /** @class */ (function () {
|
|
|
42
42
|
if (opts === void 0) { opts = {}; }
|
|
43
43
|
var autoSql = this.autoSql;
|
|
44
44
|
var uniqueId = opts.uniqueId;
|
|
45
|
-
var fields = line;
|
|
46
|
-
if (!Array.isArray(line)) {
|
|
47
|
-
if (line.startsWith('track') || line.startsWith('browser')) {
|
|
48
|
-
throw new Error("track and browser line parsing is not supported, please filter:\n".concat(line));
|
|
49
|
-
}
|
|
50
|
-
fields = line.split('\t');
|
|
51
|
-
}
|
|
45
|
+
var fields = Array.isArray(line) ? line : line.split('\t');
|
|
52
46
|
var feature = {};
|
|
53
47
|
if (!this.attemptDefaultBed ||
|
|
54
48
|
(this.attemptDefaultBed && isBed12Like(fields))) {
|
package/dist/parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":";;;;;AAAA,sDAA8B;AAC9B,gEAAkC;AAClC,+BAAqE;AAErE,IAAM,SAAS,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAA;AAE7C,oFAAoF;AACpF,SAAS,WAAW,CAAC,MAAgB;;IACnC,OAAO,CACL,MAAM,CAAC,MAAM,IAAI,EAAE;QACnB,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACtC,CAAA,MAAA,MAAM,CAAC,EAAE,CAAC,0CAAE,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,EAAH,CAAG,EAAE,MAAM,MAAK,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAC3E,CAAA;AACH,CAAC;AACD;IAKE,aAAY,IAA8C;QAA9C,qBAAA,EAAA,SAA8C;QACxD,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,IAAI,CAAC,OAAO,GAAG,IAAA,kBAAW,EAAC,iBAAM,CAAC,KA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,CAAA;YACpC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE;gBACpD,OAAO,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC,MAAM,CAAA;gBAC/B,OAAO,OAAO,CAAC,MAAM,CAAA;aACtB;YACD,IAAI,OAAO,CAAC,MAAM,KAAK,GAAG,IAAI,OAAO,CAAC,MAAM,KAAK,GAAG,EAAE;gBACpD,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;gBAC/B,OAAO,OAAO,CAAC,MAAM,CAAA;aACtB;SACF;QACD,IAAI,QAAQ,EAAE;YACZ,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAA;SAC5B;QACD,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,MAAgC,CAAC,IAAI,CAAC,CAAA;QAEzE,OAAO,CAAC,KAAK,GAAG,kBAAkB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACjD,OAAO,OAAO,CAAA;IAChB,CAAC;IACH,UAAC;AAAD,CAAC,AApFD,IAoFC"}
|
package/dist/util.d.ts
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface AutoSqlPreSchema {
|
|
2
|
+
fields: {
|
|
3
|
+
size: number;
|
|
4
|
+
type: string;
|
|
5
|
+
name: string;
|
|
6
|
+
}[];
|
|
7
|
+
}
|
|
8
|
+
export declare function detectTypes(autoSql: AutoSqlPreSchema): {
|
|
9
|
+
fields: {
|
|
10
|
+
isArray: boolean | 0;
|
|
11
|
+
arrayIsNumeric: boolean | 0;
|
|
12
|
+
isNumeric: boolean;
|
|
13
|
+
size: number;
|
|
14
|
+
type: string;
|
|
15
|
+
name: string;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
export declare type AutoSqlSchema = ReturnType<typeof detectTypes>;
|
package/dist/util.js
CHANGED
|
@@ -23,20 +23,7 @@ exports.detectTypes = void 0;
|
|
|
23
23
|
*/
|
|
24
24
|
function detectTypes(autoSql) {
|
|
25
25
|
var numericTypes = ['uint', 'int', 'float', 'long'];
|
|
26
|
-
|
|
27
|
-
var type = {};
|
|
28
|
-
if (!autoField.size && numericTypes.includes(autoField.type)) {
|
|
29
|
-
type.isNumeric = true;
|
|
30
|
-
}
|
|
31
|
-
if (autoField.size && autoField.type !== 'char') {
|
|
32
|
-
type.isArray = true;
|
|
33
|
-
}
|
|
34
|
-
if (autoField.size && numericTypes.includes(autoField.type)) {
|
|
35
|
-
type.arrayIsNumeric = true;
|
|
36
|
-
}
|
|
37
|
-
return __assign(__assign({}, autoField), type);
|
|
38
|
-
});
|
|
39
|
-
return __assign(__assign({}, autoSql), { fields: fields });
|
|
26
|
+
return __assign(__assign({}, autoSql), { fields: autoSql.fields.map(function (autoField) { return (__assign(__assign({}, autoField), { isArray: autoField.size && autoField.type !== 'char', arrayIsNumeric: autoField.size && numericTypes.includes(autoField.type), isNumeric: !autoField.size && numericTypes.includes(autoField.type) })); }) });
|
|
40
27
|
}
|
|
41
28
|
exports.detectTypes = detectTypes;
|
|
42
29
|
//# sourceMappingURL=util.js.map
|
package/dist/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAIA;;;;;;;;GAQG;AACH,SAAgB,WAAW,CAAC,OAAyB;IACnD,IAAM,YAAY,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;IACrD,6BACK,OAAO,KACV,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,UAAA,SAAS,IAAI,OAAA,uBACnC,SAAS,KACZ,OAAO,EAAE,SAAS,CAAC,IAAI,IAAI,SAAS,CAAC,IAAI,KAAK,MAAM,EACpD,cAAc,EAAE,SAAS,CAAC,IAAI,IAAI,YAAY,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,EACvE,SAAS,EAAE,CAAC,SAAS,CAAC,IAAI,IAAI,YAAY,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,IACnE,EALsC,CAKtC,CAAC,IACJ;AACH,CAAC;AAXD,kCAWC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export const bigChain
|
|
2
|
-
export const bigGenePred
|
|
3
|
-
export const bigInteract
|
|
4
|
-
export const bigLink
|
|
5
|
-
export const bigMaf
|
|
6
|
-
export const bigNarrowPeak
|
|
7
|
-
export const bigPsl
|
|
8
|
-
export const defaultBedSchema
|
|
9
|
-
export const mafFrames
|
|
10
|
-
export const mafSummary
|
|
1
|
+
export declare const bigChain = "table bigChain\n\"bigChain pairwise alignment\"\n (\n string chrom; \"Reference sequence chromosome or scaffold\"\n uint chromStart; \"Start position in chromosome\"\n uint chromEnd; \"End position in chromosome\"\n string name; \"Name or ID of item, ideally both human readable and unique\"\n uint score; \"Score (0-1000)\"\n char[1] strand; \"+ or - for strand\"\n uint tSize; \"size of target sequence\"\n string qName; \"name of query sequence\"\n uint qSize; \"size of query sequence\"\n uint qStart; \"start of alignment on query sequence\"\n uint qEnd; \"end of alignment on query sequence\"\n uint chainScore; \"score from chain\"\n )";
|
|
2
|
+
export declare const bigGenePred = "table bigGenePred\n\"bigGenePred gene models\"\n (\n string chrom; \"Reference sequence chromosome or scaffold\"\n uint chromStart; \"Start position in chromosome\"\n uint chromEnd; \"End position in chromosome\"\n string name; \"Name or ID of item, ideally both human readable and unique\"\n uint score; \"Score (0-1000)\"\n char[1] strand; \"+ or - for strand\"\n uint thickStart; \"Start of where display should be thick (start codon)\"\n uint thickEnd; \"End of where display should be thick (stop codon)\"\n uint reserved; \"RGB value (use R,G,B string in input file)\"\n int blockCount; \"Number of blocks\"\n int[blockCount] blockSizes; \"Comma separated list of block sizes\"\n int[blockCount] chromStarts; \"Start positions relative to chromStart\"\n string name2; \"Alternative/human readable name\"\n string cdsStartStat; \"Status of CDS start annotation (none, unknown, incomplete, or complete)\"\n string cdsEndStat; \"Status of CDS end annotation (none, unknown, incomplete, or complete)\"\n int[blockCount] exonFrames; \"Exon frame {0,1,2}, or -1 if no frame for exon\"\n string type; \"Transcript type\"\n string geneName; \"Primary identifier for gene\"\n string geneName2; \"Alternative/human readable gene name\"\n string geneType; \"Gene type\"\n )";
|
|
3
|
+
export declare const bigInteract = "table interact\n\"interaction between two regions\"\n (\n string chrom; \"Chromosome (or contig, scaffold, etc.). For interchromosomal, use 2 records\"\n uint chromStart; \"Start position of lower region. For interchromosomal, set to chromStart of this region\"\n uint chromEnd; \"End position of upper region. For interchromosomal, set to chromEnd of this region\"\n string name; \"Name of item, for display. Usually 'sourceName/targetName/exp' or empty\"\n uint score; \"Score (0-1000)\"\n double value; \"Strength of interaction or other data value. Typically basis for score\"\n string exp; \"Experiment name (metadata for filtering). Use . if not applicable\"\n string color; \"Item color. Specified as r,g,b or hexadecimal #RRGGBB or html color name, as in //www.w3.org/TR/css3-color/#html4. Use 0 and spectrum setting to shade by score\"\n string sourceChrom; \"Chromosome of source region (directional) or lower region. For non-directional interchromosomal, chrom of this region.\"\n uint sourceStart; \"Start position in chromosome of source/lower/this region\"\n uint sourceEnd; \"End position in chromosome of source/lower/this region\"\n string sourceName; \"Identifier of source/lower/this region\"\n string sourceStrand; \"Orientation of source/lower/this region: + or -. Use . if not applicable\"\n string targetChrom; \"Chromosome of target region (directional) or upper region. For non-directional interchromosomal, chrom of other region\"\n uint targetStart; \"Start position in chromosome of target/upper/this region\"\n uint targetEnd; \"End position in chromosome of target/upper/this region\"\n string targetName; \"Identifier of target/upper/this region\"\n string targetStrand; \"Orientation of target/upper/this region: + or -. Use . if not applicable\"\n\n )";
|
|
4
|
+
export declare const bigLink = "table bigLink\n\"bigLink pairwise alignment\"\n (\n string chrom; \"Reference sequence chromosome or scaffold\"\n uint chromStart; \"Start position in chromosome\"\n uint chromEnd; \"End position in chromosome\"\n string name; \"Name or ID of item, ideally both human readable and unique\"\n uint qStart; \"start of alignment on query sequence\"\n )";
|
|
5
|
+
export declare const bigMaf = "table bedMaf\n\"Bed3 with MAF block\"\n (\n string chrom; \"Reference sequence chromosome or scaffold\"\n uint chromStart; \"Start position in chromosome\"\n uint chromEnd; \"End position in chromosome\"\n lstring mafBlock; \"MAF block\"\n )";
|
|
6
|
+
export declare const bigNarrowPeak = "table bigNarrowPeak\n\"BED6+4 Peaks of signal enrichment based on pooled, normalized (interpreted) data.\"\n(\n string chrom; \"Reference sequence chromosome or scaffold\"\n uint chromStart; \"Start position in chromosome\"\n uint chromEnd; \"End position in chromosome\"\n string name;\t \"Name given to a region (preferably unique). Use . if no name is assigned\"\n uint score; \"Indicates how dark the peak will be displayed in the browser (0-1000) \"\n char[1] strand; \"+ or - or . for unknown\"\n float signalValue; \"Measurement of average enrichment for the region\"\n float pValue; \"Statistical significance of signal value (-log10). Set to -1 if not used.\"\n float qValue; \"Statistical significance with multiple-test correction applied (FDR -log10). Set to -1 if not used.\"\n int peak; \"Point-source called for this peak; 0-based offset from chromStart. Set to -1 if no point-source called.\"\n)";
|
|
7
|
+
export declare const bigPsl = "table bigPsl\n\"bigPsl pairwise alignment\"\n (\n string chrom; \"Reference sequence chromosome or scaffold\"\n uint chromStart; \"Start position in chromosome\"\n uint chromEnd; \"End position in chromosome\"\n string name; \"Name or ID of item, ideally both human readable and unique\"\n uint score; \"Score (0-1000)\"\n char[1] strand; \"+ or - indicates whether the query aligns to the + or - strand on the reference\"\n uint thickStart; \"Start of where display should be thick (start codon)\"\n uint thickEnd; \"End of where display should be thick (stop codon)\"\n uint reserved; \"RGB value (use R,G,B string in input file)\"\n int blockCount; \"Number of blocks\"\n int[blockCount] blockSizes; \"Comma separated list of block sizes\"\n int[blockCount] chromStarts; \"Start positions relative to chromStart\"\n\n uint oChromStart;\"Start position in other chromosome\"\n uint oChromEnd; \"End position in other chromosome\"\n char[1] oStrand; \"+ or -, - means that psl was reversed into BED-compatible coordinates\"\n uint oChromSize; \"Size of other chromosome.\"\n int[blockCount] oChromStarts; \"Start positions relative to oChromStart or from oChromStart+oChromSize depending on strand\"\n\n lstring oSequence; \"Sequence on other chrom (or empty)\"\n string oCDS; \"CDS in NCBI format\"\n\n uint chromSize;\"Size of target chromosome\"\n\n uint match; \"Number of bases matched.\"\n uint misMatch; \" Number of bases that don't match \"\n uint repMatch; \" Number of bases that match but are part of repeats \"\n uint nCount; \" Number of 'N' bases \"\n uint seqType; \"0=empty, 1=nucleotide, 2=amino_acid\"\n )";
|
|
8
|
+
export declare const defaultBedSchema = "table defaultBedSchema\n\"BED12\"\n (\n string chrom; \"The name of the chromosome (e.g. chr3, chrY, chr2_random) or scaffold (e.g. scaffold10671).\"\n uint chromStart; \"The starting position of the feature in the chromosome or scaffold. The first base in a chromosome is numbered 0.\"\n uint chromEnd; \"The ending position of the feature in the chromosome or scaffold. The chromEnd base is not included in the display of the feature. For example, the first 100 bases of a chromosome are defined as chromStart=0, chromEnd=100, and span the bases numbered 0-99.\"\n string name; \"Defines the name of the BED line.\"\n float score; \"Feature score, doesn't care about the 0-1000 limit as in bed\"\n char strand; \"Defines the strand. Either '.' (=no strand) or '+' or '-'\"\n uint thickStart; \"The starting position at which the feature is drawn thickly (for example, the start codon in gene displays). When there is no thick part, thickStart and thickEnd are usually set to the chromStart position.\"\n uint thickEnd; \"The ending position at which the feature is drawn thickly (for example the stop codon in gene displays).\"\n string itemRgb; \"An RGB value of the form R,G,B (e.g. 255,0,0). \"\n uint blockCount; \" The number of blocks (exons) in the BED line.\"\n uint[blockCount] blockSizes; \" A comma-separated list of the block sizes. The number of items in this list should correspond to blockCount.\"\n uint[blockCount] blockStarts; \"A comma-separated list of block starts. All of the blockStart positions should be calculated relative to chromStart. The number of items in this list should correspond to blockCount.\"\n )";
|
|
9
|
+
export declare const mafFrames = "table mafFrames\n\"codon frame assignment for MAF components\"\n (\n string chrom; \"Reference sequence chromosome or scaffold\"\n uint chromStart; \"Start range in chromosome\"\n uint chromEnd; \"End range in chromosome\"\n string src; \"Name of sequence source in MAF\"\n ubyte frame; \"frame (0,1,2) for first base(+) or last bast(-)\"\n char[1] strand; \"+ or -\"\n string name; \"Name of gene used to define frame\"\n int prevFramePos; \"target position of the previous base (in transcription direction) that continues this frame, or -1 if none, or frame not contiguous\"\n int nextFramePos; \"target position of the next base (in transcription direction) that continues this frame, or -1 if none, or frame not contiguous\"\n ubyte isExonStart; \"does this start the CDS portion of an exon?\"\n ubyte isExonEnd; \"does this end the CDS portion of an exon?\"\n )";
|
|
10
|
+
export declare const mafSummary = "table mafSummary\n\"Positions and scores for alignment blocks\"\n (\n string chrom; \"Reference sequence chromosome or scaffold\"\n uint chromStart; \"Start position in chromosome\"\n uint chromEnd; \"End position in chromosome\"\n string src; \"Sequence name or database of alignment\"\n float score; \"Floating point score.\"\n char[1] leftStatus; \"Gap/break annotation for preceding block\"\n char[1] rightStatus; \"Gap/break annotation for following block\"\n )";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autoSqlSchemas.js","sourceRoot":"","sources":["../../src/as/autoSqlSchemas.
|
|
1
|
+
{"version":3,"file":"autoSqlSchemas.js","sourceRoot":"","sources":["../../src/as/autoSqlSchemas.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;MAelB,CAAA;AAEN,MAAM,CAAC,MAAM,WAAW,GAAG;;;;;;;;;;;;;;;;;;;;;;;KAuBtB,CAAA;AAEL,MAAM,CAAC,MAAM,WAAW,GAAG;;;;;;;;;;;;;;;;;;;;;;MAsBrB,CAAA;AAEN,MAAM,CAAC,MAAM,OAAO,GAAG;;;;;;;;MAQjB,CAAA;AAEN,MAAM,CAAC,MAAM,MAAM,GAAG;;;;;;;MAOhB,CAAA;AACN,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;;;;;;EAa3B,CAAA;AACF,MAAM,CAAC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAgChB,CAAA;AAEN,MAAM,CAAC,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;MAe1B,CAAA;AAEN,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;;;;;;;;MAcnB,CAAA;AAEN,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;;;MAUpB,CAAA"}
|
package/esm/defaultTypes.d.ts
CHANGED
package/esm/defaultTypes.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { parse } from './autoSql';
|
|
2
2
|
import * as types from './as/autoSqlSchemas';
|
|
3
|
-
export default Object.fromEntries(Object.entries(types).map(([key, val]) =>
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export default Object.fromEntries(Object.entries(types).map(([key, val]) => [
|
|
4
|
+
key,
|
|
5
|
+
parse(val.trim()),
|
|
6
|
+
]));
|
|
6
7
|
//# sourceMappingURL=defaultTypes.js.map
|
package/esm/defaultTypes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultTypes.js","sourceRoot":"","sources":["../src/defaultTypes.
|
|
1
|
+
{"version":3,"file":"defaultTypes.js","sourceRoot":"","sources":["../src/defaultTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAEjC,OAAO,KAAK,KAAK,MAAM,qBAAqB,CAAA;AAE5C,eAAe,MAAM,CAAC,WAAW,CAC/B,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;IACxC,GAAG;IACH,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAqB;CACtC,CAAC,CACH,CAAA"}
|
package/esm/index.d.ts
CHANGED
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,UAAU,CAAA;AAE1B,eAAe,GAAG,CAAA"}
|
package/esm/parser.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export default class BED {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
private autoSql;
|
|
3
|
+
private attemptDefaultBed?;
|
|
4
|
+
constructor(args?: {
|
|
5
|
+
autoSql?: string;
|
|
6
|
+
type?: string;
|
|
7
|
+
});
|
|
8
|
+
parseLine(line: string | string[], opts?: {
|
|
9
|
+
uniqueId?: string;
|
|
10
|
+
}): {
|
|
11
|
+
[key: string]: any;
|
|
12
12
|
};
|
|
13
13
|
}
|
package/esm/parser.js
CHANGED
|
@@ -35,13 +35,7 @@ export default class BED {
|
|
|
35
35
|
parseLine(line, opts = {}) {
|
|
36
36
|
const { autoSql } = this;
|
|
37
37
|
const { uniqueId } = opts;
|
|
38
|
-
|
|
39
|
-
if (!Array.isArray(line)) {
|
|
40
|
-
if (line.startsWith('track') || line.startsWith('browser')) {
|
|
41
|
-
throw new Error(`track and browser line parsing is not supported, please filter:\n${line}`);
|
|
42
|
-
}
|
|
43
|
-
fields = line.split('\t');
|
|
44
|
-
}
|
|
38
|
+
const fields = Array.isArray(line) ? line : line.split('\t');
|
|
45
39
|
let feature = {};
|
|
46
40
|
if (!this.attemptDefaultBed ||
|
|
47
41
|
(this.attemptDefaultBed && isBed12Like(fields))) {
|
|
@@ -63,7 +57,7 @@ export default class BED {
|
|
|
63
57
|
columnVal.pop();
|
|
64
58
|
}
|
|
65
59
|
if (arrayIsNumeric) {
|
|
66
|
-
columnVal = columnVal.map(str => Number(str));
|
|
60
|
+
columnVal = columnVal.map((str) => Number(str));
|
|
67
61
|
}
|
|
68
62
|
}
|
|
69
63
|
feature[name] = columnVal;
|
package/esm/parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,WAAW,CAAA;AAC9B,OAAO,KAAK,MAAM,gBAAgB,CAAA;AAClC,OAAO,EAAE,WAAW,EAAmC,MAAM,QAAQ,CAAA;AAErE,MAAM,SAAS,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAA;AAE7C,oFAAoF;AACpF,SAAS,WAAW,CAAC,MAAgB;;IACnC,OAAO,CACL,MAAM,CAAC,MAAM,IAAI,EAAE;QACnB,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACtC,CAAA,MAAA,MAAM,CAAC,EAAE,CAAC,0CAAE,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,MAAK,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAC3E,CAAA;AACH,CAAC;AACD,MAAM,CAAC,OAAO,OAAO,GAAG;IAKtB,YAAY,OAA4C,EAAE;QACxD,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,IAAI,CAAC,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAqB,CAAC,CAAA;SAC3E;aAAM,IAAI,IAAI,CAAC,IAAI,EAAE;YACpB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBACrB,MAAM,IAAI,KAAK,CA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M,KAAK,GAAG,EAAE;gBACpD,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;gBAC/B,OAAO,OAAO,CAAC,MAAM,CAAA;aACtB;SACF;QACD,IAAI,QAAQ,EAAE;YACZ,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAA;SAC5B;QACD,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,MAAgC,CAAC,IAAI,CAAC,CAAA;QAEzE,OAAO,CAAC,KAAK,GAAG,kBAAkB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACjD,OAAO,OAAO,CAAA;IAChB,CAAC;CACF"}
|
package/esm/util.d.ts
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface AutoSqlPreSchema {
|
|
2
|
+
fields: {
|
|
3
|
+
size: number;
|
|
4
|
+
type: string;
|
|
5
|
+
name: string;
|
|
6
|
+
}[];
|
|
7
|
+
}
|
|
8
|
+
export declare function detectTypes(autoSql: AutoSqlPreSchema): {
|
|
9
|
+
fields: {
|
|
10
|
+
isArray: boolean | 0;
|
|
11
|
+
arrayIsNumeric: boolean | 0;
|
|
12
|
+
isNumeric: boolean;
|
|
13
|
+
size: number;
|
|
14
|
+
type: string;
|
|
15
|
+
name: string;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
export declare type AutoSqlSchema = ReturnType<typeof detectTypes>;
|
package/esm/util.js
CHANGED
|
@@ -9,19 +9,14 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export function detectTypes(autoSql) {
|
|
11
11
|
const numericTypes = ['uint', 'int', 'float', 'long'];
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
type.arrayIsNumeric = true;
|
|
22
|
-
}
|
|
23
|
-
return { ...autoField, ...type };
|
|
24
|
-
});
|
|
25
|
-
return { ...autoSql, fields };
|
|
12
|
+
return {
|
|
13
|
+
...autoSql,
|
|
14
|
+
fields: autoSql.fields.map(autoField => ({
|
|
15
|
+
...autoField,
|
|
16
|
+
isArray: autoField.size && autoField.type !== 'char',
|
|
17
|
+
arrayIsNumeric: autoField.size && numericTypes.includes(autoField.type),
|
|
18
|
+
isNumeric: !autoField.size && numericTypes.includes(autoField.type),
|
|
19
|
+
})),
|
|
20
|
+
};
|
|
26
21
|
}
|
|
27
22
|
//# sourceMappingURL=util.js.map
|
package/esm/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,OAAyB;IACnD,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;IACrD,OAAO;QACL,GAAG,OAAO;QACV,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;YACvC,GAAG,SAAS;YACZ,OAAO,EAAE,SAAS,CAAC,IAAI,IAAI,SAAS,CAAC,IAAI,KAAK,MAAM;YACpD,cAAc,EAAE,SAAS,CAAC,IAAI,IAAI,YAAY,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC;YACvE,SAAS,EAAE,CAAC,SAAS,CAAC,IAAI,IAAI,YAAY,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC;SACpE,CAAC,CAAC;KACJ,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gmod/bed",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "A BED file format parser with autoSql support",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -38,20 +38,20 @@
|
|
|
38
38
|
"postversion": "git push --follow-tags"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@types/jest": "^
|
|
42
|
-
"@typescript-eslint/eslint-plugin": "^5.7
|
|
43
|
-
"@typescript-eslint/parser": "^5.7
|
|
44
|
-
"eslint": "^8.
|
|
41
|
+
"@types/jest": "^28.1.6",
|
|
42
|
+
"@typescript-eslint/eslint-plugin": "^5.30.7",
|
|
43
|
+
"@typescript-eslint/parser": "^5.30.7",
|
|
44
|
+
"eslint": "^8.20.0",
|
|
45
45
|
"eslint-config-prettier": "^8.3.0",
|
|
46
|
-
"eslint-plugin-import": "^2.
|
|
47
|
-
"eslint-plugin-prettier": "^4.
|
|
48
|
-
"jest": "^
|
|
46
|
+
"eslint-plugin-import": "^2.26.0",
|
|
47
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
48
|
+
"jest": "^28.1.3",
|
|
49
49
|
"pegjs": "^0.10.0",
|
|
50
|
-
"prettier": "^2.
|
|
50
|
+
"prettier": "^2.7.1",
|
|
51
51
|
"rimraf": "^3.0.2",
|
|
52
52
|
"standard-changelog": "^2.0.24",
|
|
53
|
-
"ts-jest": "^
|
|
54
|
-
"typescript": "^4.
|
|
53
|
+
"ts-jest": "^28.0.7",
|
|
54
|
+
"typescript": "^4.7.4"
|
|
55
55
|
},
|
|
56
56
|
"keywords": [
|
|
57
57
|
"bed",
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { parse } from './autoSql'
|
|
2
|
+
import { AutoSqlPreSchema } from './util'
|
|
3
|
+
import * as types from './as/autoSqlSchemas'
|
|
4
|
+
|
|
5
|
+
export default Object.fromEntries(
|
|
6
|
+
Object.entries(types).map(([key, val]) => [
|
|
7
|
+
key,
|
|
8
|
+
parse(val.trim()) as AutoSqlPreSchema,
|
|
9
|
+
]),
|
|
10
|
+
)
|
|
File without changes
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import parser from './autoSql'
|
|
2
2
|
import types from './defaultTypes'
|
|
3
|
-
import { detectTypes } from './util'
|
|
3
|
+
import { detectTypes, AutoSqlSchema, AutoSqlPreSchema } from './util'
|
|
4
4
|
|
|
5
5
|
const strandMap = { '.': 0, '-': -1, '+': 1 }
|
|
6
6
|
|
|
7
7
|
// heuristic that a BED file is BED12 like...the number in col 10 is blockCount-like
|
|
8
|
-
function isBed12Like(fields) {
|
|
8
|
+
function isBed12Like(fields: string[]) {
|
|
9
9
|
return (
|
|
10
10
|
fields.length >= 12 &&
|
|
11
11
|
!Number.isNaN(parseInt(fields[9], 10)) &&
|
|
12
12
|
fields[10]?.split(',').filter(f => !!f).length === parseInt(fields[9], 10)
|
|
13
13
|
)
|
|
14
14
|
}
|
|
15
|
-
|
|
16
15
|
export default class BED {
|
|
17
|
-
|
|
16
|
+
private autoSql: AutoSqlSchema
|
|
17
|
+
|
|
18
|
+
private attemptDefaultBed?: boolean
|
|
19
|
+
|
|
20
|
+
constructor(args: { autoSql?: string; type?: string } = {}) {
|
|
18
21
|
if (args.autoSql) {
|
|
19
|
-
this.autoSql = detectTypes(parser.parse(args.autoSql))
|
|
22
|
+
this.autoSql = detectTypes(parser.parse(args.autoSql) as AutoSqlPreSchema)
|
|
20
23
|
} else if (args.type) {
|
|
21
24
|
if (!types[args.type]) {
|
|
22
25
|
throw new Error('Type not found')
|
|
@@ -35,27 +38,19 @@ export default class BED {
|
|
|
35
38
|
* @param opts - supply opts.uniqueId
|
|
36
39
|
* @return a object representing a feature
|
|
37
40
|
*/
|
|
38
|
-
parseLine(line, opts = {}) {
|
|
41
|
+
parseLine(line: string | string[], opts: { uniqueId?: string } = {}) {
|
|
39
42
|
const { autoSql } = this
|
|
40
43
|
const { uniqueId } = opts
|
|
41
|
-
|
|
42
|
-
if (!Array.isArray(line)) {
|
|
43
|
-
if (line.startsWith('track') || line.startsWith('browser')) {
|
|
44
|
-
throw new Error(
|
|
45
|
-
`track and browser line parsing is not supported, please filter:\n${line}`,
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
|
-
fields = line.split('\t')
|
|
49
|
-
}
|
|
44
|
+
const fields = Array.isArray(line) ? line : line.split('\t')
|
|
50
45
|
|
|
51
|
-
let feature = {}
|
|
46
|
+
let feature = {} as { [key: string]: any }
|
|
52
47
|
if (
|
|
53
48
|
!this.attemptDefaultBed ||
|
|
54
49
|
(this.attemptDefaultBed && isBed12Like(fields))
|
|
55
50
|
) {
|
|
56
51
|
for (let i = 0; i < autoSql.fields.length; i++) {
|
|
57
52
|
const autoField = autoSql.fields[i]
|
|
58
|
-
let columnVal = fields[i]
|
|
53
|
+
let columnVal: any = fields[i]
|
|
59
54
|
const { isNumeric, isArray, arrayIsNumeric, name } = autoField
|
|
60
55
|
if (columnVal === null || columnVal === undefined) {
|
|
61
56
|
break
|
|
@@ -70,7 +65,7 @@ export default class BED {
|
|
|
70
65
|
columnVal.pop()
|
|
71
66
|
}
|
|
72
67
|
if (arrayIsNumeric) {
|
|
73
|
-
columnVal = columnVal.map(str => Number(str))
|
|
68
|
+
columnVal = columnVal.map((str: string) => Number(str))
|
|
74
69
|
}
|
|
75
70
|
}
|
|
76
71
|
|
|
@@ -96,7 +91,7 @@ export default class BED {
|
|
|
96
91
|
if (uniqueId) {
|
|
97
92
|
feature.uniqueId = uniqueId
|
|
98
93
|
}
|
|
99
|
-
feature.strand = strandMap[feature.strand] || 0
|
|
94
|
+
feature.strand = strandMap[feature.strand as keyof typeof strandMap] || 0
|
|
100
95
|
|
|
101
96
|
feature.chrom = decodeURIComponent(feature.chrom)
|
|
102
97
|
return feature
|
package/src/util.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface AutoSqlPreSchema {
|
|
2
|
+
fields: { size: number; type: string; name: string }[]
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* adds some type annotations to the autoSql schema
|
|
7
|
+
* for numeric fields ['uint', 'int', 'float', 'long'] "isNumeric" is added
|
|
8
|
+
* for array types "isArray" is added
|
|
9
|
+
* for numeric array types "isArray" and "arrayIsNumeric" is set
|
|
10
|
+
*
|
|
11
|
+
* @param autoSql - an autoSql schema from the peg parser
|
|
12
|
+
* @return autoSql with type annotations added
|
|
13
|
+
*/
|
|
14
|
+
export function detectTypes(autoSql: AutoSqlPreSchema) {
|
|
15
|
+
const numericTypes = ['uint', 'int', 'float', 'long']
|
|
16
|
+
return {
|
|
17
|
+
...autoSql,
|
|
18
|
+
fields: autoSql.fields.map(autoField => ({
|
|
19
|
+
...autoField,
|
|
20
|
+
isArray: autoField.size && autoField.type !== 'char',
|
|
21
|
+
arrayIsNumeric: autoField.size && numericTypes.includes(autoField.type),
|
|
22
|
+
isNumeric: !autoField.size && numericTypes.includes(autoField.type),
|
|
23
|
+
})),
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type AutoSqlSchema = ReturnType<typeof detectTypes>
|
package/src/defaultTypes.js
DELETED
package/src/util.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* adds some type annotations to the autoSql schema
|
|
3
|
-
* for numeric fields ['uint', 'int', 'float', 'long'] "isNumeric" is added
|
|
4
|
-
* for array types "isArray" is added
|
|
5
|
-
* for numeric array types "isArray" and "arrayIsNumeric" is set
|
|
6
|
-
*
|
|
7
|
-
* @param autoSql - an autoSql schema from the peg parser
|
|
8
|
-
* @return autoSql with type annotations added
|
|
9
|
-
*/
|
|
10
|
-
export function detectTypes(autoSql) {
|
|
11
|
-
const numericTypes = ['uint', 'int', 'float', 'long']
|
|
12
|
-
const fields = autoSql.fields.map(autoField => {
|
|
13
|
-
const type = {}
|
|
14
|
-
if (!autoField.size && numericTypes.includes(autoField.type)) {
|
|
15
|
-
type.isNumeric = true
|
|
16
|
-
}
|
|
17
|
-
if (autoField.size && autoField.type !== 'char') {
|
|
18
|
-
type.isArray = true
|
|
19
|
-
}
|
|
20
|
-
if (autoField.size && numericTypes.includes(autoField.type)) {
|
|
21
|
-
type.arrayIsNumeric = true
|
|
22
|
-
}
|
|
23
|
-
return { ...autoField, ...type }
|
|
24
|
-
})
|
|
25
|
-
return { ...autoSql, fields }
|
|
26
|
-
}
|