当前位置: 首页>>代码示例>>Python>>正文


Python mymysql.connectDB函数代码示例

本文整理汇总了Python中mymysql.connectDB函数的典型用法代码示例。如果您正苦于以下问题:Python connectDB函数的具体用法?Python connectDB怎么用?Python connectDB使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了connectDB函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

def main(geneN1, geneN2, altType1='rpkm', altType2='rpkm', dset='tcga1'):

	tblN1,valN1,featN1,lab1 = altTypeH[altType1]
	tblN2,valN2,featN2,lab2 = altTypeH[altType2]

	con,cursor = mymysql.connectDB(db=dset)

	cursor.execute('select samp_id from mutation_normal where gene_symL="IDH1" and ch_aa like "%sR132%s"' % ('%','%'))
	idh1 = [x[0] for x in cursor.fetchall()]

	ret1 = os.system('''(echo "SELECT t1.samp_id,t1.%s %s,t2.%s %s FROM %s t1, %s t2 where t1.%s='%s' and t2.%s='%s' and t1.samp_id=t2.samp_id" | mysql %s -u cancer --password=cancer > /var/www/html/tmp/correlation.txt) &> /var/www/html/tmp/correaltion.err''' % \
		(valN1,geneN1, valN2,geneN2, tblN1,tblN2, featN1,geneN1, featN2,geneN2, dset))

	f = open('/var/www/html/tmp/correlation.txt')
	fo = open('/var/www/html/tmp/correlation_idh1.txt','w')

	for line in f:
		(sId, t1, t2) = line[:-1].split('\t')

		if sId in idh1:
			fo.write('%s\t%s\t%s\t%s\n' % (sId,t1,t2,'mut'))
		else:
			fo.write('%s\t%s\t%s\t%s\n' % (sId,t1,t2,'na'))
	f.close()
	fo.close()

	ret2 = os.system('Rscript correlation_idh1.r "%s" "%s" "%s" png &>> /var/www/html/tmp/correaltion.err' % (dsetH[dset],lab1,lab2))

	return ret1!=0 or ret2!=0
开发者ID:SMC1,项目名称:JK1,代码行数:29,代码来源:correlation_idh1.py

示例2: main

def main(inDir, outDir, pbs=False, server='smc1'):

	inFileNL = os.listdir(inDir)
	inFileNL = filter(lambda x: re.match('.*\.ngCGH', x), inFileNL)

	print 'Files: %s' % inFileNL

	(con, cursor) = mymysql.connectDB(user=mysetting.mysqlH[server]['user'], passwd=mysetting.mysqlH[server]['passwd'], db='ircr1', host=mysetting.mysqlH[server]['host'])
	for inFileN in inFileNL:
		sampN = re.match('(.*)\.ngCGH', inFileN).group(1)
		(sid, tag) = re.match('(.*)_(T.{,2}.*)_[STKN]{2}\.ngCGH', inFileN).groups()
		if tag != 'T':
			sid = '%s_%s' % (sid, tag)
		cursor.execute('SELECT tumor_frac FROM xsq_purity WHERE samp_id="%s"' % sid)
		purity = int(cursor.fetchall()[0][0])

		iprefix = '%s/%s' % (inDir,sampN)
		oprefix = '%s/%s' % (outDir,sampN)
		cmd = '/usr/bin/python %s/NGS/copynumber/cn_corr.py -i %s.ngCGH -o %s.corr.ngCGH -p %s' % (mysetting.SRC_HOME, iprefix, oprefix, purity)
		log = '%s.cn_corr.qlog' % (oprefix)
		print cmd
		if pbs:
			os.system('echo "%s" | qsub -N %s -o %s -j oe' % (cmd, sampN, log))

		else:
			os.system('(%s) &> %s' % (cmd, log))		
开发者ID:SMC1,项目名称:JK1,代码行数:26,代码来源:cn_corr_batch.py

示例3: prep_somatic_new

