Patch: data validation in Bio.Seq and Bio.MutableSeq
Yves Bastide <Yves.Bastide <at> irisa.fr>
2004-10-05 12:34:36 GMT
Attached patch adds a third parameter, "check", to Seq and MutableSeq's
constructors. If set, the data is checked against the alphabet.
Regards,
yves
Index: Bio/Seq.py
===================================================================
RCS file: /home/repository/biopython/biopython/Bio/Seq.py,v
retrieving revision 1.10
diff -u -p -r1.10 Seq.py
--- Bio/Seq.py 26 Aug 2004 13:22:58 -0000 1.10
+++ Bio/Seq.py 5 Oct 2004 12:28:10 -0000
<at> <at> -4,12 +4,36 <at> <at> import Alphabet
from Alphabet import IUPAC
from Data.IUPACData import ambiguous_dna_complement, ambiguous_rna_complement
+def _check_data(data, alphabet):
+ """_check_data(data, alphabet) -> bool
+
+ Check whether the data corresponds to the alphabet."""
+ if not data or not alphabet.letters:
+ return 1
+ if alphabet.size == 1:
+ import re
+ mo = re.match(r"^[%s]+$" % re.escape(alphabet.letters), data)
+ return mo is not None
+ else:
(Continue reading)