1
$\begingroup$

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)
$\endgroup$
1
  • $\begingroup$ Thank you for the edit @finswimmer $\endgroup$
    – Lipsa
    Jan 4, 2021 at 10:54

2 Answers 2

2
$\begingroup$

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

$\endgroup$
1
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.