Permalink
Browse files

Fix motif alphabet instance bug

  • Loading branch information...
1 parent 0c4ad9a commit 6e471bde475196db9992797693240b1cde709580 @peterjc peterjc committed Jul 17, 2013
Showing with 14 additions and 8 deletions.
  1. +7 −4 Bio/Motif/_Motif.py
  2. +7 −4 Bio/motifs/matrix.py
View
@@ -767,10 +767,13 @@ def scanPWM(self,seq):
- the sequence can only be a DNA sequence
- the search is performed only on one strand
"""
- if self.alphabet!=IUPAC.unambiguous_dna:
- raise ValueError("Wrong alphabet! Use only with DNA motifs")
- if seq.alphabet!=IUPAC.unambiguous_dna:
- raise ValueError("Wrong alphabet! Use only with DNA sequences")
+ #TODO - Code itself tolerates ambiguous bases (as NaN).
+ if not isinstance(self.alphabet, IUPAC.IUPACUnambiguousDNA):
+ raise ValueError("PSSM has wrong alphabet: %s - Use only with DNA motifs" \
+ % self.alphabet)
+ if not isinstance(seq.alphabet, IUPAC.IUPACUnambiguousDNA):
+ raise ValueError("Sequence has wrong alphabet: %r - Use only with DNA sequences" \
+ % sequence.alphabet)
seq = seq.tostring()
View
@@ -347,10 +347,13 @@ def calculate(self, sequence):
number is returned
- otherwise, the result is a one-dimensional list or numpy array
"""
- if self.alphabet!=IUPAC.unambiguous_dna:
- raise ValueError("Wrong alphabet! Use only with DNA motifs")
- if sequence.alphabet!=IUPAC.unambiguous_dna:
- raise ValueError("Wrong alphabet! Use only with DNA sequences")
+ #TODO - Code itself tolerates ambiguous bases (as NaN).
+ if not isinstance(self.alphabet, IUPAC.IUPACUnambiguousDNA):
+ raise ValueError("PSSM has wrong alphabet: %s - Use only with DNA motifs" \
+ % self.alphabet)
+ if not isinstance(sequence.alphabet, IUPAC.IUPACUnambiguousDNA):
+ raise ValueError("Sequence has wrong alphabet: %r - Use only with DNA sequences" \
+ % sequence.alphabet)
#TODO - Force uppercase here and optimise switch statement in C
#by assuming upper case?

0 comments on commit 6e471bd

Please sign in to comment.