# biopython-motifs , How can I create motif from sequences of different length?

I want to create motif of different length kmers. Following code works for kmers of same length but not different length.What to do ?

from Bio import motifs

sequences = SeqIO.parse("myfile.fasta","fasta")
instances = []
for data in sequences:
instance = data.seq
instances.append(instance)

motif = motifs.create(instances)

• Thank you for the edit @finswimmer Jan 4 at 10:54

## 2 Answers

Motifs are not designed to be variable length in general since PSSMs/PVMs don't support insertions/deletions (indels). Instead, I suggest profile HMMs, such as those offered by HMMER3, which do support indels. You can parse HMMER3 output with Biopython via Bio.SearchIO.HmmerIO

All sequences represented in a Biopython motif object must be the same length. For example, a motif has a __len__ property, which has to consist of a single value.

There are other methods that do support variable-length motifs, I suggest that you look into them, but unfortunately biopython seems to be limited to fixed-length motifs.