How To Generate A Motif Object Directly For A Count Matrix In Biopython
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.
• 4,002 views
•
link
2 answers
You can use:
m = Motif(counts=pfm)
• 0 views
•
link
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.
• 0 views
•
link
Log in to answer this question.