def prep_somatic_new(outFileN, server='smc1', dbN='ircr1'):
	## run VEP
	vep_batch.main(glob('/EQL3/pipeline/somatic_mutation/*S'), postfixL=['.mutect_rerun_filter.vcf','.mutect_filter.vcf','.mutect_pair_filter.vcf','.indels_pair_filter.vcf'], fork=True)

	## make table
	DIR='/EQL3/pipeline/somatic_mutation'
	cmd = 'cat %s/*/*filter_vep.dat | /usr/bin/python %s/Integration/prepDB_mutation_xsq2mut_tmp.py > %s' % (DIR, mysetting.SRC_HOME, outFileN)
	os.system(cmd)

	## update tag
	sidL = map(lambda x: x.rstrip(), os.popen('cut -f 1 %s | sort | uniq' % outFileN).readlines())
	(con, cursor) = mymysql.connectDB(user=mysetting.mysqlH[server]['user'],passwd=mysetting.mysqlH[server]['passwd'],db=dbN,host=mysetting.mysqlH[server]['host'])
	for sid in sidL:
		cursor.execute('SELECT samp_id,tag FROM sample_tag WHERE samp_id="%s" AND tag LIKE "XSeq_%%"' % sid)
		results = cursor.fetchall()
		if len(results)>0:
			if len(results)>1:
				sys.stderr.write('Duplication in sample_tag: %s\n' % sid)
				sys.exit(1)
			else:
				old_tag = results[0][1]
				new_tag = '%s,N' % old_tag
				cursor.execute('UPDATE sample_tag SET samp_id="%s", tag="%s" WHERE samp_id="%s" AND tag="%s"' % (sid,new_tag, sid,old_tag))
		else:
			cursor.execute('INSERT INTO sample_tag SET samp_id="%s", tag="XSeq_SS,N"' % sid)
开发者ID:SMC1,项目名称:JK1,代码行数:25,代码来源:post_xsq2mut.py

示例4: post_rsq2eiJunc

def post_rsq2eiJunc(dirN, server='smc1', dbN='ihlee_test', sampL=[]):
	(con, cursor) = mymysql.connectDB(user=mysqlH[server]['user'],passwd=mysqlH[server]['passwd'],db=dbN,host=mysqlH[server]['host'])
	sampNL = filter(lambda x: os.path.isdir(dirN + '/' + x), os.listdir(dirN))
	for sampN in sampNL:
		baseDir = dirN + '/' + sampN
		sid = sampN[:-4].replace('.','_').replace('-','_') ## RNASeq sample has '***_RSq'
		if sampL != [] and sid not in sampL:
			continue
		print sampN, sid
		## make sure to update sample_tag that this sample has RNA-Seq
		cursor.execute('SELECT * FROM sample_tag WHERE samp_id="%s" AND tag="RNA-Seq"' % sid)
		results = cursor.fetchall()
		if len(results) < 1:
			cursor.execute('INSERT INTO sample_tag SET samp_id="%s", tag="RNA-Seq"' % sid)
		ei_dat = glob('%s/%s*ei.dat' % (baseDir, sampN))[0]
		if dbN in ['ihlee_test','ircr1']:
			splice_eiJunc_txt = '%s/eiJunc/splice_eiJunc_%s_ft.txt' % (BASE, sampN)
		else:
			splice_eiJunc_txt = '%s/splice_eiJunc_%s_ft.txt' % (baseDir, sampN)
		ei_junc_filter.main(overlap=10, minNReads=1, inFileN=ei_dat, outFileN=splice_eiJunc_txt)
		if dbN in ['ihlee_test','ircr1']:
			splice_eiJunc_dat = '%s/eiJunc/splice_eiJunc_%s.dat' % (BASE, sampN)
		else:
			splice_eiJunc_dat = '%s/splice_eiJunc_%s.dat' % (baseDir, sampN)
		prepDB_splice_eiJunc.main(minNReads=1, sampNamePat=RSQPattern, geneList=[], inFileN=splice_eiJunc_txt, outFileN=splice_eiJunc_dat)
		cursor.execute('DELETE FROM splice_eiJunc WHERE samp_id="%s"' % sid)
		cursor.execute('LOAD DATA LOCAL INFILE "%s" IGNORE INTO TABLE splice_eiJunc' % splice_eiJunc_dat)
	makeDB_splice_AF.eiJunc(dbN=dbN, cursor=cursor)
