@jbrowse/plugin-comparative-adapters 2.16.0 → 2.17.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 (47) hide show
  1. package/dist/BlastTabularAdapter/BlastTabularAdapter.d.ts +120 -0
  2. package/dist/BlastTabularAdapter/BlastTabularAdapter.js +207 -0
  3. package/dist/BlastTabularAdapter/configSchema.d.ts +45 -0
  4. package/dist/BlastTabularAdapter/configSchema.js +52 -0
  5. package/dist/BlastTabularAdapter/index.d.ts +2 -0
  6. package/dist/BlastTabularAdapter/index.js +42 -0
  7. package/dist/ChainAdapter/ChainAdapter.js +1 -3
  8. package/dist/ChainAdapter/configSchema.js +1 -1
  9. package/dist/ChainAdapter/util.js +2 -2
  10. package/dist/DeltaAdapter/DeltaAdapter.js +1 -3
  11. package/dist/DeltaAdapter/configSchema.js +5 -2
  12. package/dist/DeltaAdapter/util.js +2 -2
  13. package/dist/MashMapAdapter/MashMapAdapter.d.ts +12 -1
  14. package/dist/MashMapAdapter/MashMapAdapter.js +1 -3
  15. package/dist/MashMapAdapter/configSchema.js +1 -1
  16. package/dist/PAFAdapter/PAFAdapter.js +4 -6
  17. package/dist/PAFAdapter/configSchema.js +1 -1
  18. package/dist/PAFAdapter/util.d.ts +1 -1
  19. package/dist/PAFAdapter/util.js +1 -1
  20. package/dist/PairwiseIndexedPAFAdapter/configSchema.js +1 -1
  21. package/dist/index.js +2 -0
  22. package/dist/util.d.ts +1 -1
  23. package/dist/util.js +9 -6
  24. package/esm/BlastTabularAdapter/BlastTabularAdapter.d.ts +120 -0
  25. package/esm/BlastTabularAdapter/BlastTabularAdapter.js +202 -0
  26. package/esm/BlastTabularAdapter/configSchema.d.ts +45 -0
  27. package/esm/BlastTabularAdapter/configSchema.js +50 -0
  28. package/esm/BlastTabularAdapter/index.d.ts +2 -0
  29. package/esm/BlastTabularAdapter/index.js +13 -0
  30. package/esm/ChainAdapter/ChainAdapter.js +2 -4
  31. package/esm/ChainAdapter/configSchema.js +1 -1
  32. package/esm/ChainAdapter/util.js +2 -2
  33. package/esm/DeltaAdapter/DeltaAdapter.js +2 -4
  34. package/esm/DeltaAdapter/configSchema.js +5 -2
  35. package/esm/DeltaAdapter/util.js +2 -2
  36. package/esm/MashMapAdapter/MashMapAdapter.d.ts +12 -1
  37. package/esm/MashMapAdapter/MashMapAdapter.js +2 -4
  38. package/esm/MashMapAdapter/configSchema.js +1 -1
  39. package/esm/PAFAdapter/PAFAdapter.js +5 -7
  40. package/esm/PAFAdapter/configSchema.js +1 -1
  41. package/esm/PAFAdapter/util.d.ts +1 -1
  42. package/esm/PAFAdapter/util.js +1 -1
  43. package/esm/PairwiseIndexedPAFAdapter/configSchema.js +1 -1
  44. package/esm/index.js +2 -0
  45. package/esm/util.d.ts +1 -1
  46. package/esm/util.js +10 -7
  47. package/package.json +2 -2
@@ -1,13 +1,11 @@
1
1
  import { openLocation } from '@jbrowse/core/util/io';
2
- import { unzip } from '@gmod/bgzf-filehandle';
3
- import { isGzip } from '@jbrowse/core/util';
2
+ import { fetchAndMaybeUnzip } from '@jbrowse/core/util';
4
3
  import PAFAdapter from '../PAFAdapter/PAFAdapter';
5
4
  import { parseLineByLine } from '../util';
6
5
  export default class MashMapAdapter extends PAFAdapter {
7
6
  async setupPre(opts) {
8
7
  const outLoc = openLocation(this.getConf('outLocation'), this.pluginManager);
9
- const buffer = (await outLoc.readFile(opts));
10
- const buf = isGzip(buffer) ? await unzip(buffer) : buffer;
8
+ const buf = await fetchAndMaybeUnzip(outLoc, opts);
11
9
  return parseLineByLine(buf, parseMashMapLine);
12
10
  }
13
11
  }
