@jbrowse/plugin-comparative-adapters 3.7.0 → 4.0.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.
Files changed (115) hide show
  1. package/esm/BlastTabularAdapter/BlastTabularAdapter.js +8 -7
  2. package/esm/BlastTabularAdapter/configSchema.d.ts +2 -2
  3. package/esm/BlastTabularAdapter/index.js +2 -2
  4. package/esm/ChainAdapter/ChainAdapter.d.ts +2 -16
  5. package/esm/ChainAdapter/ChainAdapter.js +4 -3
  6. package/esm/ChainAdapter/configSchema.d.ts +2 -2
  7. package/esm/ChainAdapter/index.js +2 -2
  8. package/esm/ChainAdapter/util.js +2 -2
  9. package/esm/ComparativeAddTrackComponent/ComparativeAddTrackComponent.js +3 -4
  10. package/esm/ComparativeAddTrackComponent/index.js +2 -2
  11. package/esm/DeltaAdapter/DeltaAdapter.d.ts +2 -11
  12. package/esm/DeltaAdapter/DeltaAdapter.js +4 -3
  13. package/esm/DeltaAdapter/configSchema.d.ts +2 -2
  14. package/esm/DeltaAdapter/index.js +2 -2
  15. package/esm/DeltaAdapter/util.js +1 -1
  16. package/esm/GuessAdapter/index.js +1 -1
  17. package/esm/MCScanAddTrackComponent/MCScanAddTrackComponent.d.ts +1 -1
  18. package/esm/MCScanAddTrackComponent/MCScanAddTrackComponent.js +3 -4
  19. package/esm/MCScanAddTrackComponent/index.js +2 -2
  20. package/esm/MCScanAnchorsAdapter/MCScanAnchorsAdapter.js +5 -6
  21. package/esm/MCScanAnchorsAdapter/configSchema.d.ts +2 -2
  22. package/esm/MCScanAnchorsAdapter/index.js +2 -2
  23. package/esm/MCScanSimpleAnchorsAdapter/MCScanSimpleAnchorsAdapter.js +5 -6
  24. package/esm/MCScanSimpleAnchorsAdapter/configSchema.d.ts +2 -2
  25. package/esm/MCScanSimpleAnchorsAdapter/index.js +2 -2
  26. package/esm/MashMapAdapter/MashMapAdapter.d.ts +2 -13
  27. package/esm/MashMapAdapter/MashMapAdapter.js +4 -3
  28. package/esm/MashMapAdapter/configSchema.d.ts +2 -2
  29. package/esm/MashMapAdapter/index.js +2 -2
  30. package/esm/PAFAdapter/PAFAdapter.d.ts +1 -1
  31. package/esm/PAFAdapter/PAFAdapter.js +10 -11
  32. package/esm/PAFAdapter/configSchema.d.ts +2 -2
  33. package/esm/PAFAdapter/index.js +2 -2
  34. package/esm/PAFAdapter/util.js +22 -32
  35. package/esm/PairwiseIndexedPAFAdapter/PairwiseIndexedPAFAdapter.js +13 -12
  36. package/esm/PairwiseIndexedPAFAdapter/configSchema.d.ts +5 -5
  37. package/esm/PairwiseIndexedPAFAdapter/configSchema.js +1 -1
  38. package/esm/PairwiseIndexedPAFAdapter/index.js +2 -2
  39. package/esm/SyntenyFeature/index.js +3 -4
  40. package/esm/index.js +12 -15
  41. package/esm/util.d.ts +1 -1
  42. package/esm/util.js +1 -1
  43. package/package.json +27 -34
  44. package/dist/BlastTabularAdapter/BlastTabularAdapter.d.ts +0 -65
  45. package/dist/BlastTabularAdapter/BlastTabularAdapter.js +0 -206
  46. package/dist/BlastTabularAdapter/configSchema.d.ts +0 -30
  47. package/dist/BlastTabularAdapter/configSchema.js +0 -34
  48. package/dist/BlastTabularAdapter/index.d.ts +0 -2
  49. package/dist/BlastTabularAdapter/index.js +0 -52
  50. package/dist/ChainAdapter/ChainAdapter.d.ts +0 -19
  51. package/dist/ChainAdapter/ChainAdapter.js +0 -15
  52. package/dist/ChainAdapter/configSchema.d.ts +0 -25
  53. package/dist/ChainAdapter/configSchema.js +0 -39
  54. package/dist/ChainAdapter/index.d.ts +0 -2
  55. package/dist/ChainAdapter/index.js +0 -52
  56. package/dist/ChainAdapter/util.d.ts +0 -16
  57. package/dist/ChainAdapter/util.js +0 -82
  58. package/dist/ComparativeAddTrackComponent/ComparativeAddTrackComponent.d.ts +0 -2
  59. package/dist/ComparativeAddTrackComponent/ComparativeAddTrackComponent.js +0 -31
  60. package/dist/ComparativeAddTrackComponent/index.d.ts +0 -2
  61. package/dist/ComparativeAddTrackComponent/index.js +0 -46
  62. package/dist/DeltaAdapter/DeltaAdapter.d.ts +0 -14
  63. package/dist/DeltaAdapter/DeltaAdapter.js +0 -15
  64. package/dist/DeltaAdapter/configSchema.d.ts +0 -25
  65. package/dist/DeltaAdapter/configSchema.js +0 -42
  66. package/dist/DeltaAdapter/index.d.ts +0 -2
  67. package/dist/DeltaAdapter/index.js +0 -52
  68. package/dist/DeltaAdapter/util.d.ts +0 -11
  69. package/dist/DeltaAdapter/util.js +0 -111
  70. package/dist/GuessAdapter/index.d.ts +0 -2
  71. package/dist/GuessAdapter/index.js +0 -74
  72. package/dist/MCScanAddTrackComponent/MCScanAddTrackComponent.d.ts +0 -2
  73. package/dist/MCScanAddTrackComponent/MCScanAddTrackComponent.js +0 -39
  74. package/dist/MCScanAddTrackComponent/index.d.ts +0 -2
  75. package/dist/MCScanAddTrackComponent/index.js +0 -46
  76. package/dist/MCScanAnchorsAdapter/MCScanAnchorsAdapter.d.ts +0 -29
  77. package/dist/MCScanAnchorsAdapter/MCScanAnchorsAdapter.js +0 -98
  78. package/dist/MCScanAnchorsAdapter/configSchema.d.ts +0 -28
  79. package/dist/MCScanAnchorsAdapter/configSchema.js +0 -53
  80. package/dist/MCScanAnchorsAdapter/index.d.ts +0 -2
  81. package/dist/MCScanAnchorsAdapter/index.js +0 -52
  82. package/dist/MCScanSimpleAnchorsAdapter/MCScanSimpleAnchorsAdapter.d.ts +0 -37
  83. package/dist/MCScanSimpleAnchorsAdapter/MCScanSimpleAnchorsAdapter.js +0 -132
  84. package/dist/MCScanSimpleAnchorsAdapter/configSchema.d.ts +0 -28
  85. package/dist/MCScanSimpleAnchorsAdapter/configSchema.js +0 -53
  86. package/dist/MCScanSimpleAnchorsAdapter/index.d.ts +0 -2
  87. package/dist/MCScanSimpleAnchorsAdapter/index.js +0 -52
  88. package/dist/MashMapAdapter/MashMapAdapter.d.ts +0 -16
  89. package/dist/MashMapAdapter/MashMapAdapter.js +0 -39
  90. package/dist/MashMapAdapter/configSchema.d.ts +0 -25
  91. package/dist/MashMapAdapter/configSchema.js +0 -42
  92. package/dist/MashMapAdapter/index.d.ts +0 -2
  93. package/dist/MashMapAdapter/index.js +0 -52
  94. package/dist/PAFAdapter/PAFAdapter.d.ts +0 -20
  95. package/dist/PAFAdapter/PAFAdapter.js +0 -137
  96. package/dist/PAFAdapter/configSchema.d.ts +0 -25
  97. package/dist/PAFAdapter/configSchema.js +0 -42
  98. package/dist/PAFAdapter/index.d.ts +0 -2
  99. package/dist/PAFAdapter/index.js +0 -52
  100. package/dist/PAFAdapter/util.d.ts +0 -17
  101. package/dist/PAFAdapter/util.js +0 -45
  102. package/dist/PairwiseIndexedPAFAdapter/PairwiseIndexedPAFAdapter.d.ts +0 -24
  103. package/dist/PairwiseIndexedPAFAdapter/PairwiseIndexedPAFAdapter.js +0 -109
  104. package/dist/PairwiseIndexedPAFAdapter/configSchema.d.ts +0 -40
  105. package/dist/PairwiseIndexedPAFAdapter/configSchema.js +0 -64
  106. package/dist/PairwiseIndexedPAFAdapter/index.d.ts +0 -2
  107. package/dist/PairwiseIndexedPAFAdapter/index.js +0 -52
  108. package/dist/SyntenyFeature/index.d.ts +0 -4
  109. package/dist/SyntenyFeature/index.js +0 -14
  110. package/dist/index.d.ts +0 -6
  111. package/dist/index.js +0 -37
  112. package/dist/syntenyTypes.d.ts +0 -3
  113. package/dist/syntenyTypes.js +0 -25
  114. package/dist/util.d.ts +0 -16
  115. package/dist/util.js +0 -79
