@jbrowse/add-track-core 5.0.0-beta.17 → 5.0.0-beta.18

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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { type AdapterSpec, type FormatEntry, type Sidecar, fileNameOf, formats, matchFormat, trackTypeForAdapter, } from './formats.ts';
2
- export { indexCandidateNames, indexSpellings, resolveIndexType, sidecarCandidateNames, } from './indexCandidates.ts';
2
+ export { indexCandidateNames, indexSpellings, pairIndexFiles, resolveIndexType, sidecarCandidateNames, } from './indexCandidates.ts';
3
3
  export { type LooseTrackInput, isLooseTrackConfig } from './looseTrackConfig.ts';
4
4
  export { adapterTypesToTrackTypeMap } from './trackTypes.generated.ts';
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export { fileNameOf, formats, matchFormat, trackTypeForAdapter, } from './formats.js';
2
- export { indexCandidateNames, indexSpellings, resolveIndexType, sidecarCandidateNames, } from './indexCandidates.js';
2
+ export { indexCandidateNames, indexSpellings, pairIndexFiles, resolveIndexType, sidecarCandidateNames, } from './indexCandidates.js';
3
3
  export { isLooseTrackConfig } from './looseTrackConfig.js';
4
4
  export { adapterTypesToTrackTypeMap } from './trackTypes.generated.js';
@@ -25,6 +25,17 @@ export declare function sidecarCandidateNames(location: string, suffix: string):
25
25
  * hic), which is how a caller knows not to go looking.
26
26
  */
27
27
  export declare function indexCandidateNames(fileName: string): string[];
28
+ /**
29
+ * A selection of files as its data files, each beside the index among them
30
+ * that names it — `reads.bam` with `reads.bam.bai` or `reads.bai` — so a file
31
+ * picker's selection opens one track per data file.
32
+ */
33
+ export declare function pairIndexFiles<T extends {
34
+ name: string;
35
+ }>(files: readonly T[]): {
36
+ data: T;
37
+ index?: T;
38
+ }[];
28
39
  /**
29
40
  * The index spelling a location implies: htslib writes `.csi` in place of a
30
41
  * `.bai` or a `.tbi` for a reference over 512 Mb, and on request at any size.
@@ -62,6 +62,18 @@ export function indexCandidateNames(fileName) {
62
62
  const suffix = INDEX_SUFFIXES.find(([re]) => re.test(fileName))?.[1];
63
63
  return suffix ? sidecarCandidateNames(fileName, suffix) : [];
64
64
  }
65
+ /**
66
+ * A selection of files as its data files, each beside the index among them
67
+ * that names it — `reads.bam` with `reads.bam.bai` or `reads.bai` — so a file
68
+ * picker's selection opens one track per data file.
69
+ */
70
+ export function pairIndexFiles(files) {
71
+ const indexOf = (data) => files.find(f => indexCandidateNames(data.name).includes(f.name));
72
+ const indexes = new Set(files.map(indexOf));
73
+ return files
74
+ .filter(f => !indexes.has(f))
75
+ .map(data => ({ data, index: indexOf(data) }));
76
+ }
65
77
  /**
66
78
  * The index spelling a location implies: htslib writes `.csi` in place of a
67
79
  * `.bai` or a `.tbi` for a reference over 512 Mb, and on request at any size.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/add-track-core",
3
- "version": "5.0.0-beta.17",
3
+ "version": "5.0.0-beta.18",
4
4
  "type": "module",
5
5
  "description": "The file-format table the add-track guessers and the CLI both read — no framework deps",
6
6
  "keywords": [