{"action":"created","comment":{"url":"https://api.github.com/repos/broadinstitute/picard/pulls/comments/61991030","id":61991030,"diff_hunk":"@@ -0,0 +1,82 @@\n+package picard.sam.revertsam;\n+\n+import htsjdk.samtools.SAMFileHeader;\n+import htsjdk.samtools.SAMReadGroupRecord;\n+import picard.PicardException;\n+import picard.util.TabbedTextFileWithHeaderParser;\n+\n+import java.io.File;\n+import java.nio.file.Files;\n+import java.nio.file.Path;\n+import java.nio.file.Paths;\n+import java.util.HashMap;\n+import java.util.List;\n+import java.util.Map;\n+\n+/**\n+ * Represents the mapping from each read group id to the corresponding output file\n+ * that RevertSam is expected to write to.\n+ */\n+public class OutputMap {\n+    final Map<String, File> idToOutput = new HashMap<String, File>();\n+\n+    OutputMap(final File outputMapFile) {","path":"src/java/picard/sam/revertsam/OutputMap.java","position":23,"original_position":23,"commit_id":"99dbe60dd4f272e090c94f29ac77624d70dc50bc","original_commit_id":"99dbe60dd4f272e090c94f29ac77624d70dc50bc","user":{"login":"nh13","id":846274,"avatar_url":"https://avatars.githubusercontent.com/u/846274?v=3","gravatar_id":"","url":"https://api.github.com/users/nh13","html_url":"https://github.com/nh13","followers_url":"https://api.github.com/users/nh13/followers","following_url":"https://api.github.com/users/nh13/following{/other_user}","gists_url":"https://api.github.com/users/nh13/gists{/gist_id}","starred_url":"https://api.github.com/users/nh13/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nh13/subscriptions","organizations_url":"https://api.github.com/users/nh13/orgs","repos_url":"https://api.github.com/users/nh13/repos","events_url":"https://api.github.com/users/nh13/events{/privacy}","received_events_url":"https://api.github.com/users/nh13/received_events","type":"User","site_admin":false},"body":"Why not simplify and have two methods that return a `Map<String,File>` that stores for each read group id the corresponding paths?","created_at":"2016-05-04T05:15:50Z","updated_at":"2016-05-04T05:15:50Z","html_url":"https://github.com/broadinstitute/picard/pull/531#discussion_r61991030","pull_request_url":"https://api.github.com/repos/broadinstitute/picard/pulls/531","_links":{"self":{"href":"https://api.github.com/repos/broadinstitute/picard/pulls/comments/61991030"},"html":{"href":"https://github.com/broadinstitute/picard/pull/531#discussion_r61991030"},"pull_request":{"href":"https://api.github.com/repos/broadinstitute/picard/pulls/531"}}},"pull_request":{"url":"https://api.github.com/repos/broadinstitute/picard/pulls/531","id":68780514,"html_url":"https://github.com/broadinstitute/picard/pull/531","diff_url":"https://github.com/broadinstitute/picard/pull/531.diff","patch_url":"https://github.com/broadinstitute/picard/pull/531.patch","issue_url":"https://api.github.com/repos/broadinstitute/picard/issues/531","number":531,"state":"open","locked":false,"title":"Allow RevertSam to output by read group","user":{"login":"dshiga","id":773882,"avatar_url":"https://avatars.githubusercontent.com/u/773882?v=3","gravatar_id":"","url":"https://api.github.com/users/dshiga","html_url":"https://github.com/dshiga","followers_url":"https://api.github.com/users/dshiga/followers","following_url":"https://api.github.com/users/dshiga/following{/other_user}","gists_url":"https://api.github.com/users/dshiga/gists{/gist_id}","starred_url":"https://api.github.com/users/dshiga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dshiga/subscriptions","organizations_url":"https://api.github.com/users/dshiga/orgs","repos_url":"https://api.github.com/users/dshiga/repos","events_url":"https://api.github.com/users/dshiga/events{/privacy}","received_events_url":"https://api.github.com/users/dshiga/received_events","type":"User","site_admin":false},"body":"### Summary of changes\r\n\r\nRevertSam's default behavior is unchanged, but you can now optionally output by read group. When run with OUTPUT_BY_READGROUP=true, multiple output bams will be created, each containing the reads for a single read group.\r\n\r\n### Usage details\r\n\r\nWhen outputting by read group, the user must provide either OUTPUT -- which must be a directory where the output files will be written (with default names of the form [read_group_id].bam) -- or OUTPUT_MAP, which is a two-column tab-separated file providing the output paths for each read group id.\r\n\r\n### Implementation\r\n\r\nWhen outputting by read group, we make a collection of writers -- one per read group -- and send each read to the appropriate writer. There is a new smart writer class that takes care of this, called PerReadGroupWriter. It wraps a collection of writers and sends each read to the correct writer, based on the read's read group.\r\n\r\nThere is also a new smart sorter that handles sorting when outputting by read group, called PerReadGroupSorter. The smart sorter wraps a bunch of SortingCollections and sends each read to the appropriate SortingCollection based on its read group.\r\n\r\nAfter constructing the smart or regular writer, RevertSam doesn't need to know which one it's using, since it calls the addAlignment method in either case, and the writer takes care of the details. The same is true for the smart vs regular sorter -- RevertSam calls add in either case, so it doesn't need to know which one it's using. This agnosticism is facilitated by a couple of new interfaces called RevertSamWriter and RevertSamSorter.\r\n\r\nSome chunks of code that look like they've been deleted from RevertSam have really been moved to RevertSamUtil and ValidationUtil.","created_at":"2016-05-03T21:45:28Z","updated_at":"2016-05-04T05:15:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7111db088c20495f67672d2bde282f5d63cfbbe8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/broadinstitute/picard/pulls/531/commits","review_comments_url":"https://api.github.com/repos/broadinstitute/picard/pulls/531/comments","review_comment_url":"https://api.github.com/repos/broadinstitute/picard/pulls/comments{/number}","comments_url":"https://api.github.com/repos/broadinstitute/picard/issues/531/comments","statuses_url":"https://api.github.com/repos/broadinstitute/picard/statuses/99dbe60dd4f272e090c94f29ac77624d70dc50bc","head":{"label":"broadinstitute:ds_revertsam_per_read_group","ref":"ds_revertsam_per_read_group","sha":"99dbe60dd4f272e090c94f29ac77624d70dc50bc","user":{"login":"broadinstitute","id":393552,"avatar_url":"https://avatars.githubusercontent.com/u/393552?v=3","gravatar_id":"","url":"https://api.github.com/users/broadinstitute","html_url":"https://github.com/broadinstitute","followers_url":"https://api.github.com/users/broadinstitute/followers","following_url":"https://api.github.com/users/broadinstitute/following{/other_user}","gists_url":"https://api.github.com/users/broadinstitute/gists{/gist_id}","starred_url":"https://api.github.com/users/broadinstitute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broadinstitute/subscriptions","organizations_url":"https://api.github.com/users/broadinstitute/orgs","repos_url":"https://api.github.com/users/broadinstitute/repos","events_url":"https://api.github.com/users/broadinstitute/events{/privacy}","received_events_url":"https://api.github.com/users/broadinstitute/received_events","type":"Organization","site_admin":false},"repo":{"id":18225913,"name":"picard","full_name":"broadinstitute/picard","owner":{"login":"broadinstitute","id":393552,"avatar_url":"https://avatars.githubusercontent.com/u/393552?v=3","gravatar_id":"","url":"https://api.github.com/users/broadinstitute","html_url":"https://github.com/broadinstitute","followers_url":"https://api.github.com/users/broadinstitute/followers","following_url":"https://api.github.com/users/broadinstitute/following{/other_user}","gists_url":"https://api.github.com/users/broadinstitute/gists{/gist_id}","starred_url":"https://api.github.com/users/broadinstitute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broadinstitute/subscriptions","organizations_url":"https://api.github.com/users/broadinstitute/orgs","repos_url":"https://api.github.com/users/broadinstitute/repos","events_url":"https://api.github.com/users/broadinstitute/events{/privacy}","received_events_url":"https://api.github.com/users/broadinstitute/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/broadinstitute/picard","description":"A set of command line tools (in Java) for manipulating high-throughput sequencing (HTS) data and formats such as SAM/BAM/CRAM and VCF.","fork":false,"url":"https://api.github.com/repos/broadinstitute/picard","forks_url":"https://api.github.com/repos/broadinstitute/picard/forks","keys_url":"https://api.github.com/repos/broadinstitute/picard/keys{/key_id}","collaborators_url":"https://api.github.com/repos/broadinstitute/picard/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/broadinstitute/picard/teams","hooks_url":"https://api.github.com/repos/broadinstitute/picard/hooks","issue_events_url":"https://api.github.com/repos/broadinstitute/picard/issues/events{/number}","events_url":"https://api.github.com/repos/broadinstitute/picard/events","assignees_url":"https://api.github.com/repos/broadinstitute/picard/assignees{/user}","branches_url":"https://api.github.com/repos/broadinstitute/picard/branches{/branch}","tags_url":"https://api.github.com/repos/broadinstitute/picard/tags","blobs_url":"https://api.github.com/repos/broadinstitute/picard/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/broadinstitute/picard/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/broadinstitute/picard/git/refs{/sha}","trees_url":"https://api.github.com/repos/broadinstitute/picard/git/trees{/sha}","statuses_url":"https://api.github.com/repos/broadinstitute/picard/statuses/{sha}","languages_url":"https://api.github.com/repos/broadinstitute/picard/languages","stargazers_url":"https://api.github.com/repos/broadinstitute/picard/stargazers","contributors_url":"https://api.github.com/repos/broadinstitute/picard/contributors","subscribers_url":"https://api.github.com/repos/broadinstitute/picard/subscribers","subscription_url":"https://api.github.com/repos/broadinstitute/picard/subscription","commits_url":"https://api.github.com/repos/broadinstitute/picard/commits{/sha}","git_commits_url":"https://api.github.com/repos/broadinstitute/picard/git/commits{/sha}","comments_url":"https://api.github.com/repos/broadinstitute/picard/comments{/number}","issue_comment_url":"https://api.github.com/repos/broadinstitute/picard/issues/comments{/number}","contents_url":"https://api.github.com/repos/broadinstitute/picard/contents/{+path}","compare_url":"https://api.github.com/repos/broadinstitute/picard/compare/{base}...{head}","merges_url":"https://api.github.com/repos/broadinstitute/picard/merges","archive_url":"https://api.github.com/repos/broadinstitute/picard/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/broadinstitute/picard/downloads","issues_url":"https://api.github.com/repos/broadinstitute/picard/issues{/number}","pulls_url":"https://api.github.com/repos/broadinstitute/picard/pulls{/number}","milestones_url":"https://api.github.com/repos/broadinstitute/picard/milestones{/number}","notifications_url":"https://api.github.com/repos/broadinstitute/picard/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/broadinstitute/picard/labels{/name}","releases_url":"https://api.github.com/repos/broadinstitute/picard/releases{/id}","deployments_url":"https://api.github.com/repos/broadinstitute/picard/deployments","created_at":"2014-03-28T20:43:35Z","updated_at":"2016-04-26T04:51:37Z","pushed_at":"2016-05-03T21:51:05Z","git_url":"git://github.com/broadinstitute/picard.git","ssh_url":"git@github.com:broadinstitute/picard.git","clone_url":"https://github.com/broadinstitute/picard.git","svn_url":"https://github.com/broadinstitute/picard","homepage":"http://broadinstitute.github.io/picard/","size":59700,"stargazers_count":167,"watchers_count":167,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":115,"mirror_url":null,"open_issues_count":78,"forks":115,"open_issues":78,"watchers":167,"default_branch":"master"}},"base":{"label":"broadinstitute:master","ref":"master","sha":"d99df451d39a2f207bf23638a7054cd975605c2d","user":{"login":"broadinstitute","id":393552,"avatar_url":"https://avatars.githubusercontent.com/u/393552?v=3","gravatar_id":"","url":"https://api.github.com/users/broadinstitute","html_url":"https://github.com/broadinstitute","followers_url":"https://api.github.com/users/broadinstitute/followers","following_url":"https://api.github.com/users/broadinstitute/following{/other_user}","gists_url":"https://api.github.com/users/broadinstitute/gists{/gist_id}","starred_url":"https://api.github.com/users/broadinstitute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broadinstitute/subscriptions","organizations_url":"https://api.github.com/users/broadinstitute/orgs","repos_url":"https://api.github.com/users/broadinstitute/repos","events_url":"https://api.github.com/users/broadinstitute/events{/privacy}","received_events_url":"https://api.github.com/users/broadinstitute/received_events","type":"Organization","site_admin":false},"repo":{"id":18225913,"name":"picard","full_name":"broadinstitute/picard","owner":{"login":"broadinstitute","id":393552,"avatar_url":"https://avatars.githubusercontent.com/u/393552?v=3","gravatar_id":"","url":"https://api.github.com/users/broadinstitute","html_url":"https://github.com/broadinstitute","followers_url":"https://api.github.com/users/broadinstitute/followers","following_url":"https://api.github.com/users/broadinstitute/following{/other_user}","gists_url":"https://api.github.com/users/broadinstitute/gists{/gist_id}","starred_url":"https://api.github.com/users/broadinstitute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broadinstitute/subscriptions","organizations_url":"https://api.github.com/users/broadinstitute/orgs","repos_url":"https://api.github.com/users/broadinstitute/repos","events_url":"https://api.github.com/users/broadinstitute/events{/privacy}","received_events_url":"https://api.github.com/users/broadinstitute/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/broadinstitute/picard","description":"A set of command line tools (in Java) for manipulating high-throughput sequencing (HTS) data and formats such as SAM/BAM/CRAM and VCF.","fork":false,"url":"https://api.github.com/repos/broadinstitute/picard","forks_url":"https://api.github.com/repos/broadinstitute/picard/forks","keys_url":"https://api.github.com/repos/broadinstitute/picard/keys{/key_id}","collaborators_url":"https://api.github.com/repos/broadinstitute/picard/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/broadinstitute/picard/teams","hooks_url":"https://api.github.com/repos/broadinstitute/picard/hooks","issue_events_url":"https://api.github.com/repos/broadinstitute/picard/issues/events{/number}","events_url":"https://api.github.com/repos/broadinstitute/picard/events","assignees_url":"https://api.github.com/repos/broadinstitute/picard/assignees{/user}","branches_url":"https://api.github.com/repos/broadinstitute/picard/branches{/branch}","tags_url":"https://api.github.com/repos/broadinstitute/picard/tags","blobs_url":"https://api.github.com/repos/broadinstitute/picard/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/broadinstitute/picard/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/broadinstitute/picard/git/refs{/sha}","trees_url":"https://api.github.com/repos/broadinstitute/picard/git/trees{/sha}","statuses_url":"https://api.github.com/repos/broadinstitute/picard/statuses/{sha}","languages_url":"https://api.github.com/repos/broadinstitute/picard/languages","stargazers_url":"https://api.github.com/repos/broadinstitute/picard/stargazers","contributors_url":"https://api.github.com/repos/broadinstitute/picard/contributors","subscribers_url":"https://api.github.com/repos/broadinstitute/picard/subscribers","subscription_url":"https://api.github.com/repos/broadinstitute/picard/subscription","commits_url":"https://api.github.com/repos/broadinstitute/picard/commits{/sha}","git_commits_url":"https://api.github.com/repos/broadinstitute/picard/git/commits{/sha}","comments_url":"https://api.github.com/repos/broadinstitute/picard/comments{/number}","issue_comment_url":"https://api.github.com/repos/broadinstitute/picard/issues/comments{/number}","contents_url":"https://api.github.com/repos/broadinstitute/picard/contents/{+path}","compare_url":"https://api.github.com/repos/broadinstitute/picard/compare/{base}...{head}","merges_url":"https://api.github.com/repos/broadinstitute/picard/merges","archive_url":"https://api.github.com/repos/broadinstitute/picard/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/broadinstitute/picard/downloads","issues_url":"https://api.github.com/repos/broadinstitute/picard/issues{/number}","pulls_url":"https://api.github.com/repos/broadinstitute/picard/pulls{/number}","milestones_url":"https://api.github.com/repos/broadinstitute/picard/milestones{/number}","notifications_url":"https://api.github.com/repos/broadinstitute/picard/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/broadinstitute/picard/labels{/name}","releases_url":"https://api.github.com/repos/broadinstitute/picard/releases{/id}","deployments_url":"https://api.github.com/repos/broadinstitute/picard/deployments","created_at":"2014-03-28T20:43:35Z","updated_at":"2016-04-26T04:51:37Z","pushed_at":"2016-05-03T21:51:05Z","git_url":"git://github.com/broadinstitute/picard.git","ssh_url":"git@github.com:broadinstitute/picard.git","clone_url":"https://github.com/broadinstitute/picard.git","svn_url":"https://github.com/broadinstitute/picard","homepage":"http://broadinstitute.github.io/picard/","size":59700,"stargazers_count":167,"watchers_count":167,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":115,"mirror_url":null,"open_issues_count":78,"forks":115,"open_issues":78,"watchers":167,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/broadinstitute/picard/pulls/531"},"html":{"href":"https://github.com/broadinstitute/picard/pull/531"},"issue":{"href":"https://api.github.com/repos/broadinstitute/picard/issues/531"},"comments":{"href":"https://api.github.com/repos/broadinstitute/picard/issues/531/comments"},"review_comments":{"href":"https://api.github.com/repos/broadinstitute/picard/pulls/531/comments"},"review_comment":{"href":"https://api.github.com/repos/broadinstitute/picard/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/broadinstitute/picard/pulls/531/commits"},"statuses":{"href":"https://api.github.com/repos/broadinstitute/picard/statuses/99dbe60dd4f272e090c94f29ac77624d70dc50bc"}}}}