{"action":"created","comment":{"url":"https://api.github.com/repos/broadinstitute/gatk/pulls/comments/73921476","id":73921476,"diff_hunk":"@@ -1137,20 +1224,121 @@ private static boolean likelihoodsAreUninformative(final double[] likelihoods) {\n      * @param allelesToKeep   the list of alleles to keep\n      * @return non-null bitset\n      */\n-    private static boolean[] getAlleleIndexBitset(final VariantContext originalVC, final List<Allele> allelesToKeep) {\n+    private static BitSet getAlleleIndexBitset(final VariantContext originalVC, final List<Allele> allelesToKeep) {\n         final int numOriginalAltAlleles = originalVC.getNAlleles() - 1;\n-        final boolean[] alleleIndexesToKeep = new boolean[numOriginalAltAlleles + 1];\n+        final BitSet alleleIndexesToKeep = new BitSet(numOriginalAltAlleles + 1);\n \n         // the reference Allele is definitely still used\n-        alleleIndexesToKeep[0] = true;\n+        alleleIndexesToKeep.set(0);\n         for ( int i = 0; i < numOriginalAltAlleles; i++ ) {\n             if ( allelesToKeep.contains(originalVC.getAlternateAllele(i)) )\n-                alleleIndexesToKeep[i+1] = true;\n+                alleleIndexesToKeep.set(i+1);\n         }\n \n         return alleleIndexesToKeep;\n     }\n \n+    /**\n+     * Find the strand allele count indexes to use for a selected set of alleles\n+     *\n+     * @param originalVC   the original VariantContext\n+     * @param allelesToUse the subset of alleles to use\n+     * @return a list of SAC indexes to use or null if none\n+     */\n+    public static List<Integer> determineSACIndexesToUse(final VariantContext originalVC, final List<Allele> allelesToUse) {\n+\n+        Utils.nonNull(originalVC, \"VariantContext is null\");\n+        Utils.nonNull(allelesToUse, \"Alleles to use is null\");\n+\n+        // the bitset representing the allele indexes we want to keep\n+        final BitSet alleleIndexesToUse = getAlleleIndexBitset(originalVC, allelesToUse);\n+\n+        // an optimization: if we are supposed to use all (or none in the case of a ref call) of the alleles,\n+        // then we can keep the SACs as is; otherwise, we determine which ones to keep\n+        if (alleleIndexesToUse.cardinality() == alleleIndexesToUse.size()) {\n+            return null;\n+        }\n+\n+        return getSACIndexes(alleleIndexesToUse);\n+    }\n+\n+    /**\n+     * Get the actual strand aleele counts indexes to use given the corresponding allele indexes\n+     *\n+     * @param alleleIndexesToUse    the bitset representing the alleles to use (@see #getAlleleIndexBitset)\n+     * @return a non-null List\n+     */\n+    private static List<Integer> getSACIndexes(final BitSet alleleIndexesToUse) {\n+\n+        Utils.nonNull(alleleIndexesToUse, \"Alleles to use is null\");\n+        if (alleleIndexesToUse.isEmpty()) throw new IllegalArgumentException(\"cannot have no alleles to use\");\n+\n+        final List<Integer> result = new ArrayList<>(2 * alleleIndexesToUse.size());\n+\n+        for (int SACindex = 0; SACindex < alleleIndexesToUse.size(); SACindex++) {\n+            if (alleleIndexesToUse.get(SACindex)) {\n+                result.add(2 * SACindex);\n+                result.add(2 * SACindex + 1);\n+            }\n+        }\n+\n+        return result;\n+    }\n+\n+    /**\n+     * Make a new SAC array from the a subset of the genotype's original SAC\n+     *\n+     * @param g               the genotype\n+     * @param sacIndexesToUse the indexes in the SAC to use given the allelesToUse (@see #determineSACIndexesToUse())\n+     * @return subset of SACs from the original genotype, the original SACs if sacIndexesToUse is null\n+     */\n+    public static int[] makeNewSACs(final Genotype g, final List<Integer> sacIndexesToUse) {\n+\n+        Utils.nonNull(g, \"Genotype is null\");\n+\n+        final int[] oldSACs  = getSACs(g);\n+\n+        if (sacIndexesToUse == null) {\n+            return oldSACs;\n+        } else {\n+            final int[] newSACs = new int[sacIndexesToUse.size()];\n+            int newIndex = 0;\n+            for (final int oldIndex : sacIndexesToUse) {\n+                newSACs[newIndex++] = oldSACs[oldIndex];\n+            }\n+            return newSACs;\n+        }\n+    }\n+\n+    /**\n+     * Get the genotype SACs\n+     *\n+     * @param g the genotype\n+     * @return an arrays of SACs\n+     * @throws GATKException if the type of the SACs is unexpected\n+     */\n+    private static int[] getSACs(final Genotype g) {\n+\n+        Utils.nonNull(g, \"Genotype is null\");","path":"src/main/java/org/broadinstitute/hellbender/utils/variant/GATKVariantContextUtils.java","position":529,"original_position":529,"commit_id":"6e4b25ff7875089442a935ea8fcfffabb876245e","original_commit_id":"6e4b25ff7875089442a935ea8fcfffabb876245e","user":{"login":"ronlevine","id":8916428,"avatar_url":"https://avatars.githubusercontent.com/u/8916428?v=3","gravatar_id":"","url":"https://api.github.com/users/ronlevine","html_url":"https://github.com/ronlevine","followers_url":"https://api.github.com/users/ronlevine/followers","following_url":"https://api.github.com/users/ronlevine/following{/other_user}","gists_url":"https://api.github.com/users/ronlevine/gists{/gist_id}","starred_url":"https://api.github.com/users/ronlevine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ronlevine/subscriptions","organizations_url":"https://api.github.com/users/ronlevine/orgs","repos_url":"https://api.github.com/users/ronlevine/repos","events_url":"https://api.github.com/users/ronlevine/events{/privacy}","received_events_url":"https://api.github.com/users/ronlevine/received_events","type":"User","site_admin":false},"body":"Done","created_at":"2016-08-08T17:53:41Z","updated_at":"2016-08-08T17:53:41Z","html_url":"https://github.com/broadinstitute/gatk/pull/1852#discussion_r73921476","pull_request_url":"https://api.github.com/repos/broadinstitute/gatk/pulls/1852","_links":{"self":{"href":"https://api.github.com/repos/broadinstitute/gatk/pulls/comments/73921476"},"html":{"href":"https://github.com/broadinstitute/gatk/pull/1852#discussion_r73921476"},"pull_request":{"href":"https://api.github.com/repos/broadinstitute/gatk/pulls/1852"}}},"pull_request":{"url":"https://api.github.com/repos/broadinstitute/gatk/pulls/1852","id":71264734,"html_url":"https://github.com/broadinstitute/gatk/pull/1852","diff_url":"https://github.com/broadinstitute/gatk/pull/1852.diff","patch_url":"https://github.com/broadinstitute/gatk/pull/1852.patch","issue_url":"https://api.github.com/repos/broadinstitute/gatk/issues/1852","number":1852,"state":"open","locked":false,"title":"Subset Strand Allele Counts intelligently","user":{"login":"ronlevine","id":8916428,"avatar_url":"https://avatars.githubusercontent.com/u/8916428?v=3","gravatar_id":"","url":"https://api.github.com/users/ronlevine","html_url":"https://github.com/ronlevine","followers_url":"https://api.github.com/users/ronlevine/followers","following_url":"https://api.github.com/users/ronlevine/following{/other_user}","gists_url":"https://api.github.com/users/ronlevine/gists{/gist_id}","starred_url":"https://api.github.com/users/ronlevine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ronlevine/subscriptions","organizations_url":"https://api.github.com/users/ronlevine/orgs","repos_url":"https://api.github.com/users/ronlevine/repos","events_url":"https://api.github.com/users/ronlevine/events{/privacy}","received_events_url":"https://api.github.com/users/ronlevine/received_events","type":"User","site_admin":false},"body":"Implements #1552 \r\n\r\nWhen the StrandAlleleCountsBySample (SAC) annotation is present in VCFs, allele subsetting by SelectVariants will now update this field in the final VCF.\r\n\r\n**Summary of changes**\r\n* `SelectVariants.subsetRecord()` uses the updated `GATKVariantContextUtils.updatePLsSACsAD()`, which contains the machinery to subset SAC by the used alleles.\r\n* Added unit and integration tests.","created_at":"2016-05-24T17:56:38Z","updated_at":"2016-08-08T17:53:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c9e51ec093d49d6384917e9a9a4c5693ed19eb63","assignee":{"login":"ronlevine","id":8916428,"avatar_url":"https://avatars.githubusercontent.com/u/8916428?v=3","gravatar_id":"","url":"https://api.github.com/users/ronlevine","html_url":"https://github.com/ronlevine","followers_url":"https://api.github.com/users/ronlevine/followers","following_url":"https://api.github.com/users/ronlevine/following{/other_user}","gists_url":"https://api.github.com/users/ronlevine/gists{/gist_id}","starred_url":"https://api.github.com/users/ronlevine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ronlevine/subscriptions","organizations_url":"https://api.github.com/users/ronlevine/orgs","repos_url":"https://api.github.com/users/ronlevine/repos","events_url":"https://api.github.com/users/ronlevine/events{/privacy}","received_events_url":"https://api.github.com/users/ronlevine/received_events","type":"User","site_admin":false},"assignees":[{"login":"ronlevine","id":8916428,"avatar_url":"https://avatars.githubusercontent.com/u/8916428?v=3","gravatar_id":"","url":"https://api.github.com/users/ronlevine","html_url":"https://github.com/ronlevine","followers_url":"https://api.github.com/users/ronlevine/followers","following_url":"https://api.github.com/users/ronlevine/following{/other_user}","gists_url":"https://api.github.com/users/ronlevine/gists{/gist_id}","starred_url":"https://api.github.com/users/ronlevine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ronlevine/subscriptions","organizations_url":"https://api.github.com/users/ronlevine/orgs","repos_url":"https://api.github.com/users/ronlevine/repos","events_url":"https://api.github.com/users/ronlevine/events{/privacy}","received_events_url":"https://api.github.com/users/ronlevine/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/broadinstitute/gatk/pulls/1852/commits","review_comments_url":"https://api.github.com/repos/broadinstitute/gatk/pulls/1852/comments","review_comment_url":"https://api.github.com/repos/broadinstitute/gatk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/broadinstitute/gatk/issues/1852/comments","statuses_url":"https://api.github.com/repos/broadinstitute/gatk/statuses/6e4b25ff7875089442a935ea8fcfffabb876245e","head":{"label":"broadinstitute:rhl_subset_sac","ref":"rhl_subset_sac","sha":"6e4b25ff7875089442a935ea8fcfffabb876245e","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-08-07T02:28:39Z","pushed_at":"2016-08-08T17:20:59Z","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":123548,"stargazers_count":81,"watchers_count":81,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":30,"mirror_url":null,"open_issues_count":408,"forks":30,"open_issues":408,"watchers":81,"default_branch":"master"}},"base":{"label":"broadinstitute:master","ref":"master","sha":"3592a5803e2fd6422b722e49d140a9602f419cfb","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-08-07T02:28:39Z","pushed_at":"2016-08-08T17:20:59Z","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":123548,"stargazers_count":81,"watchers_count":81,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":30,"mirror_url":null,"open_issues_count":408,"forks":30,"open_issues":408,"watchers":81,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/broadinstitute/gatk/pulls/1852"},"html":{"href":"https://github.com/broadinstitute/gatk/pull/1852"},"issue":{"href":"https://api.github.com/repos/broadinstitute/gatk/issues/1852"},"comments":{"href":"https://api.github.com/repos/broadinstitute/gatk/issues/1852/comments"},"review_comments":{"href":"https://api.github.com/repos/broadinstitute/gatk/pulls/1852/comments"},"review_comment":{"href":"https://api.github.com/repos/broadinstitute/gatk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/broadinstitute/gatk/pulls/1852/commits"},"statuses":{"href":"https://api.github.com/repos/broadinstitute/gatk/statuses/6e4b25ff7875089442a935ea8fcfffabb876245e"}}}}
{"actor":{"display_login":"ronlevine"}}