Skip to content

Commit

Permalink
Begin typescriptifying codecs
Browse files Browse the repository at this point in the history
Eslint

Updates
  • Loading branch information
cmdcolin committed Dec 15, 2024
1 parent f690691 commit 75df58a
Show file tree
Hide file tree
Showing 16 changed files with 1,067 additions and 1,168 deletions.
5 changes: 3 additions & 2 deletions src/cramFile/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import QuickLRU from 'quick-lru'
import { XzReadableStream } from 'xz-decompress'

import { CramMalformedError, CramUnimplementedError } from '../errors'
import htscodecs from '../htscodecs'
import * as htscodecs from '../htscodecs'
import { open } from '../io'
import ransuncompress from '../rans'
import { parseHeaderText } from '../sam'
import { unzip } from '../unzip'
import { concatUint8Array } from '../util'
import CramContainer from './container'
import CramRecord from './record'
import {
Expand All @@ -17,7 +18,7 @@ import {
cramFileDefinition,
getSectionParsers,
} from './sectionParsers'
import { concatUint8Array, parseItem, tinyMemoize } from './util'
import { parseItem, tinyMemoize } from './util'

import type { GenericFilehandle } from 'generic-filehandle2'

Expand Down
8 changes: 3 additions & 5 deletions src/cramFile/slice/decodeRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,14 @@ function decodeReadFeatures(
const data = decodeDataSeries(dataSeriesName)
if (type === 'character') {
return String.fromCharCode(data)
}
if (type === 'string') {
} else if (type === 'string') {
let r = ''
for (let i = 0; i < data.byteLength; i++) {
r += String.fromCharCode(data[i])
}
return r
}
if (type === 'numArray') {
return data.toArray()
} else if (type === 'numArray') {
return Array.from(data)
}
// else if (type === 'number') {
// return data[0]
Expand Down
17 changes: 0 additions & 17 deletions src/cramFile/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,20 +179,3 @@ export function tinyMemoize(_class: any, methodName: any) {
export function sequenceMD5(seq: string) {
return md5(seq.toUpperCase().replaceAll(/[^\u0021-\u007e]/g, ''))
}

export function sum(array: Uint8Array[]) {
let sum = 0
for (const entry of array) {
sum += entry.length
}
return sum
}
export function concatUint8Array(args: Uint8Array[]) {
const mergedArray = new Uint8Array(sum(args))
let offset = 0
for (const entry of args) {
mergedArray.set(entry, offset)
offset += entry.length
}
return mergedArray
}
Loading

0 comments on commit 75df58a

Please sign in to comment.