CSc 4630/6630 Programming Assignment #2

The first thing in your program should be documentation, such as the following. This should appear at the very top of your program.
  % hmwk2.m
  % Author: (Your Name)
  % Account: (your account name)
  % CSc 4630/6630 Program #2
  % Due date: (put the due date here)
  % Description:
  % (Give a brief description of what your program does.)
  % Input:
  % (State what the program inputs are.)
  % Output:
  % (State what the program outputs are.)
  % Usage:
  % (Give an example of how to use your program.)
  % (For example: out = myabs(in); )
Verify that the command help hmwk2 shows this information.


  1. Practice designing a program.
  2. Practice implementing a program design in MATLAB.
  3. Practice testing a program.

MATLAB provides genetic data. Your assignment is to search through a given genetic data sequence, and report all occurrences of the given pattern. Indicate how many matches there are, and where they occur. The data can be obtained through the following commands:

        S = getgenbank('M10051');
        data = S.Sequence;

The first command gets the genetic data. The second command creates a variable called "data" to store it. (Variable S is a structure; we will cover structures soon.) The save command creates a MATLAB file with the "data" variable. This way, you only have to do the top two commands once. To recover the data, run the following command.


As you probably have guessed, "load" reads the MATLAB data file.

Prompt the user for the type of results to return, such as (1) all matches, (2) only the first match, or (3) only the last match.

Prompt the user for the search string. Test your program with the example genetic data above on the pattern AGAT. It should work on any valid strings for both the data and pattern.

As with all programs:

Your program should work for all possible inputs. Make sure that you test it with several different cases. For example, how do you handle upper or lower-case? What if the pattern string contains no characters? What if the data string or pattern string contains spaces, punctuation, other letters, or numbers?

Turn In Your Work

  1. your source code (hard copy)
  2. the output from at least three different executions in which you test the correctness of your program (using a script*). Use more if the testing needs it. (hard copy)
  3. Also, e-mail your code to the TA. (soft copy)

The printouts of the above must be handed in at the start of class. To be considered "on-time", you must e-mail the TA with the final version of your code before the due date, and turn in all of the above on-time. Make sure that your printouts use a monospaced font.