Statistics for Discovering Patterns from Sequences with Applications to Protein-Protein and Protein-DNA Interaction