Algorithms for pattern matching and discovery in RNA secondary structure