Пример #1
0
 def _run_list_reference_bases_page_request(self, request):
     url_suffix = "listreferencebases"
     url = posixpath.join(self._url_prefix, url_suffix)
     response = self._session.post(url,
                                   params=self._get_http_parameters(),
                                   data=protocol.toJson(request))
     self._check_response_status(response)
     return self._deserialize_response(response.text,
                                       protocol.ListReferenceBasesResponse)
Пример #2
0
 def _run_search_page_request(self, protocol_request, object_name,
                              protocol_response_class):
     url = posixpath.join(self._url_prefix, object_name + '/search')
     data = protocol.toJson(protocol_request)
     self._logger.debug("request:{}".format(data))
     response = self._session.post(url,
                                   params=self._get_http_parameters(),
                                   data=data)
     self._check_response_status(response)
     return self._deserialize_response(response.text,
                                       protocol_response_class)
Пример #3
0
def harvest(genes):
    datasets = c.search_datasets()
    phenotype_association_set_id = None
    phenotype_association_set_name = None
    for  dataset in datasets:
      phenotype_association_sets = c.search_phenotype_association_sets(dataset_id=dataset.id)
      for phenotype_association_set in phenotype_association_sets:
        phenotype_association_set_id = phenotype_association_set.id
        phenotype_association_set_name = phenotype_association_set.name
        # print 'Found G2P phenotype_association_set:', phenotype_association_set.id, phenotype_association_set.name
        break

    assert phenotype_association_set_id
    assert phenotype_association_set_name

    feature_set_id = None
    datasets = c.search_datasets()
    for  dataset in datasets:
      featuresets = c.search_feature_sets(dataset_id=dataset.id)
      for featureset in featuresets:
        if phenotype_association_set_name in featureset.name:
          feature_set_id = featureset.id
          # print 'Found G2P feature_set:', feature_set_id
          break
    assert feature_set_id

    gene_features = []
    for gene in set(genes):
        feature_generator = c.search_features(feature_set_id=feature_set_id, name='.*{}.*'.format(gene))
        features = list(feature_generator)
        if len(features) == 0:
            # print "{} Found no features".format(gene)
            gene_features.append({'gene': gene})
        else:
            # print "{} Found {} features in G2P feature_set {}".format(gene, len(features),feature_set_id)
            a = []
            for f in features:
                a.append(json.loads(protocol.toJson(f)))
            gene_features.append({'gene': gene, 'features': a})


    for gene_feature in gene_features:
        if 'features' in gene_feature:
            for f in gene_feature['features']:
                feature_phenotype_associations =  c.search_genotype_phenotype(
                                                    phenotype_association_set_id=phenotype_association_set_id,
                                                    feature_ids=[f['id']])
                associations = list(feature_phenotype_associations)
                a = []
                for association in associations:
                    a.append(json.loads(protocol.toJson(association)))
                f['associations'] = a
                # print "{} has {} associations".format(gene_feature['gene'], len(a))


    for gene_feature in gene_features:
        gene_feature['ga4gh'] = {}
        if 'features' in gene_feature:
            gene_feature['ga4gh']['features'] = gene_feature['features']
            del gene_feature['features']
        yield gene_feature
Пример #4
0
 def _run_list_reference_bases_page_request(self, request):
     response_json = self._backend.runListReferenceBases(
         protocol.toJson(request))
     return self._deserialize_response(response_json,
                                       protocol.ListReferenceBasesResponse)
Пример #5
0
 def _run_search_page_request(self, protocol_request, object_name,
                              protocol_response_class):
     search_method = self._search_method_map[object_name]
     response_json = search_method(protocol.toJson(protocol_request))
     return self._deserialize_response(response_json,
                                       protocol_response_class)