Biopython SeqIO: AttributeError: 'str' object has no attribute 'id'
Biopython SeqIO: AttributeError: 'str' object has no attribute 'id'
我正在尝试使用 SeqIO 过滤掉序列,但出现此错误。
Traceback (most recent call last):
File "paralog_warning_filter.py", line 61, in <module>
.
.
.
SeqIO.write(desired_proteins, "filtered.fasta","fasta")
AttributeError: 'str' object has no attribute 'id'
我检查了其他类似的问题,但仍然无法理解我的脚本有什么问题。
这是我正在尝试的脚本的相关部分:
fh=open('lineageV_paralog_warning_genes.fasta')
for s_record in SeqIO.parse(fh,'fasta'):
name = s_record.id
seq = s_record.seq
for i in paralogs_in_all:
if name.endswith(i):
desired_proteins=seq
output_file=SeqIO.write(desired_proteins, "filtered.fasta","fasta")
output_file
fh.close()
我有一个单独的 paralagos_in_all
列表,这是 ID 源。当我尝试打印 name
时,它 returns 一个正确的字符串 ID 名称,格式为 >coronopifolia_tair_real-AT2G35040.1@10
.
你能帮我理解我的问题吗?提前致谢。
试着让我们知道(无法测试您的代码):
from Bio.SeqRecord import SeqRecord
from Bio import SeqIO
......
.......
desired_proteins = []
fh=open('lineageV_paralog_warning_genes.fasta')
for s_record in SeqIO.parse(fh,'fasta'):
name = s_record.id
seq = s_record.seq
for i in paralogs_in_all:
if name.endswith(i):
# desired_proteins=SeqRecord( Seq(seq), id=name) ### here seq is already a Seq object see below
desired_proteins.append(SeqRecord( seq, id=name, description="")) # description='' removes the <unknown description> that otherwise would be present
output_file=SeqIO.write(desired_proteins, "filtered.fasta","fasta") ## don't know how to have SeqIO.write to append to file instead of re-writing all of it
fh.close()
我正在尝试使用 SeqIO 过滤掉序列,但出现此错误。
Traceback (most recent call last):
File "paralog_warning_filter.py", line 61, in <module>
.
.
.
SeqIO.write(desired_proteins, "filtered.fasta","fasta")
AttributeError: 'str' object has no attribute 'id'
我检查了其他类似的问题,但仍然无法理解我的脚本有什么问题。
这是我正在尝试的脚本的相关部分:
fh=open('lineageV_paralog_warning_genes.fasta')
for s_record in SeqIO.parse(fh,'fasta'):
name = s_record.id
seq = s_record.seq
for i in paralogs_in_all:
if name.endswith(i):
desired_proteins=seq
output_file=SeqIO.write(desired_proteins, "filtered.fasta","fasta")
output_file
fh.close()
我有一个单独的 paralagos_in_all
列表,这是 ID 源。当我尝试打印 name
时,它 returns 一个正确的字符串 ID 名称,格式为 >coronopifolia_tair_real-AT2G35040.1@10
.
你能帮我理解我的问题吗?提前致谢。
试着让我们知道(无法测试您的代码):
from Bio.SeqRecord import SeqRecord
from Bio import SeqIO
......
.......
desired_proteins = []
fh=open('lineageV_paralog_warning_genes.fasta')
for s_record in SeqIO.parse(fh,'fasta'):
name = s_record.id
seq = s_record.seq
for i in paralogs_in_all:
if name.endswith(i):
# desired_proteins=SeqRecord( Seq(seq), id=name) ### here seq is already a Seq object see below
desired_proteins.append(SeqRecord( seq, id=name, description="")) # description='' removes the <unknown description> that otherwise would be present
output_file=SeqIO.write(desired_proteins, "filtered.fasta","fasta") ## don't know how to have SeqIO.write to append to file instead of re-writing all of it
fh.close()