Edit a single base in SeqRecord object in Biopython?
1
0
Entering edit mode
7.4 years ago
nchuang ▴ 260

I just want to edit a single base in one sequence in my single alignment. I read in the alignment file (ie needle-wunsch file) with SeqIO library and I get SeqRecord object. Problem is I know how to edit with .tomutable() for Seq objects but I am not sure how to do that with SeqRecord as it does not have the same function.

Do I have to slice to that position and make a single column SeqRecord object and swap it out at that position with splicing functions?

biopython • 2.3k views
ADD COMMENT
0
Entering edit mode
7.4 years ago

May be you can try converting the SeqRecord into a Python string:

>>> from Bio.Seq import Seq
>>> sequence=Seq('GCTACGATCGACTAGCTACGATCAGCATCGATC')
>>> type(sequence)
<class 'Bio.Seq.Seq'>
>>> string_sequence=str(sequence)
>>> string_sequence
'GCTACGATCGACTAGCTACGATCAGCATCGATC'
>>> type(string_sequence)
<type 'str'>

And then do whatever you want to do with the string: See this

ADD COMMENT
0
Entering edit mode

thanks but I need to keep it in alignment object and I'm not sure you can pull a SeqRecord out and replace it

ADD REPLY

Login before adding your answer.

Traffic: 1412 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6