Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Hi-C rendering for some high resolution files #4319

Merged
merged 1 commit into from Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 8 additions & 6 deletions plugins/hic/src/HicAdapter/HicAdapter.ts
Expand Up @@ -36,21 +36,23 @@ interface HicOptions extends BaseOptions {
bpPerPx?: number
}

// wraps generic-filehandle so the read function only takes a position and length
// in some ways, generic-filehandle wishes it was just this but it has
// wraps generic-filehandle so the read function only takes a position and
// length in some ways, generic-filehandle wishes it was just this but it has
// to adapt to the node.js fs promises API
class GenericFilehandleWrapper {
constructor(private filehandle: GenericFilehandle) {}

async read(position: number, length: number) {
const { buffer: b, bytesRead } = await this.filehandle.read(
Buffer.allocUnsafe(length),
const { buffer } = await this.filehandle.read(
Buffer.alloc(length),
0,
length,
position,
)
// xref https://stackoverflow.com/a/31394257/2129219
return b.buffer.slice(b.byteOffset, b.byteOffset + bytesRead)
return buffer.buffer.slice(
buffer.byteOffset,
buffer.byteOffset + buffer.byteLength,
)
}
}
export function openFilehandleWrapper(
Expand Down
2 changes: 1 addition & 1 deletion plugins/hic/src/HicRenderer/HicRenderer.tsx
Expand Up @@ -81,8 +81,8 @@ export default class HicRenderer extends ServerSideRendererType {

const w = res / (bpPerPx * Math.sqrt(2))
const baseColor = colord(readConfObject(config, 'baseColor'))
const offset = region.start
if (features.length) {
const offset = features[0].bin1
let maxScore = 0
let minBin = 0
let maxBin = 0
Expand Down