{"action":"created","comment":{"url":"https://api.github.com/repos/broadinstitute/gatk/pulls/comments/63918963","id":63918963,"diff_hunk":"@@ -0,0 +1,178 @@\n+package org.broadinstitute.hellbender.tools.walkers.qc;\n+\n+import htsjdk.tribble.Feature;\n+import org.broadinstitute.hellbender.cmdline.Argument;\n+import org.broadinstitute.hellbender.cmdline.CommandLineProgramProperties;\n+import org.broadinstitute.hellbender.cmdline.Hidden;\n+import org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions;\n+import org.broadinstitute.hellbender.cmdline.programgroups.QCProgramGroup;\n+import org.broadinstitute.hellbender.engine.*;\n+import org.broadinstitute.hellbender.utils.Utils;\n+import org.broadinstitute.hellbender.utils.pileup.PileupElement;\n+import org.broadinstitute.hellbender.utils.pileup.ReadPileup;\n+\n+import java.io.PrintStream;\n+import java.util.ArrayList;\n+import java.util.List;\n+import java.util.stream.Collectors;\n+\n+/**\n+ * Print read alignments in Pileup-style format\n+ *\n+ * <p>This tool emulates the 'samtools pileup' command. It prints the alignment in a format that is very similar to the\n+ * Samtools pileup format (see the <a href=\"http://samtools.sourceforge.net/pileup.shtml\">Pileup format\n+ * documentation</a> for more details about the original format). There is one line per genomic position, listing the\n+ * chromosome name, coordinate, reference base, read bases, and read qualities. In addition to these default fields,\n+ * additional information can be added to the output as extra columns; see options detailed below.</p>\n+ *\n+ * <h4>Emulated command:</h4>\n+ * <pre>\n+ *  samtools pileup -f in.ref.fasta -l in.site_list input.bam\n+ * </pre>\n+ *\n+ * <h3>Input</h3> <p> A BAM file and the interval to print. </p>\n+ *\n+ * <h3>Output</h3> <p> Alignment of reads formatted in the Pileup style. </p>\n+ *\n+ * <h3>Usage example</h3>\n+ * <pre>\n+ * ./gatk-launch Pileup  \\\\\n+ *   -R reference.fasta \\\n+ *   -I my_reads.bam \\\n+ *   -L chr1:257-267\n+ *   -O output.txt\n+ * </pre>\n+ * <h4>Expected output</h4>\n+ * <pre>\n+ *     chr1 257 A CAA '&=\n+ *     chr1 258 C TCC A:=\n+ *     chr1 259 C CCC )A=\n+ *     chr1 260 C ACC (=<\n+ *     chr1 261 T TCT '44\n+ *     chr1 262 A AAA '?:\n+ *     chr1 263 A AGA 1'6\n+ *     chr1 264 C TCC 987\n+ *     chr1 265 C CCC (@(\n+ *     chr1 266 C GCC ''=\n+ *     chr1 267 T AAT 7%>\n+ * </pre>\n+ */\n+@CommandLineProgramProperties(\n+    summary = \"This tool emulates the 'samtools pileup' command. It prints the alignment in a format that is very \"\n+        + \"similar to the Samtools pileup format (see the documentation in http://samtools.sourceforge.net/pileup.shtml\"\n+        + \"for more details about the original format). There is one line per genomic position, listing the chromosome \"\n+        + \"name, coordinate, reference base, read bases, and read qualities. In addition to these default fields, \"\n+        + \"additional information can be added to the output as extra columns; see options detailed below.\",\n+    oneLineSummary = \"Print read alignments in Pileup-style format\",\n+    programGroup = QCProgramGroup.class)\n+public final class Pileup extends LocusWalker {\n+\n+    private static final String VERBOSE_DELIMITER = \"@\"; // it's ugly to use \"@\" but it's literally the only usable character not allowed in read names\n+\n+    @Argument(fullName = StandardArgumentDefinitions.OUTPUT_LONG_NAME, shortName = StandardArgumentDefinitions.OUTPUT_SHORT_NAME, doc = \"An output file created by the walker. Will overwrite contents if file exists\")\n+    public PrintStream out;\n+\n+    /**\n+     * In addition to the standard pileup output, adds 'verbose' output too. The verbose output contains the number of\n+     * spanning deletions, and for each read in the pileup it has the read name, offset in the base string, read length,\n+     * and read mapping quality.  These per read items are delimited with an '@' character.\n+     */\n+    @Argument(fullName = \"showVerbose\", shortName = \"verbose\", doc = \"Add an extra verbose section to the pileup output\", optional = true)\n+    public boolean showVerbose = false;\n+\n+    /**\n+     * This enables annotating the pileup to show overlaps with metadata from a Feature file(s). For example, if you provide a\n+     * VCF and there is a SNP at a given location covered by the pileup, the pileup output at that position will be\n+     * annotated with the corresponding source Feature identifier.\n+     */\n+    @Argument(fullName = \"metadata\", shortName = \"metadata\", doc = \"Features file(s) containing metadata\", optional = true)\n+    public List<FeatureInput<Feature>> metadata = new ArrayList<>();\n+\n+    /**\n+     * Adds the length of the insert each base comes from to the output pileup. Here, \"insert\" refers to the DNA insert\n+     * produced during library generation before sequencing.\n+     */\n+    @Hidden\n+    @Argument(fullName = \"outputInsertLength\", shortName = \"outputInsertLength\", doc = \"Output insert length\", optional = true)\n+    public boolean outputInsertLength = false;\n+\n+    @Override\n+    public void apply(AlignmentContext alignmentContext, ReferenceContext referenceContext, FeatureContext featureContext) {\n+        final String features = getFeaturesString(featureContext);\n+        final ReadPileup basePileup = alignmentContext.getBasePileup();\n+        final StringBuilder s = new StringBuilder();\n+        s.append(String.format(\"%s %s\",\n+                basePileup.getPileupString((hasReference()) ? (char) referenceContext.getBase() : 'N'),\n+                features));\n+        if (outputInsertLength) {\n+            s.append(\" \").append(insertLengthOutput(basePileup));\n+        }\n+        if (showVerbose) {\n+            s.append(\" \").append(createVerboseOutput(basePileup));\n+        }\n+        s.append(\"\\n\");\n+        out.print(s.toString());\n+    }\n+\n+    /**\n+     * Get a string representation for the metadata\n+     *\n+     * @param featureContext Context for the features.\n+     *\n+     * @return String representation of the metadata\n+     */\n+    private String getFeaturesString(final FeatureContext featureContext) {\n+        List<String> featuresStrings = new ArrayList<>();","path":"src/main/java/org/broadinstitute/hellbender/tools/walkers/qc/Pileup.java","position":125,"original_position":125,"commit_id":"bfb4616e46530e38875a2ec7a7e5ea01566cc862","original_commit_id":"bfb4616e46530e38875a2ec7a7e5ea01566cc862","user":{"login":"magicDGS","id":7352559,"avatar_url":"https://avatars.githubusercontent.com/u/7352559?v=3","gravatar_id":"","url":"https://api.github.com/users/magicDGS","html_url":"https://github.com/magicDGS","followers_url":"https://api.github.com/users/magicDGS/followers","following_url":"https://api.github.com/users/magicDGS/following{/other_user}","gists_url":"https://api.github.com/users/magicDGS/gists{/gist_id}","starred_url":"https://api.github.com/users/magicDGS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magicDGS/subscriptions","organizations_url":"https://api.github.com/users/magicDGS/orgs","repos_url":"https://api.github.com/users/magicDGS/repos","events_url":"https://api.github.com/users/magicDGS/events{/privacy}","received_events_url":"https://api.github.com/users/magicDGS/received_events","type":"User","site_admin":false},"body":"Don't needed anymore because now is a lambda expression.","created_at":"2016-05-19T17:19:19Z","updated_at":"2016-05-19T17:19:19Z","html_url":"https://github.com/broadinstitute/gatk/pull/1836#discussion_r63918963","pull_request_url":"https://api.github.com/repos/broadinstitute/gatk/pulls/1836","_links":{"self":{"href":"https://api.github.com/repos/broadinstitute/gatk/pulls/comments/63918963"},"html":{"href":"https://github.com/broadinstitute/gatk/pull/1836#discussion_r63918963"},"pull_request":{"href":"https://api.github.com/repos/broadinstitute/gatk/pulls/1836"}}},"pull_request":{"url":"https://api.github.com/repos/broadinstitute/gatk/pulls/1836","id":70580361,"html_url":"https://github.com/broadinstitute/gatk/pull/1836","diff_url":"https://github.com/broadinstitute/gatk/pull/1836.diff","patch_url":"https://github.com/broadinstitute/gatk/pull/1836.patch","issue_url":"https://api.github.com/repos/broadinstitute/gatk/issues/1836","number":1836,"state":"open","locked":false,"title":"Port Pileup","user":{"login":"magicDGS","id":7352559,"avatar_url":"https://avatars.githubusercontent.com/u/7352559?v=3","gravatar_id":"","url":"https://api.github.com/users/magicDGS","html_url":"https://github.com/magicDGS","followers_url":"https://api.github.com/users/magicDGS/followers","following_url":"https://api.github.com/users/magicDGS/following{/other_user}","gists_url":"https://api.github.com/users/magicDGS/gists{/gist_id}","starred_url":"https://api.github.com/users/magicDGS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magicDGS/subscriptions","organizations_url":"https://api.github.com/users/magicDGS/orgs","repos_url":"https://api.github.com/users/magicDGS/repos","events_url":"https://api.github.com/users/magicDGS/events{/privacy}","received_events_url":"https://api.github.com/users/magicDGS/received_events","type":"User","site_admin":false},"body":"Porting Pileup (https://github.com/broadinstitute/gatk/issues/1581) and tests","created_at":"2016-05-18T18:54:12Z","updated_at":"2016-05-19T17:19:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7947de4ecd84e0fc6cd5e588476c4caab18ec409","assignee":{"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},"milestone":null,"commits_url":"https://api.github.com/repos/broadinstitute/gatk/pulls/1836/commits","review_comments_url":"https://api.github.com/repos/broadinstitute/gatk/pulls/1836/comments","review_comment_url":"https://api.github.com/repos/broadinstitute/gatk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/broadinstitute/gatk/issues/1836/comments","statuses_url":"https://api.github.com/repos/broadinstitute/gatk/statuses/bfb4616e46530e38875a2ec7a7e5ea01566cc862","head":{"label":"magicDGS:dgs_port_pileup","ref":"dgs_port_pileup","sha":"bfb4616e46530e38875a2ec7a7e5ea01566cc862","user":{"login":"magicDGS","id":7352559,"avatar_url":"https://avatars.githubusercontent.com/u/7352559?v=3","gravatar_id":"","url":"https://api.github.com/users/magicDGS","html_url":"https://github.com/magicDGS","followers_url":"https://api.github.com/users/magicDGS/followers","following_url":"https://api.github.com/users/magicDGS/following{/other_user}","gists_url":"https://api.github.com/users/magicDGS/gists{/gist_id}","starred_url":"https://api.github.com/users/magicDGS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magicDGS/subscriptions","organizations_url":"https://api.github.com/users/magicDGS/orgs","repos_url":"https://api.github.com/users/magicDGS/repos","events_url":"https://api.github.com/users/magicDGS/events{/privacy}","received_events_url":"https://api.github.com/users/magicDGS/received_events","type":"User","site_admin":false},"repo":{"id":56243756,"name":"gatk","full_name":"magicDGS/gatk","owner":{"login":"magicDGS","id":7352559,"avatar_url":"https://avatars.githubusercontent.com/u/7352559?v=3","gravatar_id":"","url":"https://api.github.com/users/magicDGS","html_url":"https://github.com/magicDGS","followers_url":"https://api.github.com/users/magicDGS/followers","following_url":"https://api.github.com/users/magicDGS/following{/other_user}","gists_url":"https://api.github.com/users/magicDGS/gists{/gist_id}","starred_url":"https://api.github.com/users/magicDGS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magicDGS/subscriptions","organizations_url":"https://api.github.com/users/magicDGS/orgs","repos_url":"https://api.github.com/users/magicDGS/repos","events_url":"https://api.github.com/users/magicDGS/events{/privacy}","received_events_url":"https://api.github.com/users/magicDGS/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/magicDGS/gatk","description":"GATK4 development","fork":true,"url":"https://api.github.com/repos/magicDGS/gatk","forks_url":"https://api.github.com/repos/magicDGS/gatk/forks","keys_url":"https://api.github.com/repos/magicDGS/gatk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/magicDGS/gatk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/magicDGS/gatk/teams","hooks_url":"https://api.github.com/repos/magicDGS/gatk/hooks","issue_events_url":"https://api.github.com/repos/magicDGS/gatk/issues/events{/number}","events_url":"https://api.github.com/repos/magicDGS/gatk/events","assignees_url":"https://api.github.com/repos/magicDGS/gatk/assignees{/user}","branches_url":"https://api.github.com/repos/magicDGS/gatk/branches{/branch}","tags_url":"https://api.github.com/repos/magicDGS/gatk/tags","blobs_url":"https://api.github.com/repos/magicDGS/gatk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/magicDGS/gatk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/magicDGS/gatk/git/refs{/sha}","trees_url":"https://api.github.com/repos/magicDGS/gatk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/magicDGS/gatk/statuses/{sha}","languages_url":"https://api.github.com/repos/magicDGS/gatk/languages","stargazers_url":"https://api.github.com/repos/magicDGS/gatk/stargazers","contributors_url":"https://api.github.com/repos/magicDGS/gatk/contributors","subscribers_url":"https://api.github.com/repos/magicDGS/gatk/subscribers","subscription_url":"https://api.github.com/repos/magicDGS/gatk/subscription","commits_url":"https://api.github.com/repos/magicDGS/gatk/commits{/sha}","git_commits_url":"https://api.github.com/repos/magicDGS/gatk/git/commits{/sha}","comments_url":"https://api.github.com/repos/magicDGS/gatk/comments{/number}","issue_comment_url":"https://api.github.com/repos/magicDGS/gatk/issues/comments{/number}","contents_url":"https://api.github.com/repos/magicDGS/gatk/contents/{+path}","compare_url":"https://api.github.com/repos/magicDGS/gatk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/magicDGS/gatk/merges","archive_url":"https://api.github.com/repos/magicDGS/gatk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/magicDGS/gatk/downloads","issues_url":"https://api.github.com/repos/magicDGS/gatk/issues{/number}","pulls_url":"https://api.github.com/repos/magicDGS/gatk/pulls{/number}","milestones_url":"https://api.github.com/repos/magicDGS/gatk/milestones{/number}","notifications_url":"https://api.github.com/repos/magicDGS/gatk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/magicDGS/gatk/labels{/name}","releases_url":"https://api.github.com/repos/magicDGS/gatk/releases{/id}","deployments_url":"https://api.github.com/repos/magicDGS/gatk/deployments","created_at":"2016-04-14T14:22:57Z","updated_at":"2016-04-14T14:23:04Z","pushed_at":"2016-05-19T17:04:10Z","git_url":"git://github.com/magicDGS/gatk.git","ssh_url":"git@github.com:magicDGS/gatk.git","clone_url":"https://github.com/magicDGS/gatk.git","svn_url":"https://github.com/magicDGS/gatk","homepage":"","size":62678,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"broadinstitute:master","ref":"master","sha":"4353d54fd2d64ea1b4c8429986f83eb873a4d687","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}","deployments_url":"https://api.github.com/repos/broadinstitute/gatk/deployments","created_at":"2014-12-02T20:50:36Z","updated_at":"2016-05-15T00:55:15Z","pushed_at":"2016-05-19T17:04:31Z","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":110662,"stargazers_count":71,"watchers_count":71,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":27,"mirror_url":null,"open_issues_count":357,"forks":27,"open_issues":357,"watchers":71,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/broadinstitute/gatk/pulls/1836"},"html":{"href":"https://github.com/broadinstitute/gatk/pull/1836"},"issue":{"href":"https://api.github.com/repos/broadinstitute/gatk/issues/1836"},"comments":{"href":"https://api.github.com/repos/broadinstitute/gatk/issues/1836/comments"},"review_comments":{"href":"https://api.github.com/repos/broadinstitute/gatk/pulls/1836/comments"},"review_comment":{"href":"https://api.github.com/repos/broadinstitute/gatk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/broadinstitute/gatk/pulls/1836/commits"},"statuses":{"href":"https://api.github.com/repos/broadinstitute/gatk/statuses/bfb4616e46530e38875a2ec7a7e5ea01566cc862"}}}}