100 likes | 116 Views
A review of Aaron Bloomfield CS 101 J3 strand string class for nucleotide sequence manipulation. Utilizes various functions like slice, splice, substrand, has to modify sequences effectively.
E N D
Review of HW J3 Aaron Bloomfield CS 101-E
Strand Strand String - nucleotideSequence = - nucleotideSequence = • text = “tgccagt” • - length = 7 Strand +public Strand() +public Strand(String s) + public Object clone() +public String toString() +public void splice(Strand otherStrand) +public Strand slice(int i1, int i2) +public int has(Strand s) +public Strand substrand(int i1) +public Strand substrand(int i1, int i2) +public Strand() +public Strand(String s) + public Object clone() +public String toString() +public void splice(Strand otherStrand) +public Strand slice(int i1, int i2) +public int has(Strand s) +public Strand substrand(int i1) +public Strand substrand(int i1, int i2) + length (): int + charAt (int i): char + subString (int m, int n): String + indexOf (String s, int m): int + ... - nucleotideSequence = + public Strand slice(int i1, int i2) +… “tgccagt” Strand representation
splice (…) trailing leading “0123456789” this Strand Strand - nucleotideSequence = - nucleotideSequence = Strand + public void splice (Strand otherStrand) +… + public void splice (Strand otherStrand) +… - nucleotideSequence = otherStrand + public void splice ( ) +… “6789” “012345” void splice (Strand otherStrand) public void splice(Strand otherStrand) { // determine the concatenation components String leading = this.nucleotideSequence; String trailing = otherStrand.nucleotideSequence; // update strand to be a concatenation this.nucleotideSequence = leading + trailing; } public void splice(Strand otherStrand) { // determine the concatenation components String leading = this.nucleotideSequence; String trailing = otherStrand.nucleotideSequence; // update strand to be a concatenation this.nucleotideSequence = leading + trailing; } public void splice(Strand otherStrand) { // determine the concatenation components String leading = this.nucleotideSequence; String trailing = otherStrand.nucleotideSequence; // update strand to be a concatenation this.nucleotideSequence = leading + trailing; } public void splice(Strand otherStrand) { // determine the concatenation components String leading = this.nucleotideSequence; String trailing = otherStrand.nucleotideSequence; // update strand to be a concatenation this.nucleotideSequence = leading + trailing; } public void splice(Strand otherStrand) { // determine the concatenation components String leading = this.nucleotideSequence; String trailing = otherStrand.nucleotideSequence; // update strand to be a concatenation this.nucleotideSequence = leading + trailing; } public void splice(Strand otherStrand) { // determine the concatenation components String leading = nucleotideSequence; String trailing = otherStrand.nucleotideSequence; // update strand to be a concatenation nucleotideSequence = leading + trailing; } Not an member variable!!! Not required!
this Strand - nucleotideSequence = + public Strand () +… “” public Strand () // Strand(): default constructor public Strand() { this.nucleotideSequence = ""; }
Strand - nucleotideSequence = this desiredSequence + public Strand ( ) +… Strand - nucleotideSequence = + public Strand (String desiredSequence) + … “012345” public Strand (String s) // Strand(): specific constructor public Strand(String desiredSequence) { this.nucleotideSequence = desiredSequence; }
this String • text = “0123456789” • - … Strand Strand Strand + subString (int m, int n): String + subString (int m): String + ... result - nucleotideSequence = - nucleotideSequence = - nucleotideSequence = (prefix+suffix) + public Strand slice (int i1, int i2) +… + public Strand slice (int i1, int i2) +… + public Strand slice (4,7) +… prefix middle suffix “01237890” “01237890” “7890” “456” “0123” public Strand slice (int i1, int i2) method returns: String middle = this.nucleotideSequence.substring(i1, i2); String prefix = this.nucleotideSequence.substring(0, i1); String suffix = this.nucleotideSequence.substring(i2); this.nucleotideSequence = prefix + suffix; Strand result = new Strand(middle); return result;
public Strand slice (int i1, int i2) // slice(): extract portion of the Strand with indices i1 - i2-1 public Strand slice(int i1, int i2) { // decompose the nucleotide sequence into three parts String prefix = this.nucleotideSequence.substring(0, i1); String middle = this.nucleotideSequence.substring(i1, i2); String suffix = this.nucleotideSequence.substring(i2); // update strand to be concatenation of prefix and suffix this.nucleotideSequence = prefix + suffix; // return the extracted strand Strand result = new Strand(middle); return result; }
this String • text = “0123456789” • - … Strand Strand Strand + indexOf (String s): int + ... - nucleotideSequence = - nucleotideSequence = - nucleotideSequence = + Strand has (Strand otherStrand): int +… + public Strand has ( ): int +… + public Strand has (Strand s): int +… otherSequence otherStrand “5678” public int has (Strand s) public int has(Strand otherStrand) { String otherSequence = otherStrand.nucleotideSequence; int result = this.nucleotideSequence. indexOf.(otherSequence); return result; }
this String • text = “0123456789” • - … Strand Strand Strand + substring (int i1, int i2): String + ... result - nucleotideSequence = - nucleotideSequence = - nucleotideSequence = middle + public Strand substrand (int i1, int i2) + … + public Strand substrand (2,6) + … + public Strand substrand (int i1, int i2) + … “2345” public Strand substrand (int i1, int i2) public Strand substrand (int i1, int i2) { String middle = this.nucleotideSequence. substring(i1, i2); Strand result = new Strand (middle); return result; }
public Strand substrand (int i1) public Strand substrand (int i) { return this.substrand (i, i + 1); }