@jbrowse/plugin-config 4.3.0 → 5.0.0-beta.1
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/esm/ConfigurationEditorWidget/components/AddNewField.d.ts +4 -0
- package/esm/ConfigurationEditorWidget/components/AddNewField.js +28 -0
- package/esm/ConfigurationEditorWidget/components/BooleanEditor.d.ts +4 -2
- package/esm/ConfigurationEditorWidget/components/BooleanEditor.js +19 -4
- package/esm/ConfigurationEditorWidget/components/CallbackEditor.d.ts +4 -2
- package/esm/ConfigurationEditorWidget/components/CallbackEditor.js +24 -42
- package/esm/ConfigurationEditorWidget/components/ColorEditor.d.ts +3 -11
- package/esm/ConfigurationEditorWidget/components/ColorEditor.js +28 -20
- package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.d.ts +2 -3
- package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.js +108 -17
- package/esm/ConfigurationEditorWidget/components/ConfigurationTextField.d.ts +1 -1
- package/esm/ConfigurationEditorWidget/components/ConfigurationTextField.js +10 -2
- package/esm/ConfigurationEditorWidget/components/HeadingComponent.d.ts +1 -1
- package/esm/ConfigurationEditorWidget/components/IntegerEditor.d.ts +10 -0
- package/esm/ConfigurationEditorWidget/components/IntegerEditor.js +9 -0
- package/esm/ConfigurationEditorWidget/components/JsonEditor.d.ts +3 -1
- package/esm/ConfigurationEditorWidget/components/JsonEditor.js +27 -40
- package/esm/ConfigurationEditorWidget/components/MapEntryCard.d.ts +8 -0
- package/esm/ConfigurationEditorWidget/components/MapEntryCard.js +23 -0
- package/esm/ConfigurationEditorWidget/components/MapSlotEditor.d.ts +8 -0
- package/esm/ConfigurationEditorWidget/components/MapSlotEditor.js +18 -0
- package/esm/ConfigurationEditorWidget/components/NumberEditor.d.ts +6 -4
- package/esm/ConfigurationEditorWidget/components/NumberEditor.js +24 -15
- package/esm/ConfigurationEditorWidget/components/NumberMapEditor.d.ts +4 -4
- package/esm/ConfigurationEditorWidget/components/NumberMapEditor.js +7 -31
- package/esm/ConfigurationEditorWidget/components/SlotEditor.d.ts +4 -5
- package/esm/ConfigurationEditorWidget/components/SlotEditor.js +83 -48
- package/esm/ConfigurationEditorWidget/components/StringArrayEditor.d.ts +3 -4
- package/esm/ConfigurationEditorWidget/components/StringArrayEditor.js +11 -24
- package/esm/ConfigurationEditorWidget/components/StringArrayMapEditor.d.ts +3 -6
- package/esm/ConfigurationEditorWidget/components/StringArrayMapEditor.js +14 -39
- package/esm/ConfigurationEditorWidget/components/TypeSelector.d.ts +1 -1
- package/esm/ConfigurationEditorWidget/components/TypeSelector.js +2 -2
- package/esm/ConfigurationEditorWidget/components/singularSlotName.d.ts +13 -0
- package/esm/ConfigurationEditorWidget/components/singularSlotName.js +23 -0
- package/esm/ConfigurationEditorWidget/components/useSlotEditorStyles.d.ts +2 -2
- package/esm/ConfigurationEditorWidget/components/useSlotEditorStyles.js +6 -1
- package/esm/ConfigurationEditorWidget/index.js +3 -3
- package/esm/ConfigurationEditorWidget/model.d.ts +8 -1
- package/esm/ConfigurationEditorWidget/model.js +40 -1
- package/esm/FromConfigAdapter/FromConfigAdapter.d.ts +6 -1
- package/esm/FromConfigAdapter/FromConfigAdapter.js +31 -1
- package/esm/FromConfigAdapter/configSchema.d.ts +36 -3
- package/esm/FromConfigAdapter/configSchema.js +34 -2
- package/esm/FromConfigAdapter/index.js +2 -2
- package/esm/FromConfigRegionsAdapter/FromConfigRegionsAdapter.d.ts +8 -0
- package/esm/FromConfigRegionsAdapter/FromConfigRegionsAdapter.js +10 -25
- package/esm/FromConfigRegionsAdapter/configSchema.d.ts +42 -3
- package/esm/FromConfigRegionsAdapter/configSchema.js +39 -2
- package/esm/FromConfigRegionsAdapter/index.js +2 -2
- package/esm/FromConfigSequenceAdapter/FromConfigSequenceAdapter.d.ts +15 -2
- package/esm/FromConfigSequenceAdapter/FromConfigSequenceAdapter.js +32 -40
- package/esm/FromConfigSequenceAdapter/configSchema.d.ts +41 -3
- package/esm/FromConfigSequenceAdapter/configSchema.js +38 -2
- package/esm/FromConfigSequenceAdapter/index.js +2 -2
- package/esm/NcbiSequenceReportAliasAdapter/NcbiSequenceReportAliasAdapter.d.ts +5 -4
- package/esm/NcbiSequenceReportAliasAdapter/NcbiSequenceReportAliasAdapter.js +28 -24
- package/esm/NcbiSequenceReportAliasAdapter/configSchema.d.ts +77 -9
- package/esm/NcbiSequenceReportAliasAdapter/configSchema.js +79 -12
- package/esm/NcbiSequenceReportAliasAdapter/index.js +3 -2
- package/esm/RefNameAliasAdapter/RefNameAliasAdapter.d.ts +4 -3
- package/esm/RefNameAliasAdapter/RefNameAliasAdapter.js +22 -28
- package/esm/RefNameAliasAdapter/configSchema.d.ts +87 -12
- package/esm/RefNameAliasAdapter/configSchema.js +86 -12
- package/esm/RefNameAliasAdapter/index.js +3 -2
- package/esm/aliasUtils.d.ts +4 -0
- package/esm/aliasUtils.js +26 -0
- package/esm/index.d.ts +2 -2
- package/esm/index.js +7 -7
- package/esm/normalizeUriSnapshot.d.ts +1 -0
- package/esm/normalizeUriSnapshot.js +13 -0
- package/package.json +11 -15
|
@@ -1,12 +1,48 @@
|
|
|
1
1
|
import { ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* #config FromConfigSequenceAdapter
|
|
4
|
+
* #trackType ReferenceSequenceTrack
|
|
5
|
+
* #fileFormat inline | Inline sequence | Each feature's `seq` holds the bases for its region
|
|
6
|
+
* supplies reference sequence inline in the config; each feature's `seq` holds
|
|
7
|
+
* the bases for its region
|
|
8
|
+
*
|
|
9
|
+
* #example
|
|
10
|
+
* Used as the adapter of an assembly's `sequence` (a `ReferenceSequenceTrack`):
|
|
11
|
+
* ```js
|
|
12
|
+
* {
|
|
13
|
+
* type: 'ReferenceSequenceTrack',
|
|
14
|
+
* trackId: 'my_refseq',
|
|
15
|
+
* adapter: {
|
|
16
|
+
* type: 'FromConfigSequenceAdapter',
|
|
17
|
+
* features: [
|
|
18
|
+
* { uniqueId: 'ctgA', refName: 'ctgA', start: 0, end: 10, seq: 'ATGCATGCAT' },
|
|
19
|
+
* ],
|
|
20
|
+
* },
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
3
24
|
const sequenceConfigSchema = ConfigurationSchema('FromConfigSequenceAdapter', {
|
|
25
|
+
/**
|
|
26
|
+
* #slot
|
|
27
|
+
* stable identifier used as the adapter cache key; avoids hashing the
|
|
28
|
+
* (potentially large) features array. optional — falls back to hash.
|
|
29
|
+
*/
|
|
30
|
+
adapterId: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
defaultValue: '',
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* #slot
|
|
36
|
+
* one entry per reference sequence, each with a `uniqueId`, `refName`,
|
|
37
|
+
* `start`, `end`, and a `seq` string holding the bases for that span. The
|
|
38
|
+
* bases live in the config, so this is for small sequences — a plasmid, a
|
|
39
|
+
* test contig — not a genome.
|
|
40
|
+
*/
|
|
4
41
|
features: {
|
|
5
42
|
type: 'frozen',
|
|
6
43
|
defaultValue: [],
|
|
7
44
|
},
|
|
8
45
|
}, {
|
|
9
46
|
explicitlyTyped: true,
|
|
10
|
-
implicitIdentifier: 'adapterId',
|
|
11
47
|
});
|
|
12
48
|
export default sequenceConfigSchema;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AdapterType } from '@jbrowse/core/pluggableElementTypes';
|
|
2
|
-
import configSchema from
|
|
2
|
+
import configSchema from './configSchema.js';
|
|
3
3
|
export default function FromConfigSequenceAdapterF(pluginManager) {
|
|
4
4
|
pluginManager.addAdapterType(() => new AdapterType({
|
|
5
5
|
name: 'FromConfigSequenceAdapter',
|
|
6
6
|
configSchema,
|
|
7
|
-
getAdapterClass: () => import(
|
|
7
|
+
getAdapterClass: () => import('./FromConfigSequenceAdapter.js').then(r => r.default),
|
|
8
8
|
adapterMetadata: {
|
|
9
9
|
hiddenFromGUI: true,
|
|
10
10
|
},
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { BaseAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import type { NcbiSequenceReportAliasAdapterConfig } from './configSchema.ts';
|
|
3
|
+
import type { BaseOptions, BaseRefNameAliasAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
4
|
+
export default class NcbiSequenceReportAliasAdapter extends BaseAdapter<NcbiSequenceReportAliasAdapterConfig> implements BaseRefNameAliasAdapter {
|
|
5
|
+
getRefNameAliases(opts?: BaseOptions): Promise<{
|
|
5
6
|
refName: string;
|
|
6
7
|
aliases: string[];
|
|
7
|
-
override:
|
|
8
|
+
override: boolean;
|
|
8
9
|
}[]>;
|
|
9
10
|
}
|
|
@@ -1,38 +1,42 @@
|
|
|
1
1
|
import { BaseAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
2
|
-
import {
|
|
2
|
+
import { readAliasRows } from '../aliasUtils.js';
|
|
3
|
+
// locate a column by its header name, throwing a column-specific error if a
|
|
4
|
+
// required one is absent
|
|
5
|
+
function requireColumn(header, name) {
|
|
6
|
+
const idx = header.indexOf(name);
|
|
7
|
+
if (idx === -1) {
|
|
8
|
+
throw new Error(`sequence_report.tsv header is missing required column "${name}"`);
|
|
9
|
+
}
|
|
10
|
+
return idx;
|
|
11
|
+
}
|
|
3
12
|
export default class NcbiSequenceReportAliasAdapter extends BaseAdapter {
|
|
4
|
-
async getRefNameAliases() {
|
|
5
|
-
const
|
|
6
|
-
if (
|
|
13
|
+
async getRefNameAliases(opts) {
|
|
14
|
+
const rows = await readAliasRows(this.getConf('location'), this.pluginManager, opts);
|
|
15
|
+
if (rows.length === 0) {
|
|
7
16
|
return [];
|
|
8
17
|
}
|
|
9
18
|
const override = this.getConf('useNameOverride');
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
return lines
|
|
24
|
-
.slice(1)
|
|
25
|
-
.filter(cols => !!cols[ucscIdx] || !!cols[seqNameIdx])
|
|
19
|
+
const header = rows[0];
|
|
20
|
+
const dataRows = rows.slice(1);
|
|
21
|
+
const genBankIdx = requireColumn(header, 'GenBank seq accession');
|
|
22
|
+
const refSeqIdx = requireColumn(header, 'RefSeq seq accession');
|
|
23
|
+
const ucscIdx = requireColumn(header, 'UCSC style name');
|
|
24
|
+
// Sequence name is optional; -1 means absent
|
|
25
|
+
const seqNameIdx = header.indexOf('Sequence name');
|
|
26
|
+
const seqName = (cols) => seqNameIdx === -1 ? undefined : cols[seqNameIdx];
|
|
27
|
+
// refName comes from the UCSC name, falling back to the Sequence name; the
|
|
28
|
+
// filter guarantees one is present, so every mapped row has a truthy refName
|
|
29
|
+
return dataRows
|
|
30
|
+
.filter(cols => !!cols[ucscIdx] || !!seqName(cols))
|
|
26
31
|
.map(cols => ({
|
|
27
|
-
refName: (cols[ucscIdx] || cols
|
|
32
|
+
refName: (cols[ucscIdx] || seqName(cols)),
|
|
28
33
|
aliases: [
|
|
29
34
|
cols[genBankIdx],
|
|
30
35
|
cols[refSeqIdx],
|
|
31
36
|
cols[ucscIdx],
|
|
32
|
-
cols
|
|
37
|
+
seqName(cols),
|
|
33
38
|
].filter((f) => !!f),
|
|
34
39
|
override,
|
|
35
|
-
}))
|
|
36
|
-
.filter(f => !!f.refName);
|
|
40
|
+
}));
|
|
37
41
|
}
|
|
38
42
|
}
|
|
@@ -1,15 +1,83 @@
|
|
|
1
|
+
import { normalizeUriSnapshot } from '../normalizeUriSnapshot.ts';
|
|
2
|
+
import type { Instance } from '@jbrowse/mobx-state-tree';
|
|
3
|
+
export declare const normalizeSnapshot: typeof normalizeUriSnapshot;
|
|
4
|
+
/**
|
|
5
|
+
* #config NcbiSequenceReportAliasAdapter
|
|
6
|
+
* can read "sequence_report.tsv" type files from NCBI
|
|
7
|
+
*
|
|
8
|
+
* #example
|
|
9
|
+
* Goes on an ASSEMBLY, under `refNameAliases` — not on a track. The file ships
|
|
10
|
+
* beside any RefSeq assembly on NCBI datasets and aliases the RefSeq, GenBank
|
|
11
|
+
* and UCSC-style names of every sequence at once, so it replaces a
|
|
12
|
+
* hand-maintained chromAlias table:
|
|
13
|
+
* ```js
|
|
14
|
+
* {
|
|
15
|
+
* name: 'GCF_000001405.40',
|
|
16
|
+
* sequence: {
|
|
17
|
+
* type: 'ReferenceSequenceTrack',
|
|
18
|
+
* trackId: 'GCF_000001405.40-ReferenceSequenceTrack',
|
|
19
|
+
* adapter: {
|
|
20
|
+
* type: 'BgzipFastaAdapter',
|
|
21
|
+
* uri: 'https://example.com/GCF_000001405.40.fa.gz',
|
|
22
|
+
* },
|
|
23
|
+
* },
|
|
24
|
+
* refNameAliases: {
|
|
25
|
+
* adapter: {
|
|
26
|
+
* type: 'NcbiSequenceReportAliasAdapter',
|
|
27
|
+
* uri: 'https://example.com/GCF_000001405.40_sequence_report.tsv',
|
|
28
|
+
* },
|
|
29
|
+
* },
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* #example keeping the FASTA's own names
|
|
34
|
+
* With an NCBI FASTA (`NC_000001.11`), the default displays UCSC-style names
|
|
35
|
+
* (`chr1`) while still fetching bases under the accession. Set
|
|
36
|
+
* `useNameOverride: false` to display the accessions instead, with `chr1` left
|
|
37
|
+
* searchable as an alias:
|
|
38
|
+
* ```js
|
|
39
|
+
* {
|
|
40
|
+
* name: 'GCF_000001405.40',
|
|
41
|
+
* sequence: {
|
|
42
|
+
* type: 'ReferenceSequenceTrack',
|
|
43
|
+
* trackId: 'GCF_000001405.40-ReferenceSequenceTrack',
|
|
44
|
+
* adapter: {
|
|
45
|
+
* type: 'BgzipFastaAdapter',
|
|
46
|
+
* uri: 'https://example.com/GCF_000001405.40.fa.gz',
|
|
47
|
+
* },
|
|
48
|
+
* },
|
|
49
|
+
* refNameAliases: {
|
|
50
|
+
* adapter: {
|
|
51
|
+
* type: 'NcbiSequenceReportAliasAdapter',
|
|
52
|
+
* uri: 'https://example.com/GCF_000001405.40_sequence_report.tsv',
|
|
53
|
+
* useNameOverride: false,
|
|
54
|
+
* },
|
|
55
|
+
* },
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
1
59
|
declare const NcbiSequenceReportAliasAdapterConfigSchema: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
60
|
+
/**
|
|
61
|
+
* #slot
|
|
62
|
+
* location of the `sequence_report.tsv` NCBI publishes with an assembly. It
|
|
63
|
+
* carries the RefSeq, GenBank and UCSC-style name of every sequence, so one
|
|
64
|
+
* file aliases them all without hand-writing a chromAlias table.
|
|
65
|
+
*/
|
|
66
|
+
readonly location: {
|
|
67
|
+
readonly type: "fileLocation";
|
|
68
|
+
readonly defaultValue: {
|
|
69
|
+
readonly uri: "/path/to/my/sequence_report.tsv";
|
|
70
|
+
readonly locationType: "UriLocation";
|
|
7
71
|
};
|
|
8
72
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
73
|
+
/**
|
|
74
|
+
* #slot
|
|
75
|
+
*/
|
|
76
|
+
readonly useNameOverride: {
|
|
77
|
+
readonly type: "boolean";
|
|
78
|
+
readonly defaultValue: true;
|
|
79
|
+
readonly description: "forces usage of the UCSC names over the NCBI style names from a FASTA";
|
|
13
80
|
};
|
|
14
81
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
|
|
82
|
+
export type NcbiSequenceReportAliasAdapterConfig = Instance<typeof NcbiSequenceReportAliasAdapterConfigSchema>;
|
|
15
83
|
export default NcbiSequenceReportAliasAdapterConfigSchema;
|
|
@@ -1,6 +1,68 @@
|
|
|
1
1
|
import { ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
2
|
-
|
|
2
|
+
import { normalizeUriSnapshot } from '../normalizeUriSnapshot.js';
|
|
3
|
+
export const normalizeSnapshot = normalizeUriSnapshot;
|
|
4
|
+
/**
|
|
5
|
+
* #config NcbiSequenceReportAliasAdapter
|
|
6
|
+
* can read "sequence_report.tsv" type files from NCBI
|
|
7
|
+
*
|
|
8
|
+
* #example
|
|
9
|
+
* Goes on an ASSEMBLY, under `refNameAliases` — not on a track. The file ships
|
|
10
|
+
* beside any RefSeq assembly on NCBI datasets and aliases the RefSeq, GenBank
|
|
11
|
+
* and UCSC-style names of every sequence at once, so it replaces a
|
|
12
|
+
* hand-maintained chromAlias table:
|
|
13
|
+
* ```js
|
|
14
|
+
* {
|
|
15
|
+
* name: 'GCF_000001405.40',
|
|
16
|
+
* sequence: {
|
|
17
|
+
* type: 'ReferenceSequenceTrack',
|
|
18
|
+
* trackId: 'GCF_000001405.40-ReferenceSequenceTrack',
|
|
19
|
+
* adapter: {
|
|
20
|
+
* type: 'BgzipFastaAdapter',
|
|
21
|
+
* uri: 'https://example.com/GCF_000001405.40.fa.gz',
|
|
22
|
+
* },
|
|
23
|
+
* },
|
|
24
|
+
* refNameAliases: {
|
|
25
|
+
* adapter: {
|
|
26
|
+
* type: 'NcbiSequenceReportAliasAdapter',
|
|
27
|
+
* uri: 'https://example.com/GCF_000001405.40_sequence_report.tsv',
|
|
28
|
+
* },
|
|
29
|
+
* },
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* #example keeping the FASTA's own names
|
|
34
|
+
* With an NCBI FASTA (`NC_000001.11`), the default displays UCSC-style names
|
|
35
|
+
* (`chr1`) while still fetching bases under the accession. Set
|
|
36
|
+
* `useNameOverride: false` to display the accessions instead, with `chr1` left
|
|
37
|
+
* searchable as an alias:
|
|
38
|
+
* ```js
|
|
39
|
+
* {
|
|
40
|
+
* name: 'GCF_000001405.40',
|
|
41
|
+
* sequence: {
|
|
42
|
+
* type: 'ReferenceSequenceTrack',
|
|
43
|
+
* trackId: 'GCF_000001405.40-ReferenceSequenceTrack',
|
|
44
|
+
* adapter: {
|
|
45
|
+
* type: 'BgzipFastaAdapter',
|
|
46
|
+
* uri: 'https://example.com/GCF_000001405.40.fa.gz',
|
|
47
|
+
* },
|
|
48
|
+
* },
|
|
49
|
+
* refNameAliases: {
|
|
50
|
+
* adapter: {
|
|
51
|
+
* type: 'NcbiSequenceReportAliasAdapter',
|
|
52
|
+
* uri: 'https://example.com/GCF_000001405.40_sequence_report.tsv',
|
|
53
|
+
* useNameOverride: false,
|
|
54
|
+
* },
|
|
55
|
+
* },
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
3
59
|
const NcbiSequenceReportAliasAdapterConfigSchema = ConfigurationSchema('NcbiSequenceReportAliasAdapter', {
|
|
60
|
+
/**
|
|
61
|
+
* #slot
|
|
62
|
+
* location of the `sequence_report.tsv` NCBI publishes with an assembly. It
|
|
63
|
+
* carries the RefSeq, GenBank and UCSC-style name of every sequence, so one
|
|
64
|
+
* file aliases them all without hand-writing a chromAlias table.
|
|
65
|
+
*/
|
|
4
66
|
location: {
|
|
5
67
|
type: 'fileLocation',
|
|
6
68
|
defaultValue: {
|
|
@@ -8,6 +70,9 @@ const NcbiSequenceReportAliasAdapterConfigSchema = ConfigurationSchema('NcbiSequ
|
|
|
8
70
|
locationType: 'UriLocation',
|
|
9
71
|
},
|
|
10
72
|
},
|
|
73
|
+
/**
|
|
74
|
+
* #slot
|
|
75
|
+
*/
|
|
11
76
|
useNameOverride: {
|
|
12
77
|
type: 'boolean',
|
|
13
78
|
defaultValue: true,
|
|
@@ -15,16 +80,18 @@ const NcbiSequenceReportAliasAdapterConfigSchema = ConfigurationSchema('NcbiSequ
|
|
|
15
80
|
},
|
|
16
81
|
}, {
|
|
17
82
|
explicitlyTyped: true,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
83
|
+
/**
|
|
84
|
+
* #preProcessSnapshot
|
|
85
|
+
*
|
|
86
|
+
*
|
|
87
|
+
* preprocessor to allow minimal config:
|
|
88
|
+
* ```json
|
|
89
|
+
* {
|
|
90
|
+
* "type": "NcbiSequenceReportAliasAdapter",
|
|
91
|
+
* "uri": "sequence_report.tsv"
|
|
92
|
+
* }
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
preProcessSnapshot: normalizeSnapshot,
|
|
29
96
|
});
|
|
30
97
|
export default NcbiSequenceReportAliasAdapterConfigSchema;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { AdapterType } from '@jbrowse/core/pluggableElementTypes';
|
|
2
|
-
import configSchema from
|
|
2
|
+
import configSchema, { normalizeSnapshot } from './configSchema.js';
|
|
3
3
|
export default function NcbiSequenceReportAliasAdapterF(pluginManager) {
|
|
4
4
|
pluginManager.addAdapterType(() => {
|
|
5
5
|
return new AdapterType({
|
|
6
6
|
name: 'NcbiSequenceReportAliasAdapter',
|
|
7
|
+
normalizeSnapshot,
|
|
7
8
|
configSchema,
|
|
8
|
-
getAdapterClass: () => import(
|
|
9
|
+
getAdapterClass: () => import('./NcbiSequenceReportAliasAdapter.js').then(r => r.default),
|
|
9
10
|
adapterMetadata: {
|
|
10
11
|
hiddenFromGUI: true,
|
|
11
12
|
},
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BaseAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import type { RefNameAliasAdapterConfig } from './configSchema.ts';
|
|
3
|
+
import type { BaseOptions, BaseRefNameAliasAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
4
|
+
export default class RefNameAliasAdapter extends BaseAdapter<RefNameAliasAdapterConfig> implements BaseRefNameAliasAdapter {
|
|
5
|
+
getRefNameAliases(opts?: BaseOptions): Promise<{
|
|
5
6
|
refName: string;
|
|
6
7
|
aliases: string[];
|
|
7
8
|
}[]>;
|
|
@@ -1,36 +1,30 @@
|
|
|
1
1
|
import { BaseAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
2
|
-
import {
|
|
2
|
+
import { readAliasRows } from '../aliasUtils.js';
|
|
3
|
+
// header lines start with '#'; the leading marker belongs to the first column
|
|
4
|
+
const isComment = (cols) => !!cols[0]?.startsWith('#');
|
|
5
|
+
// column names from a '#'-prefixed header row, with the marker stripped
|
|
6
|
+
const headerNames = (cols) => cols.map((col, i) => (i === 0 ? col.slice(1) : col).trim());
|
|
3
7
|
export default class RefNameAliasAdapter extends BaseAdapter {
|
|
4
|
-
async getRefNameAliases() {
|
|
5
|
-
const
|
|
6
|
-
if (loc.uri === '' || loc.uri === '/path/to/my/aliases.txt') {
|
|
7
|
-
return [];
|
|
8
|
-
}
|
|
9
|
-
const results = await openLocation(loc, this.pluginManager).readFile('utf8');
|
|
8
|
+
async getRefNameAliases(opts) {
|
|
9
|
+
const rows = await readAliasRows(this.getConf('location'), this.pluginManager, opts);
|
|
10
10
|
const refColumn = this.getConf('refNameColumn');
|
|
11
11
|
const refColumnHeaderName = this.getConf('refNameColumnHeaderName');
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
.
|
|
15
|
-
.filter(f => !!f);
|
|
16
|
-
const header = lines.filter(f => f.startsWith('#'));
|
|
17
|
-
const headerCol = refColumnHeaderName && header.length
|
|
18
|
-
? header
|
|
19
|
-
.at(-1)
|
|
20
|
-
.slice(1)
|
|
21
|
-
.split('\t')
|
|
22
|
-
.map(t => t.trim())
|
|
23
|
-
.indexOf(refColumnHeaderName)
|
|
12
|
+
const lastHeader = rows.filter(isComment).at(-1);
|
|
13
|
+
const headerCol = refColumnHeaderName && lastHeader
|
|
14
|
+
? headerNames(lastHeader).indexOf(refColumnHeaderName)
|
|
24
15
|
: refColumn;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
16
|
+
if (headerCol === -1) {
|
|
17
|
+
throw new Error(`refNameColumnHeaderName "${refColumnHeaderName}" not found in alias file header`);
|
|
18
|
+
}
|
|
19
|
+
return rows
|
|
20
|
+
.filter(cols => !isComment(cols))
|
|
21
|
+
.flatMap(cols => {
|
|
22
|
+
// a blank refName column (short/ragged row, leading tab) would map every
|
|
23
|
+
// alias to an empty canonical name in buildRefNameMaps; drop such rows
|
|
24
|
+
const refName = cols[headerCol]?.trim();
|
|
25
|
+
return refName
|
|
26
|
+
? [{ refName, aliases: cols.filter(f => !!f.trim()) }]
|
|
27
|
+
: [];
|
|
34
28
|
});
|
|
35
29
|
}
|
|
36
30
|
}
|
|
@@ -1,19 +1,94 @@
|
|
|
1
|
+
import { normalizeUriSnapshot } from '../normalizeUriSnapshot.ts';
|
|
2
|
+
import type { Instance } from '@jbrowse/mobx-state-tree';
|
|
3
|
+
export declare const normalizeSnapshot: typeof normalizeUriSnapshot;
|
|
4
|
+
/**
|
|
5
|
+
* #config RefNameAliasAdapter
|
|
6
|
+
* can read "chromAliases" type files from UCSC or any tab separated file of
|
|
7
|
+
* refName aliases
|
|
8
|
+
*
|
|
9
|
+
* #example
|
|
10
|
+
* Goes on an ASSEMBLY, under `refNameAliases` — not on a track. Writing
|
|
11
|
+
* `refNameAliases: { uri: '...' }` is shorthand for exactly this adapter:
|
|
12
|
+
* ```js
|
|
13
|
+
* {
|
|
14
|
+
* name: 'hg38',
|
|
15
|
+
* sequence: {
|
|
16
|
+
* type: 'ReferenceSequenceTrack',
|
|
17
|
+
* trackId: 'hg38-ReferenceSequenceTrack',
|
|
18
|
+
* adapter: {
|
|
19
|
+
* type: 'BgzipFastaAdapter',
|
|
20
|
+
* uri: 'https://example.com/hg38.fa.gz',
|
|
21
|
+
* },
|
|
22
|
+
* },
|
|
23
|
+
* refNameAliases: {
|
|
24
|
+
* adapter: {
|
|
25
|
+
* type: 'RefNameAliasAdapter',
|
|
26
|
+
* uri: 'https://example.com/hg38.chromAlias.txt',
|
|
27
|
+
* },
|
|
28
|
+
* },
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* #example named column
|
|
33
|
+
* When the primary column — the one whose values match your FASTA — is not the
|
|
34
|
+
* first, name it. `refNameColumnHeaderName` reads the last `#`-prefixed line as
|
|
35
|
+
* the header; `refNameColumn` takes a zero-based index instead.
|
|
36
|
+
* ```js
|
|
37
|
+
* {
|
|
38
|
+
* name: 'hg38',
|
|
39
|
+
* sequence: {
|
|
40
|
+
* type: 'ReferenceSequenceTrack',
|
|
41
|
+
* trackId: 'hg38-ReferenceSequenceTrack',
|
|
42
|
+
* adapter: {
|
|
43
|
+
* type: 'BgzipFastaAdapter',
|
|
44
|
+
* uri: 'https://example.com/hg38.fa.gz',
|
|
45
|
+
* },
|
|
46
|
+
* },
|
|
47
|
+
* refNameAliases: {
|
|
48
|
+
* adapter: {
|
|
49
|
+
* type: 'RefNameAliasAdapter',
|
|
50
|
+
* uri: 'https://example.com/aliases.txt',
|
|
51
|
+
* refNameColumnHeaderName: 'ucsc',
|
|
52
|
+
* },
|
|
53
|
+
* },
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
1
57
|
declare const RefNameAliasAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
58
|
+
/**
|
|
59
|
+
* #slot
|
|
60
|
+
* location of the alias table: a UCSC `chromAlias.txt`, or any
|
|
61
|
+
* tab-separated file whose rows each list the alternate names of one
|
|
62
|
+
* reference sequence (`chr1<TAB>1<TAB>NC_000001.11`). It is what lets a
|
|
63
|
+
* `1`-named file load against a `chr1`-named assembly.
|
|
64
|
+
*/
|
|
65
|
+
readonly location: {
|
|
66
|
+
readonly type: "fileLocation";
|
|
67
|
+
readonly defaultValue: {
|
|
68
|
+
readonly uri: "/path/to/my/aliases.txt";
|
|
69
|
+
readonly locationType: "UriLocation";
|
|
7
70
|
};
|
|
8
71
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
72
|
+
/**
|
|
73
|
+
* #slot
|
|
74
|
+
* by default, the "ref names that match the fasta" are assumed to be in the
|
|
75
|
+
* first column (0), change this variable if needed
|
|
76
|
+
*/
|
|
77
|
+
readonly refNameColumn: {
|
|
78
|
+
readonly type: "number";
|
|
79
|
+
readonly defaultValue: 0;
|
|
80
|
+
readonly advanced: true;
|
|
12
81
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
82
|
+
/**
|
|
83
|
+
* #slot
|
|
84
|
+
* refNameColumnHeaderName
|
|
85
|
+
*/
|
|
86
|
+
readonly refNameColumnHeaderName: {
|
|
87
|
+
readonly type: "string";
|
|
88
|
+
readonly description: "alternative to refNameColumn, instead looks at header (starts with # and finds column name)";
|
|
89
|
+
readonly defaultValue: "";
|
|
90
|
+
readonly advanced: true;
|
|
17
91
|
};
|
|
18
92
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
|
|
93
|
+
export type RefNameAliasAdapterConfig = Instance<typeof RefNameAliasAdapter>;
|
|
19
94
|
export default RefNameAliasAdapter;
|
|
@@ -1,6 +1,67 @@
|
|
|
1
1
|
import { ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
2
|
-
|
|
2
|
+
import { normalizeUriSnapshot } from '../normalizeUriSnapshot.js';
|
|
3
|
+
export const normalizeSnapshot = normalizeUriSnapshot;
|
|
4
|
+
/**
|
|
5
|
+
* #config RefNameAliasAdapter
|
|
6
|
+
* can read "chromAliases" type files from UCSC or any tab separated file of
|
|
7
|
+
* refName aliases
|
|
8
|
+
*
|
|
9
|
+
* #example
|
|
10
|
+
* Goes on an ASSEMBLY, under `refNameAliases` — not on a track. Writing
|
|
11
|
+
* `refNameAliases: { uri: '...' }` is shorthand for exactly this adapter:
|
|
12
|
+
* ```js
|
|
13
|
+
* {
|
|
14
|
+
* name: 'hg38',
|
|
15
|
+
* sequence: {
|
|
16
|
+
* type: 'ReferenceSequenceTrack',
|
|
17
|
+
* trackId: 'hg38-ReferenceSequenceTrack',
|
|
18
|
+
* adapter: {
|
|
19
|
+
* type: 'BgzipFastaAdapter',
|
|
20
|
+
* uri: 'https://example.com/hg38.fa.gz',
|
|
21
|
+
* },
|
|
22
|
+
* },
|
|
23
|
+
* refNameAliases: {
|
|
24
|
+
* adapter: {
|
|
25
|
+
* type: 'RefNameAliasAdapter',
|
|
26
|
+
* uri: 'https://example.com/hg38.chromAlias.txt',
|
|
27
|
+
* },
|
|
28
|
+
* },
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* #example named column
|
|
33
|
+
* When the primary column — the one whose values match your FASTA — is not the
|
|
34
|
+
* first, name it. `refNameColumnHeaderName` reads the last `#`-prefixed line as
|
|
35
|
+
* the header; `refNameColumn` takes a zero-based index instead.
|
|
36
|
+
* ```js
|
|
37
|
+
* {
|
|
38
|
+
* name: 'hg38',
|
|
39
|
+
* sequence: {
|
|
40
|
+
* type: 'ReferenceSequenceTrack',
|
|
41
|
+
* trackId: 'hg38-ReferenceSequenceTrack',
|
|
42
|
+
* adapter: {
|
|
43
|
+
* type: 'BgzipFastaAdapter',
|
|
44
|
+
* uri: 'https://example.com/hg38.fa.gz',
|
|
45
|
+
* },
|
|
46
|
+
* },
|
|
47
|
+
* refNameAliases: {
|
|
48
|
+
* adapter: {
|
|
49
|
+
* type: 'RefNameAliasAdapter',
|
|
50
|
+
* uri: 'https://example.com/aliases.txt',
|
|
51
|
+
* refNameColumnHeaderName: 'ucsc',
|
|
52
|
+
* },
|
|
53
|
+
* },
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
3
57
|
const RefNameAliasAdapter = ConfigurationSchema('RefNameAliasAdapter', {
|
|
58
|
+
/**
|
|
59
|
+
* #slot
|
|
60
|
+
* location of the alias table: a UCSC `chromAlias.txt`, or any
|
|
61
|
+
* tab-separated file whose rows each list the alternate names of one
|
|
62
|
+
* reference sequence (`chr1<TAB>1<TAB>NC_000001.11`). It is what lets a
|
|
63
|
+
* `1`-named file load against a `chr1`-named assembly.
|
|
64
|
+
*/
|
|
4
65
|
location: {
|
|
5
66
|
type: 'fileLocation',
|
|
6
67
|
defaultValue: {
|
|
@@ -8,27 +69,40 @@ const RefNameAliasAdapter = ConfigurationSchema('RefNameAliasAdapter', {
|
|
|
8
69
|
locationType: 'UriLocation',
|
|
9
70
|
},
|
|
10
71
|
},
|
|
72
|
+
/**
|
|
73
|
+
* #slot
|
|
74
|
+
* by default, the "ref names that match the fasta" are assumed to be in the
|
|
75
|
+
* first column (0), change this variable if needed
|
|
76
|
+
*/
|
|
11
77
|
refNameColumn: {
|
|
12
78
|
type: 'number',
|
|
13
79
|
defaultValue: 0,
|
|
80
|
+
advanced: true,
|
|
14
81
|
},
|
|
82
|
+
/**
|
|
83
|
+
* #slot
|
|
84
|
+
* refNameColumnHeaderName
|
|
85
|
+
*/
|
|
15
86
|
refNameColumnHeaderName: {
|
|
16
87
|
type: 'string',
|
|
17
88
|
description: 'alternative to refNameColumn, instead looks at header (starts with # and finds column name)',
|
|
18
89
|
defaultValue: '',
|
|
90
|
+
advanced: true,
|
|
19
91
|
},
|
|
20
92
|
}, {
|
|
21
93
|
explicitlyTyped: true,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
94
|
+
/**
|
|
95
|
+
* #preProcessSnapshot
|
|
96
|
+
*
|
|
97
|
+
*
|
|
98
|
+
* preprocessor to allow minimal config:
|
|
99
|
+
* ```json
|
|
100
|
+
* {
|
|
101
|
+
* "type": "RefNameAliasAdapter",
|
|
102
|
+
* "uri": "yourfile.chromAlias.txt"
|
|
103
|
+
* }
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
preProcessSnapshot: normalizeSnapshot,
|
|
33
107
|
});
|
|
34
108
|
export default RefNameAliasAdapter;
|