开发者ID:SMC1,项目名称:JK1,代码行数:28,代码来源:post_rsq2other.py

示例5: post_rsq2fusion

def post_rsq2fusion(dirN, server='smc1', dbN='ihlee_test', sampL=[]):
	(con, cursor) = mymysql.connectDB(user=mysqlH[server]['user'],passwd=mysqlH[server]['passwd'],db=dbN,host=mysqlH[server]['host'])
	sampNL = filter(lambda x: os.path.isdir(dirN + '/' + x), os.listdir(dirN))
	for sampN in sampNL:
		baseDir = dirN + '/' + sampN
		sid = sampN[:-4].replace('.','_').replace('-','_') ## RNASeq sample has '***_RSq'
		if sampL != [] and sid not in sampL:
			continue
		print sampN, sid
		## make sure to update sample_tag that this sample has RNA-Seq
		cursor.execute('SELECT * FROM sample_tag WHERE samp_id="%s" AND tag="RNA-Seq"' % sid)
		results = cursor.fetchall()
		if len(results) < 1:
			cursor.execute('INSERT INTO sample_tag SET samp_id="%s", tag="RNA-Seq"' % sid)

		fusion_report_annot = glob('%s/%s*_splice_transloc_annot1.report_annot.txt' % (baseDir, sampN))[0]
		if dbN in ['ihlee_test','ircr1']:
			splice_fusion_txt = '%s/fusion/splice_fusion_%s.txt' % (BASE, sampN)
		else:
			splice_fusion_txt = '%s/splice_fusion_%s.txt' % (baseDir, sampN)
		fusion_summarize.fusion_summarize_s(inputFileN=fusion_report_annot, minNPos=1, outFileN=splice_fusion_txt)
		if dbN in ['ihlee_test','ircr1']:
			splice_fusion_dat = '%s/fusion/splice_fusion_%s.dat' % (BASE, sampN)
		else:
			splice_fusion_dat = '%s/splice_fusion_%s.dat' % (baseDir, sampN)
		prepDB_splice_fusion.main(inGctFileName=splice_fusion_txt, minNPos=1, sampNamePat=RSQPattern, geneList=[], outFileN=splice_fusion_dat)
		cursor.execute('DELETE FROM splice_fusion WHERE samp_id="%s"' % sid)
		cursor.execute('LOAD DATA LOCAL INFILE "%s" IGNORE INTO TABLE splice_fusion' % splice_fusion_dat)
		cursor.execute('DELETE FROM splice_fusion WHERE gene_sym1 LIKE "HLA-%" AND gene_sym2 LIKE "HLA-%"')
	makeDB_splice_AF.fusion(dbN=dbN, cursor=cursor)
开发者ID:SMC1,项目名称:JK1,代码行数:30,代码来源:post_rsq2other.py

示例6: main

def main(outFileName,dbNL,dTypeL,outDirName,outFileN):

	for dbN in dbNL:

		(con,cursor) = mymysql.connectDB(db=dbN)

		if dbN == 'ircr1':
			cursor.execute('create temporary table t_recur select distinct samp_id from sample_tag where substring(tag,1,6)="pair_P"')
		elif dbN == 'tcga1':
			cursor.execute('create temporary table t_recur select distinct samp_id from sample_tag where tag="Recur"')

		cursor.execute('SELECT distinct loc,geneName FROM tcga1.methyl_pId where platform="Infinium27k"')
		results1 = cursor.fetchall()

		for dType in dTypeL:

			for (loc,geneN) in results1:

				outFile = open(outFileName,'w')

				outFile.write('%s\t%s\t%s\t%s\t%s\t%s\t%s\n' % ('dbT','dType','geneN','PR','sId','val','loc'))

				for PR in ('P','R'):

					cursor.execute('select pId,%s from %s where platform="Infinium27k" and loc="%s" and geneName="%s" and pId %s in (select samp_id from t_recur)' % (dTypeH[dType][1],dTypeH[dType][0],loc,geneN,'not' if PR=='P' else ''))
					results = cursor.fetchall()

					for (sId,val) in results:
						outFile.write('%s\t%s\t%s\t%s\t%s\t%s\t%s\n' % (dbH[dbN],dType,geneN,PR,sId,val,loc))

				outFile.close()
				
				os.system('Rscript %s/PrimRecur/unpaired_gene_methyl_ks.r %s %s &>> %s/error_kstest.txt' % (mysetting.SRC_HOME,outDirName,outFileN,outDirName))
		
		con.close()
