{"action":"created","comment":{"url":"https://api.github.com/repos/PacificBiosciences/FALCON/pulls/comments/68173388","id":68173388,"diff_hunk":"@@ -0,0 +1,167 @@\n+from __future__ import print_function\n+from falcon_kit.multiproc import Pool\n+import falcon_kit.util.io as io\n+import argparse\n+import sys\n+import glob\n+import os\n+from heapq import heappush, heappop, heappushpop\n+\n+Reader = io.CapturedProcessReaderContext\n+\n+\n+def get_rid_to_ctg(fn):\n+    rid_to_ctg = {}\n+    with open(fn) as f:\n+        for row in f:\n+            row = row.strip().split()\n+            pid, rid, oid, ctg = row\n+            rid_to_ctg.setdefault( rid, set()  )\n+            rid_to_ctg[ rid ].add(ctg)\n+    return rid_to_ctg\n+\n+def run_tr_stage1(db_fn, fn, min_len, bestn, rid_to_ctg):\n+    cmd = \"LA4Falcon -m %s %s\" % (db_fn, fn)\n+    reader = Reader(cmd)\n+    with reader:\n+        return fn, tr_stage1(reader.readlines, min_len, bestn, rid_to_ctg)\n+\n+def tr_stage1(readlines, min_len, bestn, rid_to_ctg):\n+    \"\"\"\n+    for each read in the b-read column inside the LAS files, we\n+    keep top `bestn` hits with a priority queue through all overlaps\n+    \"\"\"\n+    rtn = {}\n+    for l in readlines():\n+        l = l.strip().split()\n+        q_id, t_id = l[:2]\n+        overlap_len = -int(l[2])\n+        idt = float(l[3])\n+        q_s, q_e, q_l = int(l[5]), int(l[6]), int(l[7])\n+        t_s, t_e, t_l = int(l[9]), int(l[10]), int(l[11])\n+        if t_l < min_len:\n+            continue\n+        if q_id not in rid_to_ctg:\n+            continue\n+        rtn.setdefault(t_id, [])\n+        if len(rtn[t_id]) < bestn:\n+            heappush(rtn[t_id], (overlap_len, q_id) )\n+        else:\n+            heappushpop(rtn[t_id], (overlap_len, q_id) )\n+\n+    return rtn\n+\n+def run_track_reads(exe_pool, base_dir, file_list, min_len, bestn, db_fn):\n+    io.LOG('preparing tr_stage1')\n+    io.logstats()\n+    asm_dir = os.path.abspath( os.path.join(base_dir, \"2-asm-falcon\") )\n+    rid_to_ctg = get_rid_to_ctg( os.path.join(asm_dir, \"read_maps/read_to_contig_map\" ) )\n+    inputs = []\n+    for fn in file_list:\n+        if len(fn) != 0:","path":"falcon_kit/mains/rr_ctg_track.py","position":61,"original_position":61,"commit_id":"bb95376c5091e619173b6a88aa43d1c75db1926d","original_commit_id":"bb95376c5091e619173b6a88aa43d1c75db1926d","user":{"login":"pb-cdunn","id":12086299,"avatar_url":"https://avatars.githubusercontent.com/u/12086299?v=3","gravatar_id":"","url":"https://api.github.com/users/pb-cdunn","html_url":"https://github.com/pb-cdunn","followers_url":"https://api.github.com/users/pb-cdunn/followers","following_url":"https://api.github.com/users/pb-cdunn/following{/other_user}","gists_url":"https://api.github.com/users/pb-cdunn/gists{/gist_id}","starred_url":"https://api.github.com/users/pb-cdunn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pb-cdunn/subscriptions","organizations_url":"https://api.github.com/users/pb-cdunn/orgs","repos_url":"https://api.github.com/users/pb-cdunn/repos","events_url":"https://api.github.com/users/pb-cdunn/events{/privacy}","received_events_url":"https://api.github.com/users/pb-cdunn/received_events","type":"User","site_admin":false},"body":"Drop this `if`. Never happens, and it should be a pre-condition anyway.","created_at":"2016-06-23T04:13:22Z","updated_at":"2016-06-23T04:13:22Z","html_url":"https://github.com/PacificBiosciences/FALCON/pull/396#discussion_r68173388","pull_request_url":"https://api.github.com/repos/PacificBiosciences/FALCON/pulls/396","_links":{"self":{"href":"https://api.github.com/repos/PacificBiosciences/FALCON/pulls/comments/68173388"},"html":{"href":"https://github.com/PacificBiosciences/FALCON/pull/396#discussion_r68173388"},"pull_request":{"href":"https://api.github.com/repos/PacificBiosciences/FALCON/pulls/396"}}},"pull_request":{"url":"https://api.github.com/repos/PacificBiosciences/FALCON/pulls/396","id":74887943,"html_url":"https://github.com/PacificBiosciences/FALCON/pull/396","diff_url":"https://github.com/PacificBiosciences/FALCON/pull/396.diff","patch_url":"https://github.com/PacificBiosciences/FALCON/pull/396.patch","issue_url":"https://api.github.com/repos/PacificBiosciences/FALCON/issues/396","number":396,"state":"open","locked":false,"title":"Read tracker","user":{"login":"pb-jchin","id":1071734,"avatar_url":"https://avatars.githubusercontent.com/u/1071734?v=3","gravatar_id":"","url":"https://api.github.com/users/pb-jchin","html_url":"https://github.com/pb-jchin","followers_url":"https://api.github.com/users/pb-jchin/followers","following_url":"https://api.github.com/users/pb-jchin/following{/other_user}","gists_url":"https://api.github.com/users/pb-jchin/gists{/gist_id}","starred_url":"https://api.github.com/users/pb-jchin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pb-jchin/subscriptions","organizations_url":"https://api.github.com/users/pb-jchin/orgs","repos_url":"https://api.github.com/users/pb-jchin/repos","events_url":"https://api.github.com/users/pb-jchin/events{/privacy}","received_events_url":"https://api.github.com/users/pb-jchin/received_events","type":"User","site_admin":false},"body":"Utilities for tracking reads to contigs. These are current utility commands that can be run after whole assembly is done. It will be used for FALCON-Unzip to group the reads of each contig for constructing haplotype phasing blocks. The corresponding code in FALCON-Unzip will be removed.","created_at":"2016-06-23T02:39:51Z","updated_at":"2016-06-23T04:13:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0d195a6f7f54f8aad03ff9f91c3fdd5fb0c258b9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/PacificBiosciences/FALCON/pulls/396/commits","review_comments_url":"https://api.github.com/repos/PacificBiosciences/FALCON/pulls/396/comments","review_comment_url":"https://api.github.com/repos/PacificBiosciences/FALCON/pulls/comments{/number}","comments_url":"https://api.github.com/repos/PacificBiosciences/FALCON/issues/396/comments","statuses_url":"https://api.github.com/repos/PacificBiosciences/FALCON/statuses/bb95376c5091e619173b6a88aa43d1c75db1926d","head":{"label":"PacificBiosciences:read_tracker","ref":"read_tracker","sha":"bb95376c5091e619173b6a88aa43d1c75db1926d","user":{"login":"PacificBiosciences","id":999745,"avatar_url":"https://avatars.githubusercontent.com/u/999745?v=3","gravatar_id":"","url":"https://api.github.com/users/PacificBiosciences","html_url":"https://github.com/PacificBiosciences","followers_url":"https://api.github.com/users/PacificBiosciences/followers","following_url":"https://api.github.com/users/PacificBiosciences/following{/other_user}","gists_url":"https://api.github.com/users/PacificBiosciences/gists{/gist_id}","starred_url":"https://api.github.com/users/PacificBiosciences/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PacificBiosciences/subscriptions","organizations_url":"https://api.github.com/users/PacificBiosciences/orgs","repos_url":"https://api.github.com/users/PacificBiosciences/repos","events_url":"https://api.github.com/users/PacificBiosciences/events{/privacy}","received_events_url":"https://api.github.com/users/PacificBiosciences/received_events","type":"Organization","site_admin":false},"repo":{"id":15717188,"name":"FALCON","full_name":"PacificBiosciences/FALCON","owner":{"login":"PacificBiosciences","id":999745,"avatar_url":"https://avatars.githubusercontent.com/u/999745?v=3","gravatar_id":"","url":"https://api.github.com/users/PacificBiosciences","html_url":"https://github.com/PacificBiosciences","followers_url":"https://api.github.com/users/PacificBiosciences/followers","following_url":"https://api.github.com/users/PacificBiosciences/following{/other_user}","gists_url":"https://api.github.com/users/PacificBiosciences/gists{/gist_id}","starred_url":"https://api.github.com/users/PacificBiosciences/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PacificBiosciences/subscriptions","organizations_url":"https://api.github.com/users/PacificBiosciences/orgs","repos_url":"https://api.github.com/users/PacificBiosciences/repos","events_url":"https://api.github.com/users/PacificBiosciences/events{/privacy}","received_events_url":"https://api.github.com/users/PacificBiosciences/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PacificBiosciences/FALCON","description":"FALCON: experimental PacBio diploid assembler","fork":false,"url":"https://api.github.com/repos/PacificBiosciences/FALCON","forks_url":"https://api.github.com/repos/PacificBiosciences/FALCON/forks","keys_url":"https://api.github.com/repos/PacificBiosciences/FALCON/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PacificBiosciences/FALCON/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PacificBiosciences/FALCON/teams","hooks_url":"https://api.github.com/repos/PacificBiosciences/FALCON/hooks","issue_events_url":"https://api.github.com/repos/PacificBiosciences/FALCON/issues/events{/number}","events_url":"https://api.github.com/repos/PacificBiosciences/FALCON/events","assignees_url":"https://api.github.com/repos/PacificBiosciences/FALCON/assignees{/user}","branches_url":"https://api.github.com/repos/PacificBiosciences/FALCON/branches{/branch}","tags_url":"https://api.github.com/repos/PacificBiosciences/FALCON/tags","blobs_url":"https://api.github.com/repos/PacificBiosciences/FALCON/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PacificBiosciences/FALCON/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PacificBiosciences/FALCON/git/refs{/sha}","trees_url":"https://api.github.com/repos/PacificBiosciences/FALCON/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PacificBiosciences/FALCON/statuses/{sha}","languages_url":"https://api.github.com/repos/PacificBiosciences/FALCON/languages","stargazers_url":"https://api.github.com/repos/PacificBiosciences/FALCON/stargazers","contributors_url":"https://api.github.com/repos/PacificBiosciences/FALCON/contributors","subscribers_url":"https://api.github.com/repos/PacificBiosciences/FALCON/subscribers","subscription_url":"https://api.github.com/repos/PacificBiosciences/FALCON/subscription","commits_url":"https://api.github.com/repos/PacificBiosciences/FALCON/commits{/sha}","git_commits_url":"https://api.github.com/repos/PacificBiosciences/FALCON/git/commits{/sha}","comments_url":"https://api.github.com/repos/PacificBiosciences/FALCON/comments{/number}","issue_comment_url":"https://api.github.com/repos/PacificBiosciences/FALCON/issues/comments{/number}","contents_url":"https://api.github.com/repos/PacificBiosciences/FALCON/contents/{+path}","compare_url":"https://api.github.com/repos/PacificBiosciences/FALCON/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PacificBiosciences/FALCON/merges","archive_url":"https://api.github.com/repos/PacificBiosciences/FALCON/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PacificBiosciences/FALCON/downloads","issues_url":"https://api.github.com/repos/PacificBiosciences/FALCON/issues{/number}","pulls_url":"https://api.github.com/repos/PacificBiosciences/FALCON/pulls{/number}","milestones_url":"https://api.github.com/repos/PacificBiosciences/FALCON/milestones{/number}","notifications_url":"https://api.github.com/repos/PacificBiosciences/FALCON/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PacificBiosciences/FALCON/labels{/name}","releases_url":"https://api.github.com/repos/PacificBiosciences/FALCON/releases{/id}","deployments_url":"https://api.github.com/repos/PacificBiosciences/FALCON/deployments","created_at":"2014-01-07T21:26:12Z","updated_at":"2016-06-19T04:53:35Z","pushed_at":"2016-06-23T02:39:51Z","git_url":"git://github.com/PacificBiosciences/FALCON.git","ssh_url":"git@github.com:PacificBiosciences/FALCON.git","clone_url":"https://github.com/PacificBiosciences/FALCON.git","svn_url":"https://github.com/PacificBiosciences/FALCON","homepage":"","size":1444,"stargazers_count":70,"watchers_count":70,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":51,"mirror_url":null,"open_issues_count":67,"forks":51,"open_issues":67,"watchers":70,"default_branch":"master"}},"base":{"label":"PacificBiosciences:master","ref":"master","sha":"35d3d5b0706edf64577d35aed381988fb15623d9","user":{"login":"PacificBiosciences","id":999745,"avatar_url":"https://avatars.githubusercontent.com/u/999745?v=3","gravatar_id":"","url":"https://api.github.com/users/PacificBiosciences","html_url":"https://github.com/PacificBiosciences","followers_url":"https://api.github.com/users/PacificBiosciences/followers","following_url":"https://api.github.com/users/PacificBiosciences/following{/other_user}","gists_url":"https://api.github.com/users/PacificBiosciences/gists{/gist_id}","starred_url":"https://api.github.com/users/PacificBiosciences/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PacificBiosciences/subscriptions","organizations_url":"https://api.github.com/users/PacificBiosciences/orgs","repos_url":"https://api.github.com/users/PacificBiosciences/repos","events_url":"https://api.github.com/users/PacificBiosciences/events{/privacy}","received_events_url":"https://api.github.com/users/PacificBiosciences/received_events","type":"Organization","site_admin":false},"repo":{"id":15717188,"name":"FALCON","full_name":"PacificBiosciences/FALCON","owner":{"login":"PacificBiosciences","id":999745,"avatar_url":"https://avatars.githubusercontent.com/u/999745?v=3","gravatar_id":"","url":"https://api.github.com/users/PacificBiosciences","html_url":"https://github.com/PacificBiosciences","followers_url":"https://api.github.com/users/PacificBiosciences/followers","following_url":"https://api.github.com/users/PacificBiosciences/following{/other_user}","gists_url":"https://api.github.com/users/PacificBiosciences/gists{/gist_id}","starred_url":"https://api.github.com/users/PacificBiosciences/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PacificBiosciences/subscriptions","organizations_url":"https://api.github.com/users/PacificBiosciences/orgs","repos_url":"https://api.github.com/users/PacificBiosciences/repos","events_url":"https://api.github.com/users/PacificBiosciences/events{/privacy}","received_events_url":"https://api.github.com/users/PacificBiosciences/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PacificBiosciences/FALCON","description":"FALCON: experimental PacBio diploid assembler","fork":false,"url":"https://api.github.com/repos/PacificBiosciences/FALCON","forks_url":"https://api.github.com/repos/PacificBiosciences/FALCON/forks","keys_url":"https://api.github.com/repos/PacificBiosciences/FALCON/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PacificBiosciences/FALCON/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PacificBiosciences/FALCON/teams","hooks_url":"https://api.github.com/repos/PacificBiosciences/FALCON/hooks","issue_events_url":"https://api.github.com/repos/PacificBiosciences/FALCON/issues/events{/number}","events_url":"https://api.github.com/repos/PacificBiosciences/FALCON/events","assignees_url":"https://api.github.com/repos/PacificBiosciences/FALCON/assignees{/user}","branches_url":"https://api.github.com/repos/PacificBiosciences/FALCON/branches{/branch}","tags_url":"https://api.github.com/repos/PacificBiosciences/FALCON/tags","blobs_url":"https://api.github.com/repos/PacificBiosciences/FALCON/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PacificBiosciences/FALCON/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PacificBiosciences/FALCON/git/refs{/sha}","trees_url":"https://api.github.com/repos/PacificBiosciences/FALCON/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PacificBiosciences/FALCON/statuses/{sha}","languages_url":"https://api.github.com/repos/PacificBiosciences/FALCON/languages","stargazers_url":"https://api.github.com/repos/PacificBiosciences/FALCON/stargazers","contributors_url":"https://api.github.com/repos/PacificBiosciences/FALCON/contributors","subscribers_url":"https://api.github.com/repos/PacificBiosciences/FALCON/subscribers","subscription_url":"https://api.github.com/repos/PacificBiosciences/FALCON/subscription","commits_url":"https://api.github.com/repos/PacificBiosciences/FALCON/commits{/sha}","git_commits_url":"https://api.github.com/repos/PacificBiosciences/FALCON/git/commits{/sha}","comments_url":"https://api.github.com/repos/PacificBiosciences/FALCON/comments{/number}","issue_comment_url":"https://api.github.com/repos/PacificBiosciences/FALCON/issues/comments{/number}","contents_url":"https://api.github.com/repos/PacificBiosciences/FALCON/contents/{+path}","compare_url":"https://api.github.com/repos/PacificBiosciences/FALCON/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PacificBiosciences/FALCON/merges","archive_url":"https://api.github.com/repos/PacificBiosciences/FALCON/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PacificBiosciences/FALCON/downloads","issues_url":"https://api.github.com/repos/PacificBiosciences/FALCON/issues{/number}","pulls_url":"https://api.github.com/repos/PacificBiosciences/FALCON/pulls{/number}","milestones_url":"https://api.github.com/repos/PacificBiosciences/FALCON/milestones{/number}","notifications_url":"https://api.github.com/repos/PacificBiosciences/FALCON/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PacificBiosciences/FALCON/labels{/name}","releases_url":"https://api.github.com/repos/PacificBiosciences/FALCON/releases{/id}","deployments_url":"https://api.github.com/repos/PacificBiosciences/FALCON/deployments","created_at":"2014-01-07T21:26:12Z","updated_at":"2016-06-19T04:53:35Z","pushed_at":"2016-06-23T02:39:51Z","git_url":"git://github.com/PacificBiosciences/FALCON.git","ssh_url":"git@github.com:PacificBiosciences/FALCON.git","clone_url":"https://github.com/PacificBiosciences/FALCON.git","svn_url":"https://github.com/PacificBiosciences/FALCON","homepage":"","size":1444,"stargazers_count":70,"watchers_count":70,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":51,"mirror_url":null,"open_issues_count":67,"forks":51,"open_issues":67,"watchers":70,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/PacificBiosciences/FALCON/pulls/396"},"html":{"href":"https://github.com/PacificBiosciences/FALCON/pull/396"},"issue":{"href":"https://api.github.com/repos/PacificBiosciences/FALCON/issues/396"},"comments":{"href":"https://api.github.com/repos/PacificBiosciences/FALCON/issues/396/comments"},"review_comments":{"href":"https://api.github.com/repos/PacificBiosciences/FALCON/pulls/396/comments"},"review_comment":{"href":"https://api.github.com/repos/PacificBiosciences/FALCON/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/PacificBiosciences/FALCON/pulls/396/commits"},"statuses":{"href":"https://api.github.com/repos/PacificBiosciences/FALCON/statuses/bb95376c5091e619173b6a88aa43d1c75db1926d"}}}}
{"actor":{"display_login":"pb-cdunn"}}