@jbrowse/plugin-config 4.3.0 → 5.0.0-beta.10
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 +6 -0
- package/esm/ConfigurationEditorWidget/components/AddNewField.js +29 -0
- package/esm/ConfigurationEditorWidget/components/BooleanEditor.d.ts +3 -2
- package/esm/ConfigurationEditorWidget/components/BooleanEditor.js +6 -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 +5 -12
- package/esm/ConfigurationEditorWidget/components/ColorEditor.js +47 -22
- package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.d.ts +2 -3
- package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.js +168 -29
- package/esm/ConfigurationEditorWidget/components/ConfigurationTextField.d.ts +1 -1
- package/esm/ConfigurationEditorWidget/components/ConfigurationTextField.js +10 -2
- package/esm/ConfigurationEditorWidget/components/EntryListEditor.d.ts +17 -0
- package/esm/ConfigurationEditorWidget/components/EntryListEditor.js +35 -0
- 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 +2 -1
- package/esm/ConfigurationEditorWidget/components/JsonEditor.js +24 -41
- 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 +5 -4
- package/esm/ConfigurationEditorWidget/components/NumberEditor.js +15 -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 +88 -49
- package/esm/ConfigurationEditorWidget/components/StringArrayEditor.d.ts +16 -10
- package/esm/ConfigurationEditorWidget/components/StringArrayEditor.js +22 -25
- package/esm/ConfigurationEditorWidget/components/StringArrayMapEditor.d.ts +3 -6
- package/esm/ConfigurationEditorWidget/components/StringArrayMapEditor.js +14 -39
- package/esm/ConfigurationEditorWidget/components/StringMapEditor.d.ts +10 -0
- package/esm/ConfigurationEditorWidget/components/StringMapEditor.js +13 -0
- package/esm/ConfigurationEditorWidget/components/TypeSelector.d.ts +2 -2
- 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 +4 -4
- 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 +32 -4
- 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 +38 -4
- 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 +37 -4
- 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 +69 -10
- package/esm/NcbiSequenceReportAliasAdapter/configSchema.js +82 -18
- 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 +70 -12
- package/esm/RefNameAliasAdapter/configSchema.js +89 -18
- package/esm/RefNameAliasAdapter/index.js +3 -2
- package/esm/aliasUtils.d.ts +4 -0
- package/esm/aliasUtils.js +19 -0
- package/esm/index.d.ts +2 -2
- package/esm/index.js +7 -7
- package/package.json +11 -15
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
import FromConfigAdapter from '../FromConfigAdapter/FromConfigAdapter.ts';
|
|
2
|
-
import type { RegionsAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
2
|
+
import type { BaseOptions, RegionsAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
3
3
|
import type { Feature } from '@jbrowse/core/util/simpleFeature';
|
|
4
4
|
import type { NoAssemblyRegion } from '@jbrowse/core/util/types';
|
|
5
5
|
export default class FromConfigSequenceAdapter extends FromConfigAdapter implements RegionsAdapter {
|
|
6
|
+
/**
|
|
7
|
+
* Fetch features for a certain region
|
|
8
|
+
* @param region - Region
|
|
9
|
+
* @returns Observable of Feature objects in the region
|
|
10
|
+
*/
|
|
6
11
|
getFeatures(region: NoAssemblyRegion): import("rxjs").Observable<Feature>;
|
|
7
12
|
getRegions(): Promise<{
|
|
13
|
+
refName: string;
|
|
8
14
|
start: number;
|
|
9
15
|
end: number;
|
|
10
|
-
refName: string;
|
|
11
16
|
}[]>;
|
|
17
|
+
/**
|
|
18
|
+
* `BaseSequenceAdapter`'s default, which this cannot inherit — it extends
|
|
19
|
+
* `FromConfigAdapter` — and which anything resolving a sequence SUB-adapter
|
|
20
|
+
* requires by name: `getSequenceSubAdapter` checks for the method and refuses
|
|
21
|
+
* an adapter without it, so a GC content track over a from-config assembly
|
|
22
|
+
* failed with "provides no sequence".
|
|
23
|
+
*/
|
|
24
|
+
getSequence(region: NoAssemblyRegion, opts?: BaseOptions): Promise<string | undefined>;
|
|
12
25
|
}
|
|
@@ -1,50 +1,42 @@
|
|
|
1
1
|
import { ObservableCreate } from '@jbrowse/core/util/rxjs';
|
|
2
2
|
import SimpleFeature from '@jbrowse/core/util/simpleFeature';
|
|
3
|
-
import {
|
|
4
|
-
import { toArray } from 'rxjs/operators';
|
|
5
|
-
import FromConfigAdapter from "../FromConfigAdapter/FromConfigAdapter.js";
|
|
3
|
+
import FromConfigAdapter, { mergeFeaturesToRegions, } from '../FromConfigAdapter/FromConfigAdapter.js';
|
|
6
4
|
export default class FromConfigSequenceAdapter extends FromConfigAdapter {
|
|
5
|
+
/**
|
|
6
|
+
* Fetch features for a certain region
|
|
7
|
+
* @param region - Region
|
|
8
|
+
* @returns Observable of Feature objects in the region
|
|
9
|
+
*/
|
|
7
10
|
getFeatures(region) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
const { refName, start, end } = region;
|
|
12
|
+
return ObservableCreate(observer => {
|
|
13
|
+
const feats = this.features.get(refName) ?? [];
|
|
14
|
+
const feat = feats.find(f => f.get('end') > start && f.get('start') < end);
|
|
15
|
+
if (feat) {
|
|
16
|
+
const featStart = feat.get('start');
|
|
17
|
+
observer.next(new SimpleFeature({
|
|
18
|
+
...feat.toJSON(),
|
|
19
|
+
uniqueId: `${feat.id()}:${start}-${end}`,
|
|
20
|
+
start,
|
|
21
|
+
end,
|
|
22
|
+
seq: feat.get('seq').slice(Math.max(start - featStart, 0), Math.max(end - featStart, 0)),
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
20
25
|
observer.complete();
|
|
21
26
|
});
|
|
22
27
|
}
|
|
23
28
|
async getRegions() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
currentRegion = {
|
|
38
|
-
refName,
|
|
39
|
-
start: feature.get('start'),
|
|
40
|
-
end: feature.get('end'),
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (currentRegion) {
|
|
45
|
-
regions.push(currentRegion);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return regions;
|
|
29
|
+
return mergeFeaturesToRegions(this.features);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* `BaseSequenceAdapter`'s default, which this cannot inherit — it extends
|
|
33
|
+
* `FromConfigAdapter` — and which anything resolving a sequence SUB-adapter
|
|
34
|
+
* requires by name: `getSequenceSubAdapter` checks for the method and refuses
|
|
35
|
+
* an adapter without it, so a GC content track over a from-config assembly
|
|
36
|
+
* failed with "provides no sequence".
|
|
37
|
+
*/
|
|
38
|
+
async getSequence(region, opts) {
|
|
39
|
+
const features = await this.getFeaturesArray({ ...region, assemblyName: '' }, opts);
|
|
40
|
+
return features[0]?.get('seq');
|
|
49
41
|
}
|
|
50
42
|
}
|
|
@@ -1,7 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #config FromConfigSequenceAdapter
|
|
3
|
+
* #trackType ReferenceSequenceTrack
|
|
4
|
+
* #fileFormat inline | Inline sequence | Each feature's `seq` holds the bases for its region
|
|
5
|
+
* supplies reference sequence inline in the config; each feature's `seq` holds
|
|
6
|
+
* the bases for its region
|
|
7
|
+
*
|
|
8
|
+
* #example
|
|
9
|
+
* Used as the adapter of an assembly's `sequence` (a `ReferenceSequenceTrack`):
|
|
10
|
+
* ```js
|
|
11
|
+
* {
|
|
12
|
+
* type: 'ReferenceSequenceTrack',
|
|
13
|
+
* trackId: 'my_refseq',
|
|
14
|
+
* adapter: {
|
|
15
|
+
* type: 'FromConfigSequenceAdapter',
|
|
16
|
+
* features: [
|
|
17
|
+
* { uniqueId: 'ctgA', refName: 'ctgA', start: 0, end: 10, seq: 'ATGCATGCAT' },
|
|
18
|
+
* ],
|
|
19
|
+
* },
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
1
23
|
declare const sequenceConfigSchema: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
2
|
-
|
|
3
|
-
type: string;
|
|
4
|
-
|
|
24
|
+
type: {
|
|
25
|
+
type: "string";
|
|
26
|
+
} & {
|
|
27
|
+
defaultValue: string;
|
|
5
28
|
};
|
|
6
|
-
|
|
29
|
+
readonly adapterId: {
|
|
30
|
+
type: "string";
|
|
31
|
+
} & {
|
|
32
|
+
defaultValue: string;
|
|
33
|
+
};
|
|
34
|
+
readonly features: {
|
|
35
|
+
type: "frozen";
|
|
36
|
+
} & {
|
|
37
|
+
defaultValue: unknown;
|
|
38
|
+
};
|
|
39
|
+
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined, true, import("@jbrowse/core/configuration").ConfigurationSchemaRequirement<Partial<Record<string, string[]>>, string>, any>>;
|
|
7
40
|
export default sequenceConfigSchema;
|
|
@@ -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,74 @@
|
|
|
1
|
+
import type { Instance } from '@jbrowse/mobx-state-tree';
|
|
2
|
+
export declare function normalizeSnapshot(snap: Record<string, unknown>): Record<string, unknown>;
|
|
3
|
+
/**
|
|
4
|
+
* #config NcbiSequenceReportAliasAdapter
|
|
5
|
+
* can read "sequence_report.tsv" type files from NCBI
|
|
6
|
+
*
|
|
7
|
+
* #example
|
|
8
|
+
* Goes on an ASSEMBLY, under `refNameAliases` — not on a track. The file ships
|
|
9
|
+
* beside any RefSeq assembly on NCBI datasets and aliases the RefSeq, GenBank
|
|
10
|
+
* and UCSC-style names of every sequence at once, so it replaces a
|
|
11
|
+
* hand-maintained chromAlias table:
|
|
12
|
+
* ```js
|
|
13
|
+
* {
|
|
14
|
+
* name: 'GCF_000001405.40',
|
|
15
|
+
* sequence: {
|
|
16
|
+
* type: 'ReferenceSequenceTrack',
|
|
17
|
+
* trackId: 'GCF_000001405.40-ReferenceSequenceTrack',
|
|
18
|
+
* adapter: {
|
|
19
|
+
* type: 'BgzipFastaAdapter',
|
|
20
|
+
* uri: 'https://example.com/GCF_000001405.40.fa.gz',
|
|
21
|
+
* },
|
|
22
|
+
* },
|
|
23
|
+
* refNameAliases: {
|
|
24
|
+
* adapter: {
|
|
25
|
+
* type: 'NcbiSequenceReportAliasAdapter',
|
|
26
|
+
* uri: 'https://example.com/GCF_000001405.40_sequence_report.tsv',
|
|
27
|
+
* },
|
|
28
|
+
* },
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* #example keeping the FASTA's own names
|
|
33
|
+
* With an NCBI FASTA (`NC_000001.11`), the default displays UCSC-style names
|
|
34
|
+
* (`chr1`) while still fetching bases under the accession. Set
|
|
35
|
+
* `useNameOverride: false` to display the accessions instead, with `chr1` left
|
|
36
|
+
* searchable as an alias:
|
|
37
|
+
* ```js
|
|
38
|
+
* {
|
|
39
|
+
* name: 'GCF_000001405.40',
|
|
40
|
+
* sequence: {
|
|
41
|
+
* type: 'ReferenceSequenceTrack',
|
|
42
|
+
* trackId: 'GCF_000001405.40-ReferenceSequenceTrack',
|
|
43
|
+
* adapter: {
|
|
44
|
+
* type: 'BgzipFastaAdapter',
|
|
45
|
+
* uri: 'https://example.com/GCF_000001405.40.fa.gz',
|
|
46
|
+
* },
|
|
47
|
+
* },
|
|
48
|
+
* refNameAliases: {
|
|
49
|
+
* adapter: {
|
|
50
|
+
* type: 'NcbiSequenceReportAliasAdapter',
|
|
51
|
+
* uri: 'https://example.com/GCF_000001405.40_sequence_report.tsv',
|
|
52
|
+
* useNameOverride: false,
|
|
53
|
+
* },
|
|
54
|
+
* },
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
1
58
|
declare const NcbiSequenceReportAliasAdapterConfigSchema: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
2
|
-
|
|
3
|
-
type: string;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
locationType: string;
|
|
7
|
-
};
|
|
59
|
+
type: {
|
|
60
|
+
type: "string";
|
|
61
|
+
} & {
|
|
62
|
+
defaultValue: string;
|
|
8
63
|
};
|
|
9
|
-
|
|
10
|
-
type:
|
|
64
|
+
readonly location: {
|
|
65
|
+
type: "maybeFileLocation";
|
|
66
|
+
};
|
|
67
|
+
readonly useNameOverride: {
|
|
68
|
+
type: "boolean";
|
|
69
|
+
} & {
|
|
11
70
|
defaultValue: boolean;
|
|
12
|
-
description: string;
|
|
13
71
|
};
|
|
14
|
-
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
|
|
72
|
+
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined, true, import("@jbrowse/core/configuration").ConfigurationSchemaRequirement<Partial<Record<string, string[]>>, string>, any>>;
|
|
73
|
+
export type NcbiSequenceReportAliasAdapterConfig = Instance<typeof NcbiSequenceReportAliasAdapterConfigSchema>;
|
|
15
74
|
export default NcbiSequenceReportAliasAdapterConfigSchema;
|
|
@@ -1,13 +1,75 @@
|
|
|
1
|
-
import { ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
2
|
-
function
|
|
1
|
+
import { ConfigurationSchema, expandUriShorthand, } from '@jbrowse/core/configuration';
|
|
2
|
+
export function normalizeSnapshot(snap) {
|
|
3
|
+
return expandUriShorthand(snap, 'location');
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* #config NcbiSequenceReportAliasAdapter
|
|
7
|
+
* can read "sequence_report.tsv" type files from NCBI
|
|
8
|
+
*
|
|
9
|
+
* #example
|
|
10
|
+
* Goes on an ASSEMBLY, under `refNameAliases` — not on a track. The file ships
|
|
11
|
+
* beside any RefSeq assembly on NCBI datasets and aliases the RefSeq, GenBank
|
|
12
|
+
* and UCSC-style names of every sequence at once, so it replaces a
|
|
13
|
+
* hand-maintained chromAlias table:
|
|
14
|
+
* ```js
|
|
15
|
+
* {
|
|
16
|
+
* name: 'GCF_000001405.40',
|
|
17
|
+
* sequence: {
|
|
18
|
+
* type: 'ReferenceSequenceTrack',
|
|
19
|
+
* trackId: 'GCF_000001405.40-ReferenceSequenceTrack',
|
|
20
|
+
* adapter: {
|
|
21
|
+
* type: 'BgzipFastaAdapter',
|
|
22
|
+
* uri: 'https://example.com/GCF_000001405.40.fa.gz',
|
|
23
|
+
* },
|
|
24
|
+
* },
|
|
25
|
+
* refNameAliases: {
|
|
26
|
+
* adapter: {
|
|
27
|
+
* type: 'NcbiSequenceReportAliasAdapter',
|
|
28
|
+
* uri: 'https://example.com/GCF_000001405.40_sequence_report.tsv',
|
|
29
|
+
* },
|
|
30
|
+
* },
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* #example keeping the FASTA's own names
|
|
35
|
+
* With an NCBI FASTA (`NC_000001.11`), the default displays UCSC-style names
|
|
36
|
+
* (`chr1`) while still fetching bases under the accession. Set
|
|
37
|
+
* `useNameOverride: false` to display the accessions instead, with `chr1` left
|
|
38
|
+
* searchable as an alias:
|
|
39
|
+
* ```js
|
|
40
|
+
* {
|
|
41
|
+
* name: 'GCF_000001405.40',
|
|
42
|
+
* sequence: {
|
|
43
|
+
* type: 'ReferenceSequenceTrack',
|
|
44
|
+
* trackId: 'GCF_000001405.40-ReferenceSequenceTrack',
|
|
45
|
+
* adapter: {
|
|
46
|
+
* type: 'BgzipFastaAdapter',
|
|
47
|
+
* uri: 'https://example.com/GCF_000001405.40.fa.gz',
|
|
48
|
+
* },
|
|
49
|
+
* },
|
|
50
|
+
* refNameAliases: {
|
|
51
|
+
* adapter: {
|
|
52
|
+
* type: 'NcbiSequenceReportAliasAdapter',
|
|
53
|
+
* uri: 'https://example.com/GCF_000001405.40_sequence_report.tsv',
|
|
54
|
+
* useNameOverride: false,
|
|
55
|
+
* },
|
|
56
|
+
* },
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
3
60
|
const NcbiSequenceReportAliasAdapterConfigSchema = ConfigurationSchema('NcbiSequenceReportAliasAdapter', {
|
|
61
|
+
/**
|
|
62
|
+
* #slot
|
|
63
|
+
* location of the `sequence_report.tsv` NCBI publishes with an assembly. It
|
|
64
|
+
* carries the RefSeq, GenBank and UCSC-style name of every sequence, so one
|
|
65
|
+
* file aliases them all without hand-writing a chromAlias table.
|
|
66
|
+
*/
|
|
4
67
|
location: {
|
|
5
|
-
type: '
|
|
6
|
-
defaultValue: {
|
|
7
|
-
uri: '/path/to/my/sequence_report.tsv',
|
|
8
|
-
locationType: 'UriLocation',
|
|
9
|
-
},
|
|
68
|
+
type: 'maybeFileLocation',
|
|
10
69
|
},
|
|
70
|
+
/**
|
|
71
|
+
* #slot
|
|
72
|
+
*/
|
|
11
73
|
useNameOverride: {
|
|
12
74
|
type: 'boolean',
|
|
13
75
|
defaultValue: true,
|
|
@@ -15,16 +77,18 @@ const NcbiSequenceReportAliasAdapterConfigSchema = ConfigurationSchema('NcbiSequ
|
|
|
15
77
|
},
|
|
16
78
|
}, {
|
|
17
79
|
explicitlyTyped: true,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
80
|
+
/**
|
|
81
|
+
* #preProcessSnapshot
|
|
82
|
+
*
|
|
83
|
+
*
|
|
84
|
+
* preprocessor to allow minimal config:
|
|
85
|
+
* ```json
|
|
86
|
+
* {
|
|
87
|
+
* "type": "NcbiSequenceReportAliasAdapter",
|
|
88
|
+
* "uri": "sequence_report.tsv"
|
|
89
|
+
* }
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
preProcessSnapshot: normalizeSnapshot,
|
|
29
93
|
});
|
|
30
94
|
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
|
}
|