开发者ID:SMC1,项目名称:JK1,代码行数:35,代码来源:df_unpaired_gene_methyl.py

示例7: post_s_rsq2expr

def post_s_rsq2expr(baseDir, server='smc1', dbN='ihlee_test'):
	sampN = baseDir.split('/')[-1]
	sid = sampN[:-4].replace('-','_').replace('.','_') ##drop '_RSq'

	if dbN in ['ihlee_test','ircr1']:
		gctFileN = '/EQL1/NSL/RNASeq/results/expression/%s.gct' % sampN
		datFileN = '/EQL1/NSL/RNASeq/results/expression/%s.dat' % sampN
	else:
		gctFileN = '%s/%s.gct' % (baseDir, sampN)
		datFileN = '%s/%s.dat' % (baseDir, sampN)
	print sampN, gctFileN
	rpkm_process.rpkm_process(inputDirN=baseDir, filePattern='*.rpkm', sampRegex='(.*)_RSq\.rpkm', outputFileN=gctFileN)
	## prep
	prepDB_rpkm_gene_expr.main(inGctFileName=gctFileN, geneList=[], samplePrefix='', outDatFileName=datFileN)
	## import
	(con, cursor) = mymysql.connectDB(user=mysqlH[server]['user'],passwd=mysqlH[server]['passwd'],db=dbN,host=mysqlH[server]['host'])
	cursor.execute('DELETE FROM rpkm_gene_expr WHERE samp_id="%s"' % sid)
	cursor.execute('LOAD DATA LOCAL INFILE "%s" INTO TABLE rpkm_gene_expr' % datFileN)
	cursor.execute('DROP VIEW IF EXISTS rpkm_gene_expr_lg2')
	cursor.execute('CREATE VIEW rpkm_gene_expr_lg2 AS SELECT samp_id,gene_sym,log2(rpkm+1) AS lg2_rpkm FROM rpkm_gene_expr')
	## make sure to update sample_tag that this sample has RNA-Seq
	cursor.execute('SELECT * FROM sample_tag WHERE samp_id="%s" AND tag="RNA-Seq"' % sid)
	results = cursor.fetchall()
	if len(results) < 1:
		cursor.execute('INSERT INTO sample_tag SET samp_id="%s", tag="RNA-Seq"' % sid)
	
	##draw boxplot
	boxplot_expr_cs_gene.main(sid, '/EQL1/NSL/RNASeq/results/expression')
开发者ID:SMC1,项目名称:JK1,代码行数:28,代码来源:post_rsq2expr.py

示例8: main

def main(dbN='ircr1', cursor=None):
	if cursor == None:
		(con,cursor) = mymysql.connectDB(db=dbN)

	cursor.execute('drop table if exists mutation_rxsq')

	cursor.execute('create temporary table t_m as \
		select n.samp_id,n.chrom,n.chrSta,n.chrEnd,n.ref,n.alt,n.n_nReads_ref,n.n_nReads_alt,n.nReads_ref,n.nReads_alt,r.r_nReads_ref,r.r_nReads_alt,n.strand,n.gene_symL,n.ch_dna,n.ch_aa,n.ch_type,n.cosmic,n.mutsig \
		from mutation_normal n left join mutation_rsq r \
		on n.samp_id = r.samp_id and n.chrom=r.chrom and n.chrSta=r.chrSta and n.ref=r.ref and n.alt=r.alt \
		union \
		select r.samp_id,r.chrom,r.chrSta,r.chrEnd,r.ref,r.alt,n.n_nReads_ref,n.n_nReads_alt,n.nReads_ref,n.nReads_alt,r.r_nReads_ref,r.r_nReads_alt,r.strand,r.gene_symL,r.ch_dna,r.ch_aa,r.ch_type,r.cosmic,r.mutsig \
		from mutation_normal n right join mutation_rsq r \
		on n.samp_id = r.samp_id and n.chrom=r.chrom and n.chrSta=r.chrSta and n.ref=r.ref and n.alt=r.alt')

	cursor.execute('create table mutation_rxsq as \
		select * from (select * from t_m order by ch_dna desc) as i group by samp_id,chrom,chrSta,ref,alt,ch_aa')

	cursor.execute('update mutation_rxsq set r_nReads_ref = 0, r_nReads_alt = 0 where r_nReads_ref is null')
	cursor.execute('update mutation_rxsq set n_nReads_ref = 0, n_nReads_alt = 0 where n_nReads_ref is null')
	cursor.execute('update mutation_rxsq set nReads_ref = 0, nReads_alt = 0 where nReads_ref is null')

	cursor.execute('alter table mutation_rxsq add index (samp_id,gene_symL)')
	cursor.execute('alter table mutation_rxsq add index (samp_id,chrom,chrSta,chrEnd)')
	cursor.execute('alter table mutation_rxsq add index (samp_id,chrom,chrSta,ref,alt)')
	cursor.execute('alter table mutation_rxsq add index (samp_id,chrom,chrSta,chrEnd,ref,alt)')
	
	cursor.execute('drop temporary table if exists t_m')