@@ -10,7 +10,7 @@ const MashMapAdapter = ConfigurationSchema('MashMapAdapter', {
10
10
  assemblyNames: {
11
11
  type: 'stringArray',
12
12
  defaultValue: [],
13
- description: 'Target is the first value in the array, query is the second',
13
+ description: 'Array of assembly names to use for this file. The query assembly name is the first value in the array, target assembly name is the second',
14
14
  },
15
15
  /**
16
16
  * #slot
@@ -2,9 +2,8 @@ import { BaseFeatureDataAdapter, } from '@jbrowse/core/data_adapters/BaseAdapter
2
2
  import { doesIntersect2 } from '@jbrowse/core/util/range';
3
3
  import { openLocation } from '@jbrowse/core/util/io';
4
4
  import { ObservableCreate } from '@jbrowse/core/util/rxjs';
5
- import { isGzip } from '@jbrowse/core/util';
5
+ import { fetchAndMaybeUnzip } from '@jbrowse/core/util';
6
6
  import { readConfObject, } from '@jbrowse/core/configuration';
7
- import { unzip } from '@gmod/bgzf-filehandle';
8
7
  import { MismatchParser } from '@jbrowse/plugin-alignments';
9
8
  // locals
10
9
  import SyntenyFeature from '../SyntenyFeature';
@@ -24,14 +23,13 @@ class PAFAdapter extends BaseFeatureDataAdapter {
24
23
  async setupPre(opts) {
25
24
  const pm = this.pluginManager;
26
25
  const pafLocation = openLocation(this.getConf('pafLocation'), pm);
27
- const buffer = (await pafLocation.readFile(opts));
28
- const buf = isGzip(buffer) ? await unzip(buffer) : buffer;
26
+ const buf = await fetchAndMaybeUnzip(pafLocation, opts);
29
27
  return parseLineByLine(buf, parsePAFLine);
30
28
  }
31
29
  async hasDataForRefName() {
32
- // determining this properly is basically a call to getFeatures
33
- // so is not really that important, and has to be true or else
34
- // getFeatures is never called (BaseAdapter filters it out)
30
+ // determining this properly is basically a call to getFeatures so is not
31
+ // really that important, and has to be true or else getFeatures is never
32
+ // called (BaseAdapter filters it out)
35
33
  return true;
36
34
  }
37
35
  getAssemblyNames() {
@@ -10,7 +10,7 @@ const PAFAdapter = ConfigurationSchema('PAFAdapter', {
10
10
  assemblyNames: {
11
11
  type: 'stringArray',
12
12
  defaultValue: [],
13
- description: 'Array of assembly names to use for this file. The target assembly name is the first value in the array, query assembly name is the second',
13
+ description: 'Array of assembly names to use for this file. The query assembly name is the first value in the array, target assembly name is the second',
14
14
  },
15
15
  /**
16
16
  * #slot
@@ -9,7 +9,7 @@ export interface PAFRecord {
9
9
  extra: {
10
10
  cg?: string;
11
11
  blockLen?: number;
12
- mappingQual: number;
12
+ mappingQual?: number;
13
13
  numMatches?: number;
14
14
  meanScore?: number;
15
15
  };
@@ -42,7 +42,7 @@ export function getWeightedMeans(ret) {
42
42
  if (!scoreMap[key]) {
43
43
  scoreMap[key] = { quals: [], len: [] };
44
44
  }
45
- scoreMap[key].quals.push(entry.extra.mappingQual);
45
+ scoreMap[key].quals.push(entry.extra.mappingQual || 1);
46
46
  scoreMap[key].len.push(entry.extra.blockLen || 1);
47
47
  }
48
48
  const meanScoreMap = Object.fromEntries(Object.entries(scoreMap).map(([key, val]) => {
@@ -11,7 +11,7 @@ const PairwiseIndexedPAFAdapter = ConfigurationSchema('PairwiseIndexedPAFAdapter
11
11
  assemblyNames: {
12
12
  type: 'stringArray',
13
13
  defaultValue: [],
14
- description: 'Array of assembly names to use for this file. The target assembly name is the first value in the array, query assembly name is the second',
14
+ description: 'Array of assembly names to use for this file. The query assembly name is the first value in the array, target assembly name is the second',
15
15
  },
16
16
  /**
17
17
  * #slot
package/esm/index.js CHANGED
@@ -6,6 +6,7 @@ import MCScanSimpleAnchorsAdapterF from './MCScanSimpleAnchorsAdapter';
6
6
  import MashMapAdapterF from './MashMapAdapter';
7
7
  import DeltaAdapterF from './DeltaAdapter';
8
8
  import ChainAdapterF from './ChainAdapter';
9
+ import BlastTabularAdapter from './BlastTabularAdapter';
9
10
  import { getFileName, } from '@jbrowse/core/util/tracks';
10
11
  export default class ComparativeAdaptersPlugin extends Plugin {
11
12
  constructor() {
@@ -20,6 +21,7 @@ export default class ComparativeAdaptersPlugin extends Plugin {
20
21
  MCScanAnchorsAdapterF(pluginManager);
21
22
  MCScanSimpleAnchorsAdapterF(pluginManager);
22
23
  MashMapAdapterF(pluginManager);
24
+ BlastTabularAdapter(pluginManager);
23
25
  pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', (adapterGuesser) => {
24
26
  return (file, index, adapterHint) => {
25
27
  const regexGuess = /\.paf/i;
package/esm/util.d.ts CHANGED
@@ -12,7 +12,7 @@ export declare function parseBed(text: string): Map<string | undefined, {
12
12
  }>;
13
13
  export declare function readFile(file: GenericFilehandle, opts?: BaseOptions): Promise<string>;
14
14
  export declare function zip(a: number[], b: number[]): [number, number][];
15
- export declare function parseLineByLine(buffer: Buffer, cb: (line: string) => PAFRecord): PAFRecord[];
15
+ export declare function parseLineByLine<T>(buffer: Buffer, cb: (line: string) => T | undefined): T[];
16
16
  export declare function parsePAFLine(line: string): PAFRecord;
17
17
  export declare function flipCigar(cigar: string[]): (string | undefined)[];
18
18
  export declare function swapIndelCigar(cigar: string): string;
package/esm/util.js CHANGED
@@ -1,5 +1,4 @@
1
- import { unzip } from '@gmod/bgzf-filehandle';
2
- import { isGzip } from '@jbrowse/core/util';
1
+ import { fetchAndMaybeUnzip } from '@jbrowse/core/util';
3
2
  export function parseBed(text) {
4
3
  return new Map(text
5
4
  .split(/\n|\r\n|\r/)
@@ -20,25 +19,29 @@ export function parseBed(text) {
20
19
  }));
21
20
  }
22
21
  export async function readFile(file, opts) {
23
- const buffer = (await file.readFile(opts));
24
- return new TextDecoder('utf8', { fatal: true }).decode(isGzip(buffer) ? await unzip(buffer) : buffer);
22
+ const buf = await fetchAndMaybeUnzip(file, opts);
23
+ const decoder = new TextDecoder('utf8');
24
+ return decoder.decode(buf);
25
25
  }
26
26
  export function zip(a, b) {
27
27
  return a.map((e, i) => [e, b[i]]);
28
28
  }
29
- const decoder = typeof TextDecoder !== 'undefined' ? new TextDecoder('utf8') : undefined;
30
29
  export function parseLineByLine(buffer, cb) {
31
30
  let blockStart = 0;
32
31
  const entries = [];
32
+ const decoder = new TextDecoder('utf8');
33
33
  while (blockStart < buffer.length) {
34
34
  const n = buffer.indexOf('\n', blockStart);
35
35
  if (n === -1) {
36
36
  break;
37
37
  }
38
38
  const b = buffer.subarray(blockStart, n);
39
- const line = ((decoder === null || decoder === void 0 ? void 0 : decoder.decode(b)) || b.toString()).trim();
39
+ const line = decoder.decode(b).trim();
40
40
  if (line) {
41
- entries.push(cb(line));
41
+ const entry = cb(line);
42
+ if (entry) {
43
+ entries.push(entry);
44
+ }
42
45
  }
43
46
  blockStart = n + 1;
44
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-comparative-adapters",
3
- "version": "2.16.0",
3
+ "version": "2.17.0",
4
4
  "description": "JBrowse 2 comparative adapters",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -58,5 +58,5 @@
58
58
  "publishConfig": {
59
59
  "access": "public"
60
60
  },
61
- "gitHead": "1e6d4fbc27ce684eed19e3c217f34bd2da24ab75"
61
+ "gitHead": "eed30b5e671f8f7823652d7cecc51aa89226de46"
62
62
  }