Saturday, March 14, 2015

bpy4. SeqRecord in Biopython

A SeqRecord object contains annotations describing the sequence.


An example, based on one from their docs, is presented.


You can get the help docs using SeqRecord? in IPython or help(SeqRecord).


The docs pertaining to creating a SeqRecord is printed. This is only partial, and a complete printout will occur the subscripts are omitted.

# bpy4.py

from __future__ import print_function
from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord
from Bio.Alphabet.IUPAC import protein
seqStr = 'MKQHKAMIVALIVICITAVVAALVTRKDLCEVHIRTGQTEVAVF'  
record = SeqRecord(Seq(seqStr,protein),
                       id="YP_025292.1", name="HokC",
                       description="toxic membrane protein")
print("record.annotations:",record.annotations)
record.annotations['where']="from docs, 'SecRecord?'"
print("record.annotations:",record.annotations)
print("record.annotations['where']:",record.annotations['where'])
createSeqRec = SeqRecord.__init__.__doc__[:317]
for i in createSeqRec.split("\n"): print(i.strip())
#record.annotations: {}
#record.annotations: {'where': "from docs, 'SecRecord?'"}
#record.annotations['where']: from docs, 'SecRecord?'
#Create a SeqRecord.
#
#Arguments:
#- seq         - Sequence, required (Seq, MutableSeq or UnknownSeq)
#- id          - Sequence identifier, recommended (string)
#- name        - Sequence name, optional (string)
#- description - Sequence description, optional (string)

No comments:

Post a Comment