{"action":"created","comment":{"url":"https://api.github.com/repos/icgc-dcc/dcc-portal/pulls/comments/88023313","pull_request_review_id":8609335,"id":88023313,"diff_hunk":"@@ -99,42 +99,48 @@\n       return result;\n     }\n \n-    function transformMutations(mutations, transcriptId) {\n-      var result = [], fiFilter = [];\n-      var filters = LocationService.filters();\n-\n-      if (mutations.hits) {\n-        mutations.hits.forEach(function (mutation) {\n-          var transcript = _.find(mutation.transcripts, function (t) {\n-            return t.id === transcriptId;\n-          });\n-          var start = transcript.consequence.aaMutation.replace(/[^\\d]/g, '');\n-\n-          if (start > 0) {\n-            var m = {\n-              id: transcript.consequence.aaMutation,\n-              position: start,\n-              value: mutation.affectedDonorCountTotal,\n-              ref: mutation.id,\n-            };\n-\n-            // Add function impact scores\n-            if (transcript.functionalImpact) {\n-              m.functionalImpact = transcript.functionalImpact || 'Unknown';\n-            }\n-\n-            if (filters.mutation && filters.mutation.functionalImpact) {\n-              fiFilter = filters.mutation.functionalImpact.is;\n-              if (fiFilter.indexOf(m.functionalImpact) >= 0) {\n-                result.push(m);\n-              }\n-            } else {\n-              result.push(m);\n-            }\n-\n+    /**\n+     * Push data to results if matches functional impact criteria of filter \n+     */\n+    function pushResults(data, filters, result) {\n+      var start = data.transcript.consequence.aaMutation.replace(/[^\\d]/g, '');\n+      if (start > 0) {\n+        var m = {\n+          id: data.transcript.consequence.aaMutation,\n+          position: start,\n+          value: data.mutation.affectedDonorCountTotal,\n+          ref: data.mutation.id,\n+        };\n+\n+        // Add function impact scores\n+        if (data.transcript.functionalImpact) {\n+          m.functionalImpact = data.transcript.functionalImpact || 'Unknown';\n+        }\n+        if (filters.mutation && filters.mutation.functionalImpact) {\n+          var fiFilter = filters.mutation.functionalImpact.is;\n+          if (fiFilter.indexOf(m.functionalImpact) >= 0) {\n+            result.push(m);\n           }\n-        });\n+        } else {\n+          result.push(m);\n+        }\n       }\n+    }\n+\n+    /**\n+     * Transforms mutation hits to results for protein vewier. \n+     */\n+    function transformMutations(mutations, transcriptId) {\n+      var result = [], filters = LocationService.filters();\n+\n+      _(mutations.hits)\n+        .map(hit => ({\n+            mutation: hit, \n+            transcript: _.find(hit.transcripts, {id: transcriptId})\n+          }))\n+        .filter( m => m.transcript !== undefined && m.transcript !== null )\n+        .forEach( data => pushResults(data, filters, result) ) // Push to result through side effect ","path":"dcc-portal-ui/app/scripts/proteinstructureviewer/js/directives.js","position":78,"original_position":78,"commit_id":"0938be04ddc32379401e16575cdbf91f04009b5e","original_commit_id":"0938be04ddc32379401e16575cdbf91f04009b5e","user":{"login":"btiernay","id":2717578,"avatar_url":"https://avatars.githubusercontent.com/u/2717578?v=3","gravatar_id":"","url":"https://api.github.com/users/btiernay","html_url":"https://github.com/btiernay","followers_url":"https://api.github.com/users/btiernay/followers","following_url":"https://api.github.com/users/btiernay/following{/other_user}","gists_url":"https://api.github.com/users/btiernay/gists{/gist_id}","starred_url":"https://api.github.com/users/btiernay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/btiernay/subscriptions","organizations_url":"https://api.github.com/users/btiernay/orgs","repos_url":"https://api.github.com/users/btiernay/repos","events_url":"https://api.github.com/users/btiernay/events{/privacy}","received_events_url":"https://api.github.com/users/btiernay/received_events","type":"User","site_admin":false},"body":"Why mutate? Why not flat map?","created_at":"2016-11-15T14:13:22Z","updated_at":"2016-11-15T14:13:22Z","html_url":"https://github.com/icgc-dcc/dcc-portal/pull/233#discussion_r88023313","pull_request_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/pulls/233","_links":{"self":{"href":"https://api.github.com/repos/icgc-dcc/dcc-portal/pulls/comments/88023313"},"html":{"href":"https://github.com/icgc-dcc/dcc-portal/pull/233#discussion_r88023313"},"pull_request":{"href":"https://api.github.com/repos/icgc-dcc/dcc-portal/pulls/233"}}},"pull_request":{"url":"https://api.github.com/repos/icgc-dcc/dcc-portal/pulls/233","id":93638705,"html_url":"https://github.com/icgc-dcc/dcc-portal/pull/233","diff_url":"https://github.com/icgc-dcc/dcc-portal/pull/233.diff","patch_url":"https://github.com/icgc-dcc/dcc-portal/pull/233.patch","issue_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/issues/233","number":233,"state":"open","locked":false,"title":"Feature/dccprtl 8 pv endpoint","user":{"login":"andricDu","id":6350043,"avatar_url":"https://avatars.githubusercontent.com/u/6350043?v=3","gravatar_id":"","url":"https://api.github.com/users/andricDu","html_url":"https://github.com/andricDu","followers_url":"https://api.github.com/users/andricDu/followers","following_url":"https://api.github.com/users/andricDu/following{/other_user}","gists_url":"https://api.github.com/users/andricDu/gists{/gist_id}","starred_url":"https://api.github.com/users/andricDu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andricDu/subscriptions","organizations_url":"https://api.github.com/users/andricDu/orgs","repos_url":"https://api.github.com/users/andricDu/repos","events_url":"https://api.github.com/users/andricDu/events{/privacy}","received_events_url":"https://api.github.com/users/andricDu/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-14T20:11:56Z","updated_at":"2016-11-15T14:13:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f5f5b4f255185d1122f68ae04a17c0db01f2a7cd","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/pulls/233/commits","review_comments_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/pulls/233/comments","review_comment_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/pulls/comments{/number}","comments_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/issues/233/comments","statuses_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/statuses/0938be04ddc32379401e16575cdbf91f04009b5e","head":{"label":"icgc-dcc:feature/DCCPRTL-8-pv-endpoint","ref":"feature/DCCPRTL-8-pv-endpoint","sha":"0938be04ddc32379401e16575cdbf91f04009b5e","user":{"login":"icgc-dcc","id":1508638,"avatar_url":"https://avatars.githubusercontent.com/u/1508638?v=3","gravatar_id":"","url":"https://api.github.com/users/icgc-dcc","html_url":"https://github.com/icgc-dcc","followers_url":"https://api.github.com/users/icgc-dcc/followers","following_url":"https://api.github.com/users/icgc-dcc/following{/other_user}","gists_url":"https://api.github.com/users/icgc-dcc/gists{/gist_id}","starred_url":"https://api.github.com/users/icgc-dcc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/icgc-dcc/subscriptions","organizations_url":"https://api.github.com/users/icgc-dcc/orgs","repos_url":"https://api.github.com/users/icgc-dcc/repos","events_url":"https://api.github.com/users/icgc-dcc/events{/privacy}","received_events_url":"https://api.github.com/users/icgc-dcc/received_events","type":"Organization","site_admin":false},"repo":{"id":62242110,"name":"dcc-portal","full_name":"icgc-dcc/dcc-portal","owner":{"login":"icgc-dcc","id":1508638,"avatar_url":"https://avatars.githubusercontent.com/u/1508638?v=3","gravatar_id":"","url":"https://api.github.com/users/icgc-dcc","html_url":"https://github.com/icgc-dcc","followers_url":"https://api.github.com/users/icgc-dcc/followers","following_url":"https://api.github.com/users/icgc-dcc/following{/other_user}","gists_url":"https://api.github.com/users/icgc-dcc/gists{/gist_id}","starred_url":"https://api.github.com/users/icgc-dcc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/icgc-dcc/subscriptions","organizations_url":"https://api.github.com/users/icgc-dcc/orgs","repos_url":"https://api.github.com/users/icgc-dcc/repos","events_url":"https://api.github.com/users/icgc-dcc/events{/privacy}","received_events_url":"https://api.github.com/users/icgc-dcc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/icgc-dcc/dcc-portal","description":"Data portal for exploring and accessing data","fork":false,"url":"https://api.github.com/repos/icgc-dcc/dcc-portal","forks_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/forks","keys_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/teams","hooks_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/hooks","issue_events_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/issues/events{/number}","events_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/events","assignees_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/assignees{/user}","branches_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/branches{/branch}","tags_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/tags","blobs_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/git/refs{/sha}","trees_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/statuses/{sha}","languages_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/languages","stargazers_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/stargazers","contributors_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/contributors","subscribers_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/subscribers","subscription_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/subscription","commits_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/commits{/sha}","git_commits_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/git/commits{/sha}","comments_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/comments{/number}","issue_comment_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/issues/comments{/number}","contents_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/contents/{+path}","compare_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/merges","archive_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/downloads","issues_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/issues{/number}","pulls_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/pulls{/number}","milestones_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/milestones{/number}","notifications_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/labels{/name}","releases_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/releases{/id}","deployments_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/deployments","created_at":"2016-06-29T16:44:10Z","updated_at":"2016-10-25T01:49:27Z","pushed_at":"2016-11-14T22:17:48Z","git_url":"git://github.com/icgc-dcc/dcc-portal.git","ssh_url":"git@github.com:icgc-dcc/dcc-portal.git","clone_url":"https://github.com/icgc-dcc/dcc-portal.git","svn_url":"https://github.com/icgc-dcc/dcc-portal","homepage":"https://dcc.icgc.org/","size":13842,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":7,"forks":3,"open_issues":7,"watchers":3,"default_branch":"develop"}},"base":{"label":"icgc-dcc:develop","ref":"develop","sha":"7488956dfb5dc21ab72c1df02eb0af00d9c603c9","user":{"login":"icgc-dcc","id":1508638,"avatar_url":"https://avatars.githubusercontent.com/u/1508638?v=3","gravatar_id":"","url":"https://api.github.com/users/icgc-dcc","html_url":"https://github.com/icgc-dcc","followers_url":"https://api.github.com/users/icgc-dcc/followers","following_url":"https://api.github.com/users/icgc-dcc/following{/other_user}","gists_url":"https://api.github.com/users/icgc-dcc/gists{/gist_id}","starred_url":"https://api.github.com/users/icgc-dcc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/icgc-dcc/subscriptions","organizations_url":"https://api.github.com/users/icgc-dcc/orgs","repos_url":"https://api.github.com/users/icgc-dcc/repos","events_url":"https://api.github.com/users/icgc-dcc/events{/privacy}","received_events_url":"https://api.github.com/users/icgc-dcc/received_events","type":"Organization","site_admin":false},"repo":{"id":62242110,"name":"dcc-portal","full_name":"icgc-dcc/dcc-portal","owner":{"login":"icgc-dcc","id":1508638,"avatar_url":"https://avatars.githubusercontent.com/u/1508638?v=3","gravatar_id":"","url":"https://api.github.com/users/icgc-dcc","html_url":"https://github.com/icgc-dcc","followers_url":"https://api.github.com/users/icgc-dcc/followers","following_url":"https://api.github.com/users/icgc-dcc/following{/other_user}","gists_url":"https://api.github.com/users/icgc-dcc/gists{/gist_id}","starred_url":"https://api.github.com/users/icgc-dcc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/icgc-dcc/subscriptions","organizations_url":"https://api.github.com/users/icgc-dcc/orgs","repos_url":"https://api.github.com/users/icgc-dcc/repos","events_url":"https://api.github.com/users/icgc-dcc/events{/privacy}","received_events_url":"https://api.github.com/users/icgc-dcc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/icgc-dcc/dcc-portal","description":"Data portal for exploring and accessing data","fork":false,"url":"https://api.github.com/repos/icgc-dcc/dcc-portal","forks_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/forks","keys_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/teams","hooks_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/hooks","issue_events_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/issues/events{/number}","events_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/events","assignees_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/assignees{/user}","branches_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/branches{/branch}","tags_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/tags","blobs_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/git/refs{/sha}","trees_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/statuses/{sha}","languages_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/languages","stargazers_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/stargazers","contributors_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/contributors","subscribers_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/subscribers","subscription_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/subscription","commits_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/commits{/sha}","git_commits_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/git/commits{/sha}","comments_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/comments{/number}","issue_comment_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/issues/comments{/number}","contents_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/contents/{+path}","compare_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/merges","archive_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/downloads","issues_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/issues{/number}","pulls_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/pulls{/number}","milestones_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/milestones{/number}","notifications_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/labels{/name}","releases_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/releases{/id}","deployments_url":"https://api.github.com/repos/icgc-dcc/dcc-portal/deployments","created_at":"2016-06-29T16:44:10Z","updated_at":"2016-10-25T01:49:27Z","pushed_at":"2016-11-14T22:17:48Z","git_url":"git://github.com/icgc-dcc/dcc-portal.git","ssh_url":"git@github.com:icgc-dcc/dcc-portal.git","clone_url":"https://github.com/icgc-dcc/dcc-portal.git","svn_url":"https://github.com/icgc-dcc/dcc-portal","homepage":"https://dcc.icgc.org/","size":13842,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":7,"forks":3,"open_issues":7,"watchers":3,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/icgc-dcc/dcc-portal/pulls/233"},"html":{"href":"https://github.com/icgc-dcc/dcc-portal/pull/233"},"issue":{"href":"https://api.github.com/repos/icgc-dcc/dcc-portal/issues/233"},"comments":{"href":"https://api.github.com/repos/icgc-dcc/dcc-portal/issues/233/comments"},"review_comments":{"href":"https://api.github.com/repos/icgc-dcc/dcc-portal/pulls/233/comments"},"review_comment":{"href":"https://api.github.com/repos/icgc-dcc/dcc-portal/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/icgc-dcc/dcc-portal/pulls/233/commits"},"statuses":{"href":"https://api.github.com/repos/icgc-dcc/dcc-portal/statuses/0938be04ddc32379401e16575cdbf91f04009b5e"}}}}
{"actor":{"display_login":"btiernay"}}