def printprobesandorderthem(probesfile, probesoutputfile): import os import simplejson import Bio.Seq import info if probesoutputfile in os.listdir('./'): print "WARNING: file exists" file = open(probesfile) probeslist = simplejson.load(file) file.close() cells = info.lineinfo().all file = open(probesoutputfile,'w') file.write('NAME'+','+ 'SEQUENCE' + '\n') for pl in probeslist: for i,p in enumerate(pl): pr = Primer(p[0], p[1], cells.index(p[2]), p[3], p[4]) print pr.seqlig (file.write(pr.line + str(i) + ',' + Bio.Seq.reverse_complement(pr.seqlig) + pr.backbone + Bio.Seq.reverse_complement(pr.seqext) + '\n')) file.close()
def __init__(self, chr, pos, snpline, ref, alt): import info self.ref = ref self.alt = alt lines = info.lineinfo() cells = lines.individuals['CEU'] + lines.individuals['CHBJPT'] + lines.individuals['YRI'] self.chr = chr self.pos = pos self.lpos = self.ligpos() self.epos = self.extpos() self.seqlig = str(hg18['chr'+str(self.chr)][self.lpos[0]:self.lpos[1]]) self.seqext = str(hg18['chr'+str(self.chr)][self.epos[0]:self.epos[1]]) self.backbone = 'AGATCGGAAGAGCGTCGCATGTTATCGAGGTC' self.line = cells[snpline]
def num_genotypes_trios(genotypes): import info num_genos = [] num_alleles = [] lineID = [] for geno in genotypes: print geno a = num_genotypes([geno]) num_genos.append(a[0]) num_alleles.append(a[1]) lineID.append(a[2]) if num_genos[0] == 2 and num_genos[1] == 2: i = info.lineinfo() snp1cells = map(lambda x: i.all[x], lineID[0]) snp2cells = map(lambda x: i.all[x], lineID[1]) if i.child['YRI'] in snp1cells and i.child['YRI'] in snp2cells: if i.parents['YRI'][0] in snp1cells+snp2cells and i.parents['YRI'][1] in snp1cells+snp2cells: return i.child['YRI']
sa = 0 for al in records[r].alignments: if 'GRCh37.p2' in al.title: for hsp in al.hsps: if hsp.expect < EXPECT_THRESH: sa = sa+1 if sa == 2: goodprobes.append(r) return goodprobes if __name__ == "__main__": import simplejson import info import os lines = info.lineinfo() cells = lines.all file = open('./19.outputUniqueSNPs') # file = open('./probes1') candidateloci = simplejson.load(file) file.close() # take only num alleles == 2 #a = alleles(candidateloci, 2) a = candidateloci primersbeforeblastandtrio = runTests(a) ''' file = open('./primersbeforeblastandtrio1026') plist = simplejson.load(file) file.close()