GA4GH 1000 Genomes Variant Annotation Example

This example illustrates how to access the different variant calls implemented within the variant service.

Initialize the client

In this step we create a client object which will be used to communicate with the server. It is initialized using the URL.


In [1]:
from ga4gh.client import client
c = client.HttpClient("http://1kgenomes.ga4gh.org")

In [19]:
#Obtain dataSet id REF: -> `1kg_metadata_service`
dataset = c.search_datasets().next() 

#Obtain functional-annotations set id REF: -> `1kg_variant_service`
for variant_sets in c.search_variant_sets(dataset_id=dataset.id):
    if variant_sets.name == "functional-annotations":
        variant_sets = variant_sets.id
        break

Search Variant Annotation Sets method

Variant Annotation Sets collect together information about variants that are not otherwise described in a variant message. These variant annotations mainly describe transcriptional effects of a variation, as well as which genomic feature they may occur on.


In [20]:
for variant_annotation_sets in c.search_variant_annotation_sets(variant_set_id=variant_sets.id):
    print "\nName: {},".format(variant_annotation_sets.name)
    print" Id: {},".format(variant_annotation_sets.id)
    print" Variant Set Id: {},".format(variant_annotation_sets.variant_set_id)


Name: functional-annotation,
 Id: WyIxa2dlbm9tZXMiLCJ2cyIsImZ1bmN0aW9uYWwtYW5ub3RhdGlvbiIsImZ1bmN0aW9uYWwtYW5ub3RhdGlvbiJd,
 Variant Set Id: WyIxa2dlbm9tZXMiLCJ2cyIsImZ1bmN0aW9uYWwtYW5ub3RhdGlvbiJd,

Search Variant Annotations

Searching Variant Annotations is done by making a genomic range query using the Variant Annotation Set ID found above. The returned annotations include details on the transcript effects for variants in that range.


In [21]:
counter = 3
for variant_annotations in c.search_variant_annotations(variant_annotation_set_id=variant_annotation_sets.id, reference_name="1", start=0, end=1000000):
    if counter <= 0:
        break
    counter -= 1 
    print"Id: {},".format(variant_annotations.id)
    print" Variant Id: {},".format(variant_annotations.variant_id)
    print" Variant Annotation Set Id: {}".format(variant_annotations.variant_annotation_set_id)
    print" Created: {}".format(variant_annotations.created)
    print" Transcript Effects Id: {},".format(variant_annotations.transcript_effects[0].id)
    print" Featured Id: {},".format(variant_annotations.transcript_effects[0].feature_id)
    print" Alternate Bases: {},".format(variant_annotations.transcript_effects[0].alternate_bases)
    print" Effects Id: {},".format(variant_annotations.transcript_effects[0].effects[0].id)
    print" Effect Term: {},".format(variant_annotations.transcript_effects[0].effects[0].term)
    print" Effect Sorce Name: {},".format(variant_annotations.transcript_effects[0].effects[0].source_name)
    print" Effect Source Version: {}\n".format(variant_annotations.transcript_effects[0].effects[0].source_version)


Id: WyIxa2dlbm9tZXMiLCJ2cyIsImZ1bmN0aW9uYWwtYW5ub3RhdGlvbiIsImZ1bmN0aW9uYWwtYW5ub3RhdGlvbiIsIjEiLCIxMDE3NiIsIjhjYjI5MGJhNTcyNzlmNjg1MDc4ZGUwZGNmMGNjYzJiIl0,
 Variant Id: WyIxa2dlbm9tZXMiLCJ2cyIsImZ1bmN0aW9uYWwtYW5ub3RhdGlvbiIsIjEiLCIxMDE3NiIsImQwMTZjNGUxYWRjYWQ1ZDFiYzg5YzJjYTRhZGJhM2E4Il0,
 Variant Annotation Set Id: WyIxa2dlbm9tZXMiLCJ2cyIsImZ1bmN0aW9uYWwtYW5ub3RhdGlvbiIsImZ1bmN0aW9uYWwtYW5ub3RhdGlvbiJd
 Created: 2014-07-30T00:00:00Z
 Transcript Effects Id: 4ef6c08cbb50fec318e9815d897e511f,
 Featured Id: ENST00000456328,
 Alternate Bases: C,
 Effects Id: SO:0001631,
 Effect Term: upstream_gene_variant,
 Effect Sorce Name: so-xp,
 Effect Source Version: so-xp/releases/2015-11-24/so-xp.owl

