Thanks. m1 == m, I just haven't updated all the variable names yet from my other program that I borrowed this block of code from.
Import Fasta Sequences To A Motif
I need to construct a PWM from every sequence in a fasta file, using biopython. The way I'm trying to do this is to import each line of sequence into a motif, then run a PWM on each instance of the motif. Currently, I'm trying it this way, but different variations of it have generated their fair share of errors, mostly "Wrong Alphabet" and "NoneType object is not iterable":
alphabet = IUPAC.unambiguous_dna
m = Motif.Motif(alphabet)
for seq_record in SeqIO.parse("10fasta.fasta", "fasta"):
m.add_instance(seq_record.seq)
print m1.pwm()
Does anyone see what's wrong with the way I'm adding instances to the motif? Of course, if there's a better way to do this that I'm completely missing, feel free to comment on that too.
• 4,522 views
•
link
1 answer
You need to tell SeqIO.parse which alphabet to use as well:
from Bio import SeqIO
from Bio.Alphabet import IUPAC
from Bio import Motif
alphabet = IUPAC.unambiguous_dna
m = Motif.Motif(alphabet)
for seq_record in SeqIO.parse("some.fasta", "fasta", alphabet=alphabet):
m.add_instance(seq_record.seq)
print m.pwm()
(and your m1 is undefined).
• 2 views
•
link
• 0 views
•
link
Log in to answer this question.