def test_vanilla(self): dummy = Genome(name='GRCh37.75_Y-Only', SNPs='dummySRY_AGN') persProt = dummy.get(Protein, id='ENSP00000438917')[0] refProt = self.ref.get(Protein, id='ENSP00000438917')[0] self.assertEqual('ATGCAATCATATGCTTCTGC', refProt.transcript.cDNA[:20]) self.assertEqual('HTGCAATCATATGCTTCTGC', persProt.transcript.cDNA[:20])
def test_noModif(self) : from pyGeno.SNPFiltering import SNPFilter class MyFilter(SNPFilter) : def __init__(self) : SNPFilter.__init__(self) def filter(self, chromosome, dummySRY_AGN) : return None dummy = Genome(name = 'GRCh37.75_Y-Only', SNPs = 'dummySRY_AGN', SNPFilter = MyFilter()) persProt = dummy.get(Protein, id = 'ENSP00000438917')[0] refProt = self.ref.get(Protein, id = 'ENSP00000438917')[0] self.assertEqual(persProt.transcript.cDNA[:20], refProt.transcript.cDNA[:20])
def test_SNP(self) : from pyGeno.SNPFiltering import SNPFilter class MyFilter(SNPFilter) : def __init__(self) : SNPFilter.__init__(self) def filter(self, chromosome, dummySRY_AGN) : from pyGeno.SNPFiltering import SequenceSNP return SequenceSNP(dummySRY_AGN.alt) dummy = Genome(name = 'GRCh37.75_Y-Only', SNPs = 'dummySRY_AGN', SNPFilter = MyFilter()) persProt = dummy.get(Protein, id = 'ENSP00000438917')[0] refProt = self.ref.get(Protein, id = 'ENSP00000438917')[0] self.assertEqual('M', refProt.sequence[0]) self.assertEqual('L', persProt.sequence[0])
def test_deletion(self) : from pyGeno.SNPFiltering import SNPFilter class MyFilter(SNPFilter) : def __init__(self) : SNPFilter.__init__(self) def filter(self, chromosome, dummySRY_AGN) : from pyGeno.SNPFiltering import SequenceDel refAllele = chromosome.refSequence[dummySRY_AGN.start] return SequenceDel(1) dummy = Genome(name = 'GRCh37.75_Y-Only', SNPs = 'dummySRY_AGN', SNPFilter = MyFilter()) persProt = dummy.get(Protein, id = 'ENSP00000438917')[0] refProt = self.ref.get(Protein, id = 'ENSP00000438917')[0] self.assertEqual('ATGCAATCATATGCTTCTGC', refProt.transcript.cDNA[:20]) self.assertEqual('TGCAATCATATGCTTCTGCT', persProt.transcript.cDNA[:20])
def test_indels(self): from pyGeno.SNPFiltering import SNPFilter class MyFilter(SNPFilter): def __init__(self): SNPFilter.__init__(self) def filter(self, chromosome, dummySRY_AGN_indels): from pyGeno.SNPFiltering import SequenceInsert ret = "" for s in dummySRY_AGN_indels: ret += "X" return SequenceInsert(ret) dummy = Genome(name='GRCh37.75_Y-Only', SNPs='dummySRY_AGN_indels', SNPFilter=MyFilter()) persProt = dummy.get(Protein, id='ENSP00000438917')[0] refProt = self.ref.get(Protein, id='ENSP00000438917')[0] self.assertEqual('XXXATGCAATCATATGCTTC', persProt.transcript.cDNA[:20])
class pyGenoSNPTests(unittest.TestCase): def setUp(self): # try : # B.importGenome("Human.GRCh37.75_Y-Only.tar.gz") # except KeyError : # deleteGenome("human", "GRCh37.75_Y-Only") # B.importGenome("Human.GRCh37.75_Y-Only.tar.gz") # print "--> Seems to already exist in db" # try : # B.importSNPs("Human_agnostic.dummySRY.tar.gz") # except KeyError : # deleteSNPs("dummySRY_AGN") # B.importSNPs("Human_agnostic.dummySRY.tar.gz") # print "--> Seems to already exist in db" # try : # B.importSNPs("Human_agnostic.dummySRY_indels") # except KeyError : # deleteSNPs("dummySRY_AGN_indels") # B.importSNPs("Human_agnostic.dummySRY_indels") # print "--> Seems to already exist in db" self.ref = Genome(name='GRCh37.75_Y-Only') def tearDown(self): pass # @unittest.skip("skipping") def test_vanilla(self): dummy = Genome(name='GRCh37.75_Y-Only', SNPs='dummySRY_AGN') persProt = dummy.get(Protein, id='ENSP00000438917')[0] refProt = self.ref.get(Protein, id='ENSP00000438917')[0] self.assertEqual('ATGCAATCATATGCTTCTGC', refProt.transcript.cDNA[:20]) self.assertEqual('HTGCAATCATATGCTTCTGC', persProt.transcript.cDNA[:20]) # @unittest.skip("skipping") def test_noModif(self): from pyGeno.SNPFiltering import SNPFilter class MyFilter(SNPFilter): def __init__(self): SNPFilter.__init__(self) def filter(self, chromosome, dummySRY_AGN): return None dummy = Genome(name='GRCh37.75_Y-Only', SNPs='dummySRY_AGN', SNPFilter=MyFilter()) persProt = dummy.get(Protein, id='ENSP00000438917')[0] refProt = self.ref.get(Protein, id='ENSP00000438917')[0] self.assertEqual(persProt.transcript.cDNA[:20], refProt.transcript.cDNA[:20]) # @unittest.skip("skipping") def test_insert(self): from pyGeno.SNPFiltering import SNPFilter class MyFilter(SNPFilter): def __init__(self): SNPFilter.__init__(self) def filter(self, chromosome, dummySRY_AGN): from pyGeno.SNPFiltering import SequenceInsert refAllele = chromosome.refSequence[dummySRY_AGN.start] return SequenceInsert('XXX') dummy = Genome(name='GRCh37.75_Y-Only', SNPs='dummySRY_AGN', SNPFilter=MyFilter()) persProt = dummy.get(Protein, id='ENSP00000438917')[0] refProt = self.ref.get(Protein, id='ENSP00000438917')[0] self.assertEqual('ATGCAATCATATGCTTCTGC', refProt.transcript.cDNA[:20]) self.assertEqual('XXXATGCAATCATATGCTTC', persProt.transcript.cDNA[:20]) # @unittest.skip("skipping") def test_SNP(self): from pyGeno.SNPFiltering import SNPFilter class MyFilter(SNPFilter): def __init__(self): SNPFilter.__init__(self) def filter(self, chromosome, dummySRY_AGN): from pyGeno.SNPFiltering import SequenceSNP return SequenceSNP(dummySRY_AGN.alt) dummy = Genome(name='GRCh37.75_Y-Only', SNPs='dummySRY_AGN', SNPFilter=MyFilter()) persProt = dummy.get(Protein, id='ENSP00000438917')[0] refProt = self.ref.get(Protein, id='ENSP00000438917')[0] self.assertEqual('M', refProt.sequence[0]) self.assertEqual('L', persProt.sequence[0]) # @unittest.skip("skipping") def test_deletion(self): from pyGeno.SNPFiltering import SNPFilter class MyFilter(SNPFilter): def __init__(self): SNPFilter.__init__(self) def filter(self, chromosome, dummySRY_AGN): from pyGeno.SNPFiltering import SequenceDel refAllele = chromosome.refSequence[dummySRY_AGN.start] return SequenceDel(1) dummy = Genome(name='GRCh37.75_Y-Only', SNPs='dummySRY_AGN', SNPFilter=MyFilter()) persProt = dummy.get(Protein, id='ENSP00000438917')[0] refProt = self.ref.get(Protein, id='ENSP00000438917')[0] self.assertEqual('ATGCAATCATATGCTTCTGC', refProt.transcript.cDNA[:20]) self.assertEqual('TGCAATCATATGCTTCTGCT', persProt.transcript.cDNA[:20]) # @unittest.skip("skipping") def test_indels(self): from pyGeno.SNPFiltering import SNPFilter class MyFilter(SNPFilter): def __init__(self): SNPFilter.__init__(self) def filter(self, chromosome, dummySRY_AGN_indels): from pyGeno.SNPFiltering import SequenceInsert ret = "" for s in dummySRY_AGN_indels: ret += "X" return SequenceInsert(ret) dummy = Genome(name='GRCh37.75_Y-Only', SNPs='dummySRY_AGN_indels', SNPFilter=MyFilter()) persProt = dummy.get(Protein, id='ENSP00000438917')[0] refProt = self.ref.get(Protein, id='ENSP00000438917')[0] self.assertEqual('XXXATGCAATCATATGCTTC', persProt.transcript.cDNA[:20]) # @unittest.skip("skipping") def test_bags(self): dummy = Genome(name='GRCh37.75_Y-Only') self.assertEqual(dummy.wrapped_object, self.ref.wrapped_object) # @unittest.skip("skipping") def test_prot_find(self): prot = self.ref.get(Protein, id='ENSP00000438917')[0] needle = prot.sequence[:10] self.assertEqual(0, prot.find(needle)) needle = prot.sequence[-10:] self.assertEqual(len(prot) - 10, prot.find(needle)) # @unittest.skip("skipping") def test_trans_find(self): trans = self.ref.get(Transcript, name="SRY-001")[0] self.assertEqual(0, trans.find(trans[:5]))
class pyGenoSNPTests(unittest.TestCase): def setUp(self): self.ref = Genome(name='GRCh37.75_Y-Only') def tearDown(self): pass def test_vanilla(self): dummy = Genome(name='GRCh37.75_Y-Only', SNPs='dummySRY_AGN') persProt = dummy.get(Protein, id='ENSP00000438917')[0] refProt = self.ref.get(Protein, id='ENSP00000438917')[0] self.assertEqual('ATGCAATCATATGCTTCTGC', refProt.transcript.cDNA[:20]) self.assertEqual('HTGCAATCATATGCTTCTGC', persProt.transcript.cDNA[:20]) def test_noModif(self): from pyGeno.SNPFiltering import SNPFilter class MyFilter(SNPFilter): def __init__(self): SNPFilter.__init__(self) def filter(self, chromosome, dummySRY_AGN): return None dummy = Genome(name='GRCh37.75_Y-Only', SNPs='dummySRY_AGN', SNPFilter=MyFilter()) persProt = dummy.get(Protein, id='ENSP00000438917')[0] refProt = self.ref.get(Protein, id='ENSP00000438917')[0] self.assertEqual(persProt.transcript.cDNA[:20], refProt.transcript.cDNA[:20]) def test_insert(self): from pyGeno.SNPFiltering import SNPFilter class MyFilter(SNPFilter): def __init__(self): SNPFilter.__init__(self) def filter(self, chromosome, dummySRY_AGN): from pyGeno.SNPFiltering import SequenceInsert refAllele = chromosome.refSequence[dummySRY_AGN.start] return SequenceInsert('TCA') dummy = Genome(name='GRCh37.75_Y-Only', SNPs='dummySRY_AGN', SNPFilter=MyFilter()) persProt = dummy.get(Protein, id='ENSP00000438917')[0] refProt = self.ref.get(Protein, id='ENSP00000438917')[0] self.assertEqual('ATGCAATCATATGCTTCTGC', refProt.transcript.cDNA[:20]) self.assertEqual('ATGATGCAATCATATGCTTC', persProt.transcript.cDNA[:20]) def test_SNP(self): from pyGeno.SNPFiltering import SNPFilter class MyFilter(SNPFilter): def __init__(self): SNPFilter.__init__(self) def filter(self, chromosome, dummySRY_AGN): from pyGeno.SNPFiltering import SequenceSNP return SequenceSNP(dummySRY_AGN.alt) dummy = Genome(name='GRCh37.75_Y-Only', SNPs='dummySRY_AGN', SNPFilter=MyFilter()) persProt = dummy.get(Protein, id='ENSP00000438917')[0] refProt = self.ref.get(Protein, id='ENSP00000438917')[0] self.assertEqual('M', refProt.sequence[0]) self.assertEqual('L', persProt.sequence[0]) def test_deletion(self): from pyGeno.SNPFiltering import SNPFilter class MyFilter(SNPFilter): def __init__(self): SNPFilter.__init__(self) def filter(self, chromosome, dummySRY_AGN): from pyGeno.SNPFiltering import SequenceDel refAllele = chromosome.refSequence[dummySRY_AGN.start] return SequenceDel(1) dummy = Genome(name='GRCh37.75_Y-Only', SNPs='dummySRY_AGN', SNPFilter=MyFilter()) persProt = dummy.get(Protein, id='ENSP00000438917')[0] refProt = self.ref.get(Protein, id='ENSP00000438917')[0] self.assertEqual('ATGCAATCATATGCTTCTGC', refProt.transcript.cDNA[:20]) self.assertEqual('TGCAATCATATGCTTCTGCT', persProt.transcript.cDNA[:20]) def test_bags(self): dummy = Genome(name='GRCh37.75_Y-Only') self.assertEqual(dummy.wrapped_object, self.ref.wrapped_object) def test_prot_find(self): prot = self.ref.get(Protein, id='ENSP00000438917')[0] needle = prot.sequence[:10] self.assertEqual(0, prot.find(needle)) needle = prot.sequence[-10:] self.assertEqual(len(prot) - 10, prot.find(needle)) def test_trans_find(self): trans = self.ref.get(Transcript, name="SRY-001")[0] self.assertEqual(0, trans.find(trans[:5])) def test_import_remote_genome(self): self.assertRaises(KeyError, B.importRemoteGenome, "Human.GRCh37.75_Y-Only.tar.gz") def test_import_remote_snps(self): self.assertRaises(KeyError, B.importRemoteSNPs, "Human_agnostic.dummySRY.tar.gz")
from pyGeno.Genome import * g = Genome(name = "GRCh37.75") prot = g.get(Protein, id = 'ENSP00000438917')[0] #print the protein sequence print prot.sequence #print the protein's gene biotype print prot.gene.biotype #print protein's transcript sequence print prot.transcript.sequence #fancy queries for exon in g.get(Exon, {"CDS_start >": x1, "CDS_end <=" : x2, "chromosome.number" : "22"}) : #print the exon's coding sequence print exon.CDS #print the exon's transcript sequence print exon.transcript.sequence #You can do the same for your subject specific genomes #by combining a reference genome with polymorphisms g = Genome(name = "GRCh37.75", SNPs = ["STY21_RNA"], SNPFilter = MyFilter())