本文整理汇总了Python中TestUtils.TestUtils类的典型用法代码示例。如果您正苦于以下问题:Python TestUtils类的具体用法?Python TestUtils怎么用?Python TestUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testRealWorld
def testRealWorld(self):
"""Test that the full COSMIC datasource can retrieve entries by both gp and gpp."""
gafDS = TestUtils.createTranscriptProviderDatasource(self.config)
cosmicDS = TestUtils.createCosmicDatasource(self.config)
# These values are not taken from a real world scenario, but are cooked for this test.
m = MutationData()
m.chr = '1'
m.start = '12941796'
m.end = '12941796'
m.ref_allele = "G"
m.alt_allele = "T"
m = gafDS.annotate_mutation(m)
m = cosmicDS.annotate_mutation(m)
self.assertTrue(m['COSMIC_n_overlapping_mutations'] == '0')
#1 150483621 150483621
m = MutationData()
m.chr = '1'
m.start = '150483621'
m.end = '150483621'
m.ref_allele = "G"
m.alt_allele = "T"
m = gafDS.annotate_mutation(m)
m = cosmicDS.annotate_mutation(m)
示例2: testSpliceSiteWithinNBases
def testSpliceSiteWithinNBases(self):
"""Test that a silent mutation is changed to splice site w/in 10 bases of a splice site """
# chr21:10,998,326-10,998,346
# 10,998,336 is a splice site. (Junction between 10998335 and 336)
# AGTTCTCCTT C TGGAAAAAAG
refs = 'AGTTCTCCTTCTGGAAAAAAG'
alts = 'TCAGACTGAAAATACCCCCCT'
gafDatasource = TestUtils.createTranscriptProviderDatasource(self.config)
vcs = []
for s in range(10998326, 10998347):
m = MutationDataFactory.default_create()
m.start = str(s)
m.end = str(s)
m.chr = "21"
m.ref_allele = refs[s - 10998326]
m.alt_allele = alts[s - 10998326]
m = gafDatasource.annotate_mutation(m)
distanceFromSpliceSite = abs(10998336 - int(m.start))
vc = m['variant_classification']
self.assertTrue(vc != 'Silent', 'Silent mutation found when it should be a splice site.')
vcs.append(vc)
print vc + " " + m.start
self.assertTrue(all([tmp == "Splice_Site" for tmp in vcs[8:12]]), "Not all vcs within 2 bases were splice site: " + str(vcs[8:12]))
self.assertTrue(all([tmp != "Splice_Site" for tmp in vcs[0:8]]), "No splice sites should be seen: " + str(vcs[0:8]))
self.assertTrue(all([tmp != "Splice_Site" for tmp in vcs[12:20]]), "No splice sites should be seen: " + str(vcs[12:20]))
示例3: testSilentMutationGoingToSpliceSite
def testSilentMutationGoingToSpliceSite(self):
"""Test that a silent mutation within 10 bp of a splice junction should become a splice site"""
#chr1:28,233,780-28,233,805 Junction is at chr1:28,233,793 & 94
#
refs = "TGGGCTCGGGCTCTCTGAAAAGAAAA"
alts = "TGGGCTCAGGCTCGCTGAAAAGAAAA"
vcs = []
gafDatasource = TestUtils.createTranscriptProviderDatasource(self.config)
numSpliceSites = 0
numSilent = 0
startWindow = 28233780
for s in range(startWindow, 28233806):
m = MutationDataFactory.default_create()
m.start = str(s)
m.end = str(s)
m.chr = "1"
m.ref_allele = refs[s - startWindow]
m.alt_allele = alts[s - startWindow]
m = gafDatasource.annotate_mutation(m)
distanceFromSpliceSite = abs(28233793 - int(m.start))
vc = m['variant_classification']
vcs.append(vc)
# self.assertTrue(vc <> 'Silent', 'Silent mutation found when it should be a splice site.')
if vc.lower() == "splice_site":
numSpliceSites += 1
if vc.lower() == "silent":
numSilent += 1
print vc + " " + m.start + " " + str(distanceFromSpliceSite)
self.assertTrue(numSpliceSites == 4, "Should have seen 4 splice site mutations, but saw: " + str(numSpliceSites))
self.assertTrue(numSilent == 11, "Should have seen 11 Silent mutations, but saw: " + str(numSilent))
示例4: test_denovo
def test_denovo(self):
"""GAF de novo test """
gafDatasource = TestUtils.createTranscriptProviderDatasource(self.config)
m = MutationDataFactory.default_create()
m.start = str(22221735)
m.end = str(22221737)
m.chr="22"
m.ref_allele = ''
m.alt_allele = 'CAT'
m = gafDatasource.annotate_mutation(m)
self.assertTrue(m['variant_classification'] == 'De_novo_Start_OutOfFrame')
m = MutationDataFactory.default_create()
m.start = str(22221735)
m.end = str(22221740)
m.chr="22"
m.ref_allele = ''
m.alt_allele = 'AACATAA'
m = gafDatasource.annotate_mutation(m)
self.assertTrue(m['variant_classification'] == 'De_novo_Start_OutOfFrame')
m = MutationDataFactory.default_create()
m.start = str(22221735)
m.end = str(22221739)
m.chr="22"
m.ref_allele = ''
m.alt_allele = 'ACATAA'
m = gafDatasource.annotate_mutation(m)
self.assertTrue(m['variant_classification'] == 'De_novo_Start_InFrame')
示例5: testMulticoreAnnotate
def testMulticoreAnnotate(self):
"""Test a (too) simple annotating exercise from GAF on 2 cores"""
gafDatasource = TestUtils.createGafDatasourceProxy(self.config)
# Test pickling
dump(gafDatasource, file('out/testGAFPickle.pkl','w'))
m1 = MutationDataFactory.default_create()
m1.chr = '3'
m1.start = '178866811'
m1.end = '178866811'
m1.ref_allele = "A"
m1.alt_allele = "C"
m1.build = "hg19"
m2 = MutationDataFactory.default_create()
m2.chr = '3'
m2.start = '178866812'
m2.end = '178866812'
m2.ref_allele = "A"
m2.alt_allele = "C"
m2.build = "hg19"
p = LoggingPool(processes=2)
result = p.map(annotate_mutation_global, [(gafDatasource, m1), (gafDatasource, m2)])
p.close()
p.join()
for r in result:
self.assertTrue("transcript_id" in r.keys())
self.assertTrue("gene" in r.keys())
self.assertTrue(r["gene"] == "PIK3CA")
self.assertTrue(result[0].start != result[1].start)
示例6: testCreationAndAnnotation
def testCreationAndAnnotation(self):
""" Test the datasource creation and then do a simple annotation
"""
outputFilename = 'out/genericGeneProteinPositionTest.out.tsv'
gafDS = TestUtils.createTranscriptProviderDatasource(self.config)
gppDS = DatasourceFactory.createDatasource("testdata/simple_uniprot_natvar/simple_uniprot_natvar.config", "testdata/simple_uniprot_natvar/")
annotator = Annotator()
annotator.setInputCreator(MafliteInputMutationCreator('testdata/maflite/tiny_maflite_natvar.maf.tsv'))
annotator.setOutputRenderer(SimpleOutputRenderer(outputFilename))
annotator.addDatasource(gafDS)
annotator.addDatasource(gppDS)
testFilename = annotator.annotate()
# Make sure that some values were populated
self.assertTrue(os.path.exists(testFilename))
tsvReader = GenericTsvReader(testFilename)
ctr = 0
for lineDict in tsvReader:
colName = "UniProt_NatVar_natural_variations"
self.assertTrue(sorted(lineDict[colName].split("|")) == sorted("R -> RR (in EDMD2).|R -> Q (in EDMD2).".split("|")), "Annotation value did not match: " + lineDict[colName])
ctr += 1
self.assertTrue(ctr == 1, "Number of mutations incorrect (1): " + str(ctr) )
示例7: test_effect_tx_mode
def test_effect_tx_mode(self):
gafDatasource = TestUtils.createTranscriptProviderDatasource(self.config)
gafDatasource.set_tx_mode(TranscriptProvider.TX_MODE_BEST_EFFECT)
# Canonical mutation was Intron
m = MutationDataFactory.default_create()
m.chr = '2'
m.start = '219137340'
m.end = '219137340'
m.ref_allele = 'G'
m.alt_allele = 'T'
m = gafDatasource.annotate_mutation(m)
self.assertTrue(m['gene'] == "PNKD")
self.assertTrue(m['variant_classification'] == "Missense_Mutation")
gafDatasource.set_tx_mode(TranscriptProvider.TX_MODE_CANONICAL)
m = MutationDataFactory.default_create()
m.chr = '2'
m.start = '219137340'
m.end = '219137340'
m.ref_allele = 'G'
m.alt_allele = 'T'
m = gafDatasource.annotate_mutation(m)
self.assertTrue(m['gene'] == "PNKD")
self.assertTrue(m['variant_classification'] == "Intron", "Canonical no longer is Intron. This test is no longer valid. This failure can come up when changing the GAF datasource.")
示例8: testFlank
def testFlank(self):
"""Test that we can see a Flank mutation."""
#chr1:28,233,780-28,233,805 Junction is at chr1:28,233,793 & 94
#
refs = "TGGGCTCGGGCTCTCTGAAAAGAAAA"
alts = "TGGGCTCAGGCTCTCTGAAAAGAAAA"
vcs = []
gafDatasource = TestUtils.createTranscriptProviderDatasource(self.config)
numSpliceSites = 0
numSilent = 0
startWindow = 11042200
for s in range(startWindow, startWindow+len(refs)):
m = MutationDataFactory.default_create()
m.start = str(s)
m.end = str(s)
m.chr="1"
m.ref_allele = refs[s-startWindow]
m.alt_allele = alts[s-startWindow]
m = gafDatasource.annotate_mutation(m)
vc = m['variant_classification']
vcs.append(vc)
print vc + " " + m.start
pass
示例9: testExonRetrievalForGene
def testExonRetrievalForGene(self):
"""Make sure that the GAF datasource can retrieve exons, given a gene"""
testGeneList = ['CEBPA', 'BRCA1', 'PIK3CA']
gafDatasource = TestUtils.createTranscriptProviderDatasource(self.config)
for gene in testGeneList:
exons = gafDatasource.retrieveExons(gene, isCodingOnly=True)
self.assertTrue(exons is not None)
print(str(exons))
示例10: testChangeInTxModeChangesHashcode
def testChangeInTxModeChangesHashcode(self):
"""Test that a change in the tx-mode will change the hashcode"""
gafDatasource = TestUtils.createTranscriptProviderDatasource(self.config)
gafDatasource.set_tx_mode(TranscriptProvider.TX_MODE_BEST_EFFECT)
old_hashcode = gafDatasource.get_hashcode()
gafDatasource.set_tx_mode(TranscriptProvider.TX_MODE_CANONICAL)
new_hashcode = gafDatasource.get_hashcode()
self.assertTrue(old_hashcode != new_hashcode)
示例11: testBasicDatasourceSorting
def testBasicDatasourceSorting(self):
"""Test that the GAF datasource is sorted before a gene-based datasource"""
gafDatasource = TestUtils.createTranscriptProviderDatasource(self.config)
geneDS = DatasourceFactory.createDatasource("testdata/small_tsv_ds/small_tsv_ds.config", "testdata/small_tsv_ds/")
incorrectSortList = [geneDS, gafDatasource]
guessSortList = DatasourceFactory.sortDatasources(incorrectSortList)
self.assertTrue(guessSortList[1] == geneDS, "Sorting is incorrect.")
self.assertTrue(len(guessSortList) == 2, "Sorting altered number of datasources (gt: 2): " + str(len(guessSortList)))
示例12: testVersionHeader
def testVersionHeader(self):
""" This method simply tests that the version string returned by the annotator does not cause an exception.
Minimal checking that the returned sting is actually correct.
Does not attempt to initialize input or output. Only a gaf datasource.
"""
annotator = Annotator()
annotator.addDatasource(TestUtils.createTranscriptProviderDatasource(self.config))
tmp = annotator.createHeaderString()
self.assertTrue(tmp.find("Gaf ") != -1 or tmp.find("GENCODE") != -1, "Could not find Gaf or GENCODE version in header string.")
self.assertTrue(tmp.find("Oncotator") != -1, "Could not find the word Oncotator in header string.")
示例13: testNoUnknownAnnotations
def testNoUnknownAnnotations(self):
""" Make sure that the gaf 3.0 datasource does not annotate anything with source set to Unknown """
inputCreator = MafliteInputMutationCreator('testdata/maflite/Patient0.snp.maf.txt')
gafDatasource = TestUtils.createTranscriptProviderDatasource(self.config)
mutations = inputCreator.createMutations()
for m in mutations:
m = gafDatasource.annotate_mutation(m)
MutUtils.validateMutation(m)
unknownAnnotations = MutUtils.getUnknownAnnotations(m)
self.assertTrue(len(unknownAnnotations) == 0, "Unknown annotations exist in mutation: " + str(unknownAnnotations))
示例14: testAKT1
def testAKT1(self):
""" Test that this version of the GAF produces the up to date gene for a position given from a website user.
"""
m = MutationDataFactory.default_create()
m.chr = '14'
m.start = '105246407'
m.end = '105246407'
m.ref_allele = 'G'
m.alt_allele = 'A'
gafDatasource = TestUtils.createTranscriptProviderDatasource(self.config)
m = gafDatasource.annotate_mutation(m)
self.assertTrue(m['gene'] == "AKT1", "Incorrect gene found: " + m['gene'] + " If updating GAF, this may not be an error, but should be confirmed manually.")
示例15: test_start_codon
def test_start_codon(self):
"""Test a start codon hit in a GAF datasource"""
gafDatasource = TestUtils.createTranscriptProviderDatasource(self.config)
m = MutationDataFactory.default_create()
m.start = str(22221729)
m.end = str(22221729)
m.chr="22"
m.ref_allele = 'A'
m.alt_allele = 'T'
m = gafDatasource.annotate_mutation(m)
self.assertTrue(m['variant_classification'] == VariantClassification.MISSENSE)