Uno degli esempi più felici per l'utilizzo di espressioni regolari è fornito da PROSITE (www.expasy.ch/prosite/). PROSITE è un database di domini di famiglie proteiche, ed è costituito da pattern (regolari) che rappresentano 'siti biologici significativi'. Questi siti sono definiti lungo la sequnza proteica in modo contiguo e tramite una 'grammatica regolare', il che implica che possono essere espressi tramite le nostre RE di Python. La nomenclatura utilizzata in PROSITE è leggermente differente e si può riassumere nel modo seguente
PA [AC]-x-V-x(4)-{ED}.
significa [Ala or Cys]-any-Val-any-any-any-any-{any but Glu or Asp}, mentre
PA <A-x-[ST](2)-x(0,1)-V.significa che siamo all N-terminale e viene letto come Ala-any-[Ser or Thr]-[Ser or Thr]-(any or none)-Val
Come esempio finale vediamo una funzione Python che utilizza il pattern PROSITE per le lipoproteine procariotiche e cerca se esso è presente in una sequenza data. Come si può vedere il patter originale PROSITE è
PROSITE {DERK}(6)-[LIVMFWSTAG](2)-[LIVMFYSTAGCQ]-[AGS]-C.
da cui la nostra traduzione in Python re diviene
re '[^DERK]{6,6}[LIVMFWSTAG]{2,2}[LIVMFYSTAGCQ][AGS]C'
in aggiunta utilizziamo il fatto di poter fare il match sia di caratteri
maiuscoli sia di quelli minuscoli (indipendentemente da come è stata
passata la sequenza), utilizzando in compile
la keyword re.IGNORECASE.
''' When a sequence is predicted to be a signal peptide and the
organism is a gram- or gram+ then there is the possibility
that the signal peptide is cleaved by the Signap peptidase II.
This means that the cutting site is a Cysteine and that there
is a regular expression to apply
Lipoprotein re = {DERK}(6)-[LIVMFWSTAG](2)-[LIVMFYSTAGCQ]-[AGS]-C
additional rule
RU (1) The cysteine must be between positions 15 and 35 of the sequence in
RU consideration.
RU (2) There must be at least one charged residue (Lys or Arg) in the first
RU seven residues of the sequence.
'''
def findLipo(seq,rule2=None):
'''
findlipo(seq)
'''
import re
retval=None
if len(seq) < 35 :
return retval # sequence too short
if rule2: # rule (2)
ok=None
s=seq[:7]
s.upper()
if 'R' in s or 'K' in s:
ok='yes' # ok proceed
else:
return retval # no K or R in the firrst seven
pat=re.compile('[^DERK]{6,6}[LIVMFWSTAG]{2,2}[LIVMFYSTAGCQ][AGS]C',re.IGNORECASE)
res=pat.search(seq[:36]) # rule (1)
if res and (rule2 == None or ok):
(end)=res.end()
if 15<=end : # rule (1)
retval=end,seq[:end+1]
return retval