0

我正在尝试使用后缀 /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")
4

1 回答 1

0

您收到错误是因为您的新序列没有质量分数。您可以从输入序列中传输质量分数:

record.letter_annotations["phred_quality"]=seq_record.letter_annotations["phred_quality"]

只修改原始序列的 id 并将它们写入输出文件可能更容易:

seq_record.id = header
final_records.append(seq_record)
于 2014-12-22T09:49:40.593 回答