from Bio.SeqRecord import SeqRecord
#help(SeqRecord)
#creat a SeqRecord
from Bio.Seq import Seq
simple_seq = Seq("GATCGATC")
simple_seq_r = SeqRecord(simple_seq) #可以同时指定id,description,name等属性,也可以随后重新赋值
simple_seq_r.id
'<unknown id>'
simple_seq_r.id = "ACT001.1"
simple_seq_r.id
'ACT001.1'
simple_seq_r.description
'<unknown description>'
simple_seq_r.description = "this is a test!"
simple_seq_r.description
'this is a test!'
simple_seq_r.seq
Seq('GATCGATC', Alphabet())
#SeqRecord 有一个annotation属性,会以字典的形式记录注释信息
simple_seq_r.annotations["evidence"] = "None. I just make it up"
print(simple_seq_r.annotations)
print("===========")
print(simple_seq_r.annotations["evidence"])
{'evidence': 'None. I just make it up'}
===========
None. I just make it up
eqRecord object from Fasta files
#SeqRecord object from Fasta files
from Bio import SeqIO
record = SeqIO.read("NC_005816.fna","fasta")
record.id
SeqRecord object from GenBank files
#SeqRecord object from GenBank files
record = SeqIO.read("NC_005816.gb","genbank")
record
record.seq