How To Generate A Motif Object Directly For A Count Matrix In Biopython
2
1
Entering edit mode
12.2 years ago
cauyrd ▴ 20

If I have a variable in python like this:

pfm = {'A': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
       'C': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
       'G': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
       'T': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}

how to generate a Biopython Motif object from this variable directly other than save above matrix in a file and use Motif.read() to load the matrix into a Motif object.

biopython • 3.6k views
ADD COMMENT
1
Entering edit mode
10.0 years ago

You can use:

m = Motif(counts=pfm)
ADD COMMENT
0
Entering edit mode
12.2 years ago
lelle ▴ 830

As far as I can see there is no way to do this with a proper function of the Motif class. You could try to just do:

m = Motif()
m.counts = pfm
m.has_counts = True
m.set_mask("*"*m.length)

I did not test it and have no idea if there are any problems with the alphabet, but something along this lines could work.

ADD COMMENT

Login before adding your answer.

Traffic: 1889 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