test2f09

# test2f09 - CompSci 6 PROBLEM 1 Test 2(Blasting out DNA(24...

This preview shows pages 1–3. Sign up to view the full content.

CompSci 6 Test 2 Fall 2009 PROBLEM 1 : ( Blasting out DNA (24 points) ) In this problem, we use a single strand of DNA to generate fragments of DNA. A DNA strand is made up of the nucleotides A, C, G and T. For example, a DNA strand might be ”CGTA”. Each symbol has a complement. A and T are complements of each other, and C and G are complements of each other. The complement of ”CGTA” is the complement of each symbol, resulting in ”GCAT”. We want to generate DNA fragments from a DNA strand and a reactant (one of the four nucleotides). A DNA fragment is generated by generating a string of complements, stopping randomly at the chosen reactant. For example, suppose the DNA strand is ”CGATACTCTGT” and the reactant is ”A”. Shown below are four copies of this DNA strand on the ﬁrst line with the four possible fragments below it. Each symbol in the fragment is the complement of the corresponding symbol directly above it and each fragment has to end in the reactant A. CGATACTCTGT CGATACTCTGT CGATACTCTGT CGATACTCTGT GCTA GCTATGA GCTATGAGA GCTATGAGACA In this problem, given a DNA strand and a reactant we will randomly generate an array of possible fragments. We will write this in three parts. First we give you the method complement which given a string of one letter (C,G,T or A) gives you the complement letter. You may want to use this method. public String complement(String str) { if (str.equals("A")) return "T"; if (str.equals("T")) return "A"; if (str.equals("C")) return "G"; return "C"; } PART A. (8) Complete the method ﬁndPositionOfAllOccurences which has two String parameters: dna is a string of nucleotides and nuc is one nucleotide. This method returns an ArrayList of the positions of nuc in dna. For example, if dna is AGCATA and nuc is A, then return the ArrayList of integers 0, 3, 5, which are the positions of the A in the dna strand. public ArrayList<Integer> findPositionOfAllOccurences(String dna, String nuc) { 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
PART B. (8) Complete the method createOneFragment that is given a dna String and a position in the String and returns one fragment that ends at that position. The fragment is created by generating a new String in which each character is the complement of the character in the dna String. The fragment may be shorter then the dna String as it must stop at the lastposition parameter. For example, suppose the dna string is ”CGTAG” and the last position is 2, then the fragment returned is ”GCA”, since GCA is the complement of CGT and the fragment ends at position 2. public String createOneFragment (String dna, int lastPosition)
This is the end of the preview. Sign up to access the rest of the document.

## This document was uploaded on 01/17/2012.

### Page1 / 7

test2f09 - CompSci 6 PROBLEM 1 Test 2(Blasting out DNA(24...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online