我正在尝试使用postfix / 1和/ 2更改fastq标头并将其写回新的fie。但是,我收到了这个错误:
No suitable quality scores found in letter_annotations of SeqRecord
有什么方法可以解决这个问题吗?我是否需要修改质量得分信息以匹配已更改的fastq标头?
import sys
from Bio.Seq import Seq
from Bio import SeqIO
from Bio.SeqRecord import SeqRecord
file = sys.argv[1]
final_records=[]
for seq_record in SeqIO.parse(file, "fastq"):
print seq_record.format("fastq")
#read header
header =seq_record.id
#add /1 at the end
header ="{0}/1".format(header)
# print(repr(seq_record.seq))
record = SeqRecord(seq_record.seq,id=header,description=seq_record.description)
final_records.append(record)
SeqIO.write(final_records, "my_example.fastq", "fastq")
答案 0 :(得分:0)
您收到错误是因为您的新序列没有质量得分。您可以从输入序列中传输质量分数:
record.letter_annotations["phred_quality"]=seq_record.letter_annotations["phred_quality"]
修改原始序列的id并将它们写入输出文件可能更容易:
seq_record.id = header
final_records.append(seq_record)