Skip to content

Commit

Permalink
Make gf2
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Dec 12, 2024
1 parent f1c0480 commit 0fd594e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 30 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
],
"dependencies": {
"@gmod/bgzf-filehandle": "^1.4.0",
"buffer": "^6.0.3",
"generic-filehandle": "^3.0.0"
"generic-filehandle2": "^0.0.1"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^8.17.0",
Expand Down
20 changes: 10 additions & 10 deletions src/indexedFasta.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { LocalFile, GenericFilehandle } from 'generic-filehandle'
import { Buffer } from 'buffer'
import { LocalFile, GenericFilehandle } from 'generic-filehandle2'

interface BaseOpts {
signal?: AbortSignal
Expand Down Expand Up @@ -134,18 +133,18 @@ export default class IndexedFasta {
}

/**
* @param name
*
* @param {string} name
* @returns {Promise[boolean]} true if the file contains the given reference sequence name
* @returns true if the file contains the given reference sequence name
*/
async hasReferenceSequence(name: string, opts?: BaseOpts) {
return !!(await this._getIndexes(opts))[name]
}

/**
* @param {string} seqName
* @param {number} min
* @param {number} max
* @param seqName
* @param min
* @param max
*/
async getResiduesByName(
seqName: string,
Expand Down Expand Up @@ -189,8 +188,9 @@ export default class IndexedFasta {
const position = _faiOffset(indexEntry, min)
const readlen = _faiOffset(indexEntry, end) - position

const residues = Buffer.allocUnsafe(readlen)
await this.fasta.read(residues, 0, readlen, position, opts)
return residues.toString('utf8').replace(/\s+/g, '')
const decoder = new TextDecoder('utf8')
return decoder
.decode(await this.fasta.read(readlen, position, opts))
.replace(/\s+/g, '')
}
}
23 changes: 5 additions & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -891,11 +891,6 @@ balanced-match@^1.0.0:
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==

base64-js@^1.3.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==

binary-extensions@^2.0.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.3.0.tgz#f6e14a97858d327252200242d4ccfe522c445522"
Expand Down Expand Up @@ -933,14 +928,6 @@ browserslist@^4.24.0, browserslist@^4.24.2:
node-releases "^2.0.18"
update-browserslist-db "^1.1.1"

buffer@^6.0.3:
version "6.0.3"
resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6"
integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==
dependencies:
base64-js "^1.3.1"
ieee754 "^1.2.1"

builtin-modules@^3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.3.0.tgz#cae62812b89801e9656336e46223e030386be7b6"
Expand Down Expand Up @@ -1592,6 +1579,11 @@ function-bind@^1.1.2:
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c"
integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==

generic-filehandle2@^0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/generic-filehandle2/-/generic-filehandle2-0.0.1.tgz#7f26ee54a939ed588d6bdb3a453bb2255ccd2be9"
integrity sha512-cySnWoVmNUSkRztAwlghNVAYXUh+VVy/fxn8tT3jZIo8UQEHkYL7ueSUseBZrwqBCq9n06Wp/F4xv2q2/SwYCQ==

generic-filehandle@^3.0.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/generic-filehandle/-/generic-filehandle-3.2.0.tgz#f65401ce71bccadb796335495c3d9250185876d4"
Expand Down Expand Up @@ -1876,11 +1868,6 @@ html-void-elements@^2.0.0:
resolved "https://registry.yarnpkg.com/html-void-elements/-/html-void-elements-2.0.1.tgz#29459b8b05c200b6c5ee98743c41b979d577549f"
integrity sha512-0quDb7s97CfemeJAnW9wC0hw78MtW7NU3hqtCD75g2vFlDLt36llsYD7uB7SUzojLMP24N5IatXf7ylGXiGG9A==

ieee754@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352"
integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==

ignore@^5.2.0, ignore@^5.3.1:
version "5.3.2"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.2.tgz#3cd40e729f3643fd87cb04e50bf0eb722bc596f5"
Expand Down

0 comments on commit 0fd594e

Please sign in to comment.