Question: Import Fasta Sequences To A Motif
1
gravatar for RossCampbell
7.8 years ago by
RossCampbell140
USA/Frederick
RossCampbell140 wrote:

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.

motif biopython parsing • 2.4k views
ADD COMMENTlink written 7.8 years ago by RossCampbell140
2
gravatar for brentp
7.8 years ago by
brentp23k
Salt Lake City, UT
brentp23k wrote:

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).

ADD COMMENTlink written 7.8 years ago by brentp23k

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.

ADD REPLYlink written 7.8 years ago by RossCampbell140
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1869 users visited in the last hour