Skip to content

Instantly share code, notes, and snippets.

@guma44
Last active September 27, 2018 07:00
Show Gist options
  • Save guma44/e1ee22b0d308b3cadb437287c79d9380 to your computer and use it in GitHub Desktop.
Save guma44/e1ee22b0d308b3cadb437287c79d9380 to your computer and use it in GitHub Desktop.
Some useful regular expressions
import re
pdb_identification_regex = re.compile("^[1-9][a-zA-Z0-9]{3}$")
uniprot_identification_regex = re.compile("^[OPQ][0-9][A-Z0-9]{3}[0-9]$|^[A-NR-Z][0-9]([A-Z][A-Z0-9]{2}[0-9]){1,2}$")
aminoacid_sequence_regex = re.compile("^[GPAVLIMCFYWHKRQNEDST\n\r]{10,}$", re.I | re.M)
float_regex = re.compile(r"^-?(?:\d+())?(?:\.\d*())?(?:e-?\d+())?(?:\2|\1\3)$")
int_regex = re.compile(r"^(?<![\d.])[0-9]+(?![\d.])$")
email_regex = re.compile(r"(.+@[a-zA-Z0-9\.]+,?){1,}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment