本文整理汇总了Python中Bio.SeqIO.QualityIO._get_phred_quality方法的典型用法代码示例。如果您正苦于以下问题:Python QualityIO._get_phred_quality方法的具体用法?Python QualityIO._get_phred_quality怎么用?Python QualityIO._get_phred_quality使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bio.SeqIO.QualityIO
的用法示例。
在下文中一共展示了QualityIO._get_phred_quality方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: write_record
# 需要导入模块: from Bio.SeqIO import QualityIO [as 别名]
# 或者: from Bio.SeqIO.QualityIO import _get_phred_quality [as 别名]
def write_record(self, record):
"""Write a single Phd record to the file."""
assert record.seq, "No sequence present in SeqRecord"
# This method returns the 'phred_quality' scores or converted
# 'solexa_quality' scores if present, else raises a value error
phred_qualities = QualityIO._get_phred_quality(record)
peak_locations = record.letter_annotations.get("peak_location")
if len(record.seq) != len(phred_qualities):
raise ValueError("Number of phd quality scores does not match "
"length of sequence")
if peak_locations:
if len(record.seq) != len(peak_locations):
raise ValueError("Number of peak location scores does not "
"match length of sequence")
if None in phred_qualities:
raise ValueError("A quality value of None was found")
if record.description.startswith("%s " % record.id):
title = record.description
else:
title = "%s %s" % (record.id, record.description)
self.handle.write("BEGIN_SEQUENCE %s\nBEGIN_COMMENT\n"
% self.clean(title))
for annot in [k.lower() for k in Phd.CKEYWORDS]:
value = None
if annot == "trim":
if record.annotations.get("trim"):
value = "%s %s %.4f" % record.annotations["trim"]
elif annot == "trace_peak_area_ratio":
if record.annotations.get("trace_peak_area_ratio"):
value = "%.4f" % record.annotations[
"trace_peak_area_ratio"]
else:
value = record.annotations.get(annot)
if value or value == 0:
self.handle.write("%s: %s\n" % (annot.upper(), value))
self.handle.write("END_COMMENT\nBEGIN_DNA\n")
for i, site in enumerate(record.seq):
if peak_locations:
self.handle.write("%s %i %i\n" % (
site,
round(phred_qualities[i]),
peak_locations[i])
)
else:
self.handle.write("%s %i\n" % (
site,
round(phred_qualities[i]))
)
self.handle.write("END_DNA\nEND_SEQUENCE\n")