开发者ID:SMC1,项目名称:JK1,代码行数:28,代码来源:makeDB_mutation_rxsq.py

示例9: main

def main(inDir, outDir, cnDir, pbs=False, server='smc1'):

	inFileNL = os.listdir(inDir)
	inFileNL = filter(lambda x: not re.match('(.*)\.union_pos\.mutect$', x), filter(lambda x: re.match('(.*)\.mutect$', x), inFileNL))

	print 'Files: %s' % inFileNL

	(con, cursor) = mymysql.connectDB(user=mysetting.mysqlH[server]['user'], passwd=mysetting.mysqlH[server]['passwd'], db='ircr1', host=mysetting.mysqlH[server]['host'])
	for inFileN in inFileNL:
		sampN = re.match('(.*)\.mutect', inFileN).group(1)
		(sid, postfix) = re.match('(.*)_(T.{,2})_[STKN]{2}\.mutect', inFileN).groups()
		if postfix != 'T':
			sid = '%s_%s' % (sid, postfix)
		cursor.execute('SELECT tumor_frac FROM xsq_purity WHERE samp_id="%s"' % sid)
		result = cursor.fetchall()
		if len(result) > 0 and result[0][0] != 'ND':
			purity = int(result[0][0])
			iprefix = '%s/%s' % (inDir, sampN)
			oprefix = '%s/%s' % (outDir, sampN)
			segFile = '%s/%s/%s.ngCGH.seg' % (cnDir, sampN, sampN)
			if os.path.isfile(segFile) and not os.path.isfile('%s.mutect_cl.dat' % (oprefix)):
				cmd = '/usr/bin/python %s/NGS/mutation/mut_clonality.py -s %s -i %s.mutect -o %s.mutect_cl.dat -p %s' % (mysetting.SRC_HOME, segFile, iprefix, oprefix, purity)
				log = '%s.mutect_cl.log' % (oprefix)

				if pbs:
					os.system('echo "%s" | qsub -N %s -o %s -j oe' % (cmd, sampN, log))
				else:
					os.system('(%s) &> %s' % (cmd, log))
			else:
				print "Missing copy number segmentation file!"
				sys.exit(1)
开发者ID:SMC1,项目名称:JK1,代码行数:31,代码来源:mut_clonality_batch.py

示例10: main

