{"action":"created","comment":{"url":"https://api.github.com/repos/broadinstitute/hellbender/pulls/comments/32113829","id":32113829,"diff_hunk":"@@ -0,0 +1,472 @@\n+package org.broadinstitute.hellbender.tools.dataflow;\n+\n+import com.google.api.client.json.GenericJson;\n+import com.google.api.services.genomics.model.Read;\n+import com.google.cloud.dataflow.sdk.Pipeline;\n+import com.google.cloud.dataflow.sdk.coders.*;\n+import com.google.cloud.dataflow.sdk.io.TextIO;\n+import com.google.cloud.dataflow.sdk.transforms.*;\n+import com.google.cloud.dataflow.sdk.transforms.Partition.PartitionFn;\n+import com.google.cloud.dataflow.sdk.values.KV;\n+import com.google.cloud.dataflow.sdk.values.PCollection;\n+import com.google.cloud.dataflow.sdk.values.PCollectionList;\n+import com.google.cloud.dataflow.sdk.values.PCollectionView;\n+import com.google.cloud.genomics.dataflow.coders.GenericJsonCoder;\n+import com.google.common.collect.*;\n+import htsjdk.samtools.*;\n+import org.broadinstitute.hellbender.cmdline.Argument;\n+import org.broadinstitute.hellbender.cmdline.ArgumentCollection;\n+import org.broadinstitute.hellbender.cmdline.CommandLineProgramProperties;\n+import org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions;\n+import org.broadinstitute.hellbender.cmdline.argumentcollections.IntervalArgumentCollection;\n+import org.broadinstitute.hellbender.cmdline.argumentcollections.OptionalIntervalArgumentCollection;\n+import org.broadinstitute.hellbender.cmdline.programgroups.DataFlowProgramGroup;\n+import org.broadinstitute.hellbender.engine.dataflow.DataflowCommandLineProgram;\n+import org.broadinstitute.hellbender.engine.dataflow.ReadsSource;\n+import org.broadinstitute.hellbender.tools.dataflow.transforms.MarkDuplicatesReadsKey;\n+import org.broadinstitute.hellbender.utils.GenomeLocSortedSet;\n+import org.broadinstitute.hellbender.utils.SimpleInterval;\n+import org.broadinstitute.hellbender.utils.dataflow.DataflowUtils;\n+\n+import java.io.IOException;\n+import java.io.InputStream;\n+import java.io.OutputStream;\n+import java.io.Serializable;\n+import java.util.*;\n+import java.util.stream.Collectors;\n+import java.util.stream.StreamSupport;\n+\n+import static org.broadinstitute.hellbender.tools.dataflow.GenomicsReadUtils.getAlignmentStart;\n+import static org.broadinstitute.hellbender.tools.dataflow.GenomicsReadUtils.getReferenceName;\n+import static org.broadinstitute.hellbender.tools.dataflow.GenomicsReadUtils.isPrimaryAlignment;\n+\n+@CommandLineProgramProperties(\n+        usage=\"Marks duplicates on dataflow\",\n+        usageShort=\"Mark Duplicates\",\n+        programGroup = DataFlowProgramGroup.class)\n+public final class MarkDuplicatesDataflow extends DataflowCommandLineProgram {\n+\n+    //Bases below this quality will not be included in picking the best read from a set of duplicates.\n+    private static final int MIN_BASE_QUAL = 15;\n+\n+    @Argument(doc=\"a prefix for the dataflow output files\", shortName = StandardArgumentDefinitions.OUTPUT_SHORT_NAME, fullName = StandardArgumentDefinitions.OUTPUT_LONG_NAME, optional = false)\n+    protected String outputFile;\n+\n+    @Argument(doc = \"uri for the input bam, either a local file path or a gs:// bucket path\",\n+            shortName = StandardArgumentDefinitions.INPUT_SHORT_NAME, fullName = StandardArgumentDefinitions.INPUT_LONG_NAME,\n+            optional = false)\n+    protected String bam;\n+\n+    @ArgumentCollection\n+    protected IntervalArgumentCollection intervalArgumentCollection = new OptionalIntervalArgumentCollection();\n+\n+    @Override\n+    protected void setupPipeline(final Pipeline pipeline) {\n+        final ReadsSource readsSource = new ReadsSource(bam, pipeline);\n+        final SAMFileHeader header = readsSource.getHeader();\n+        final SAMSequenceDictionary sequenceDictionary = header.getSequenceDictionary();\n+        final List<SimpleInterval> intervals = intervalArgumentCollection.intervalsSpecified() ? intervalArgumentCollection.getIntervals(sequenceDictionary):\n+                getAllIntervalsForReference(sequenceDictionary);\n+\n+        final PCollectionView<SAMFileHeader> headerPcolView = pipeline.apply(Create.of(header)).apply(View.<SAMFileHeader>asSingleton());\n+\n+        final PCollection<Read> preads = readsSource.getReadPCollection(intervals);","path":"src/main/java/org/broadinstitute/hellbender/tools/dataflow/MarkDuplicatesDataflow.java","position":73,"original_position":73,"commit_id":"07a6232c0dd3bf4bd0c5dab6177a57d766ebcd40","original_commit_id":"07a6232c0dd3bf4bd0c5dab6177a57d766ebcd40","user":{"login":"davidadamsphd","id":12084283,"avatar_url":"https://avatars.githubusercontent.com/u/12084283?v=3","gravatar_id":"","url":"https://api.github.com/users/davidadamsphd","html_url":"https://github.com/davidadamsphd","followers_url":"https://api.github.com/users/davidadamsphd/followers","following_url":"https://api.github.com/users/davidadamsphd/following{/other_user}","gists_url":"https://api.github.com/users/davidadamsphd/gists{/gist_id}","starred_url":"https://api.github.com/users/davidadamsphd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidadamsphd/subscriptions","organizations_url":"https://api.github.com/users/davidadamsphd/orgs","repos_url":"https://api.github.com/users/davidadamsphd/repos","events_url":"https://api.github.com/users/davidadamsphd/events{/privacy}","received_events_url":"https://api.github.com/users/davidadamsphd/received_events","type":"User","site_admin":false},"body":"Here and elsewhere, we'll need to switch to the Read interface. If David's refactor doesn't get in first, this can get merged as-is.","created_at":"2015-06-10T12:57:01Z","updated_at":"2015-06-10T12:57:01Z","html_url":"https://github.com/broadinstitute/hellbender/pull/541#discussion_r32113829","pull_request_url":"https://api.github.com/repos/broadinstitute/hellbender/pulls/541","_links":{"self":{"href":"https://api.github.com/repos/broadinstitute/hellbender/pulls/comments/32113829"},"html":{"href":"https://github.com/broadinstitute/hellbender/pull/541#discussion_r32113829"},"pull_request":{"href":"https://api.github.com/repos/broadinstitute/hellbender/pulls/541"}}},"pull_request":{"url":"https://api.github.com/repos/broadinstitute/hellbender/pulls/541","id":36793095,"html_url":"https://github.com/broadinstitute/hellbender/pull/541","diff_url":"https://github.com/broadinstitute/hellbender/pull/541.diff","patch_url":"https://github.com/broadinstitute/hellbender/pull/541.patch","issue_url":"https://api.github.com/repos/broadinstitute/hellbender/issues/541","number":541,"state":"open","locked":false,"title":"mark duplicates in dataflow","user":{"login":"akiezun","id":1993519,"avatar_url":"https://avatars.githubusercontent.com/u/1993519?v=3","gravatar_id":"","url":"https://api.github.com/users/akiezun","html_url":"https://github.com/akiezun","followers_url":"https://api.github.com/users/akiezun/followers","following_url":"https://api.github.com/users/akiezun/following{/other_user}","gists_url":"https://api.github.com/users/akiezun/gists{/gist_id}","starred_url":"https://api.github.com/users/akiezun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akiezun/subscriptions","organizations_url":"https://api.github.com/users/akiezun/orgs","repos_url":"https://api.github.com/users/akiezun/repos","events_url":"https://api.github.com/users/akiezun/events{/privacy}","received_events_url":"https://api.github.com/users/akiezun/received_events","type":"User","site_admin":false},"body":"mark duplicates in dataflow - based on the code by garrickevans \r\n\r\nThe main work is done in\r\n`private static final class MarkDuplicatesDataflowTransform extends PTransform<PCollection<Read>, PCollection<Read>>` - the sigrature conforms to the main read processing pipeline.\r\n\r\nLimitations:\r\n- no optical duplicates\r\n- only integration tests (would be good to have unit tests that check dup detection logic on very specific reads - ideally those from picard's tests)\r\n\r\n@droazen please review\r\n","created_at":"2015-06-03T02:20:31Z","updated_at":"2015-06-10T12:57:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"867b47078f906ddd717f1e3ff2fb9f1407e12f04","assignee":{"login":"davidadamsphd","id":12084283,"avatar_url":"https://avatars.githubusercontent.com/u/12084283?v=3","gravatar_id":"","url":"https://api.github.com/users/davidadamsphd","html_url":"https://github.com/davidadamsphd","followers_url":"https://api.github.com/users/davidadamsphd/followers","following_url":"https://api.github.com/users/davidadamsphd/following{/other_user}","gists_url":"https://api.github.com/users/davidadamsphd/gists{/gist_id}","starred_url":"https://api.github.com/users/davidadamsphd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidadamsphd/subscriptions","organizations_url":"https://api.github.com/users/davidadamsphd/orgs","repos_url":"https://api.github.com/users/davidadamsphd/repos","events_url":"https://api.github.com/users/davidadamsphd/events{/privacy}","received_events_url":"https://api.github.com/users/davidadamsphd/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/broadinstitute/hellbender/pulls/541/commits","review_comments_url":"https://api.github.com/repos/broadinstitute/hellbender/pulls/541/comments","review_comment_url":"https://api.github.com/repos/broadinstitute/hellbender/pulls/comments{/number}","comments_url":"https://api.github.com/repos/broadinstitute/hellbender/issues/541/comments","statuses_url":"https://api.github.com/repos/broadinstitute/hellbender/statuses/07a6232c0dd3bf4bd0c5dab6177a57d766ebcd40","head":{"label":"broadinstitute:ak_mark_duplicates","ref":"ak_mark_duplicates","sha":"07a6232c0dd3bf4bd0c5dab6177a57d766ebcd40","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":27452807,"name":"hellbender","full_name":"broadinstitute/hellbender","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/hellbender","description":"GATK4 development","fork":false,"url":"https://api.github.com/repos/broadinstitute/hellbender","forks_url":"https://api.github.com/repos/broadinstitute/hellbender/forks","keys_url":"https://api.github.com/repos/broadinstitute/hellbender/keys{/key_id}","collaborators_url":"https://api.github.com/repos/broadinstitute/hellbender/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/broadinstitute/hellbender/teams","hooks_url":"https://api.github.com/repos/broadinstitute/hellbender/hooks","issue_events_url":"https://api.github.com/repos/broadinstitute/hellbender/issues/events{/number}","events_url":"https://api.github.com/repos/broadinstitute/hellbender/events","assignees_url":"https://api.github.com/repos/broadinstitute/hellbender/assignees{/user}","branches_url":"https://api.github.com/repos/broadinstitute/hellbender/branches{/branch}","tags_url":"https://api.github.com/repos/broadinstitute/hellbender/tags","blobs_url":"https://api.github.com/repos/broadinstitute/hellbender/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/broadinstitute/hellbender/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/broadinstitute/hellbender/git/refs{/sha}","trees_url":"https://api.github.com/repos/broadinstitute/hellbender/git/trees{/sha}","statuses_url":"https://api.github.com/repos/broadinstitute/hellbender/statuses/{sha}","languages_url":"https://api.github.com/repos/broadinstitute/hellbender/languages","stargazers_url":"https://api.github.com/repos/broadinstitute/hellbender/stargazers","contributors_url":"https://api.github.com/repos/broadinstitute/hellbender/contributors","subscribers_url":"https://api.github.com/repos/broadinstitute/hellbender/subscribers","subscription_url":"https://api.github.com/repos/broadinstitute/hellbender/subscription","commits_url":"https://api.github.com/repos/broadinstitute/hellbender/commits{/sha}","git_commits_url":"https://api.github.com/repos/broadinstitute/hellbender/git/commits{/sha}","comments_url":"https://api.github.com/repos/broadinstitute/hellbender/comments{/number}","issue_comment_url":"https://api.github.com/repos/broadinstitute/hellbender/issues/comments{/number}","contents_url":"https://api.github.com/repos/broadinstitute/hellbender/contents/{+path}","compare_url":"https://api.github.com/repos/broadinstitute/hellbender/compare/{base}...{head}","merges_url":"https://api.github.com/repos/broadinstitute/hellbender/merges","archive_url":"https://api.github.com/repos/broadinstitute/hellbender/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/broadinstitute/hellbender/downloads","issues_url":"https://api.github.com/repos/broadinstitute/hellbender/issues{/number}","pulls_url":"https://api.github.com/repos/broadinstitute/hellbender/pulls{/number}","milestones_url":"https://api.github.com/repos/broadinstitute/hellbender/milestones{/number}","notifications_url":"https://api.github.com/repos/broadinstitute/hellbender/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/broadinstitute/hellbender/labels{/name}","releases_url":"https://api.github.com/repos/broadinstitute/hellbender/releases{/id}","created_at":"2014-12-02T20:50:36Z","updated_at":"2015-06-01T18:15:16Z","pushed_at":"2015-06-10T00:08:08Z","git_url":"git://github.com/broadinstitute/hellbender.git","ssh_url":"git@github.com:broadinstitute/hellbender.git","clone_url":"https://github.com/broadinstitute/hellbender.git","svn_url":"https://github.com/broadinstitute/hellbender","homepage":"","size":28876,"stargazers_count":20,"watchers_count":20,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":193,"forks":4,"open_issues":193,"watchers":20,"default_branch":"master"}},"base":{"label":"broadinstitute:master","ref":"master","sha":"af16a71d2c76c57d00112da3694f8e5fcd0e1b73","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":27452807,"name":"hellbender","full_name":"broadinstitute/hellbender","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/hellbender","description":"GATK4 development","fork":false,"url":"https://api.github.com/repos/broadinstitute/hellbender","forks_url":"https://api.github.com/repos/broadinstitute/hellbender/forks","keys_url":"https://api.github.com/repos/broadinstitute/hellbender/keys{/key_id}","collaborators_url":"https://api.github.com/repos/broadinstitute/hellbender/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/broadinstitute/hellbender/teams","hooks_url":"https://api.github.com/repos/broadinstitute/hellbender/hooks","issue_events_url":"https://api.github.com/repos/broadinstitute/hellbender/issues/events{/number}","events_url":"https://api.github.com/repos/broadinstitute/hellbender/events","assignees_url":"https://api.github.com/repos/broadinstitute/hellbender/assignees{/user}","branches_url":"https://api.github.com/repos/broadinstitute/hellbender/branches{/branch}","tags_url":"https://api.github.com/repos/broadinstitute/hellbender/tags","blobs_url":"https://api.github.com/repos/broadinstitute/hellbender/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/broadinstitute/hellbender/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/broadinstitute/hellbender/git/refs{/sha}","trees_url":"https://api.github.com/repos/broadinstitute/hellbender/git/trees{/sha}","statuses_url":"https://api.github.com/repos/broadinstitute/hellbender/statuses/{sha}","languages_url":"https://api.github.com/repos/broadinstitute/hellbender/languages","stargazers_url":"https://api.github.com/repos/broadinstitute/hellbender/stargazers","contributors_url":"https://api.github.com/repos/broadinstitute/hellbender/contributors","subscribers_url":"https://api.github.com/repos/broadinstitute/hellbender/subscribers","subscription_url":"https://api.github.com/repos/broadinstitute/hellbender/subscription","commits_url":"https://api.github.com/repos/broadinstitute/hellbender/commits{/sha}","git_commits_url":"https://api.github.com/repos/broadinstitute/hellbender/git/commits{/sha}","comments_url":"https://api.github.com/repos/broadinstitute/hellbender/comments{/number}","issue_comment_url":"https://api.github.com/repos/broadinstitute/hellbender/issues/comments{/number}","contents_url":"https://api.github.com/repos/broadinstitute/hellbender/contents/{+path}","compare_url":"https://api.github.com/repos/broadinstitute/hellbender/compare/{base}...{head}","merges_url":"https://api.github.com/repos/broadinstitute/hellbender/merges","archive_url":"https://api.github.com/repos/broadinstitute/hellbender/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/broadinstitute/hellbender/downloads","issues_url":"https://api.github.com/repos/broadinstitute/hellbender/issues{/number}","pulls_url":"https://api.github.com/repos/broadinstitute/hellbender/pulls{/number}","milestones_url":"https://api.github.com/repos/broadinstitute/hellbender/milestones{/number}","notifications_url":"https://api.github.com/repos/broadinstitute/hellbender/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/broadinstitute/hellbender/labels{/name}","releases_url":"https://api.github.com/repos/broadinstitute/hellbender/releases{/id}","created_at":"2014-12-02T20:50:36Z","updated_at":"2015-06-01T18:15:16Z","pushed_at":"2015-06-10T00:08:08Z","git_url":"git://github.com/broadinstitute/hellbender.git","ssh_url":"git@github.com:broadinstitute/hellbender.git","clone_url":"https://github.com/broadinstitute/hellbender.git","svn_url":"https://github.com/broadinstitute/hellbender","homepage":"","size":28876,"stargazers_count":20,"watchers_count":20,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":193,"forks":4,"open_issues":193,"watchers":20,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/broadinstitute/hellbender/pulls/541"},"html":{"href":"https://github.com/broadinstitute/hellbender/pull/541"},"issue":{"href":"https://api.github.com/repos/broadinstitute/hellbender/issues/541"},"comments":{"href":"https://api.github.com/repos/broadinstitute/hellbender/issues/541/comments"},"review_comments":{"href":"https://api.github.com/repos/broadinstitute/hellbender/pulls/541/comments"},"review_comment":{"href":"https://api.github.com/repos/broadinstitute/hellbender/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/broadinstitute/hellbender/pulls/541/commits"},"statuses":{"href":"https://api.github.com/repos/broadinstitute/hellbender/statuses/07a6232c0dd3bf4bd0c5dab6177a57d766ebcd40"}}}}