{"action":"closed","issue":{"url":"https://api.github.com/repos/dpryan79/libBigWig/issues/11","repository_url":"https://api.github.com/repos/dpryan79/libBigWig","labels_url":"https://api.github.com/repos/dpryan79/libBigWig/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/dpryan79/libBigWig/issues/11/comments","events_url":"https://api.github.com/repos/dpryan79/libBigWig/issues/11/events","html_url":"https://github.com/dpryan79/libBigWig/issues/11","id":189176627,"number":11,"title":"Feature request: iterator","user":{"login":"dzerbino","id":33239,"avatar_url":"https://avatars.githubusercontent.com/u/33239?v=3","gravatar_id":"","url":"https://api.github.com/users/dzerbino","html_url":"https://github.com/dzerbino","followers_url":"https://api.github.com/users/dzerbino/followers","following_url":"https://api.github.com/users/dzerbino/following{/other_user}","gists_url":"https://api.github.com/users/dzerbino/gists{/gist_id}","starred_url":"https://api.github.com/users/dzerbino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dzerbino/subscriptions","organizations_url":"https://api.github.com/users/dzerbino/orgs","repos_url":"https://api.github.com/users/dzerbino/repos","events_url":"https://api.github.com/users/dzerbino/events{/privacy}","received_events_url":"https://api.github.com/users/dzerbino/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-11-14T17:39:20Z","updated_at":"2016-11-21T21:01:07Z","closed_at":"2016-11-21T21:01:07Z","body":"Hello,\r\n\r\nI have developed a library to compute whole genome statistics from multiple BigWig files [WiggleTools](https://github.com/Ensembl/WiggleTools). To do this, it needs to be efficient with memory, and therefore uses iterators intensively. \r\n\r\nWiggleTools uses the Kent source tree, but this entails quite a few dependencies that I would like to get rid of. I would be very keen to switch to libBigWig. \r\n\r\nWould it be possible to create iterator functions within libBigWig?\r\n\r\nTypically, an iterator could be created either as a whole genome iterator, or over a region of interest. \r\n\r\nInstead of returning all results in a single bwOverlappingIntervals_t struct, it could return a sequence of bwOverlappingIntervals_t structs, each object covering a number of consecutive compressed blocks on disk. FWIW, my code currently looks like (using Kent functions):\r\n\r\n```\r\n\tstruct fileOffsetSize *blockList, *block, *beforeGap, *afterGap;\r\n\r\n       // Search for linked list of blocks overlapping region of interest \r\n       blockList = bbiOverlappingBlocks(file_handle, search_tree, chrom, start, finish, NULL);\r\n\r\n\tfor (block = blockList; block; block=afterGap) {\r\n\t\t/* Read contiguous blocks into mergedBuf. */\r\n\t\tfileOffsetSizeFindGap(block, &beforeGap, &afterGap);\r\n\r\n\t\t// Little hack to limit the number of blocks read at any time\r\n\t\tstruct fileOffsetSize * blockPtr, * prevBlock;\r\n\t\tint blockCounter = 0;\r\n\t\tprevBlock = block;\r\n\r\n                // Count max blocks or until you hit a gap in the disk\r\n\t\tfor (blockPtr = block; blockPtr != afterGap && blockCounter < MAX_BLOCKS; blockPtr = blockPtr->next) {\r\n\t\t\tblockCounter++;\r\n\t\t\tprevBlock = blockPtr;\r\n\t\t}\r\n\r\n                // If you stopped before the gap, pretend you hit a gap\r\n\t\tif (blockCounter == MAX_BLOCKS) {\r\n\t\t\tbeforeGap = prevBlock;\r\n\t\t\tafterGap = blockPtr;\r\n\t\t}\r\n\r\n\t\tbits64 mergedSize = beforeGap->offset + beforeGap->size - block->offset;\r\n\r\n\t\tif (downloadBlockRun(data, chrom, block, afterGap, mergedSize)) {\r\n\t\t\tslFreeList(blockList);\r\n\t\t\treturn true;\r\n\t\t}\r\n\t}\r\n```\r\n\r\nThanks in advance for considering my request,\r\n\r\nDaniel"}}
{"actor":{"display_login":"dpryan79"}}