omics.co.in logo omics.co.in

Day 11: Sequence Motif Discovery & Functional Pattern Matching (PROSITE & MEME)

Tested Stacks: GATK 4.6.1 Samtools 1.21 Nextflow 24.10 Seurat v5.1 Python 3.12
Prerequisites: Basic Linux CLI & Sequencing Formats
📚 Chapter 11 of 15 0% Course Completed

1. Biological Nature of Motifs: Patterns vs. Profiles

While a domain is an independently folding structural globule of 50–300 amino acids, a motif is a short, contiguous or semi-contiguous functional sequence signature (typically 3–20 residues). Biological motifs mediate:

  • Post-Translational Modification (PTM) Sites: Phosphorylation target sites for kinases (e.g. Protein Kinase C, Tyrosine Kinases), N-linked glycosylation (N-{P}-[ST]-{P}).
  • Subcellular Localization Signals: Nuclear Localization Signals (NLS, e.g. the SV40 large T antigen classical monopartite NLS PKKKRKV).
  • Small Molecule / Ligand Binding: The P-loop (Walker A motif) for ATP/GTP nucleotide binding: [AG]-x(4)-G-K-[ST].
  • Proteolytic Cleavage Signatures: Caspase cleavage sites (e.g. D-E-V-D for Caspase-3/7).

2. PROSITE Pattern Syntax Standard

The PROSITE database formalizes deterministic regular expression patterns using an exact, standardized biological syntax:

PROSITE Syntax ElementBiological Representation / InterpretationRegex Equivalent
Standard letter (e.g. C)An invariant single amino acid (Cysteine)C
xAny of the 20 standard amino acids. (dot)
[ALT]Any single amino acid listed inside brackets (Ala, Leu, or Thr)[ALT]
{V}Any amino acid except those listed inside braces (Not Valine)[^V]
x(4)Exact repetition: exactly 4 variable amino acids.{4}
x(2,4)Range repetition: between 2 and 4 variable amino acids.{2,4}
< and >Anchored at N-terminus (<) or C-terminus (>)^ and $
Hyphen (-)Separator between pattern tokens(Concatenation)

Deconstructing the Walker A Nucleotide-Binding Motif

$$\text{PROSITE Pattern: } [\text{AG}]-\text{x}(4)-\text{G}-\text{K}-[\text{ST}]$$

Translation: Starts with Alanine or Glycine, followed by any 4 amino acids, followed by invariant Glycine, followed by invariant Lysine, followed by Serine or Threonine.

3. Probabilistic Motifs, PWMs & Sequence Logos

Transcription Factor Binding Sites (TFBS) and degenerate motifs cannot be captured by rigid deterministic regular expressions. They are represented by Position Weight Matrices (PWMs). The information content ($R_i$) of column $i$ in bits is quantified using Shannon entropy ($H_i$):

$$R_i = \log_2(20) - \left( -\sum_{a=1}^{20} p_{ia} \log_2 p_{ia} \right)$$

In a Sequence Logo, the total height of a column represents its information content (up to $\log_2(20) \approx 4.32\text{ bits}$ for proteins, $2.0\text{ bits}$ for DNA), and the relative height of each individual letter is proportional to its observed frequency.

4. Production Python Script: PROSITE-to-Regex Compiler & Motif Scanner

#!/usr/bin/env python3
"""
Day 11 Practical: PROSITE Pattern Compiler & Proteome Scanner
Converts biological PROSITE syntax into standard Python Regex and scans proteins.
"""

import re

def prosite_to_regex(prosite_pattern: str) -> str:
    """Translate standard PROSITE notation to Python regular expression."""
    p = prosite_pattern.strip()
    # Remove hyphens
    p = p.replace("-", "")
    # Convert {XYZ} (not X, Y, Z) to [^XYZ]
    p = re.sub(r"\{([A-Z]+)\}", r"[^]", p)
    # Convert x(N) to .{N} and x(N,M) to .{N,M}
    p = re.sub(r"x\((\d+)\)", r".{}", p)
    p = re.sub(r"x\((\d+),(\d+)\)", r".{,}", p)
    # Convert x to .
    p = p.replace("x", ".")
    # Convert < to ^ (N-terminus) and > to $ (C-terminus)
    p = p.replace("<", "^").replace(">", "$")
    return p

def scan_protein_for_motif(protein_seq: str, prosite_pattern: str, motif_name="Motif"):
    """Scan protein sequence and output match coordinates and matching text."""
    regex_pattern = prosite_to_regex(prosite_pattern)
    regex = re.compile(regex_pattern)
    
    matches = []
    for match in regex.finditer(protein_seq):
        start = match.start() + 1
        end = match.end()
        matched_seq = match.group()
        matches.append((start, end, matched_seq))
        
    print(f"=== {motif_name} SCAN ===")
    print(f"PROSITE: {prosite_pattern} -> Regex: {regex_pattern}")
    print(f"Matches Found: {len(matches)}")
    for start, end, seq in matches:
        print(f"  Position: {start}..{end} | Matched Sequence: {seq}")
    return matches

if __name__ == "__main__":
    # Test on Human Ras oncogene GTPase sequence
    kras_sequence = (
        "MTEYKLVVVGAGGVGKSALTIQLIQNHFVDEYDPTIEDSYRKQVVIDGETCLLDILDTAGQEEYSAMRDQYMRTG"
        "EGFLCVFAINNTKSFEDIHHYREQIKRVKDSEDVPMVLVGNKCDLPSRTVDTKQAQDLARSYGIPFIETSAKTRQ"
        "RVEDAFYTLVREIRQYRLKKISKEEKTPGCVKIKKCIIM"
    )

    # 1. ATP/GTP-binding site motif A (P-loop): [AG]-x(4)-G-K-[ST]
    scan_protein_for_motif(kras_sequence, "[AG]-x(4)-G-K-[ST]", "P-loop (Walker A Motif)")

    # 2. Protein Kinase C phosphorylation site: [ST]-x-[RK]
    scan_protein_for_motif(kras_sequence, "[ST]-x-[RK]", "PKC Phosphorylation Site")
⚠️

Common Pitfalls & Troubleshooting Checklist

  • Java Heap Exhaustion (GATK / Picard): If processes terminate with java.lang.OutOfMemoryError, set your environment variable explicitly: export _JAVA_OPTIONS="-Xmx16g -Djava.io.tmpdir=/tmp".
  • Index Timestamp Mismatch: If tools complain that a BAM index is missing or out of date, regenerate with samtools index -@ 4 sample.bam.
  • Conda Channel Conflicts: Avoid ABI incompatibilities between bioconda and conda-forge by setting strict priority: conda config --set channel_priority strict.
  • Chromosome Naming Contamination: Always verify whether reference FASTA headers use chr1 or 1; divergent naming causes silent alignment drops.
Was this guide helpful to your research?
Help us maintain 100% accurate, peer-reviewed bioinformatics standards.
📝 Propose Edit on GitHub ↗