예제 #1
0
    def testCompoundFeatureSearch(self):
        datasetName, featureSet = self.getCGDDataSetFeatureSet()
        featureId = \
            "http://cancer.sanger.ac.uk/cosmic/mutation/overview?id=736"
        obfuscated = self.getObfuscatedFeatureCompoundId(
            datasetName, featureSet.name, featureId)
        request = protocol.GetFeatureRequest
        request.feature_id = obfuscated
        response = self.sendGetRequest('/features/{}'.format(obfuscated))

        feature = self.deserialize(response.data, protocol.Feature)

        self.assertIsNotNone(feature)
        featureId = feature.id

        request = protocol.SearchGenotypePhenotypeRequest()
        request.phenotype_association_set_id = \
            self.getPhenotypeAssociationSetId()
        request.feature_ids.append(featureId)
        response = self.sendSearchRequest(
            '/featurephenotypeassociations/search',
            request,
            protocol.SearchGenotypePhenotypeResponse)
        self.assertEqual(1, len(response.associations))
        self.assertEqual(1, len(response.associations[0].feature_ids))
예제 #2
0
 def testNoFind(self):
     request = protocol.SearchGenotypePhenotypeRequest()
     request.phenotype_association_set_id = \
         self.getPhenotypeAssociationSetId()
     request.feature_ids.extend(["FOOBAR"])
     response = self.sendSearchRequest(
         '/featurephenotypeassociations/search',
         request,
         protocol.SearchGenotypePhenotypeResponse)
     self.assertEqual(0, len(response.associations))
예제 #3
0
 def testGenotypePhenotypeSearchPhenotype(self):
     """
     Search for associations given a phenotype
     """
     request = protocol.SearchGenotypePhenotypeRequest()
     request.phenotype_association_set_id = \
         self.getPhenotypeAssociationSetId()
     request.phenotype_ids.extend(["http://ohsu.edu/cgd/25abbb09"])
     response = self.sendSearchRequest(
         '/featurephenotypeassociations/search',
         request,
         protocol.SearchGenotypePhenotypeResponse)
     self.assertEqual(1, len(response.associations[0].feature_ids))
예제 #4
0
 def testGenotypePhenotypeSearchEvidence(self):
     """
     Search for associations given an evidence
     """
     request = protocol.SearchGenotypePhenotypeRequest()
     request.phenotype_association_set_id = \
         self.getPhenotypeAssociationSetId()
     eq = protocol.EvidenceQuery()
     eq.description = "imatinib"
     request.evidence.extend([eq])
     response = self.sendSearchRequest(
         '/featurephenotypeassociations/search',
         request,
         protocol.SearchGenotypePhenotypeResponse)
     self.assertEqual(1, len(response.associations[0].feature_ids))
예제 #5
0
 def testSearchGenotypePhenotype(self):
     request = protocol.SearchGenotypePhenotypeRequest()
     request.phenotype_association_set_id = \
         self.phenotype_association_set_id
     request.feature_ids.extend(self.feature_ids)
     request.phenotype_ids.extend(self.phenotype_ids)
     request.evidence.extend([self.evidence])
     request.page_size = self.pageSize
     self.httpClient.search_genotype_phenotype(
         phenotype_association_set_id=self.phenotype_association_set_id,
         feature_ids=self.feature_ids,
         phenotype_ids=self.phenotype_ids,
         evidence=[self.evidence])
     self.httpClient._run_search_request.assert_called_once_with(
         request, "featurephenotypeassociations",
         protocol.SearchGenotypePhenotypeResponse)
예제 #6
0
 def testGenotypePhenotypeSearchFeature(self):
     """
     Search for associations given a feature
     """
     # simulate user interacting with sequenceAnnotations
     request = protocol.SearchGenotypePhenotypeRequest()
     request.phenotype_association_set_id = \
         self.getPhenotypeAssociationSetId()
     datasetName, featureSet = self.getCGDDataSetFeatureSet()
     featureId = \
         "http://ohsu.edu/cgd/27d2169c"
     obfuscated = self.getObfuscatedFeatureCompoundId(
         datasetName, featureSet.name, featureId)
     # use the feature to look up associations
     request.feature_ids.extend([obfuscated])
     response = self.sendSearchRequest(
         '/featurephenotypeassociations/search',
         request,
         protocol.SearchGenotypePhenotypeResponse)
     self.assertEqual(1, len(response.associations[0].feature_ids))
예제 #7
0
 def testGenotypePhenotypeSearchEnsureEnvironment(self):
     request = protocol.SearchGenotypePhenotypeRequest()
     request.phenotype_association_set_id = \
         self.getPhenotypeAssociationSetId()
     datasetName, featureSet = self.getCGDDataSetFeatureSet()
     featureId = \
         "http://ohsu.edu/cgd/27d2169c"
     obfuscated = self.getObfuscatedFeatureCompoundId(
         datasetName, featureSet.name, featureId)
     request.feature_ids.extend([obfuscated])
     eq = protocol.EvidenceQuery()
     eq.description = "imatinib"
     request.evidence.extend([eq])
     response = self.sendSearchRequest(
         '/featurephenotypeassociations/search',
         request,
         protocol.SearchGenotypePhenotypeResponse)
     self.assertEqual(
         1, len(response.associations[0].environmental_contexts))
     environmentalContext = response.associations[0] \
                                    .environmental_contexts[0]
     self.assertEqual('imatinib', environmentalContext.description)
예제 #8
0
 def testGenotypePhenotypeSearchEnsureEvidence(self):
     """
     Ensure evidence level is serialized in responses
     """
     request = protocol.SearchGenotypePhenotypeRequest()
     request.phenotype_association_set_id = \
         self.getPhenotypeAssociationSetId()
     request.phenotype_association_set_id = \
         self.getPhenotypeAssociationSetId()
     datasetName, featureSet = self.getCGDDataSetFeatureSet()
     featureId = \
         "http://ohsu.edu/cgd/27d2169c"
     obfuscated = self.getObfuscatedFeatureCompoundId(datasetName,
                                                      featureSet.name,
                                                      featureId)
     request.feature_ids.extend([obfuscated])
     response = self.sendSearchRequest(
         '/featurephenotypeassociations/search',
         request,
         protocol.SearchGenotypePhenotypeResponse)
     self.assertEqual(1, len(response.associations[0].evidence))
     evidence = response.associations[0].evidence[0]
     self.assertEqual('decreased_sensitivity', evidence.description)
예제 #9
0
 def sendGenotypePhenotypesSearch(self):
     request = protocol.SearchGenotypePhenotypeRequest()
     request.phenotype_association_set_id = self.phenotypeAssociationSetId
     return self.sendPostRequest('/featurephenotypeassociations/search',
                                 request)