gosling.js 2.0.0-alpha.8 → 2.0.0-alpha.9

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.
@@ -9911,8 +9911,25 @@ function getChromTotalSize(chromSize) {
9911
9911
  return Object.values(chromSize).reduce((sum, current) => sum + current, 0);
9912
9912
  }
9913
9913
  function parseGenomicPosition(position) {
9914
- const [chromosome, intervalString] = position.split(":");
9915
- if (intervalString) {
9914
+ const firstColonIndex = position.indexOf(":");
9915
+ if (firstColonIndex === -1) {
9916
+ return { chromosome: position };
9917
+ }
9918
+ const chromosome = position.substring(0, firstColonIndex);
9919
+ const intervalString = position.substring(firstColonIndex + 1);
9920
+ if (intervalString.includes(":")) {
9921
+ const dashIndex = intervalString.indexOf("-");
9922
+ if (dashIndex !== -1) {
9923
+ const startPosStr = intervalString.substring(0, dashIndex);
9924
+ const endPart = intervalString.substring(dashIndex + 1);
9925
+ const [chromosomeEnd, endPosStr] = endPart.split(":");
9926
+ const start = +startPosStr.replace(/,/g, "");
9927
+ const end = +endPosStr.replace(/,/g, "");
9928
+ if (!Number.isNaN(start) && !Number.isNaN(end)) {
9929
+ return { chromosome, start, chromosomeEnd, end };
9930
+ }
9931
+ }
9932
+ } else {
9916
9933
  const [start, end] = intervalString.split("-").map((s) => +s.replace(/,/g, ""));
9917
9934
  if (!Number.isNaN(start) && !Number.isNaN(end)) {
9918
9935
  return { chromosome, start, end };
@@ -9921,14 +9938,15 @@ function parseGenomicPosition(position) {
9921
9938
  return { chromosome };
9922
9939
  }
9923
9940
  class GenomicPositionHelper {
9924
- constructor(chromosome, start, end) {
9941
+ constructor(chromosome, start, end, chromosomeEnd) {
9925
9942
  this.chromosome = chromosome;
9926
9943
  this.start = start;
9927
9944
  this.end = end;
9945
+ this.chromosomeEnd = chromosomeEnd;
9928
9946
  }
9929
9947
  static fromString(str) {
9930
9948
  const result = parseGenomicPosition(str);
9931
- return new GenomicPositionHelper(result.chromosome, result.start, result.end);
9949
+ return new GenomicPositionHelper(result.chromosome, result.start, result.end, result.chromosomeEnd);
9932
9950
  }
9933
9951
  toAbsoluteCoordinates(assembly, padding = 0) {
9934
9952
  const info = computeChromSizes(assembly);
@@ -9942,6 +9960,15 @@ class GenomicPositionHelper {
9942
9960
  [start, end] = [1, size];
9943
9961
  }
9944
9962
  const offset = interval[0];
9963
+ if (this.chromosomeEnd && this.chromosomeEnd !== this.chromosome) {
9964
+ const endSize = info.size[this.chromosomeEnd];
9965
+ const endInterval = info.interval[this.chromosomeEnd];
9966
+ if (endSize === void 0 || endInterval === void 0) {
9967
+ throw new Error(`End chromosome name ${this.chromosomeEnd} is not valid`);
9968
+ }
9969
+ const endOffset = endInterval[0];
9970
+ return [start + offset - padding, end + endOffset + padding];
9971
+ }
9945
9972
  return [start + offset - padding, end + offset + padding];
9946
9973
  }
9947
9974
  }
@@ -10015,4 +10042,4 @@ export {
10015
10042
  commonjsGlobal as y,
10016
10043
  RemoteFile as z
10017
10044
  };
10018
- //# sourceMappingURL=exported-utils-9e651c40.js.map
10045
+ //# sourceMappingURL=exported-utils-bca41fe4.js.map