Due date
Downloads
Objective
Gain experience using a new class. The class will be concerned with the
representation of a DNA strand.
Background
DNA is the building block of life. A segment of DNA has two molecular strands
of alternating sugar and phosphate molecules arranged as a double helix.
Connecting the strands are pairs of nucleotides. If you view DNA as surrealistic
ladder, the nucleotide pairs are the rungs.
There are four types of nucleotides that connect the strands—adenine (A),
guanine (G), cytosine (C), and thymine (T). Because nucleotides determine the
role of the DNA segment, geneticists describe a strand by its nucleotide
sequence. Thus, the description of a strand of a possible DNA molecule could be
written as TGCCAGT.
Class description
The likely uses for nucleotide sequence representations involve slicing,
splicing, duplication, and strand analysis.
- Construction: build a Strand by either default or specific
construction
- public Strand()
- Configure the newly created Strand object to represent an empty
nucleotide sequence.
- public Strand(String s)
- Configure the newly created Strand object to represent the
nucleotide sequence denoted by string s.
- Slicing: Remove a nucleotide subsequence from a strand.
- public Strand slice(int i1, int i2)
- Updates the Strand object by deleting the nucleotide
subsequence beginning at i1 and ending at i2-1.
- The method returns a representation of the deleted nucleotide
subsequence.
- Splicing: Modify a strand by appending another strand to it.
- public void splice(Strand otherStrand)
- Updates the Strand object so that it represents the
concatenation of its previous representation with the nucleotide sequence
of otherStrand.
- Duplication: Produce a new copy of a strand. In Java parlance, this
behavior is referred to as cloning. Given the genetic information being
represented, the name is very apropos.
- public Object clone()
- Return a new duplicate of the Strand object.
- Java requires that the clone() return type be Object.
Because every Java class is an extension (specialization) of Object,
the clone() method can return a Strand object.
- Analysis: Report whether a strand contains a particular nucleotide
sequence; report the nucleotide at a particular location; and report the
nucleotide sequence at a particular sequence of strand locations.
- public boolean has(Strand s)
- Returns the index of the first occurrence of nucleotide sequence s in
the Strand object. If the object does not contain sequence s, then -1 is
returned,
- public Strand substrand(int i1)
- Returns the nucleotide in the Strand object with index i1.
- public Strand substrand(int i1, int i2)
- Returns the nucleotide sequence corresponding to the subsequence in
the Strand object starting with index i1 and ending with index i2-1.
- String casting: produce a string representation of the strand
- public String toString()
- Return a string representation of the Strand object.
Assignment
- Submit your completed development of program
StrandDemonstration.java. The method main() of this program should
perform the following tasks:
- Define a Scanner stdin associated with standard input
- Define and initialize a Strand variable empty, which
is initialized using the Strand default constructor.
- Prompt and extract from standard input a string of nucleotides. Define
and initialize a Strand variable strand1 which is specific
constructed using that input string.
- Prompt and extract from standard input a string of nucleotides. Define
and initialize a Strand variable strand2 which is specific
constructed using that input string.
- Prompt and extract from standard input a string of nucleotides. Define
and initialize a Strand variable strand3 which is specific
constructed using that input string.
- Define and initialize a Strand variable duplicate1 to
be duplicate of the Strand object referenced by strand1. Do
not invoke a constructor to get the new object.
- Define and initialize initialize a Strand variable duplicate2 to
be duplicate of the Strand object referenced by strand2. Do
not invoke a constructor to get the new object.
- Update the Strand referenced by strand1 so that the object
is now a concatenation of itself and strand2.
- Update the Strand referenced by strand2 so that its
nucleotides with indices 5 through 10 are removed.
- Define and initialize initialize a Strand variable substrand1 to
represent the nucleotide with index 3 in the Strand represented by
strand3.
- Define and initialize initialize a Strand variable substrand2 to
represent the nucleotides with indices 4 through 8 in the Strand
represented by strand3.
- Display the Strand objects referenced by empty, strand1,
strand2, strand3, duplicate1, duplicate2,
substrand1, and substrand2.
Copyright: Jim Cohoon, 2004