本文整理汇总了Python中lib.BtLog.progress方法的典型用法代码示例。如果您正苦于以下问题:Python BtLog.progress方法的具体用法?Python BtLog.progress怎么用?Python BtLog.progress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.BtLog
的用法示例。
在下文中一共展示了BtLog.progress方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: readBam
# 需要导入模块: from lib import BtLog [as 别名]
# 或者: from lib.BtLog import progress [as 别名]
def readBam(infile, set_of_blobs):
reads_total, reads_mapped = checkBam(infile)
progress_unit = int(int(reads_mapped)/1000) + 1 # lazy fix
base_cov_dict = {}
read_cov_dict = {}
cigar_match_re = re.compile(r"(\d+)M") # only gets digits before M's
# execute samtools to get only mapped reads
command = "samtools view -F 4 " + infile
# ADD flag picard -F 1028 to not consider optical duplicates
#command = "samtools view -F 1028 " + infile
# only one counter since only yields mapped reads
parsed_reads = 0
for line in runCmd(command):
match = line.split("\t")
if match >= 11:
seq_name = match[2]
base_cov = sum([int(matching) for matching in cigar_match_re.findall(match[5])])
if (base_cov):
parsed_reads += 1
if seq_name not in set_of_blobs:
print BtLog.warn_d['2'] % (seq_name, infile)
else:
base_cov_dict[seq_name] = base_cov_dict.get(seq_name, 0) + base_cov
read_cov_dict[seq_name] = read_cov_dict.get(seq_name, 0) + 1
BtLog.progress(parsed_reads, progress_unit, reads_total)
BtLog.progress(reads_total, progress_unit, reads_total)
if not int(reads_mapped) == int(parsed_reads):
print warn_d['3'] % (reads_mapped, parsed_reads)
return base_cov_dict, reads_total, parsed_reads, read_cov_dict
示例2: readCas
# 需要导入模块: from lib import BtLog [as 别名]
# 或者: from lib.BtLog import progress [as 别名]
def readCas(infile, order_of_blobs):
seqs_total, reads_total, reads_mapped = checkCas(infile)
progress_unit = int(len(order_of_blobs)/100)
cas_line_re = re.compile(r"\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+.\d{2})\s+(\d+)\s+(\d+.\d{2})")
command = "clc_mapping_info -n " + infile
cov_dict = {}
read_cov_dict = {}
seqs_parsed = 0
if (runCmd(command)):
for line in runCmd(command):
cas_line_match = cas_line_re.search(line)
if cas_line_match:
idx = int(cas_line_match.group(1)) - 1 # -1 because index of contig list starts with zero
try:
name = order_of_blobs[idx]
reads = int(cas_line_match.group(3))
cov = float(cas_line_match.group(6))
cov_dict[name] = cov
read_cov_dict[name] = reads
seqs_parsed += 1
except:
pass
BtLog.progress(seqs_parsed, progress_unit, seqs_total)
BtLog.progress(seqs_total, progress_unit, seqs_total)
return cov_dict, reads_total, reads_mapped, read_cov_dict
示例3: readBam
# 需要导入模块: from lib import BtLog [as 别名]
# 或者: from lib.BtLog import progress [as 别名]
def readBam(infile, fasta_headers):
reads_total, reads_mapped = checkBam(infile)
progress_unit = int(int(reads_total)/1000)
base_cov_dict = {}
cigar_match_re = re.compile(r"(\d+)M") # only gets digits before M's
read_cov_dict = {}
# execute samtools to get only mapped reads from primary alignment
command = "samtools view -q " + str(mq) + " -F 256 -F 4 " + infile
# only one counter since only yields mapped reads
parsed_reads = 0
for line in runCmd(command):
match = line.split("\t")
seq_name = match[2]
if seq_name not in fasta_headers:
print BtLog.warn_d['2'] % (seq_name, infile)
else:
read_cov_dict[seq_name] = read_cov_dict.get(seq_name, 0) + 1
if not (no_base_cov_flag):
base_cov = sum([int(matching) for matching in cigar_match_re.findall(match[5])])
if (base_cov):
base_cov_dict[seq_name] = base_cov_dict.get(seq_name, 0) + base_cov
parsed_reads += 1
BtLog.progress(parsed_reads, progress_unit, reads_total)
BtLog.progress(reads_total, progress_unit, reads_total)
return base_cov_dict, read_cov_dict, reads_total, parsed_reads
示例4: writeNodesDB
# 需要导入模块: from lib import BtLog [as 别名]
# 或者: from lib.BtLog import progress [as 别名]
def writeNodesDB(nodesDB, nodesDB_f):
nodes_count = nodesDB['nodes_count']
i = 0
with open(nodesDB_f, 'w') as fh:
fh.write("# nodes_count = %s\n" % nodes_count)
for node in nodesDB:
if not node == "nodes_count":
i += 1
BtLog.progress(i, 1000, nodes_count)
fh.write("%s\t%s\t%s\t%s\n" % (node, nodesDB[node]['rank'], nodesDB[node]['name'], nodesDB[node]['parent']))
示例5: computeTaxonomy
# 需要导入模块: from lib import BtLog [as 别名]
# 或者: from lib.BtLog import progress [as 别名]
def computeTaxonomy(self, taxrules, nodesDB):
tree_lists = BtTax.getTreeList(self.set_of_taxIds, nodesDB)
self.lineages = BtTax.getLineages(tree_lists, nodesDB)
self.taxrules = taxrules
i = 0
for blObj in self.dict_of_blobs.values():
i += 1
BtLog.progress(i, 100, self.seqs)
for taxrule in taxrules:
if (blObj.hits):
blObj.taxonomy[taxrule] = BtTax.taxRule(taxrule, blObj.hits, self.lineages)
else:
blObj.taxonomy[taxrule] = BtTax.noHit()
示例6: readNodesDB
# 需要导入模块: from lib import BtLog [as 别名]
# 或者: from lib.BtLog import progress [as 别名]
def readNodesDB(nodesDB_f):
nodesDB = {}
nodes_count = 0
i = 0
with open(nodesDB_f) as fh:
for line in fh:
if line.startswith("#"):
nodes_count = int(line.lstrip("# nodes_count = ").rstrip("\n"))
else:
i += 1
node, rank, name, parent = line.rstrip("\n").split("\t")
nodesDB[node] = {'rank' : rank, 'name' : name, 'parent' : parent}
BtLog.progress(i, 1000, nodes_count)
return nodesDB
示例7: readCov
# 需要导入模块: from lib import BtLog [as 别名]
# 或者: from lib.BtLog import progress [as 别名]
def readCov(infile, set_of_blobs):
old_cov_line_re = re.compile(r"^(\S+)\t(\d+\.*\d*)")
base_cov_dict = {}
cov_line_re = re.compile(r"^(\S+)\t(\d+\.*\d*)\t(\d+\.*\d*)")
reads_total = 0
reads_mapped = 0
read_cov_dict = {}
seqs_parsed = 0
progress_unit = 1
old_format = 1
with open(infile) as fh:
for line in fh:
if line.startswith("#"):
old_format = 0
if old_format == 0:
if line.startswith("# Total Reads"):
reads_total = int(line.split(" = ")[1])
elif line.startswith("# Mapped Reads"):
reads_mapped = int(line.split(" = ")[1])
elif line.startswith("# Unmapped Reads"):
pass
elif line.startswith("# Parameters"):
pass
elif line.startswith("# contig_id"):
pass
else:
match = cov_line_re.search(line)
if match:
seqs_parsed += 1
name, read_cov, base_cov = match.group(1), int(match.group(2)), float(match.group(3))
if name not in set_of_blobs:
print BtLog.warn_d['2'] % (name, infile)
read_cov_dict[name] = read_cov
base_cov_dict[name] = base_cov
else:
match = old_cov_line_re.search(line)
if match:
seqs_parsed += 1
name, base_cov = match.group(1), float(match.group(2))
if name not in set_of_blobs:
print BtLog.warn_d['2'] % (name, infile)
base_cov_dict[name] = base_cov
BtLog.progress(seqs_parsed, progress_unit, len(set_of_blobs))
#BtLog.progress(len(set_of_blobs), progress_unit, len(set_of_blobs))
return base_cov_dict, reads_total, reads_mapped, read_cov_dict
示例8: readCov
# 需要导入模块: from lib import BtLog [as 别名]
# 或者: from lib.BtLog import progress [as 别名]
def readCov(infile, set_of_blobs):
cov_line_re = re.compile(r"^(\S+)\t(\d+\.*\d*)")
cov_dict = {}
seqs_parsed = 0
progress_unit = int(len(set_of_blobs)/100)
with open(infile) as fh:
for line in fh:
BtLog.progress(seqs_parsed, 10, len(set_of_blobs))
match = cov_line_re.search(line)
if match:
seqs_parsed += 1
name, cov = match.group(1), float(match.group(2))
if name not in set_of_blobs:
print BtLog.warn_d['2'] % (name, infile)
cov_dict[name] = cov
BtLog.progress(seqs_parsed, progress_unit, len(set_of_blobs))
BtLog.progress(len(set_of_blobs), progress_unit, len(set_of_blobs))
return cov_dict