Skip to content

Commit

Permalink
Index-debug
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Aug 8, 2024
1 parent 8ac9191 commit c5178f3
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 138 deletions.
3 changes: 0 additions & 3 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ const compat = new FlatCompat({
})

export default [
{
ignores: ['src/binary-parser/*.js'],
},
...compat.extends(
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-type-checked',
Expand Down
49 changes: 49 additions & 0 deletions example/index-debug.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<html>
<head>
<script src="cram-bundle.js"></script>
<script>
const { IndexedCramFile, CramFile, CraiIndex } = window.gmodCRAM

// open local files
const indexedFile = new IndexedCramFile({
cramUrl: 'volvox-sorted.cram',
index: new CraiIndex({
url: 'volvox-sorted.cram.crai',
}),
seqFetch: async (seqId, start, end) => {
return ''
},
checkSequenceMD5: false,
})

// example of fetching records from an indexed CRAM file.
// NOTE: only numeric IDs for the reference sequence are accepted.
// For indexedfasta the numeric ID is the order in which the sequence names appear in the header

// Wrap in an async and then run
run = async () => {
const records = await indexedFile.getRecordsForRange(0, 10000, 20000)
const r = []
records.forEach(record => {
console.log(`got a record named ${record.readName}`)
if (record.readFeatures != undefined) {
record.readFeatures.forEach(({ code, pos, refPos, ref, sub }) => {
if (code === 'X') {
r.push(
`${record.readName} shows a base substitution at ${refPos}`,
)
}
})
}
})
document.getElementById('output').innerHTML = r.join('\n')
}

run()
</script>
</head>
<body>
<h1>Hello world</h1>
<pre id="output" />
</body>
</html>
4 changes: 0 additions & 4 deletions src/cramFile/codecs/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ export default class ExternalCodec extends CramCodec<
cursors: Cursors,
) {
const { blockContentId } = this.parameters
// console.log({
// blocksByContentId: Object.keys(blocksByContentId),
// blockContentId,
// })
const contentBlock = blocksByContentId[blockContentId]
if (!contentBlock) {
throw new CramMalformedError(
Expand Down
2 changes: 1 addition & 1 deletion src/cramFile/slice/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export default class CramSlice {
const sectionParsers = getSectionParsers(majorVersion)
const containerHeader = await this.container.getHeader()
if (!containerHeader) {
throw new Error('wow')
throw new Error('no container header detected')
}

const header = await this.file.readBlock(
Expand Down
3 changes: 0 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ module.exports = {
mode: 'production',
entry: './dist/index.js',
plugins: [
// this is needed to properly polyfill buffer in desktop, after the CRA5
// conversion it was observed cram, twobit, etc that use
// @gmod/binary-parser complained of buffers not being real buffers
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
Expand Down
Loading

0 comments on commit c5178f3

Please sign in to comment.