{"action":"created","comment":{"url":"https://api.github.com/repos/broadinstitute/gatk/pulls/comments/42488011","id":42488011,"diff_hunk":"@@ -0,0 +1,240 @@\n+package org.broadinstitute.hellbender.tools.spark.pipelines.metrics;\n+\n+import com.google.cloud.genomics.dataflow.utils.GCSOptions;\n+import htsjdk.samtools.SAMFileHeader;\n+import htsjdk.samtools.SAMReadGroupRecord;\n+import htsjdk.samtools.metrics.MetricsFile;\n+import htsjdk.samtools.util.StringUtil;\n+import org.apache.spark.api.java.JavaRDD;\n+import org.apache.spark.api.java.JavaSparkContext;\n+import org.apache.spark.api.java.function.Function;\n+import org.broadinstitute.hellbender.cmdline.Argument;\n+import org.broadinstitute.hellbender.cmdline.CommandLineProgramProperties;\n+import org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions;\n+import org.broadinstitute.hellbender.cmdline.programgroups.SparkProgramGroup;\n+import org.broadinstitute.hellbender.engine.spark.GATKSparkTool;\n+import org.broadinstitute.hellbender.exceptions.GATKException;\n+import org.broadinstitute.hellbender.tools.picard.analysis.BaseDistributionByCycleMetrics;\n+import org.broadinstitute.hellbender.tools.picard.analysis.CollectBaseDistributionByCycle;\n+import org.broadinstitute.hellbender.utils.R.RScriptExecutor;\n+import org.broadinstitute.hellbender.utils.Utils;\n+import org.broadinstitute.hellbender.utils.gcs.BucketUtils;\n+import org.broadinstitute.hellbender.utils.io.Resource;\n+import org.broadinstitute.hellbender.utils.read.GATKRead;\n+\n+import java.io.*;\n+import java.util.Arrays;\n+import java.util.List;\n+\n+@CommandLineProgramProperties(\n+        summary = \"Program to chart the nucleotide distribution per cycle in a SAM or BAM file.\",\n+        oneLineSummary = \"Program to chart the nucleotide distribution per cycle in a SAM or BAM file.\",\n+        programGroup = SparkProgramGroup.class\n+)\n+public final class CollectBaseDistributionByCycleSpark extends GATKSparkTool {\n+\n+    private static final long serialVersionUID = 1L;\n+\n+    @Argument(doc = \"uri for the output file: a local file path\",\n+            shortName = StandardArgumentDefinitions.OUTPUT_SHORT_NAME, fullName = StandardArgumentDefinitions.OUTPUT_LONG_NAME,\n+            optional = true)\n+    public String out;\n+\n+    @Argument(shortName=\"C\", fullName = \"chart\", doc=\"A file (with .pdf extension) to write the chart to.\", optional=true)\n+    public File chartOutput;\n+\n+    @Argument(shortName=\"A\", fullName = \"alignedReadsOnly\", doc=\"If set to true, calculate the base distribution over aligned reads only.\")\n+    public boolean alignedReadsOnly = false;\n+\n+    @Argument(shortName=\"F\", fullName = \"pfReadsOnly\", doc=\"If set to true calculate the base distribution over PF reads only.\")\n+    public boolean pfReadsOnly = false;\n+\n+    private static final class HistogramGenerator implements Serializable{\n+        private static final long serialVersionUID = 1L;\n+\n+        private static final int NBASES = 5; //ACGT + unknown\n+        private int maxLengthSoFar = 0;\n+        private final long[][] firstReadTotalsByCycle = new long[NBASES][maxLengthSoFar];\n+        private long[] firstReadCountsByCycle = new long[maxLengthSoFar];\n+        private final long[][] secondReadTotalsByCycle = new long[NBASES][maxLengthSoFar];\n+        private long[] secondReadCountsByCycle = new long[maxLengthSoFar];\n+        private boolean seenSecondEnd = false;","path":"src/main/java/org/broadinstitute/hellbender/tools/spark/pipelines/metrics/CollectBaseDistributionByCycleSpark.java","position":61,"original_position":61,"commit_id":"ccb792429ff5ffa502009a3010b777d43dab383a","original_commit_id":"ccb792429ff5ffa502009a3010b777d43dab383a","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":"or maybe seenAnySecondOfPair (because this appears to only be used as a signal that there is any data from the second read of pairs).","created_at":"2015-10-20T12:25:56Z","updated_at":"2015-10-20T12:25:56Z","html_url":"https://github.com/broadinstitute/gatk/pull/1013#discussion_r42488011","pull_request_url":"https://api.github.com/repos/broadinstitute/gatk/pulls/1013","_links":{"self":{"href":"https://api.github.com/repos/broadinstitute/gatk/pulls/comments/42488011"},"html":{"href":"https://github.com/broadinstitute/gatk/pull/1013#discussion_r42488011"},"pull_request":{"href":"https://api.github.com/repos/broadinstitute/gatk/pulls/1013"}}},"pull_request":{"url":"https://api.github.com/repos/broadinstitute/gatk/pulls/1013","id":47980448,"html_url":"https://github.com/broadinstitute/gatk/pull/1013","diff_url":"https://github.com/broadinstitute/gatk/pull/1013.diff","patch_url":"https://github.com/broadinstitute/gatk/pull/1013.patch","issue_url":"https://api.github.com/repos/broadinstitute/gatk/issues/1013","number":1013,"state":"open","locked":false,"title":"CollectBaseDistributionByCycle in Spark + tests","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":"fixes #1000 \r\n\r\nfor @davidadamsphd ","created_at":"2015-10-17T05:53:54Z","updated_at":"2015-10-20T12:25:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f02441a04a1afd096d006421306ad3a6cf68beaa","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/gatk/pulls/1013/commits","review_comments_url":"https://api.github.com/repos/broadinstitute/gatk/pulls/1013/comments","review_comment_url":"https://api.github.com/repos/broadinstitute/gatk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/broadinstitute/gatk/issues/1013/comments","statuses_url":"https://api.github.com/repos/broadinstitute/gatk/statuses/ccb792429ff5ffa502009a3010b777d43dab383a","head":{"label":"broadinstitute:ak_CollectBaseDistributionByCycle_spark","ref":"ak_CollectBaseDistributionByCycle_spark","sha":"ccb792429ff5ffa502009a3010b777d43dab383a","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":"gatk","full_name":"broadinstitute/gatk","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/gatk","description":"GATK4 development","fork":false,"url":"https://api.github.com/repos/broadinstitute/gatk","forks_url":"https://api.github.com/repos/broadinstitute/gatk/forks","keys_url":"https://api.github.com/repos/broadinstitute/gatk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/broadinstitute/gatk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/broadinstitute/gatk/teams","hooks_url":"https://api.github.com/repos/broadinstitute/gatk/hooks","issue_events_url":"https://api.github.com/repos/broadinstitute/gatk/issues/events{/number}","events_url":"https://api.github.com/repos/broadinstitute/gatk/events","assignees_url":"https://api.github.com/repos/broadinstitute/gatk/assignees{/user}","branches_url":"https://api.github.com/repos/broadinstitute/gatk/branches{/branch}","tags_url":"https://api.github.com/repos/broadinstitute/gatk/tags","blobs_url":"https://api.github.com/repos/broadinstitute/gatk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/broadinstitute/gatk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/broadinstitute/gatk/git/refs{/sha}","trees_url":"https://api.github.com/repos/broadinstitute/gatk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/broadinstitute/gatk/statuses/{sha}","languages_url":"https://api.github.com/repos/broadinstitute/gatk/languages","stargazers_url":"https://api.github.com/repos/broadinstitute/gatk/stargazers","contributors_url":"https://api.github.com/repos/broadinstitute/gatk/contributors","subscribers_url":"https://api.github.com/repos/broadinstitute/gatk/subscribers","subscription_url":"https://api.github.com/repos/broadinstitute/gatk/subscription","commits_url":"https://api.github.com/repos/broadinstitute/gatk/commits{/sha}","git_commits_url":"https://api.github.com/repos/broadinstitute/gatk/git/commits{/sha}","comments_url":"https://api.github.com/repos/broadinstitute/gatk/comments{/number}","issue_comment_url":"https://api.github.com/repos/broadinstitute/gatk/issues/comments{/number}","contents_url":"https://api.github.com/repos/broadinstitute/gatk/contents/{+path}","compare_url":"https://api.github.com/repos/broadinstitute/gatk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/broadinstitute/gatk/merges","archive_url":"https://api.github.com/repos/broadinstitute/gatk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/broadinstitute/gatk/downloads","issues_url":"https://api.github.com/repos/broadinstitute/gatk/issues{/number}","pulls_url":"https://api.github.com/repos/broadinstitute/gatk/pulls{/number}","milestones_url":"https://api.github.com/repos/broadinstitute/gatk/milestones{/number}","notifications_url":"https://api.github.com/repos/broadinstitute/gatk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/broadinstitute/gatk/labels{/name}","releases_url":"https://api.github.com/repos/broadinstitute/gatk/releases{/id}","created_at":"2014-12-02T20:50:36Z","updated_at":"2015-10-19T14:48:52Z","pushed_at":"2015-10-20T08:48:42Z","git_url":"git://github.com/broadinstitute/gatk.git","ssh_url":"git@github.com:broadinstitute/gatk.git","clone_url":"https://github.com/broadinstitute/gatk.git","svn_url":"https://github.com/broadinstitute/gatk","homepage":"","size":48293,"stargazers_count":32,"watchers_count":32,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":231,"forks":9,"open_issues":231,"watchers":32,"default_branch":"master"}},"base":{"label":"broadinstitute:master","ref":"master","sha":"9c5cbd1c840d87dddf426785a2d0ac03333bd81e","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":"gatk","full_name":"broadinstitute/gatk","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/gatk","description":"GATK4 development","fork":false,"url":"https://api.github.com/repos/broadinstitute/gatk","forks_url":"https://api.github.com/repos/broadinstitute/gatk/forks","keys_url":"https://api.github.com/repos/broadinstitute/gatk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/broadinstitute/gatk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/broadinstitute/gatk/teams","hooks_url":"https://api.github.com/repos/broadinstitute/gatk/hooks","issue_events_url":"https://api.github.com/repos/broadinstitute/gatk/issues/events{/number}","events_url":"https://api.github.com/repos/broadinstitute/gatk/events","assignees_url":"https://api.github.com/repos/broadinstitute/gatk/assignees{/user}","branches_url":"https://api.github.com/repos/broadinstitute/gatk/branches{/branch}","tags_url":"https://api.github.com/repos/broadinstitute/gatk/tags","blobs_url":"https://api.github.com/repos/broadinstitute/gatk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/broadinstitute/gatk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/broadinstitute/gatk/git/refs{/sha}","trees_url":"https://api.github.com/repos/broadinstitute/gatk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/broadinstitute/gatk/statuses/{sha}","languages_url":"https://api.github.com/repos/broadinstitute/gatk/languages","stargazers_url":"https://api.github.com/repos/broadinstitute/gatk/stargazers","contributors_url":"https://api.github.com/repos/broadinstitute/gatk/contributors","subscribers_url":"https://api.github.com/repos/broadinstitute/gatk/subscribers","subscription_url":"https://api.github.com/repos/broadinstitute/gatk/subscription","commits_url":"https://api.github.com/repos/broadinstitute/gatk/commits{/sha}","git_commits_url":"https://api.github.com/repos/broadinstitute/gatk/git/commits{/sha}","comments_url":"https://api.github.com/repos/broadinstitute/gatk/comments{/number}","issue_comment_url":"https://api.github.com/repos/broadinstitute/gatk/issues/comments{/number}","contents_url":"https://api.github.com/repos/broadinstitute/gatk/contents/{+path}","compare_url":"https://api.github.com/repos/broadinstitute/gatk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/broadinstitute/gatk/merges","archive_url":"https://api.github.com/repos/broadinstitute/gatk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/broadinstitute/gatk/downloads","issues_url":"https://api.github.com/repos/broadinstitute/gatk/issues{/number}","pulls_url":"https://api.github.com/repos/broadinstitute/gatk/pulls{/number}","milestones_url":"https://api.github.com/repos/broadinstitute/gatk/milestones{/number}","notifications_url":"https://api.github.com/repos/broadinstitute/gatk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/broadinstitute/gatk/labels{/name}","releases_url":"https://api.github.com/repos/broadinstitute/gatk/releases{/id}","created_at":"2014-12-02T20:50:36Z","updated_at":"2015-10-19T14:48:52Z","pushed_at":"2015-10-20T08:48:42Z","git_url":"git://github.com/broadinstitute/gatk.git","ssh_url":"git@github.com:broadinstitute/gatk.git","clone_url":"https://github.com/broadinstitute/gatk.git","svn_url":"https://github.com/broadinstitute/gatk","homepage":"","size":48293,"stargazers_count":32,"watchers_count":32,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":231,"forks":9,"open_issues":231,"watchers":32,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/broadinstitute/gatk/pulls/1013"},"html":{"href":"https://github.com/broadinstitute/gatk/pull/1013"},"issue":{"href":"https://api.github.com/repos/broadinstitute/gatk/issues/1013"},"comments":{"href":"https://api.github.com/repos/broadinstitute/gatk/issues/1013/comments"},"review_comments":{"href":"https://api.github.com/repos/broadinstitute/gatk/pulls/1013/comments"},"review_comment":{"href":"https://api.github.com/repos/broadinstitute/gatk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/broadinstitute/gatk/pulls/1013/commits"},"statuses":{"href":"https://api.github.com/repos/broadinstitute/gatk/statuses/ccb792429ff5ffa502009a3010b777d43dab383a"}}}}