def main(outFileName):

	(con,cursor) = mymysql.connectDB(db='ircr1')

	outFile = open(outFileName,'w')

	cursor.execute('select distinct samp_id from sample_tag where substring(tag,1,6)="pair_R" and samp_id!="S520" and samp_id!="S042"')
	sIdL_prim = [x for (x,) in cursor.fetchall()]

	outFile.write('%s\t%s\t%s\t%s\t%s\t%s\n' % ('dType','geneN','sId_p','sId_r','val_p','val_r'))

	for dType in dTypeL:

		for geneN in geneL:

			for sId_p in sIdL_prim:

				(tbl,col_name,col_val) = dTypeH[dType]

				cursor.execute('select samp_id from sample_tag where tag="pair_P:%s"' % sId_p)
				(sId_r,) = cursor.fetchone()

				cursor.execute('select %s from %s where %s="%s" and samp_id="%s"' % (col_val,tbl,col_name,geneN,sId_p))
				r_p = cursor.fetchone()

				cursor.execute('select %s from %s where %s="%s" and samp_id="%s"' % (col_val,tbl,col_name,geneN,sId_r))
				r_r = cursor.fetchone()

				if r_p and r_r:
					outFile.write('%s\t%s\t%s\t%s\t%.2f\t%.2f\n' % (dType,geneN,sId_p,sId_r,r_p[0],r_r[0]))

	outFile.close()
	con.close()
开发者ID:SMC1,项目名称:JK1,代码行数:33,代码来源:df_paired_pathway.py

示例11: main

def main():

	con,cursor = mymysql.connectDB(db='tcga1')

	cursor.execute('SELECT distinct platform,loc FROM methyl_pId')
	results1 = cursor.fetchall()

	output = []

	for (plat,loc) in results1:

		#cursor.execute('select fraction,z_score from methyl_pId, array_gene_expr where platform="%s" and loc="%s" and gene_sym="MGMT" and pId=samp_id' % (plat,loc))
		cursor.execute('select fraction,log2(rpkm+1) from methyl_pId, rpkm_gene_expr where platform="%s" and loc="%s" and gene_sym="MGMT" and pId=samp_id' % (plat,loc))
		results2 = cursor.fetchall()

		methyl,expr = zip(*results2)

		r = numpy.corrcoef(methyl,expr)[0,1]

		output.append((plat,loc,len(methyl),r))

	output.sort(lambda x,y: cmp(y[-1],x[-1]))

	for (plat,loc,n,r) in output:
		print '%s\t%s\t%s\t%.2f' % (plat,loc,n,r)
开发者ID:SMC1,项目名称:JK1,代码行数:25,代码来源:select_methyl_loc.py

示例12: post_xsq2cn

def post_xsq2cn(outFileN, platform='', server='smc1', dbN='ircr1'):
	if platform == 'CS':
		cmd = 'cat %s/*/*%s.cn_gene.dat | /usr/bin/python %s/Integration/prepDB_xsq_cn.py > %s' % (mysetting.CScnaDir,platform, mysetting.SRC_HOME, outFileN)
	else:
		cmd = 'cat %s/*/*%s.cn_gene.dat | /usr/bin/python %s/Integration/prepDB_xsq_cn.py > %s' % (mysetting.wxsCNADir,platform, mysetting.SRC_HOME, outFileN)
	os.system(cmd)
	if platform == 'SS':
		tableN = 'xsq_cn'
	elif platform == 'CS':
		tableN = 'cs_cn'
	else:
		sys.stderr.write('illegal platform name: %s' % platform)
		sys.exit(1)

	mymysql.reset_table(tableN=tableN, dataFileN=outFileN, user=mysetting.mysqlH[server]['user'],passwd=mysetting.mysqlH[server]['passwd'],db=dbN, host=mysetting.mysqlH[server]['host'])

	## add samp_id if missing
	(con, cursor) = mymysql.connectDB(user=mysetting.mysqlH[server]['user'], passwd=mysetting.mysqlH[server]['passwd'], db=dbN, host=mysetting.mysqlH[server]['host'])
	cursor.execute('SELECT DISTINCT samp_id FROM %s' % tableN)
	sIdL = [x for (x,) in cursor.fetchall()]
	cursor.execute('SELECT DISTINCT samp_id FROM sample_tag WHERE tag like "XSeq_%s%%"' % platform)
	refL = [x for (x,) in cursor.fetchall()]
	for sid in sIdL:
		if sid not in refL:
			pl = platform
			cursor.execute('INSERT INTO sample_tag SET samp_id="%s", tag="XSeq_%s"' % (sid, pl))
开发者ID:SMC1,项目名称:JK1,代码行数:26,代码来源:post_xsq2other.py

示例13: main