@@ -1,42 +1,32 @@
1
- import { zip } from '../util';
2
1
  export function getWeightedMeans(ret) {
3
2
  const scoreMap = {};
4
3
  for (const entry of ret) {
5
- const query = entry.qname;
6
- const target = entry.tname;
7
- const key = `${query}-${target}`;
8
- if (!scoreMap[key]) {
9
- scoreMap[key] = { quals: [], len: [] };
4
+ const key = `${entry.qname}-${entry.tname}`;
5
+ const qual = entry.extra.mappingQual || 1;
6
+ const len = entry.extra.blockLen || 1;
7
+ const existing = scoreMap[key];
8
+ if (existing) {
9
+ existing.valueSum += qual * len;
10
+ existing.weightSum += len;
11
+ }
12
+ else {
13
+ scoreMap[key] = { valueSum: qual * len, weightSum: len };
10
14
  }
11
- scoreMap[key].quals.push(entry.extra.mappingQual || 1);
12
- scoreMap[key].len.push(entry.extra.blockLen || 1);
13
15
  }
14
- const meanScoreMap = Object.fromEntries(Object.entries(scoreMap).map(([key, val]) => {
15
- const vals = zip(val.quals, val.len);
16
- return [key, weightedMean(vals)];
17
- }));
18
- for (const entry of ret) {
19
- const query = entry.qname;
20
- const target = entry.tname;
21
- const key = `${query}-${target}`;
22
- entry.extra.meanScore = meanScoreMap[key];
16
+ const meanScoreMap = {};
17
+ let min = Infinity;
18
+ let max = -Infinity;
19
+ for (const [key, { valueSum, weightSum }] of Object.entries(scoreMap)) {
20
+ const mean = valueSum / weightSum;
21
+ meanScoreMap[key] = mean;
22
+ min = Math.min(mean, min);
23
+ max = Math.max(mean, max);
23
24
  }
24
- let min = 10000;
25
- let max = 0;
25
+ const range = max - min;
26
26
  for (const entry of ret) {
27
- min = Math.min(entry.extra.meanScore || 0, min);
28
- max = Math.max(entry.extra.meanScore || 0, max);
29
- }
30
- for (const entry of ret) {
31
- const b = entry.extra.meanScore || 0;
32
- entry.extra.meanScore = (b - min) / (max - min);
27
+ const key = `${entry.qname}-${entry.tname}`;
28
+ const score = meanScoreMap[key];
29
+ entry.extra.meanScore = range > 0 ? (score - min) / range : 1;
33
30
  }
34
31
  return ret;
35
32
  }
36
- function weightedMean(tuples) {
37
- const [valueSum, weightSum] = tuples.reduce(([valueSum, weightSum], [value, weight]) => [
38
- valueSum + value * weight,
39
- weightSum + weight,
40
- ], [0, 0]);
41
- return valueSum / weightSum;
42
- }
@@ -3,9 +3,11 @@ import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter'
3
3
  import { updateStatus } from '@jbrowse/core/util';
4
4
  import { openLocation } from '@jbrowse/core/util/io';
5
5
  import { ObservableCreate } from '@jbrowse/core/util/rxjs';
6
- import SyntenyFeature from '../SyntenyFeature';
7
- import { parsePAFLine } from '../util';
8
- class PAFAdapter extends BaseFeatureDataAdapter {
6
+ import SyntenyFeature from "../SyntenyFeature/index.js";
7
+ import { parsePAFLine } from "../util.js";
8
+ export default class PAFAdapter extends BaseFeatureDataAdapter {
9
+ static capabilities = ['getFeatures', 'getRefNames'];
10
+ pif;
9
11
  constructor(config, getSubAdapter, pluginManager) {
10
12
  super(config, getSubAdapter, pluginManager);
11
13
  const pifGzLoc = this.getConf('pifGzLocation');
@@ -36,8 +38,7 @@ class PAFAdapter extends BaseFeatureDataAdapter {
36
38
  return true;
37
39
  }
38
40
  async getRefNames(opts = {}) {
39
- var _a, _b;
40
- const r1 = (_b = (_a = opts.regions) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.assemblyName;
41
+ const r1 = opts.regions?.[0]?.assemblyName;
41
42
  if (!r1) {
42
43
  throw new Error('no assembly name provided');
43
44
  }
@@ -61,17 +62,19 @@ class PAFAdapter extends BaseFeatureDataAdapter {
61
62
  const index = assemblyNames.indexOf(assemblyName);
62
63
  const flip = index === 0;
63
64
  const letter = flip ? 'q' : 't';
65
+ const mateAssemblyName = assemblyNames[flip ? 1 : 0];
64
66
  await updateStatus('Downloading features', statusCallback, () => this.pif.getLines(letter + query.refName, query.start, query.end, {
65
67
  lineCallback: (line, fileOffset) => {
66
68
  const r = parsePAFLine(line);
67
- const refName = r.qname.slice(1);
69
+ const { extra, strand } = r;
70
+ const { numMatches = 0, blockLen = 1, cg, ...rest } = extra;
68
71
  const start = r.qstart;
69
72
  const end = r.qend;
73
+ const refName = r.qname.slice(1);
70
74
  const mateName = r.tname;
71
75
  const mateStart = r.tstart;
72
76
  const mateEnd = r.tend;
73
- const { extra, strand } = r;
74
- const { numMatches = 0, blockLen = 1, cg, ...rest } = extra;
77
+ const CIGAR = extra.cg;
75
78
  observer.next(new SyntenyFeature({
76
79
  uniqueId: fileOffset + assemblyName,
77
80
  assemblyName,
@@ -81,7 +84,7 @@ class PAFAdapter extends BaseFeatureDataAdapter {
81
84
  refName,
82
85
  strand,
83
86
  ...rest,
84
- CIGAR: extra.cg,
87
+ CIGAR,
85
88
  syntenyId: fileOffset,
86
89
  identity: numMatches / blockLen,
87
90
  numMatches,
@@ -90,7 +93,7 @@ class PAFAdapter extends BaseFeatureDataAdapter {
90
93
  start: mateStart,
91
94
  end: mateEnd,
92
95
  refName: mateName,
93
- assemblyName: assemblyNames[+flip],
96
+ assemblyName: mateAssemblyName,
94
97
  },
95
98
  }));
96
99
  },
@@ -100,5 +103,3 @@ class PAFAdapter extends BaseFeatureDataAdapter {
100
103
  });
101
104
  }
102
105
  }
103
- PAFAdapter.capabilities = ['getFeatures', 'getRefNames'];
104
- export default PAFAdapter;
@@ -1,4 +1,4 @@
1
- declare const PairwiseIndexedPAFAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
1
+ declare const PairwiseIndexedPAFAdapter: import("node_modules/@jbrowse/core/src/configuration/configurationSchema").ConfigurationSchemaType<{
2
2
  assemblyNames: {
3
3
  type: string;
4
4
  defaultValue: never[];
@@ -22,9 +22,9 @@ declare const PairwiseIndexedPAFAdapter: import("@jbrowse/core/configuration/con
22
22
  locationType: string;
23
23
  };
24
24
  };
25
- index: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
25
+ index: import("node_modules/@jbrowse/core/src/configuration/configurationSchema").ConfigurationSchemaType<{
26
26
  indexType: {
27
- model: import("mobx-state-tree").ISimpleType<string>;
27
+ model: import("@jbrowse/mobx-state-tree").ISimpleType<string>;
28
28
  type: string;
29
29
  defaultValue: string;
30
30
  };
@@ -35,6 +35,6 @@ declare const PairwiseIndexedPAFAdapter: import("@jbrowse/core/configuration/con
35
35
  locationType: string;
36
36
  };
37
37
  };
38
- }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
39
- }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
38
+ }, import("node_modules/@jbrowse/core/src/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
39
+ }, import("node_modules/@jbrowse/core/src/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
40
40
  export default PairwiseIndexedPAFAdapter;
@@ -1,5 +1,5 @@
1
1
  import { ConfigurationSchema } from '@jbrowse/core/configuration';
2
- import { types } from 'mobx-state-tree';
2
+ import { types } from '@jbrowse/mobx-state-tree';
3
3
  function x() { }
4
4
  const PairwiseIndexedPAFAdapter = ConfigurationSchema('PairwiseIndexedPAFAdapter', {
5
5
  assemblyNames: {
@@ -1,5 +1,5 @@
1
1
  import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType';
2
- import configSchema from './configSchema';
2
+ import configSchema from "./configSchema.js";
3
3
  export default function PairwiseIndexedPAFAdapterF(pluginManager) {
4
4
  pluginManager.addAdapterType(() => new AdapterType({
5
5
  name: 'PairwiseIndexedPAFAdapter',
@@ -8,6 +8,6 @@ export default function PairwiseIndexedPAFAdapterF(pluginManager) {
8
8
  adapterMetadata: {
9
9
  category: 'Synteny adapters',
10
10
  },
11
- getAdapterClass: () => import('./PairwiseIndexedPAFAdapter').then(r => r.default),
11
+ getAdapterClass: () => import("./PairwiseIndexedPAFAdapter.js").then(r => r.default),
12
12
  }));
13
13
  }
@@ -3,9 +3,8 @@ import { MismatchParser } from '@jbrowse/plugin-alignments';
3
3
  const { getMismatches } = MismatchParser;
4
4
  export default class SyntenyFeature extends SimpleFeature {
5
5
  get(arg) {
6
- if (arg === 'mismatches') {
7
- return getMismatches(this.get('CIGAR'));
8
- }
9
- return super.get(arg);
6
+ return arg === 'mismatches'
7
+ ? getMismatches(this.get('CIGAR'))
8
+ : super.get(arg);
10
9
  }
11
10
  }
package/esm/index.js CHANGED
@@ -1,20 +1,17 @@
1
1
  import Plugin from '@jbrowse/core/Plugin';
2
- import BlastTabularAdapter from './BlastTabularAdapter';
3
- import ChainAdapterF from './ChainAdapter';
4
- import ComparativeAddTrackComponentF from './ComparativeAddTrackComponent';
5
- import DeltaAdapterF from './DeltaAdapter';
6
- import GuessAdapterF from './GuessAdapter';
7
- import MCScanAddTrackComponentF from './MCScanAddTrackComponent';
8
- import MCScanAnchorsAdapterF from './MCScanAnchorsAdapter';
9
- import MCScanSimpleAnchorsAdapterF from './MCScanSimpleAnchorsAdapter';
10
- import MashMapAdapterF from './MashMapAdapter';
11
- import PAFAdapterF from './PAFAdapter';
12
- import PairwiseIndexedPAFAdapterF from './PairwiseIndexedPAFAdapter';
2
+ import BlastTabularAdapter from "./BlastTabularAdapter/index.js";
3
+ import ChainAdapterF from "./ChainAdapter/index.js";
4
+ import ComparativeAddTrackComponentF from "./ComparativeAddTrackComponent/index.js";
5
+ import DeltaAdapterF from "./DeltaAdapter/index.js";
6
+ import GuessAdapterF from "./GuessAdapter/index.js";
7
+ import MCScanAddTrackComponentF from "./MCScanAddTrackComponent/index.js";
8
+ import MCScanAnchorsAdapterF from "./MCScanAnchorsAdapter/index.js";
9
+ import MCScanSimpleAnchorsAdapterF from "./MCScanSimpleAnchorsAdapter/index.js";
10
+ import MashMapAdapterF from "./MashMapAdapter/index.js";
11
+ import PAFAdapterF from "./PAFAdapter/index.js";
12
+ import PairwiseIndexedPAFAdapterF from "./PairwiseIndexedPAFAdapter/index.js";
13
13
  export default class ComparativeAdaptersPlugin extends Plugin {
14
- constructor() {
15
- super(...arguments);
16
- this.name = 'ComparativeAdaptersPlugin';
17
- }
14
+ name = 'ComparativeAdaptersPlugin';
18
15
  install(pluginManager) {
19
16
  PAFAdapterF(pluginManager);
20
17
  PairwiseIndexedPAFAdapterF(pluginManager);
package/esm/util.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { PAFRecord } from './PAFAdapter/util';
1
+ import type { PAFRecord } from './PAFAdapter/util.ts';
2
2
  import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
3
3
  import type { GenericFilehandle } from 'generic-filehandle2';
4
4
  export declare function parseBed(text: string): Map<string | undefined, {
package/esm/util.js CHANGED
@@ -2,7 +2,7 @@ import { fetchAndMaybeUnzipText } from '@jbrowse/core/util';
2
2
  export function parseBed(text) {
3
3
  return new Map(text
4
4
  .split(/\n|\r\n|\r/)
5
- .filter(f => !!f || f.startsWith('#'))
5
+ .filter(f => !!f && !f.startsWith('#'))
6
6
  .map(line => {
7
7
  const [refName, start, end, name, score, strand] = line.split('\t');
8
8
  return [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-comparative-adapters",
3
- "version": "3.7.0",
3
+ "version": "4.0.0",
4
4
  "description": "JBrowse 2 comparative adapters",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -15,48 +15,41 @@
15
15
  "directory": "plugins/comparative-adapters"
16
16
  },
17
17
  "author": "JBrowse Team",
18
- "distMain": "dist/index.js",
19
- "srcMain": "src/index.ts",
20
- "main": "dist/index.js",
18
+ "main": "esm/index.js",
21
19
  "files": [
22
- "dist",
23
20
  "esm"
24
21
  ],
25
- "scripts": {
26
- "build": "npm-run-all build:*",
27
- "test": "cd ../..; jest --passWithNoTests plugins/comparative-adapters",
28
- "prepublishOnly": "yarn test",
29
- "prepack": "yarn build && yarn useDist",
30
- "postpack": "yarn useSrc",
31
- "useDist": "node ../../scripts/useDist.js",
32
- "useSrc": "node ../../scripts/useSrc.js",
33
- "prebuild": "npm run clean",
34
- "build:esm": "tsc --build tsconfig.build.esm.json",
35
- "build:commonjs": "tsc --build tsconfig.build.commonjs.json",
36
- "clean": "rimraf dist esm *.tsbuildinfo"
37
- },
38
22
  "dependencies": {
39
- "@gmod/bgzf-filehandle": "^4.0.0",
40
- "@gmod/tabix": "^3.0.1",
41
- "@jbrowse/core": "^3.7.0",
42
- "@jbrowse/plugin-alignments": "^3.7.0",
43
- "@jbrowse/plugin-linear-genome-view": "^3.7.0",
44
- "@mui/material": "^7.0.0",
45
- "generic-filehandle2": "^2.0.1",
46
- "mobx": "^6.0.0",
47
- "mobx-react": "^9.0.0",
48
- "mobx-state-tree": "^5.0.0",
49
- "rxjs": "^7.0.0"
23
+ "@gmod/tabix": "^3.2.2",
24
+ "@jbrowse/mobx-state-tree": "^5.5.0",
25
+ "@mui/material": "^7.3.6",
26
+ "generic-filehandle2": "^2.0.18",
27
+ "mobx": "^6.15.0",
28
+ "mobx-react": "^9.2.1",
29
+ "rxjs": "^7.8.2",
30
+ "@jbrowse/core": "^4.0.0",
31
+ "@jbrowse/plugin-alignments": "^4.0.0"
50
32
  },
51
33
  "peerDependencies": {
52
34
  "react": ">=18.0.0",
53
35
  "react-dom": ">=18.0.0"
54
36
  },
55
- "distModule": "esm/index.js",
56
- "srcModule": "src/index.ts",
57
- "module": "esm/index.js",
58
37
  "publishConfig": {
59
38
  "access": "public"
60
39
  },
61
- "gitHead": "85bdd0d58286b7adbfd408146b15847676317635"
62
- }
40
+ "sideEffects": false,
41
+ "scripts": {
42
+ "build": "pnpm run /^build:/",
43
+ "test": "cd ../..; jest --passWithNoTests plugins/comparative-adapters",
44
+ "prebuild": "pnpm clean",
45
+ "build:esm": "tsc -p tsconfig.build.esm.json",
46
+ "clean": "rimraf esm *.tsbuildinfo"
47
+ },
48
+ "types": "esm/index.d.ts",
49
+ "exports": {
50
+ ".": {
51
+ "types": "./esm/index.d.ts",
52
+ "import": "./esm/index.js"
53
+ }
54
+ }
55
+ }
@@ -1,65 +0,0 @@
1
- import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
2
- import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
3
- import type { Feature, Region } from '@jbrowse/core/util';
4
- interface BlastColumns {
5
- qseqid?: string;
6
- qgi?: string;
7
- qacc?: string;
8
- sseqid?: string;
9
- sallseqid?: string;
10
- sgi?: string;
11
- sallgi?: string;
12
- sacc?: string;
13
- sallacc?: string;
14
- qstart?: number;
15
- qend?: number;
16
- sstart?: number;
17
- send?: number;
18
- qseq?: string;
19
- sseq?: string;
20
- evalue?: string;
21
- bitscore?: string;
22
- score?: string;
23
- length?: string;
24
- pident?: string;
25
- nident?: string;
26
- mismatch?: string;
27
- positive?: string;
28
- gapopen?: string;
29
- gaps?: string;
30
- ppos?: string;
31
- frames?: string;
32
- qframe?: string;
33
- sframe?: string;
34
- btop?: string;
35
- staxids?: string;
36
- sscinames?: string;
37
- scomnames?: string;
38
- sblastnames?: string;
39
- sskingdoms?: string;
40
- stitle?: string;
41
- salltitles?: string;
42
- sstrand?: string;
43
- qcovs?: string;
44
- qcovhsp?: string;
45
- qcovus?: string;
46
- }
47
- interface BlastRecord extends BlastColumns {
48
- qseqid: string;
49
- sseqid: string;
50
- qstart: number;
51
- qend: number;
52
- sstart: number;
53
- send: number;
54
- }
55
- export default class BlastTabularAdapter extends BaseFeatureDataAdapter {
56
- private data;
57
- static capabilities: string[];
58
- getData(opts?: BaseOptions): Promise<BlastRecord[]>;
59
- setup(opts?: BaseOptions): Promise<BlastRecord[]>;
60
- hasDataForRefName(): Promise<boolean>;
61
- getAssemblyNames(): string[];
62
- getRefNames(opts?: BaseOptions): Promise<string[]>;
63
- getFeatures(query: Region, opts?: BaseOptions): import("rxjs").Observable<Feature>;
64
- }
65
- export {};
@@ -1,206 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const configuration_1 = require("@jbrowse/core/configuration");
7
- const BaseAdapter_1 = require("@jbrowse/core/data_adapters/BaseAdapter");
8
- const util_1 = require("@jbrowse/core/util");
9
- const io_1 = require("@jbrowse/core/util/io");
10
- const parseLineByLine_1 = require("@jbrowse/core/util/parseLineByLine");
11
- const rxjs_1 = require("@jbrowse/core/util/rxjs");
12
- const SyntenyFeature_1 = __importDefault(require("../SyntenyFeature"));
13
- function createBlastLineParser(columns) {
14
- const columnNames = columns.trim().split(' ');
15
- const qseqidIndex = columnNames.indexOf('qseqid');
16
- if (qseqidIndex === -1) {
17
- throw new Error('Missing required column "qseqid"');
18
- }
19
- const sseqidIndex = columnNames.indexOf('sseqid');
20
- if (sseqidIndex === -1) {
21
- throw new Error('Missing required column "sseqid"');
22
- }
23
- const qstartIndex = columnNames.indexOf('qstart');
24
- if (qstartIndex === -1) {
25
- throw new Error('Missing required column "qstart"');
26
- }
27
- const qendIndex = columnNames.indexOf('qend');
28
- if (qendIndex === -1) {
29
- throw new Error('Missing required column "qend"');
30
- }
31
- const sstartIndex = columnNames.indexOf('sstart');
32
- if (sstartIndex === -1) {
33
- throw new Error('Missing required column "sstart"');
34
- }
35
- const sendIndex = columnNames.indexOf('send');
36
- if (sendIndex === -1) {
37
- throw new Error('Missing required column "send"');
38
- }
39
- const columnNameSet = new Map(columnNames
40
- .map((c, idx) => [c, idx])
41
- .filter(f => !['qseqid', 'sseqid', 'qstart', 'qend', 'sstart', 'send'].includes(f[0])));
42
- return (line) => {
43
- if (line.startsWith('#')) {
44
- return;
45
- }
46
- const row = line.split('\t');
47
- const qseqid = row[qseqidIndex];
48
- const sseqid = row[sseqidIndex];
49
- const qstart = row[qstartIndex];
50
- const qend = row[qendIndex];
51
- const sstart = row[sstartIndex];
52
- const send = row[sendIndex];
53
- if (!(qseqid && sseqid && qstart && qend && sstart && send)) {
54
- console.warn('Invalid BLAST line');
55
- console.warn(line);
56
- return;
57
- }
58
- const record = {
59
- qseqid,
60
- sseqid,
61
- qstart: Number.parseInt(qstart),
62
- qend: Number.parseInt(qend),
63
- sstart: Number.parseInt(sstart),
64
- send: Number.parseInt(send),
65
- };
66
- for (const [columnName, idx] of columnNameSet.entries()) {
67
- const value = row[idx];
68
- if (!value) {
69
- continue;
70
- }
71
- record[columnName] = value;
72
- }
73
- return record;
74
- };
75
- }
76
- class BlastTabularAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
77
- getData(opts) {
78
- if (!this.data) {
79
- this.data = this.setup(opts).catch((e) => {
80
- this.data = undefined;
81
- throw e;
82
- });
83
- }
84
- return this.data;
85
- }
86
- async setup(opts) {
87
- const columns = (0, configuration_1.readConfObject)(this.config, 'columns');
88
- const lines = [];
89
- const cb = createBlastLineParser(columns);
90
- (0, parseLineByLine_1.parseLineByLine)(await (0, util_1.fetchAndMaybeUnzip)((0, io_1.openLocation)((0, configuration_1.readConfObject)(this.config, 'blastTableLocation'), this.pluginManager), opts), line => {
91
- const res = cb(line);
92
- if (res) {
93
- lines.push(res);
94
- }
95
- return true;
96
- }, opts === null || opts === void 0 ? void 0 : opts.statusCallback);
97
- return lines;
98
- }
99
- async hasDataForRefName() {
100
- return true;
101
- }
102
- getAssemblyNames() {
103
- const assemblyNames = this.getConf('assemblyNames');
104
- if (assemblyNames.length === 0) {
105
- const query = this.getConf('queryAssembly');
106
- const target = this.getConf('targetAssembly');
107
- return [query, target];
108
- }
109
- return assemblyNames;
110
- }
111
- async getRefNames(opts = {}) {
112
- var _a;
113
- const r1 = (_a = opts.regions) === null || _a === void 0 ? void 0 : _a[0].assemblyName;
114
- const feats = await this.getData(opts);
115
- const idx = this.getAssemblyNames().indexOf(r1);
116
- if (idx !== -1) {
117
- const set = new Set();
118
- for (const feat of feats) {
119
- set.add(idx === 0 ? feat.qseqid : feat.sseqid);
120
- }
121
- return [...set];
122
- }
123
- console.warn('Unable to do ref renaming on adapter');
124
- return [];
125
- }
126
- getFeatures(query, opts = {}) {
127
- return (0, rxjs_1.ObservableCreate)(async (observer) => {
128
- const blastRecords = await this.getData(opts);
129
- const [queryAssembly, targetAssembly] = this.getAssemblyNames();
130
- const { refName: queryRefName, assemblyName: queryAssemblyName, start: queryStart, end: queryEnd, } = query;
131
- if (queryAssemblyName !== targetAssembly &&
132
- queryAssemblyName !== queryAssembly) {
133
- console.warn(`${queryAssemblyName} not found in this adapter`);
134
- observer.complete();
135
- return;
136
- }
137
- for (let i = 0; i < blastRecords.length; i++) {
138
- const r = blastRecords[i];
139
- let start;
140
- let end;
141
- let refName;
142
- let assemblyName;
143
- let mateStart;
144
- let mateEnd;
145
- let mateRefName;
146
- let mateAssemblyName;
147
- const { qseqid, sseqid, qstart, qend, sstart, send, ...rest } = r;
148
- if (queryAssemblyName === queryAssembly) {
149
- start = qstart;
150
- end = qend;
151
- refName = qseqid;
152
- assemblyName = queryAssembly;
153
- mateStart = sstart;
154
- mateEnd = send;
155
- mateRefName = sseqid;
156
- mateAssemblyName = targetAssembly;
157
- }
158
- else {
159
- start = sstart;
160
- end = send;
161
- refName = sseqid;
162
- assemblyName = targetAssembly;
163
- mateStart = qstart;
164
- mateEnd = qend;
165
- mateRefName = qseqid;
166
- mateAssemblyName = queryAssembly;
167
- }
168
- let strand = 1;
169
- let mateStrand = 1;
170
- if (start > end) {
171
- ;
172
- [start, end] = [end, start];
173
- strand = -1;
174
- }
175
- if (mateStart > mateEnd) {
176
- ;
177
- [mateStart, mateEnd] = [mateEnd, mateStart];
178
- mateStrand = -1;
179
- }
180
- if (refName === queryRefName &&
181
- (0, util_1.doesIntersect2)(queryStart, queryEnd, start, end)) {
182
- observer.next(new SyntenyFeature_1.default({
183
- uniqueId: i + queryAssemblyName,
184
- assemblyName,
185
- start,
186
- end,
187
- type: 'match',
188
- refName,
189
- strand: strand * mateStrand,
190
- syntenyId: i,
191
- ...rest,
192
- mate: {
193
- start: mateStart,
194
- end: mateEnd,
195
- refName: mateRefName,
196
- assemblyName: mateAssemblyName,
197
- },
198
- }));
199
- }
200
- }
201
- observer.complete();
202
- });
203
- }
204
- }
205
- BlastTabularAdapter.capabilities = ['getFeatures', 'getRefNames'];
206
- exports.default = BlastTabularAdapter;
@@ -1,30 +0,0 @@
1
- declare const BlastTabularAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
2
- assemblyNames: {
3
- type: string;
4
- defaultValue: never[];
5
- description: string;
6
- };
7
- targetAssembly: {
8
- type: string;
9
- defaultValue: string;
10
- description: string;
11
- };
12
- queryAssembly: {
13
- type: string;
14
- defaultValue: string;
15
- description: string;
16
- };
17
- blastTableLocation: {
18
- type: string;
19
- defaultValue: {
20
- uri: string;
21
- locationType: string;
22
- };
23
- };
24
- columns: {
25
- type: string;
26
- description: string;
27
- defaultValue: string;
28
- };
29
- }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
30
- export default BlastTabularAdapter;