{"action":"created","comment":{"url":"https://api.github.com/repos/ga4gh/server/pulls/comments/41491387","id":41491387,"diff_hunk":"@@ -0,0 +1,338 @@\n+\"\"\"\n+Module responsible for translating g2p data into GA4GH native\n+objects.\n+\"\"\"\n+\n+import ga4gh.protocol as protocol\n+import ga4gh.exceptions as exceptions\n+from urlparse import urlparse, urlunsplit\n+import rdflib","path":"ga4gh/datamodel/genotype_phenotype.py","position":9,"original_position":9,"commit_id":"c10e4db19e3677d56a3f09691f8d7afe461e3ae6","original_commit_id":"c10e4db19e3677d56a3f09691f8d7afe461e3ae6","user":{"login":"jeromekelleher","id":2664569,"avatar_url":"https://avatars.githubusercontent.com/u/2664569?v=3","gravatar_id":"","url":"https://api.github.com/users/jeromekelleher","html_url":"https://github.com/jeromekelleher","followers_url":"https://api.github.com/users/jeromekelleher/followers","following_url":"https://api.github.com/users/jeromekelleher/following{/other_user}","gists_url":"https://api.github.com/users/jeromekelleher/gists{/gist_id}","starred_url":"https://api.github.com/users/jeromekelleher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeromekelleher/subscriptions","organizations_url":"https://api.github.com/users/jeromekelleher/orgs","repos_url":"https://api.github.com/users/jeromekelleher/repos","events_url":"https://api.github.com/users/jeromekelleher/events{/privacy}","received_events_url":"https://api.github.com/users/jeromekelleher/received_events","type":"User","site_admin":false},"body":"We need to add rdflib to requirements.txt","created_at":"2015-10-08T09:09:33Z","updated_at":"2015-10-08T09:09:33Z","html_url":"https://github.com/ga4gh/server/pull/607#discussion_r41491387","pull_request_url":"https://api.github.com/repos/ga4gh/server/pulls/607","_links":{"self":{"href":"https://api.github.com/repos/ga4gh/server/pulls/comments/41491387"},"html":{"href":"https://github.com/ga4gh/server/pull/607#discussion_r41491387"},"pull_request":{"href":"https://api.github.com/repos/ga4gh/server/pulls/607"}}},"pull_request":{"url":"https://api.github.com/repos/ga4gh/server/pulls/607","id":44175327,"html_url":"https://github.com/ga4gh/server/pull/607","diff_url":"https://github.com/ga4gh/server/pull/607.diff","patch_url":"https://github.com/ga4gh/server/pull/607.patch","issue_url":"https://api.github.com/repos/ga4gh/server/issues/607","number":607,"state":"open","locked":false,"title":"G2P '/genotypephenotype/search' endpoint","user":{"login":"bwalsh","id":47808,"avatar_url":"https://avatars.githubusercontent.com/u/47808?v=3","gravatar_id":"","url":"https://api.github.com/users/bwalsh","html_url":"https://github.com/bwalsh","followers_url":"https://api.github.com/users/bwalsh/followers","following_url":"https://api.github.com/users/bwalsh/following{/other_user}","gists_url":"https://api.github.com/users/bwalsh/gists{/gist_id}","starred_url":"https://api.github.com/users/bwalsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bwalsh/subscriptions","organizations_url":"https://api.github.com/users/bwalsh/orgs","repos_url":"https://api.github.com/users/bwalsh/repos","events_url":"https://api.github.com/users/bwalsh/events{/privacy}","received_events_url":"https://api.github.com/users/bwalsh/received_events","type":"User","site_admin":false},"body":"## Summary\r\nWe extended the GA4GH Reference server to include a the '/genotypephenotype/search' endpoint.  This document describes the work to date  \r\n\r\n## Approach\r\nWe based our work on the model captured in [ga4gh/schemas commit of Jul 30, 2015](https://github.com/ga4gh/schemas/tree/be171b00a5f164836dfd40ea5ae75ea56924d316).  This version of the schema predates the [separated genotype to phenotype files from baseline](https://github.com/ga4gh/schemas/commit/846b711fdcf544bf889cc7dbab19c6c48e9a9428).\r\n\r\nThe code was based on a [branch](https://github.com/ga4gh/server/tree/g2p) setup for this purpose by the server team.\r\nNo major refactoring of the server was needed, additional code was added to ga4gh/backend.py,ga4gh/frontend.py and test/unit/test_views.py.  A new model was created in datamodel/genotype_phenotype.py\r\n\r\n## Data\r\nThe cancer genome database [Clinical Genomics Knowledge Base](http://nif-crawler.neuinfo.org/monarch/ttl/cgd.ttl) published by the Monarch project was the source of Evidence.   \r\n\r\n\r\n![image](https://cloud.githubusercontent.com/assets/47808/9338065/a0a84b8e-4597-11e5-82ed-65d7b9f3ae97.png)\r\n\r\n\r\n## API\r\nThe GA4GH schemas define a single endpoint `/genotypephenotype/search` which accepts a POST of a [request body](https://github.com/ga4gh/schemas/blob/be171b00a5f164836dfd40ea5ae75ea56924d316/src/main/resources/avro/genotypephenotypemethods.avdl#L102)  containing one or more of [Feature](https://github.com/ga4gh/schemas/blob/be171b00a5f164836dfd40ea5ae75ea56924d316/src/main/resources/avro/sequenceAnnotations.avdl#L105), [PhenotypeInstance](https://github.com/ga4gh/schemas/blob/be171b00a5f164836dfd40ea5ae75ea56924d316/src/main/resources/avro/genotypephenotype.avdl#L77), [EnvironmentalContext](https://github.com/ga4gh/schemas/blob/be171b00a5f164836dfd40ea5ae75ea56924d316/src/main/resources/avro/genotypephenotype.avdl#L49), and [Evidence](https://github.com/ga4gh/schemas/blob/be171b00a5f164836dfd40ea5ae75ea56924d316/src/main/resources/avro/genotypephenotype.avdl#L113) which are combined as a logical AND to query the underlying datastore.  Missing types are treated as a `wildcard` returning all data.  Responses of matching data are returned as a list of  [FeaturePhenotypeAssociation](https://github.com/ga4gh/schemas/blob/be171b00a5f164836dfd40ea5ae75ea56924d316/src/main/resources/avro/genotypephenotype.avdl#L132).  All types rely heavily on [OntologyTerm](https://github.com/ga4gh/schemas/blob/be171b00a5f164836dfd40ea5ae75ea56924d316/src/main/resources/avro/ontologies.avdl#L10)\r\n\r\n### Request\r\n![image](https://cloud.githubusercontent.com/assets/47808/9643362/4e081ae0-5176-11e5-8550-abd9c7c43d23.png)\r\nhttp://yuml.me/edit/bf06b90a\r\n\r\n### Response\r\n![image](https://cloud.githubusercontent.com/assets/47808/9339152/53d42aca-459d-11e5-8c91-204f42dc233a.png)\r\n\r\nhttp://yuml.me/edit/25343da1\r\n\r\n----\r\n## Implementation\r\n\r\n![image](https://cloud.githubusercontent.com/assets/47808/9591417/18e1d2c0-4ff0-11e5-90b6-3d2d4f76d31e.png)\r\n\r\nhttp://yuml.me/c97fada2\r\n\r\n\r\n----\r\n## Issues \r\n\r\n### Query by example\r\n\r\nThere are four datatypes types for each entity [string, external identifier, ontology identifier and 'entity'].\r\nCurrently the implementation handles queries of [string, external identifier and ontology identifier].  \r\n\r\nThe  'entity' query is a type of query-by-example has been deferred.  Challenges that arose: \r\n\r\n* schema constraints:  there are several fields within the schemas that are defined as non-null. This may be fine when creating an entity from a data store, however, they are problematic when creating an entity to be used in a query.\r\n\r\n* additional discussions needed to determine what properties from an existing entity will be used for the query and which will be ignored.  For example [a Feature](https://github.com/ga4gh/schemas/blob/6725fb6653eb5642c0dc4884c82016db1c24c5c3/src/main/resources/avro/sequenceAnnotations.avdl#L105) has [id,parentIds, featureSetId, referenceName, start,end, strand, featureType, attributes]  we need to specify exactly what the query's expectations are.  \r\n\r\n*Recommendation:* Leave the schema definitions as-is.  However, leave the entity query-by-example unimplemented.  Implement when demand exists with sufficient use case details.\r\n\r\n \r\n### Name collision (SearchFeaturesResponse)\r\n\r\nThat schema contains two definitions of the class `[SearchFeaturesRequest,SearchFeaturesResponse]`.  These conflict in the generated code with other classes of the same name.\r\n\r\nThe schema project the current server is based on is  `version = '0.6.be171b00'`\r\nSnippets from this commit follow\r\n\r\n* One in the file genotypephenotypemethods.avdl,  protocol GenotypePhenotypeMethods\r\n```\r\n/** This is the response from `POST /genotypephenotype/search` expressed as JSON. */\r\nrecord SearchFeaturesResponse {\r\n  /**\r\n  The list of matching FeaturePhenotypeAssociation.\r\n  */\r\n  array<org.ga4gh.models.FeaturePhenotypeAssociation> associations = [];\r\n\r\n  ...\r\n```\r\n\r\n* The second one is found in sequenceAnnotationmethods.avdl \r\n```\r\n  /** This is the response from `POST /features/search` expressed as JSON. */\r\n  record SearchFeaturesResponse {\r\n    /**\r\n    The list of matching annotations, sorted by start position. Annotations which\r\n    share a start position are returned in a deterministic order.\r\n    */\r\n    array<org.ga4gh.models.Feature> features = [];\r\n\r\n    ... \r\n```\r\n\r\n* The generated code only has the class associated with `sequenceAnnotationmethods.avdl`\r\n \r\n\r\nBoth sequenceAnnotationmethods.avdl and genotypephenotypemethods.avdl share the same namespace `@namespace(\"org.ga4gh.methods\")` each file defines an enclosing `protocol`.\r\n\r\nIn the [names section of the spec](https://avro.apache.org/docs/1.7.7/spec.html#Names)\r\n\r\n```\r\nA name only is specified, i.e., a name that contains no dots. In this case the namespace is taken from the most tightly enclosing schema or protocol. For example, if \"name\": \"X\" is specified, and this occurs within a field of the record definition of org.foo.Y, then the fullname is org.foo.X. If there is no enclosing namespace then the null namespace is used.\r\n```\r\n\r\nThe schemas pass validation.\r\n```\r\nA schema or protocol may not contain multiple definitions of a fullname. Further, a name must be defined before it is used (\"before\" in the depth-first, left-to-right traversal of the JSON parse tree, where the types attribute of a protocol is always deemed to come \"before\" the messages attribute.)\r\n```\r\n\r\n*Recommendation:*  Rename the GenotypePhenotypeMethods [SearchFeaturesRequest,SearchFeaturesResponse] to [SearchGenotypePhenotypeRequest,SearchGenotypePhenotypeResponse]\r\n\r\n","created_at":"2015-09-04T01:20:44Z","updated_at":"2015-10-08T09:09:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"20afe2a164cedd104cec4627dfef0d728c7947b3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ga4gh/server/pulls/607/commits","review_comments_url":"https://api.github.com/repos/ga4gh/server/pulls/607/comments","review_comment_url":"https://api.github.com/repos/ga4gh/server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ga4gh/server/issues/607/comments","statuses_url":"https://api.github.com/repos/ga4gh/server/statuses/c10e4db19e3677d56a3f09691f8d7afe461e3ae6","head":{"label":"ohsu-computational-biology:g2p","ref":"g2p","sha":"c10e4db19e3677d56a3f09691f8d7afe461e3ae6","user":{"login":"ohsu-computational-biology","id":11467587,"avatar_url":"https://avatars.githubusercontent.com/u/11467587?v=3","gravatar_id":"","url":"https://api.github.com/users/ohsu-computational-biology","html_url":"https://github.com/ohsu-computational-biology","followers_url":"https://api.github.com/users/ohsu-computational-biology/followers","following_url":"https://api.github.com/users/ohsu-computational-biology/following{/other_user}","gists_url":"https://api.github.com/users/ohsu-computational-biology/gists{/gist_id}","starred_url":"https://api.github.com/users/ohsu-computational-biology/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ohsu-computational-biology/subscriptions","organizations_url":"https://api.github.com/users/ohsu-computational-biology/orgs","repos_url":"https://api.github.com/users/ohsu-computational-biology/repos","events_url":"https://api.github.com/users/ohsu-computational-biology/events{/privacy}","received_events_url":"https://api.github.com/users/ohsu-computational-biology/received_events","type":"Organization","site_admin":false},"repo":{"id":39584465,"name":"server","full_name":"ohsu-computational-biology/server","owner":{"login":"ohsu-computational-biology","id":11467587,"avatar_url":"https://avatars.githubusercontent.com/u/11467587?v=3","gravatar_id":"","url":"https://api.github.com/users/ohsu-computational-biology","html_url":"https://github.com/ohsu-computational-biology","followers_url":"https://api.github.com/users/ohsu-computational-biology/followers","following_url":"https://api.github.com/users/ohsu-computational-biology/following{/other_user}","gists_url":"https://api.github.com/users/ohsu-computational-biology/gists{/gist_id}","starred_url":"https://api.github.com/users/ohsu-computational-biology/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ohsu-computational-biology/subscriptions","organizations_url":"https://api.github.com/users/ohsu-computational-biology/orgs","repos_url":"https://api.github.com/users/ohsu-computational-biology/repos","events_url":"https://api.github.com/users/ohsu-computational-biology/events{/privacy}","received_events_url":"https://api.github.com/users/ohsu-computational-biology/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ohsu-computational-biology/server","description":"A reference implementation of the APIs defined in the schemas repository.","fork":true,"url":"https://api.github.com/repos/ohsu-computational-biology/server","forks_url":"https://api.github.com/repos/ohsu-computational-biology/server/forks","keys_url":"https://api.github.com/repos/ohsu-computational-biology/server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ohsu-computational-biology/server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ohsu-computational-biology/server/teams","hooks_url":"https://api.github.com/repos/ohsu-computational-biology/server/hooks","issue_events_url":"https://api.github.com/repos/ohsu-computational-biology/server/issues/events{/number}","events_url":"https://api.github.com/repos/ohsu-computational-biology/server/events","assignees_url":"https://api.github.com/repos/ohsu-computational-biology/server/assignees{/user}","branches_url":"https://api.github.com/repos/ohsu-computational-biology/server/branches{/branch}","tags_url":"https://api.github.com/repos/ohsu-computational-biology/server/tags","blobs_url":"https://api.github.com/repos/ohsu-computational-biology/server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ohsu-computational-biology/server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ohsu-computational-biology/server/git/refs{/sha}","trees_url":"https://api.github.com/repos/ohsu-computational-biology/server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ohsu-computational-biology/server/statuses/{sha}","languages_url":"https://api.github.com/repos/ohsu-computational-biology/server/languages","stargazers_url":"https://api.github.com/repos/ohsu-computational-biology/server/stargazers","contributors_url":"https://api.github.com/repos/ohsu-computational-biology/server/contributors","subscribers_url":"https://api.github.com/repos/ohsu-computational-biology/server/subscribers","subscription_url":"https://api.github.com/repos/ohsu-computational-biology/server/subscription","commits_url":"https://api.github.com/repos/ohsu-computational-biology/server/commits{/sha}","git_commits_url":"https://api.github.com/repos/ohsu-computational-biology/server/git/commits{/sha}","comments_url":"https://api.github.com/repos/ohsu-computational-biology/server/comments{/number}","issue_comment_url":"https://api.github.com/repos/ohsu-computational-biology/server/issues/comments{/number}","contents_url":"https://api.github.com/repos/ohsu-computational-biology/server/contents/{+path}","compare_url":"https://api.github.com/repos/ohsu-computational-biology/server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ohsu-computational-biology/server/merges","archive_url":"https://api.github.com/repos/ohsu-computational-biology/server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ohsu-computational-biology/server/downloads","issues_url":"https://api.github.com/repos/ohsu-computational-biology/server/issues{/number}","pulls_url":"https://api.github.com/repos/ohsu-computational-biology/server/pulls{/number}","milestones_url":"https://api.github.com/repos/ohsu-computational-biology/server/milestones{/number}","notifications_url":"https://api.github.com/repos/ohsu-computational-biology/server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ohsu-computational-biology/server/labels{/name}","releases_url":"https://api.github.com/repos/ohsu-computational-biology/server/releases{/id}","created_at":"2015-07-23T18:32:29Z","updated_at":"2015-08-18T17:54:58Z","pushed_at":"2015-10-06T23:51:05Z","git_url":"git://github.com/ohsu-computational-biology/server.git","ssh_url":"git@github.com:ohsu-computational-biology/server.git","clone_url":"https://github.com/ohsu-computational-biology/server.git","svn_url":"https://github.com/ohsu-computational-biology/server","homepage":null,"size":4539,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":0,"default_branch":"develop"}},"base":{"label":"ga4gh:g2p","ref":"g2p","sha":"747fefb2f1f92971730cae2af7dc59c6a8859f66","user":{"login":"ga4gh","id":6921777,"avatar_url":"https://avatars.githubusercontent.com/u/6921777?v=3","gravatar_id":"","url":"https://api.github.com/users/ga4gh","html_url":"https://github.com/ga4gh","followers_url":"https://api.github.com/users/ga4gh/followers","following_url":"https://api.github.com/users/ga4gh/following{/other_user}","gists_url":"https://api.github.com/users/ga4gh/gists{/gist_id}","starred_url":"https://api.github.com/users/ga4gh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ga4gh/subscriptions","organizations_url":"https://api.github.com/users/ga4gh/orgs","repos_url":"https://api.github.com/users/ga4gh/repos","events_url":"https://api.github.com/users/ga4gh/events{/privacy}","received_events_url":"https://api.github.com/users/ga4gh/received_events","type":"Organization","site_admin":false},"repo":{"id":22882621,"name":"server","full_name":"ga4gh/server","owner":{"login":"ga4gh","id":6921777,"avatar_url":"https://avatars.githubusercontent.com/u/6921777?v=3","gravatar_id":"","url":"https://api.github.com/users/ga4gh","html_url":"https://github.com/ga4gh","followers_url":"https://api.github.com/users/ga4gh/followers","following_url":"https://api.github.com/users/ga4gh/following{/other_user}","gists_url":"https://api.github.com/users/ga4gh/gists{/gist_id}","starred_url":"https://api.github.com/users/ga4gh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ga4gh/subscriptions","organizations_url":"https://api.github.com/users/ga4gh/orgs","repos_url":"https://api.github.com/users/ga4gh/repos","events_url":"https://api.github.com/users/ga4gh/events{/privacy}","received_events_url":"https://api.github.com/users/ga4gh/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ga4gh/server","description":"A reference implementation of the APIs defined in the schemas repository.","fork":false,"url":"https://api.github.com/repos/ga4gh/server","forks_url":"https://api.github.com/repos/ga4gh/server/forks","keys_url":"https://api.github.com/repos/ga4gh/server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ga4gh/server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ga4gh/server/teams","hooks_url":"https://api.github.com/repos/ga4gh/server/hooks","issue_events_url":"https://api.github.com/repos/ga4gh/server/issues/events{/number}","events_url":"https://api.github.com/repos/ga4gh/server/events","assignees_url":"https://api.github.com/repos/ga4gh/server/assignees{/user}","branches_url":"https://api.github.com/repos/ga4gh/server/branches{/branch}","tags_url":"https://api.github.com/repos/ga4gh/server/tags","blobs_url":"https://api.github.com/repos/ga4gh/server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ga4gh/server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ga4gh/server/git/refs{/sha}","trees_url":"https://api.github.com/repos/ga4gh/server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ga4gh/server/statuses/{sha}","languages_url":"https://api.github.com/repos/ga4gh/server/languages","stargazers_url":"https://api.github.com/repos/ga4gh/server/stargazers","contributors_url":"https://api.github.com/repos/ga4gh/server/contributors","subscribers_url":"https://api.github.com/repos/ga4gh/server/subscribers","subscription_url":"https://api.github.com/repos/ga4gh/server/subscription","commits_url":"https://api.github.com/repos/ga4gh/server/commits{/sha}","git_commits_url":"https://api.github.com/repos/ga4gh/server/git/commits{/sha}","comments_url":"https://api.github.com/repos/ga4gh/server/comments{/number}","issue_comment_url":"https://api.github.com/repos/ga4gh/server/issues/comments{/number}","contents_url":"https://api.github.com/repos/ga4gh/server/contents/{+path}","compare_url":"https://api.github.com/repos/ga4gh/server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ga4gh/server/merges","archive_url":"https://api.github.com/repos/ga4gh/server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ga4gh/server/downloads","issues_url":"https://api.github.com/repos/ga4gh/server/issues{/number}","pulls_url":"https://api.github.com/repos/ga4gh/server/pulls{/number}","milestones_url":"https://api.github.com/repos/ga4gh/server/milestones{/number}","notifications_url":"https://api.github.com/repos/ga4gh/server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ga4gh/server/labels{/name}","releases_url":"https://api.github.com/repos/ga4gh/server/releases{/id}","created_at":"2014-08-12T15:31:49Z","updated_at":"2015-09-16T11:44:20Z","pushed_at":"2015-10-07T19:26:43Z","git_url":"git://github.com/ga4gh/server.git","ssh_url":"git@github.com:ga4gh/server.git","clone_url":"https://github.com/ga4gh/server.git","svn_url":"https://github.com/ga4gh/server","homepage":null,"size":6937,"stargazers_count":41,"watchers_count":41,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":47,"mirror_url":null,"open_issues_count":67,"forks":47,"open_issues":67,"watchers":41,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/ga4gh/server/pulls/607"},"html":{"href":"https://github.com/ga4gh/server/pull/607"},"issue":{"href":"https://api.github.com/repos/ga4gh/server/issues/607"},"comments":{"href":"https://api.github.com/repos/ga4gh/server/issues/607/comments"},"review_comments":{"href":"https://api.github.com/repos/ga4gh/server/pulls/607/comments"},"review_comment":{"href":"https://api.github.com/repos/ga4gh/server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ga4gh/server/pulls/607/commits"},"statuses":{"href":"https://api.github.com/repos/ga4gh/server/statuses/c10e4db19e3677d56a3f09691f8d7afe461e3ae6"}}}}