← Back to Book Detail

Chapter 2: Sequence Motifs (2/6) -- Applied Bioinformatics

Browse
33%

Chapter 2: Sequence Motifs

Chapter 2: Sequence Motifs 2.1 Introduction to Motifs A biological motif, broadly speaking, is a pattern found occurring in a set of biological sequences, such as in DNA or protein sequences. A motif could be an exact sequence, such as [latex]\texttt{TGACGTCA}[/latex], or it could be a degenerate consensus sequence, allowing for ambiguous characters, such as [latex]\texttt{R}[/latex] for [latex]\texttt{A}[/latex] or [latex]\texttt{G}[/latex]. Motifs can also be described by a probabilistic model, such as a position-specific scoring matrix (PSSM) or weight matrix. 2.2 String Matching Frequently we want to search for an exact string or pattern within a larger sequence. For example, when using a restriction enzyme to cut a larger sequence at sequence-specific sites that match a particular pattern, we would like know where this pattern occurs in the larger sequence. This task can be called string matching. There are numerous algorithms that have been developed to make this task more efficient, such as the Knuth-Morris-Pratt algorithm [9] and the Burrows-Wheeler transform [10]. These approaches are beyond the scope of this course, but definitely worth mentioning. Let’s examine how to utilize the Biopython function [latex]\texttt{nt_search}[/latex] as part of the [latex]\texttt{SeqUtils}[/latex] module. We can use the function as follows to search for the short pattern [latex]\texttt{ACG}[/latex]. >>> from Bio.Seq import Seq >>> from Bio import SeqUtils >>> pattern = Seq("ACG") >>> sequence = Seq("ATGCGCGACGGCGTGATCAGCTTATAGCCGTACGACTGCTGCAACGTGACTGAT") >>> results = SeqUtils.nt_search(str(sequence),pattern) >>> print(results) ['ACG', 7, 31, 43] You’ll note that the function takes in two arguments. The first is the sequence to search, but it is not a [latex]\texttt{Seq}[/latex] object, but the basic python string. The python function “str()” converts the [latex]\texttt{Seq}[/latex] object into a string. The second argument is the pattern or string that we are searching, but this argument clearly can be the [latex]\texttt{Seq}[/latex] object, which it is in this example. Typically, we consider the DNA sequence that we are searching as double stranded, hence we want to search the forward strand and its reverse complement. In many cases for bioinformatics, such as searching an entire chromosome, it is easier to reverse complement the pattern rather that the sequence to search. In this example, this looks like >>> results_rc = SeqUtils.nt_search(str(sequence),pattern.reverse_complement()) >>> print(results_rc) ['CGT', 11, 28, 44] In this example, we have searched the forward strand of the DNA sequence. Alternatively, a biologist might want to know where the patterns occurs with positions defined along the reverse complement of the sequence we are searching, or the reverse strand if the DNA is double stranded. In the example of the restriction enzyme, positions defined along the reverse complement of the larger sequence are more useful for predicting the le
← Previous Chapter Next Chapter →