def probesetfreeze_list(inbredsetid, dir):
    strains = datastructure.get_strains(inbredsetid)
    print(strains)
    probesetfreezes = datastructure.get_probesetfreezes(inbredsetid)
    print "From DB, get %d probesetfreezes" % (len(probesetfreezes))
    for probesetfreeze in probesetfreezes:
        print probesetfreeze
        probesetfreeze_item(strains, dir, probesetfreeze)
Beispiel #2
0
def bxd_correlations():
    #
    inbredsetid = 1
    genofile = "/home/leiyan/gn/web/genotypes/BXD.geno"
    outputdir = "/home/leiyan/gn2/wqflask/maintenance/dataset/datadir/20140205_Ash_correlations/output"
    #
    t = genotypes.load_genos(genofile)
    genostrains = t[0]
    genos = t[1]
    print "From geno file, get %d strains" % (len(genostrains))
    print "From geno file, get %d genos" % (len(genos))
    #
    probesetfreezes = datastructure.get_probesetfreezes(inbredsetid)
    print "From DB, get %d probesetfreezes" % (len(probesetfreezes))
    for probesetfreeze in probesetfreezes:
        correlations(outputdir=outputdir, genos=genos, probesetfreeze=probesetfreeze)
Beispiel #3
0
def probesetfreeze_list():
    #
    inbredsetid = 1
    outputdir = "/home/leiyan/gn2/wqflask/maintenance/dataset/datadir/20140205_Ash_correlations/output"
    #
    probesetfreezes = datastructure.get_probesetfreezes(inbredsetid)
    print "From DB, get %d probesetfreezes" % (len(probesetfreezes))
    file = open(outputdir + '/' + 'probesetfreezes.txt', 'w+')
    #
    for probesetfreeze in probesetfreezes:
        #
        print probesetfreeze
        probesetfreezeid = probesetfreeze[0]
        probesetfreezename = probesetfreeze[1]
        probesetfreezefullname = probesetfreeze[2]
        #
        file.write("%s\t" % probesetfreezeid)
        file.write("%s" % probesetfreezefullname)
        file.write("\n")
        file.flush()
        #
    file.close()
Beispiel #4
0
def traverse(outputfile):
	#
	file = open(outputfile, 'w')
	inbredsetid = 1
	strains = datastructure.get_strains(inbredsetid)
	print("strains: %s" % len(strains))
	sum = [0] * len(strains)
	probesetfreezes = datastructure.get_probesetfreezes(inbredsetid)
	print("probesetfreezes: %s" % len(probesetfreezes))
	#
	cursor, con = utilities.get_cursor()
	#
	file.write("DatasetID\t")
	file.write("DatasetName\t")
	file.write("RecordNumber\t")
	for strain in strains:
		file.write("%s\t" % strain[1])
	file.write("\n")
	file.flush()
	# phenotypes
	publishxrefs = phenotypes.get_publishxrefs(inbredsetid)
	file.write("-\t")
	file.write("%s\t" % "Phenotypes")
	file.write("%d\t" % len(publishxrefs))
	#
	for i,strain in enumerate(strains):
		sql = """
			SELECT COUNT(PublishData.Id)
			FROM PublishXRef,PublishData
			WHERE PublishXRef.InbredSetId=%s
			AND PublishXRef.DataId=PublishData.Id
			AND PublishData.StrainId=%s
			AND PublishData.value IS NOT NULL
			"""
		cursor.execute(sql, (inbredsetid, strain[0]))
		n = cursor.fetchone()[0]
		file.write("%d\t" % n)
		file.flush()
		sum[i] += n
	#
	file.write("\n")
	file.flush()
	#
	for probesetfreeze in probesetfreezes:
		#
		probesetfreezeid = probesetfreeze[0]
		probesetfreezename = probesetfreeze[1]
		probesetfreezefullname = probesetfreeze[2]
		probesetxrefs = probesets.get_probesetxref(probesetfreezeid)
		#
		file.write("%d\t" % probesetfreezeid)
		file.write("%s\t" % probesetfreezefullname)
		file.write("%d\t" % len(probesetxrefs))
		#
		for i,strain in enumerate(strains):
			sql = """
				SELECT COUNT(ProbeSetData.`Id`)
				FROM ProbeSetXRef,ProbeSetData
				WHERE ProbeSetXRef.`ProbeSetFreezeId`=%s
				AND ProbeSetXRef.`DataId`=ProbeSetData.`Id`
				AND ProbeSetData.`StrainId`=%s
				AND ProbeSetData.`value` IS NOT NULL
				"""
			cursor.execute(sql, (probesetfreezeid, strain[0]))
			n = cursor.fetchone()[0]
			file.write("%d\t" % n)
			file.flush()
			sum[i] += n
		#
		file.write("\n")
		file.flush()
	# sum
	file.write("-\t")
	file.write("%s\t" % "Sum")
	file.write("-\t")
	#
	for e in sum:
		file.write("%d\t" % e)
		file.flush()
	#
	file.write("\n")
	file.flush()
	#
	file.close()
	con.close()