本文整理汇总了Python中Pipeline.getTempFile方法的典型用法代码示例。如果您正苦于以下问题:Python Pipeline.getTempFile方法的具体用法?Python Pipeline.getTempFile怎么用?Python Pipeline.getTempFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pipeline
的用法示例。
在下文中一共展示了Pipeline.getTempFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadCoverageData
# 需要导入模块: import Pipeline [as 别名]
# 或者: from Pipeline import getTempFile [as 别名]
def loadCoverageData(infile, outfile):
'''
load coverage data into database
'''
to_cluster = True
tablename = P.toTable(outfile)
database = os.path.join(PARAMS["results_resultsdir"], PARAMS["database"])
dbh = sqlite3.connect(database)
cc = dbh.cursor()
temp = P.getTempFile()
temp.write("contig_id\tacoverage\n")
for data in cc.execute("""SELECT contig_id, AVG(coverage) FROM %s GROUP BY contig_id""" % tablename).fetchall():
temp.write("\t".join(list(data)) + "\n")
temp.close()
P.load(temp.name, outfile)
os.unlink(temp.name)
示例2: plotRelativeAbundanceCorrelations
# 需要导入模块: import Pipeline [as 别名]
# 或者: from Pipeline import getTempFile [as 别名]
def plotRelativeAbundanceCorrelations(infiles, outfile):
'''
plot the correlation between the estimated
relative abundance of species and the true
relative abundances - done on the shared set
'''
# connect to database
dbh = sqlite3.connect(PARAMS["database"])
cc = dbh.cursor()
true_file = infiles[0]
temp = P.getTempFile()
temp.write("true\testimate\n")
for estimate_file in infiles[1:]:
if os.path.basename(estimate_file)[len("metaphlan_"):] == os.path.basename(true_file):
tablenames = [P.toTable(os.path.basename(true_file)), P.toTable(os.path.basename(estimate_file))]
# get data
statement = """SELECT a.relab, b.rel_abundance
FROM %s as a, %s as b
WHERE b.taxon_level == "species"
AND a.species_name == b.taxon""" % (tablenames[0], tablenames[1])
for data in cc.execute(statement).fetchall():
true, estimate = data[0], data[1]
temp.write("%f\t%f\n" % (true, estimate))
temp.close()
print temp.name
inf = temp.name
R('''data <- read.csv("%s", header = T, stringsAsFactors = F, sep = "\t")''' % inf)
R('''png("%s")''' % outfile)
main_name = P.snip(outfile, ".png")
R('''data$estimate <- data$estimate/100''')
R('''plot(data$estimate, data$true, pch = 16, main = "%s", xlab = "estimated relative abundance", ylab = "observed relative abundance")''' % main_name)
R('''text(0.05, y = 0.35, labels = paste("r = ", round(cor(data$estimate, data$true),2)), cex = 2)''')
R["dev.off"]()
os.unlink(inf)