Created
March 21, 2018 11:32
-
-
Save mattravenhall/2221437a6c32093a283266ff6e355c23 to your computer and use it in GitHub Desktop.
Convert a fasta to a genbank file with SeqIO, accounting for issues with alphabets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Fasta to Genbank (dna) | |
| filename = 'example_fasta' | |
| from Bio import SeqIO | |
| from Bio.Alphabet import generic_dna | |
| seqs = list(SeqIO.parse(filename+'.fa','fasta')) | |
| for seq in seqs: | |
| seq.seq.alphabet = generic_dna | |
| SeqIO.write(seqs, filename+'.gbk', 'genbank') |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fasta to Genbank conversion with SeqIO requires that the seq alphabet types be converted to generic_dna. This short script avoids having to mess around with that.