Id: WyIxa2dlbm9tZXMiLCJ2cyIsImZ1bmN0aW9uYWwtYW5ub3RhdGlvbiIsImZ1bmN0aW9uYWwtYW5ub3RhdGlvbiIsIjEiLCIxMDIzNCIsImZjZGQzZjU2MTMxNWUwMTM4YWNlMmE4MjA2NjllY2QyIl0,
 Variant Id: WyIxa2dlbm9tZXMiLCJ2cyIsImZ1bmN0aW9uYWwtYW5ub3RhdGlvbiIsIjEiLCIxMDIzNCIsIjBjZTM1MDcyNDQ2MTRjMzcwNWY1ZTJhYTJkMTBhZjI1Il0,
 Variant Annotation Set Id: WyIxa2dlbm9tZXMiLCJ2cyIsImZ1bmN0aW9uYWwtYW5ub3RhdGlvbiIsImZ1bmN0aW9uYWwtYW5ub3RhdGlvbiJd
 Created: 2014-07-30T00:00:00Z
 Transcript Effects Id: 36da0f368090af154c25b9f56266b920,
 Featured Id: ENST00000456328,
 Alternate Bases: A,
 Effects Id: SO:0001631,
 Effect Term: upstream_gene_variant,
 Effect Sorce Name: so-xp,
 Effect Source Version: so-xp/releases/2015-11-24/so-xp.owl

Id: WyIxa2dlbm9tZXMiLCJ2cyIsImZ1bmN0aW9uYWwtYW5ub3RhdGlvbiIsImZ1bmN0aW9uYWwtYW5ub3RhdGlvbiIsIjEiLCIxMDM1MSIsImZjZGQzZjU2MTMxNWUwMTM4YWNlMmE4MjA2NjllY2QyIl0,
 Variant Id: WyIxa2dlbm9tZXMiLCJ2cyIsImZ1bmN0aW9uYWwtYW5ub3RhdGlvbiIsIjEiLCIxMDM1MSIsIjBjZTM1MDcyNDQ2MTRjMzcwNWY1ZTJhYTJkMTBhZjI1Il0,
 Variant Annotation Set Id: WyIxa2dlbm9tZXMiLCJ2cyIsImZ1bmN0aW9uYWwtYW5ub3RhdGlvbiIsImZ1bmN0aW9uYWwtYW5ub3RhdGlvbiJd
 Created: 2014-07-30T00:00:00Z
 Transcript Effects Id: 36da0f368090af154c25b9f56266b920,
 Featured Id: ENST00000456328,
 Alternate Bases: A,
 Effects Id: SO:0001631,
 Effect Term: upstream_gene_variant,
 Effect Sorce Name: so-xp,
 Effect Source Version: so-xp/releases/2015-11-24/so-xp.owl

Get Variant Annotation Set

Variant Annotation Sets can be retrieved using their ID.


In [22]:
variant_annotation_set = c.get_variant_annotation_set(variant_annotation_set_id=variant_annotation_sets.id)

In [23]:
print"Name: {}".format(variant_annotation_set.name)
print" Id: {} ".format(variant_annotation_set.id)
print" Variant Set Id: {}".format(variant_annotation_set.variant_set_id)


Name: functional-annotation
 Id: WyIxa2dlbm9tZXMiLCJ2cyIsImZ1bmN0aW9uYWwtYW5ub3RhdGlvbiIsImZ1bmN0aW9uYWwtYW5ub3RhdGlvbiJd 
 Variant Set Id: WyIxa2dlbm9tZXMiLCJ2cyIsImZ1bmN0aW9uYWwtYW5ub3RhdGlvbiJd
For documentation on the service, and more information go to:

https://ga4gh-schemas.readthedocs.io/en/latest/schemas/allele_annotation_service.proto.html