def main(locFileName):

	con,cursor = mymysql.connectDB(db='tcga1')
	
	locFile = open(locFileName)

	cursor.execute('drop table if exists methyl_gene')

	for line in locFile:
		
		(plat, gN, loc, n, r) = line[:-1].split('\t')

		if r != '-nan' and float(r) <= -0.25:

			cursor.execute('create temporary table t_methyl as \
				select * from methyl where geneName="%s" and platform="%s" and loc="%s"' % (gN,plat,loc))
			
			cursor.execute('alter table t_methyl add column r float, add column n smallint unsigned')
			cursor.execute('update t_methyl set n=%s, r=%s' % (int(n),float(r)))

			try:
				cursor.execute('create table methyl_gene as \
					select platform,pId,geneName,loc,sum(fraction)/count(fraction) fraction, n, r from t_methyl group by pId')
			except:
				cursor.execute('insert into methyl_gene \
					select platform,pId,geneName,loc,sum(fraction)/count(fraction) fraction, n, r from t_methyl group by pId')

			cursor.execute('drop table t_methyl')

	cursor.execute('alter table methyl_gene add index (geneName)')
	cursor.execute('alter table methyl_gene add index (pId)')
开发者ID:SMC1,项目名称:JK1,代码行数:31,代码来源:makeDB_methyl_gene.py

示例14: main

def main():

	con,cursor = mymysql.connectDB(db='tcga1')

	cursor.execute('create temporary table t_EGFR as \
		select platform,pId,geneName,loc,sum(fraction)/count(fraction) fraction from tcga1.methyl where TN="T" and geneName = "EGFR" \
		group by platform, pId, loc')

	cursor.execute('alter table t_EGFR add index (geneName)')
	cursor.execute('alter table t_EGFR add index (pId)')

	cursor.execute('SELECT distinct platform,loc FROM t_EGFR')
	results1 = cursor.fetchall()

	output = []

	for (plat,loc) in results1:

		#cursor.execute('select fraction,z_score from methyl_pId, array_gene_expr where platform="%s" and loc="%s" and gene_sym="MGMT" and pId=samp_id' % (plat,loc))
		cursor.execute('select fraction,log2(rpkm+1) from t_EGFR, rpkm_gene_expr where platform="%s" and loc="%s" and gene_sym="EGFR" and pId=samp_id' % (plat,loc))
		results2 = cursor.fetchall()

		methyl,expr = zip(*results2)

		r = numpy.corrcoef(methyl,expr)[0,1]

		output.append((plat,loc,len(methyl),r))

	output.sort(lambda x,y: cmp(y[-1],x[-1]))

	for (plat,loc,n,r) in output:
		print '%s\t%s\t%s\t%.3f' % (plat,loc,n,r)
开发者ID:SMC1,项目名称:JK1,代码行数:32,代码来源:select_methyl_loc_EGFR.py

示例15: main

def main(outFileName,dbNL,dTypeL,geneNL):

	outFile = open(outFileName,'w')

	outFile.write('%s\t%s\t%s\t%s\t%s\t%s\n' % ('dbT','dType','geneN','PR','sId','val'))

	for dbN in dbNL:

		(con,cursor) = mymysql.connectDB(db=dbN)

		if dbN == 'ircr1':
			cursor.execute('create temporary table t_recur select distinct samp_id from sample_tag where substring(tag,1,6)="pair_P"')
		elif dbN == 'tcga1':
			cursor.execute('create temporary table t_recur select distinct samp_id from sample_tag where tag="Recur"')

		for dType in dTypeL:

			for geneN in geneNL:

				for PR in ('P','R'):

					cursor.execute('select samp_id,%s from %s where gene_sym="%s" and samp_id %s in (select samp_id from t_recur)' % (dTypeH[dType][1],dTypeH[dType][0],geneN,'not' if PR=='P' else ''))
					results = cursor.fetchall()

					for (sId,val) in results:
						outFile.write('%s\t%s\t%s\t%s\t%s\t%s\n' % (dbH[dbN],dType,geneN,PR,sId,val))

		con.close()

	outFile.close()
开发者ID:SMC1,项目名称:JK1,代码行数:30,代码来源:df_unpaired_gene.py


注:本文中的mymysql.connectDB函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。