{"action":"created","comment":{"url":"https://api.github.com/repos/broadinstitute/picard/pulls/comments/53530496","id":53530496,"diff_hunk":"@@ -131,4 +160,42 @@ private boolean isVcfOrBcf(final File file) {\n         final String fileName = file.getName();\n         return fileName.endsWith(\".vcf\") || fileName.endsWith(\".bcf\");\n     }\n+    \n+    /** Javascript filter implementing VariantFilter */\n+    private static class VariantContextJavascriptFilter\n+            extends JavascriptVariantFilter\n+            implements VariantFilter {\n+        /** filter name */\n+        private final String filterName;\n+        /** script file */\n+        private final File scriptFile;\n+        private VariantContextJavascriptFilter(final File scriptFile, final VCFHeader header) throws IOException {","path":"src/java/picard/vcf/filter/FilterVcf.java","position":101,"original_position":101,"commit_id":"c14b76dc13adf008e8f69848825530c429ab460d","original_commit_id":"c14b76dc13adf008e8f69848825530c429ab460d","user":{"login":"lbergelson","id":4700332,"avatar_url":"https://avatars.githubusercontent.com/u/4700332?v=3","gravatar_id":"","url":"https://api.github.com/users/lbergelson","html_url":"https://github.com/lbergelson","followers_url":"https://api.github.com/users/lbergelson/followers","following_url":"https://api.github.com/users/lbergelson/following{/other_user}","gists_url":"https://api.github.com/users/lbergelson/gists{/gist_id}","starred_url":"https://api.github.com/users/lbergelson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lbergelson/subscriptions","organizations_url":"https://api.github.com/users/lbergelson/orgs","repos_url":"https://api.github.com/users/lbergelson/repos","events_url":"https://api.github.com/users/lbergelson/events{/privacy}","received_events_url":"https://api.github.com/users/lbergelson/received_events","type":"User","site_admin":false},"body":"probably want another newline between scriptFile and here","created_at":"2016-02-19T22:53:11Z","updated_at":"2016-02-19T22:53:11Z","html_url":"https://github.com/broadinstitute/picard/pull/335#discussion_r53530496","pull_request_url":"https://api.github.com/repos/broadinstitute/picard/pulls/335","_links":{"self":{"href":"https://api.github.com/repos/broadinstitute/picard/pulls/comments/53530496"},"html":{"href":"https://github.com/broadinstitute/picard/pull/335#discussion_r53530496"},"pull_request":{"href":"https://api.github.com/repos/broadinstitute/picard/pulls/335"}}},"pull_request":{"url":"https://api.github.com/repos/broadinstitute/picard/pulls/335","id":50174651,"html_url":"https://github.com/broadinstitute/picard/pull/335","diff_url":"https://github.com/broadinstitute/picard/pull/335.diff","patch_url":"https://github.com/broadinstitute/picard/pull/335.patch","issue_url":"https://api.github.com/repos/broadinstitute/picard/issues/335","number":335,"state":"open","locked":false,"title":"Javascript filters for SAM and VCF","user":{"login":"lindenb","id":33838,"avatar_url":"https://avatars.githubusercontent.com/u/33838?v=3","gravatar_id":"","url":"https://api.github.com/users/lindenb","html_url":"https://github.com/lindenb","followers_url":"https://api.github.com/users/lindenb/followers","following_url":"https://api.github.com/users/lindenb/following{/other_user}","gists_url":"https://api.github.com/users/lindenb/gists{/gist_id}","starred_url":"https://api.github.com/users/lindenb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lindenb/subscriptions","organizations_url":"https://api.github.com/users/lindenb/orgs","repos_url":"https://api.github.com/users/lindenb/repos","events_url":"https://api.github.com/users/lindenb/events{/privacy}","received_events_url":"https://api.github.com/users/lindenb/received_events","type":"User","site_admin":false},"body":"I wrote two related tools filtering SAM/VCF using ù*javascript** expressions and the JDK embedded javascript engine:\r\n\r\n* src/java/picard/sam/SamFilterJavascript.java : is a picard version of my tool SAMJS https://github.com/lindenb/jvarkit/wiki/SamJS \r\n\r\n> Filters a SAM or BAM file with a javascript expression.  The script puts the following variables in the script context:  'record' a SamRecord ( https://samtools.github.io/htsjdk/javadoc/htsjdk/htsjdk/samtools/SAMRecord.html ) and  'header' a SAMFileHeader ( https://samtools.github.io/htsjdk/javadoc/htsjdk/htsjdk/samtools/SAMFileHeader.html ). Last value of the script should be a boolean to tell wether we should accept or reject the record.\r\n\r\n```\r\nINPUT=String\r\nI=String                      The SAM or BAM file  Required. \r\n\r\nOUTPUT=File\r\nO=File                        Output BAM file.  Required. \r\n\r\nJAVASCRIPT_FILE=File\r\nF=File                        javascript file  Default value: null. \r\n\r\nJAVASCRIPT_EXPRESSION=String\r\nE=String                      javascript expression  Default value: null. \r\n```\r\n\r\nExample:\r\n\r\n```\r\njava -jar dist/picard.jar SamFilterJavascript I=testdata/picard/sam/aligned.sam O=jeter.sam E='record.getStart()%3==0'\r\n\r\n```\r\n\r\nsrc/java/picard/vcf/VcfFilterJavascript.java : is a picard version of my tool VCFFILTERJS https://github.com/lindenb/jvarkit/wiki/VCFFilterJS\r\n\r\n\r\n> Filters a VCF file with a javascript expression.  The script puts the following variables in the script context:  'variant' a VariantContext ( https://samtools.github.io/htsjdk/javadoc/htsjdk/htsjdk/variant/variantcontext/VariantContext.html ) and  'header' a VCFHeader ( https://samtools.github.io/htsjdk/javadoc/htsjdk/htsjdk/variant/vcf/VCFHeader.html ). Last value of the script should be a boolean to tell wether we should accept or reject the record.\r\n\r\n\r\n```\r\n(...)INPUT=File\r\nI=File                        Input file for analysis  Required. \r\n\r\nOUTPUT=File\r\nO=File                        Output file.  Required. \r\n\r\nJAVASCRIPT_FILE=File\r\nF=File                        javascript file  Default value: null. \r\n\r\nJAVASCRIPT_EXPRESSION=String\r\nE=String                      javascript expression  Default value: null. \r\n```\r\n\r\nexample:\r\n\r\n```\r\n$ java -jar dist/picard.jar VcfFilterJavascript  I=testdata/picard/vcf/CEUTrio-snps.vcf O=jeter.vcf E='variant.isSNP() && variant.getStart()%2==0'\r\n[Mon Nov 09 21:35:59 CET 2015] picard.vcf.VcfFilterJavascript INPUT=testdata/picard/vcf/CEUTrio-snps.vcf OUTPUT=jeter.vcf JAVASCRIPT_EXPRESSION=variant.isSNP() && variant.getStart()%2==0    VERBOSITY=INFO QUIET=false VALIDATION_STRINGENCY=STRICT COMPRESSION_LEVEL=5 MAX_RECORDS_IN_RAM=500000 CREATE_INDEX=false CREATE_MD5_FILE=false GA4GH_CLIENT_SECRETS=client_secrets.json\r\n[Mon Nov 09 21:35:59 CET 2015] Executing as lindenb@bird on Linux 3.16.0-52-generic i386; Java HotSpot(TM) Server VM 1.8.0_51-b16; Picard version: 1.140(6a4a5d0088bfa4d84985465b966181596cf621b2_1447100655) JdkDeflater\r\nINFO\t2015-11-09 21:36:00\tAbstractJavascriptFilterProgram\tCompiling variant.isSNP() && variant.getStart()%2==0\r\n[Mon Nov 09 21:36:00 CET 2015] picard.vcf.VcfFilterJavascript done. Elapsed time: 0.01 minutes.\r\nRuntime.totalMemory()=64487424\r\n```\r\n\r\nI wrote some tests for both programs.","created_at":"2015-11-09T20:42:58Z","updated_at":"2016-02-19T22:53:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4e5b154242766a89623e41d3541e54650897b93c","assignee":{"login":"lbergelson","id":4700332,"avatar_url":"https://avatars.githubusercontent.com/u/4700332?v=3","gravatar_id":"","url":"https://api.github.com/users/lbergelson","html_url":"https://github.com/lbergelson","followers_url":"https://api.github.com/users/lbergelson/followers","following_url":"https://api.github.com/users/lbergelson/following{/other_user}","gists_url":"https://api.github.com/users/lbergelson/gists{/gist_id}","starred_url":"https://api.github.com/users/lbergelson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lbergelson/subscriptions","organizations_url":"https://api.github.com/users/lbergelson/orgs","repos_url":"https://api.github.com/users/lbergelson/repos","events_url":"https://api.github.com/users/lbergelson/events{/privacy}","received_events_url":"https://api.github.com/users/lbergelson/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/broadinstitute/picard/pulls/335/commits","review_comments_url":"https://api.github.com/repos/broadinstitute/picard/pulls/335/comments","review_comment_url":"https://api.github.com/repos/broadinstitute/picard/pulls/comments{/number}","comments_url":"https://api.github.com/repos/broadinstitute/picard/issues/335/comments","statuses_url":"https://api.github.com/repos/broadinstitute/picard/statuses/c14b76dc13adf008e8f69848825530c429ab460d","head":{"label":"lindenb:javascript","ref":"javascript","sha":"c14b76dc13adf008e8f69848825530c429ab460d","user":{"login":"lindenb","id":33838,"avatar_url":"https://avatars.githubusercontent.com/u/33838?v=3","gravatar_id":"","url":"https://api.github.com/users/lindenb","html_url":"https://github.com/lindenb","followers_url":"https://api.github.com/users/lindenb/followers","following_url":"https://api.github.com/users/lindenb/following{/other_user}","gists_url":"https://api.github.com/users/lindenb/gists{/gist_id}","starred_url":"https://api.github.com/users/lindenb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lindenb/subscriptions","organizations_url":"https://api.github.com/users/lindenb/orgs","repos_url":"https://api.github.com/users/lindenb/repos","events_url":"https://api.github.com/users/lindenb/events{/privacy}","received_events_url":"https://api.github.com/users/lindenb/received_events","type":"User","site_admin":false},"repo":{"id":29185695,"name":"picard","full_name":"lindenb/picard","owner":{"login":"lindenb","id":33838,"avatar_url":"https://avatars.githubusercontent.com/u/33838?v=3","gravatar_id":"","url":"https://api.github.com/users/lindenb","html_url":"https://github.com/lindenb","followers_url":"https://api.github.com/users/lindenb/followers","following_url":"https://api.github.com/users/lindenb/following{/other_user}","gists_url":"https://api.github.com/users/lindenb/gists{/gist_id}","starred_url":"https://api.github.com/users/lindenb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lindenb/subscriptions","organizations_url":"https://api.github.com/users/lindenb/orgs","repos_url":"https://api.github.com/users/lindenb/repos","events_url":"https://api.github.com/users/lindenb/events{/privacy}","received_events_url":"https://api.github.com/users/lindenb/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lindenb/picard","description":"A set of tools (in Java) for working with next generation sequencing data in the BAM (http://samtools.github.io/hts-specs) format.","fork":true,"url":"https://api.github.com/repos/lindenb/picard","forks_url":"https://api.github.com/repos/lindenb/picard/forks","keys_url":"https://api.github.com/repos/lindenb/picard/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lindenb/picard/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lindenb/picard/teams","hooks_url":"https://api.github.com/repos/lindenb/picard/hooks","issue_events_url":"https://api.github.com/repos/lindenb/picard/issues/events{/number}","events_url":"https://api.github.com/repos/lindenb/picard/events","assignees_url":"https://api.github.com/repos/lindenb/picard/assignees{/user}","branches_url":"https://api.github.com/repos/lindenb/picard/branches{/branch}","tags_url":"https://api.github.com/repos/lindenb/picard/tags","blobs_url":"https://api.github.com/repos/lindenb/picard/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lindenb/picard/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lindenb/picard/git/refs{/sha}","trees_url":"https://api.github.com/repos/lindenb/picard/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lindenb/picard/statuses/{sha}","languages_url":"https://api.github.com/repos/lindenb/picard/languages","stargazers_url":"https://api.github.com/repos/lindenb/picard/stargazers","contributors_url":"https://api.github.com/repos/lindenb/picard/contributors","subscribers_url":"https://api.github.com/repos/lindenb/picard/subscribers","subscription_url":"https://api.github.com/repos/lindenb/picard/subscription","commits_url":"https://api.github.com/repos/lindenb/picard/commits{/sha}","git_commits_url":"https://api.github.com/repos/lindenb/picard/git/commits{/sha}","comments_url":"https://api.github.com/repos/lindenb/picard/comments{/number}","issue_comment_url":"https://api.github.com/repos/lindenb/picard/issues/comments{/number}","contents_url":"https://api.github.com/repos/lindenb/picard/contents/{+path}","compare_url":"https://api.github.com/repos/lindenb/picard/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lindenb/picard/merges","archive_url":"https://api.github.com/repos/lindenb/picard/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lindenb/picard/downloads","issues_url":"https://api.github.com/repos/lindenb/picard/issues{/number}","pulls_url":"https://api.github.com/repos/lindenb/picard/pulls{/number}","milestones_url":"https://api.github.com/repos/lindenb/picard/milestones{/number}","notifications_url":"https://api.github.com/repos/lindenb/picard/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lindenb/picard/labels{/name}","releases_url":"https://api.github.com/repos/lindenb/picard/releases{/id}","deployments_url":"https://api.github.com/repos/lindenb/picard/deployments","created_at":"2015-01-13T10:52:09Z","updated_at":"2016-01-30T21:45:45Z","pushed_at":"2016-01-31T12:11:08Z","git_url":"git://github.com/lindenb/picard.git","ssh_url":"git@github.com:lindenb/picard.git","clone_url":"https://github.com/lindenb/picard.git","svn_url":"https://github.com/lindenb/picard","homepage":"http://broadinstitute.github.io/picard/","size":42468,"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":"c4d743a9e093c3bcc6c4777ea8490e990115f28d","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":18225913,"name":"picard","full_name":"broadinstitute/picard","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/picard","description":"A set of command line tools (in Java) for manipulating high-throughput sequencing (HTS) data and formats such as SAM/BAM/CRAM and VCF.","fork":false,"url":"https://api.github.com/repos/broadinstitute/picard","forks_url":"https://api.github.com/repos/broadinstitute/picard/forks","keys_url":"https://api.github.com/repos/broadinstitute/picard/keys{/key_id}","collaborators_url":"https://api.github.com/repos/broadinstitute/picard/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/broadinstitute/picard/teams","hooks_url":"https://api.github.com/repos/broadinstitute/picard/hooks","issue_events_url":"https://api.github.com/repos/broadinstitute/picard/issues/events{/number}","events_url":"https://api.github.com/repos/broadinstitute/picard/events","assignees_url":"https://api.github.com/repos/broadinstitute/picard/assignees{/user}","branches_url":"https://api.github.com/repos/broadinstitute/picard/branches{/branch}","tags_url":"https://api.github.com/repos/broadinstitute/picard/tags","blobs_url":"https://api.github.com/repos/broadinstitute/picard/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/broadinstitute/picard/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/broadinstitute/picard/git/refs{/sha}","trees_url":"https://api.github.com/repos/broadinstitute/picard/git/trees{/sha}","statuses_url":"https://api.github.com/repos/broadinstitute/picard/statuses/{sha}","languages_url":"https://api.github.com/repos/broadinstitute/picard/languages","stargazers_url":"https://api.github.com/repos/broadinstitute/picard/stargazers","contributors_url":"https://api.github.com/repos/broadinstitute/picard/contributors","subscribers_url":"https://api.github.com/repos/broadinstitute/picard/subscribers","subscription_url":"https://api.github.com/repos/broadinstitute/picard/subscription","commits_url":"https://api.github.com/repos/broadinstitute/picard/commits{/sha}","git_commits_url":"https://api.github.com/repos/broadinstitute/picard/git/commits{/sha}","comments_url":"https://api.github.com/repos/broadinstitute/picard/comments{/number}","issue_comment_url":"https://api.github.com/repos/broadinstitute/picard/issues/comments{/number}","contents_url":"https://api.github.com/repos/broadinstitute/picard/contents/{+path}","compare_url":"https://api.github.com/repos/broadinstitute/picard/compare/{base}...{head}","merges_url":"https://api.github.com/repos/broadinstitute/picard/merges","archive_url":"https://api.github.com/repos/broadinstitute/picard/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/broadinstitute/picard/downloads","issues_url":"https://api.github.com/repos/broadinstitute/picard/issues{/number}","pulls_url":"https://api.github.com/repos/broadinstitute/picard/pulls{/number}","milestones_url":"https://api.github.com/repos/broadinstitute/picard/milestones{/number}","notifications_url":"https://api.github.com/repos/broadinstitute/picard/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/broadinstitute/picard/labels{/name}","releases_url":"https://api.github.com/repos/broadinstitute/picard/releases{/id}","deployments_url":"https://api.github.com/repos/broadinstitute/picard/deployments","created_at":"2014-03-28T20:43:35Z","updated_at":"2016-02-19T12:38:57Z","pushed_at":"2016-02-19T20:46:36Z","git_url":"git://github.com/broadinstitute/picard.git","ssh_url":"git@github.com:broadinstitute/picard.git","clone_url":"https://github.com/broadinstitute/picard.git","svn_url":"https://github.com/broadinstitute/picard","homepage":"http://broadinstitute.github.io/picard/","size":58384,"stargazers_count":150,"watchers_count":150,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":102,"mirror_url":null,"open_issues_count":63,"forks":102,"open_issues":63,"watchers":150,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/broadinstitute/picard/pulls/335"},"html":{"href":"https://github.com/broadinstitute/picard/pull/335"},"issue":{"href":"https://api.github.com/repos/broadinstitute/picard/issues/335"},"comments":{"href":"https://api.github.com/repos/broadinstitute/picard/issues/335/comments"},"review_comments":{"href":"https://api.github.com/repos/broadinstitute/picard/pulls/335/comments"},"review_comment":{"href":"https://api.github.com/repos/broadinstitute/picard/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/broadinstitute/picard/pulls/335/commits"},"statuses":{"href":"https://api.github.com/repos/broadinstitute/picard/statuses/c14b76dc13adf008e8f69848825530c429ab460d"}}}}