Problem 5: Finding the Motif in DNA

Hard

In bioinformatics, a motif is a nucleotide sequence pattern that has some biological significance, often representing binding sites for proteins or regulatory regions in DNA. Finding a motif within a DNA sequence is a common task in genomics, where the goal is to locate all occurrences of a short nucleotide sequence (the motif) within a longer DNA sequence (the genome).


For example, given a DNA sequence and a motif, the task is to find all starting positions where the motif appears as a substring in the DNA sequence. Positions in the sequence are usually 1-based, meaning the first nucleotide in the sequence is considered to be at position 1.


Your task is to write a program that locates all occurrences of a given motif within a given DNA sequence. Run your program with the provided input, and then paste your results here to submit. The output should be a space-separated list of starting positions.


Sample Input:

GATATATGCATATACTT ATAT

Sample Output:

2 4 10

Constraints:

The DNA sequence will contain at most 1,000 nucleotides, and the motif will be a substring of length at most 10.

Explanation:

In the sample input, the DNA sequence is "GATATATGCATATACTT" and the motif is "ATAT". The motif occurs in the DNA sequence at positions 2, 4, and 10. Note that these positions are 1-based, which is typical in bioinformatics.

The output "2 4 10" represents the starting positions of each occurrence of the motif in the sequence. This process is crucial in various genomic analyses, particularly in identifying functional elements within a genome.

Post a Comment

0Comments

Post a Comment (0)

#buttons=(Ok, Go it!) #days=(20)

Our app uses cookies to enhance your experience. Check Now
Ok, Go it!