view x/static/js/6310.ae82dc58.chunk.js.map @ 125:49f3d3878413 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5ea1f9c1eef1de76232e69aa6d34cda77d90d566
author fubar
date Sat, 05 Oct 2024 23:58:05 +0000
parents
children
line wrap: on
line source

{"version":3,"file":"static/js/6310.ae82dc58.chunk.js","mappings":"+NAGA,MAAMA,EAAe,WAAWC,MAAM,IAAIC,KAAIC,GAAKA,EAAEC,WAAW,KAC1DC,EAAa,SAASJ,MAAM,IAAIC,KAAIC,GAAKA,EAAEC,WAAW,KACtDE,EAAe,IAAIL,MAAM,IAAIC,KAAIC,GAAKA,EAAEC,WAAW,KAEzD,SAASG,EAAgBC,EAAkBC,EAAgBC,GACzD,IAAIC,EAAI,EACR,KAAOA,EAAID,EAAME,OAAQD,GAAK,EAC5B,GAAIF,EAAOD,EAAWG,KAAOD,EAAMC,GACjC,OAAO,EAGX,OAAO,CACT,CAEO,SAASE,EAAiBJ,GAG/B,IAAIE,EAAI,EACR,KAAOA,EAAIF,EAAOG,SAEdL,EAAgBI,EAAGF,EAAQT,IAC3BO,EAAgBI,EAAGF,EAAQJ,IAC3BE,EAAgBI,EAAGF,EAAQH,IAJLK,GAAK,EAO3B,GACEA,GAAK,QACgB,KAAdF,EAAOE,IAMpB,OAAIA,EACKF,EAAOK,SAASH,GAElBF,CACT,CAEOM,eAAeC,EAAeP,EAAgBQ,GACnD,MAAMC,EAAIL,EAAiBJ,GACrBU,QAAaC,EAAAA,EAAAA,gBAAeF,GAE5BG,EAAa,CACjB,CAAEC,KAAM,QAASC,SAAU,CAAEC,KAAM,WACnC,CAAEF,KAAM,aAAcC,SAAU,CAAEC,KAAM,aACxC,CAAEF,KAAM,WAAYC,SAAU,CAAEC,KAAM,WACtC,CAAEF,KAAM,OAAQC,SAAU,CAAEC,KAAM,SAClC,CAAEF,KAAM,QAASC,SAAU,CAAEC,KAAM,WACnC,CAAEF,KAAM,SAAUC,SAAU,CAAE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eAAeuE,EAAe7E,EAAgBQ,GAEnD,OAAOyD,QADYhB,EAAUjD,GACUQ,EACzC,CAEOF,eAAeK,EAAeX,EAAgBQ,GAEnD,OAAOyD,QADYhB,EAAUjD,EAAQ,CAAE8E,UAAW,OACXtE,EACzC,C","sources":["../../../plugins/spreadsheet-view/src/SpreadsheetView/importAdapters/BedImport.ts","../../../plugins/spreadsheet-view/src/SpreadsheetView/importAdapters/ImportUtils.ts"],"sourcesContent":["import { ParseOptions, parseTsvBuffer } from './ImportUtils'\nimport type { Buffer } from 'buffer'\n\nconst browserBytes = 'browser '.split('').map(c => c.charCodeAt(0))\nconst trackBytes = 'track '.split('').map(c => c.charCodeAt(0))\nconst commentBytes = '#'.split('').map(c => c.charCodeAt(0))\n\nfunction bytesAreFoundAt(position: number, buffer: Buffer, bytes: number[]) {\n  let i = 0\n  for (; i < bytes.length; i += 1) {\n    if (buffer[position + i] !== bytes[i]) {\n      return false\n    }\n  }\n  return true\n}\n\nexport function removeBedHeaders(buffer: Buffer) {\n  // slice off the first lines of the buffer if it starts with one or more\n  // header lines\n  let i = 0\n  for (; i < buffer.length; i += 1) {\n    if (\n      bytesAreFoundAt(i, buffer, browserBytes) ||\n      bytesAreFoundAt(i, buffer, trackBytes) ||\n      bytesAreFoundAt(i, buffer, commentBytes)\n    ) {\n      // consume up to the next newline\n      do {\n        i += 1\n      } while (buffer[i] !== 10)\n    } else {\n      // end of headers, return\n      break\n    }\n  }\n  if (i) {\n    return buffer.subarray(i)\n  }\n  return buffer\n}\n\nexport async function parseBedBuffer(buffer: Buffer, options: ParseOptions) {\n  const b = removeBedHeaders(buffer)\n  const data = await parseTsvBuffer(b)\n\n  const bedColumns = [\n    { name: 'chrom', dataType: { type: 'LocRef' } },\n    { name: 'chromStart', dataType: { type: 'LocStart' } },\n    { name: 'chromEnd', dataType: { type: 'LocEnd' } },\n    { name: 'name', dataType: { type: 'Text' } },\n    { name: 'score', dataType: { type: 'Number' } },\n    { name: 'strand', dataType: { type: 'Text' } },\n  ] as const\n\n  data.columns.forEach((col, colNumber) => {\n    const bedColumn = bedColumns[colNumber]\n    if (bedColumn) {\n      col.name = bedColumn.name\n      col.dataType = bedColumn.dataType\n    }\n  })\n  data.hasColumnNames = true\n  data.assemblyName = options.selectedAssemblyName\n\n  data.columnDisplayOrder.push(data.columnDisplayOrder.length)\n  data.columns.unshift({\n    name: 'Location',\n    dataType: { type: 'LocString' },\n    isDerived: true,\n    derivationFunctionText: `jexl:{text:row.cells[0].text+':'+row.cells[1].text+'..'+row.cells[2].text,\\n\n    extendedData: {refName: row.cells.ref.text, start: parseInt(row.cells.start.text,10), end: parseInt(row.cells.end.text,10)}}`,\n  })\n  return data\n}\n\nexport async function parseBedPEBuffer(buffer: Buffer, options: ParseOptions) {\n  const b = removeBedHeaders(buffer)\n  const data = await parseTsvBuffer(b)\n  interface BedColumn {\n    name: string\n    dataType: {\n      type: string\n    }\n    featureField: string[]\n  }\n  const bedColumns: BedColumn[] = [\n    { name: 'chrom1', dataType: { type: 'Text' }, featureField: ['refName'] },\n    { name: 'start1', dataType: { type: 'Number' }, featureField: ['start'] },\n    { name: 'end1', dataType: { type: 'Number' }, featureField: ['end'] },\n    {\n      name: 'chrom2',\n      dataType: { type: 'Text' },\n      featureField: ['mate', 'refName'],\n    },\n    {\n      name: 'start2',\n      dataType: { type: 'Number' },\n      featureField: ['mate', 'start'],\n    },\n    {\n      name: 'end2',\n      dataType: { type: 'Number' },\n      featureField: ['mate', 'end'],\n    },\n    { name: 'name', dataType: { type: 'Text' }, featureField: ['name'] },\n    { name: 'score', dataType: { type: 'Number' }, featureField: ['score'] },\n    { name: 'strand1', dataType: { type: 'Text' }, featureField: ['strand'] },\n    {\n      name: 'strand2',\n      dataType: { type: 'Text' },\n      featureField: ['mate', 'strand'],\n    },\n  ] as const\n  data.columns.forEach((col, colNumber) => {\n    const bedColumn = bedColumns[colNumber]\n    if (bedColumn) {\n      col.name = bedColumn.name\n      col.dataType = bedColumn.dataType\n    }\n  })\n  data.hasColumnNames = true\n\n  // decorate each row with a feature object in its extendedData\n  data.rowSet.rows.forEach((row, rowNumber) => {\n    const featureData: Record<string, any> = {}\n    row.cells.forEach(({ text }, columnNumber) => {\n      const bedColumn = bedColumns[columnNumber]\n      const val =\n        bedColumn && bedColumn.dataType.type === 'Number' && text\n          ? Number.parseFloat(text)\n          : text\n      if (bedColumn) {\n        // a predefined column\n        if (bedColumn.featureField.length === 2) {\n          if (!featureData[bedColumn.featureField[0]!]) {\n            featureData[bedColumn.featureField[0]!] = {}\n          }\n          featureData[bedColumn.featureField[0]!][bedColumn.featureField[1]!] =\n            val\n        } else {\n          featureData[bedColumn.featureField[0]!] = val\n        }\n      } else {\n        // some other column\n        featureData[`column${columnNumber + 1}`] = val\n      }\n    })\n    featureData.uniqueId = `bedpe-${rowNumber}`\n    row.extendedData = {\n      feature: featureData,\n    }\n  })\n\n  data.assemblyName = options.selectedAssemblyName\n\n  return data\n}\n","import { ParsedLocString, parseLocString } from '@jbrowse/core/util'\nimport type { Buffer } from 'buffer'\n\nexport function bufferToString(buffer: Buffer) {\n  return new TextDecoder('utf8', { fatal: true }).decode(buffer)\n}\n\nasync function parseWith(buffer: Buffer, options = {}) {\n  const csv = await import('csvtojson').then(module => module.default)\n  return csv({ noheader: true, output: 'csv', ...options }).fromString(\n    bufferToString(buffer),\n  )\n}\n\nexport interface Row {\n  id: string\n\n  extendedData?: any\n  cells: {\n    text: string\n\n    extendedData?: any\n  }[]\n}\n\nexport interface RowSet {\n  isLoaded: boolean\n  rows: Row[]\n}\n\nexport interface ParseOptions {\n  hasColumnNameLine?: boolean\n  columnNameLineNumber?: number\n  selectedAssemblyName?: string\n  isValidRefName?: (refName: string, assemblyName?: string) => boolean\n}\n\nexport interface Column {\n  name: string\n  dataType: { type: string }\n  isDerived?: boolean\n  derivationFunctionText?: string\n}\n\nfunction guessColumnType(\n  rowSet: RowSet,\n  columnNumber: number,\n  isValidRefName: (refName: string, assemblyName?: string) => boolean,\n) {\n  const text = rowSet.rows[0]!.cells[columnNumber]!.text || ''\n\n  let guessedType = 'Text'\n\n  let parsedLoc: ParsedLocString | undefined\n  try {\n    parsedLoc = parseLocString(text, isValidRefName)\n  } catch (error) {\n    //\n  }\n  if (parsedLoc?.refName && typeof parsedLoc.start === 'number') {\n    guessedType = 'LocString'\n  } else if (/^\\d+(\\.\\d+)?$/.test(text)) {\n    guessedType = 'Number'\n  }\n\n  // MAYBE TODO: iterate over the rest of the rows to confirm\n  // the type for all the rows\n\n  return guessedType\n}\n\nfunction dataToSpreadsheetSnapshot(\n  rows: string[][],\n  options: ParseOptions = {},\n) {\n  const {\n    hasColumnNameLine = false,\n    columnNameLineNumber = 1,\n    isValidRefName = () => false,\n    selectedAssemblyName,\n  } = options\n  // rows is an array of row objects and columnNames\n  // is an array of column names (in import order)\n  let maxCols = 0\n  const rowSet: RowSet = {\n    isLoaded: true,\n    rows: rows.map((row, rowNumber) => {\n      const id = rowNumber + (hasColumnNameLine ? 0 : 1)\n      if (row.length > maxCols) {\n        maxCols = row.length\n      }\n      return {\n        id: String(id),\n        cells: row.map((text, columnNumber) => {\n          return { columnNumber, text }\n        }),\n      }\n    }),\n  }\n\n  // process the column names row if present\n  const columnNames: Record<string, string> = {}\n  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n  if (hasColumnNameLine && columnNameLineNumber !== undefined) {\n    const [colNamesRow] = rowSet.rows.splice(columnNameLineNumber - 1, 1)\n\n    if (colNamesRow) {\n      colNamesRow.cells.forEach((cell, columnNumber) => {\n        columnNames[columnNumber] = cell.text || ''\n      })\n    }\n  }\n\n  // make our column definitions\n  const columns: Column[] = []\n  const columnDisplayOrder = []\n  for (let columnNumber = 0; columnNumber < maxCols; columnNumber += 1) {\n    columnDisplayOrder.push(columnNumber)\n    const guessedType = guessColumnType(rowSet, columnNumber, isValidRefName)\n\n    // store extendeddata for LocString column\n    if (guessedType === 'LocString') {\n      for (const row of rowSet.rows) {\n        const cell = row.cells[columnNumber]!\n        cell.extendedData = parseLocString(cell.text, isValidRefName)\n      }\n    }\n\n    columns[columnNumber] = {\n      name: columnNames[columnNumber]!,\n      dataType: {\n        type: guessedType,\n      },\n    }\n  }\n\n  return {\n    rowSet,\n    columnDisplayOrder,\n    hasColumnNames: !!hasColumnNameLine,\n    columns,\n    assemblyName: selectedAssemblyName,\n  }\n}\n\nexport async function parseCsvBuffer(buffer: Buffer, options?: ParseOptions) {\n  const rows = await parseWith(buffer)\n  return dataToSpreadsheetSnapshot(rows, options)\n}\n\nexport async function parseTsvBuffer(buffer: Buffer, options?: ParseOptions) {\n  const rows = await parseWith(buffer, { delimiter: '\\t' })\n  return dataToSpreadsheetSnapshot(rows, options)\n}\n"],"names":["browserBytes","split","map","c","charCodeAt","trackBytes","commentBytes","bytesAreFoundAt","position","buffer","bytes","i","length","removeBedHeaders","subarray","async","parseBedBuffer","options","b","data","parseTsvBuffer","bedColumns","name","dataType","type","columns","forEach","col","colNumber","bedColumn","hasColumnNames","assemblyName","selectedAssemblyName","columnDisplayOrder","push","unshift","isDerived","derivationFunctionText","parseBedPEBuffer","featureField","rowSet","rows","row","rowNumber","featureData","cells","text","columnNumber","val","Number","parseFloat","uniqueId","extendedData","feature","bufferToString","TextDecoder","fatal","decode","parseWith","then","module","default","noheader","output","fromString","guessColumnType","isValidRefName","parsedLoc","guessedType","parseLocString","error","refName","start","test","dataToSpreadsheetSnapshot","hasColumnNameLine","columnNameLineNumber","maxCols","isLoaded","id","String","columnNames","undefined","colNamesRow","splice","cell","parseCsvBuffer","delimiter"],"sourceRoot":""}