@@ -0,0 +1,1619 @@
+%0A%0Aimport java.util.regex.Pattern;%0A%0A/**%0A * %3Cdl%3E%0A * %3Cdt%3EPurpose:%0A * %3Cdd%3EAPI that simulates DNA%0A * %3C/dl%3E%0A * %0A * @author Tobias B%C3%BCschel%0A * @version 1.0%0A */%0A%0Apublic class DNAStrand %7B%0A%0A%09// Class constructor%0A%09public DNAStrand(String dna) %7B%0A%09%09this.dna = dna;%0A%09%7D%0A%0A%09// instance variables%0A%09String dna;%0A%0A%09// Returns true if the DNA is valid, i.e, only contains the%0A%09// letters, A,T,C,G (in uppercase) and at least one of these characters.%0A%09public boolean isValidDNA() %7B%0A%09%09return Pattern.matches(%22%5BATCG%5D+%22, dna);%0A%09%7D%0A%0A%09// Returns theWatson Crick complement, which is a string representing the%0A%09// complementary DNA strand%0A%09// (i.e., the other strand in the double helix). So swap all T%E2%80%99s with A%E2%80%99s,%0A%09// all A%E2%80%99s with T%E2%80%99s, all C%E2%80%99s%0A%09// with G%E2%80%99s and all G%E2%80%99s with C%E2%80%99s.%0A%09public String complementWC() %7B%0A%09%09StringBuilder sb = new StringBuilder();%0A%0A%09%09for (int i = 0; i %3C dna.length(); i++) %7B%0A%09%09%09char a = dna.charAt(i);%0A%0A%09%09%09switch (a) %7B%0A%09%09%09case 'A':%0A%09%09%09%09sb.append(%22T%22);%0A%09%09%09%09break;%0A%09%09%09case 'T':%0A%09%09%09%09sb.append(%22A%22);%0A%09%09%09%09break;%0A%09%09%09case 'C':%0A%09%09%09%09sb.append(%22G%22);%0A%09%09%09%09break;%0A%09%09%09case 'G':%0A%09%09%09%09sb.append(%22C%22);%0A%09%09%09%09break;%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09return sb.toString();%0A%09%7D%0A%0A%09// Returns the Watson Crick Palindrome, which is the reversed sequence of%0A%09// the complement.%0A%09public String palindromeWC() %7B%0A%09%09StringBuilder sb = new StringBuilder(complementWC());%0A%09%09return sb.reverse().toString();%0A%09%7D%0A%0A%09// Returns true if the DNA contains the subsequence seq.%0A%09public boolean containsSequence(String seq) %7B%0A%09%09return Pattern.matches(%22(.*)(%22 + seq + %22)(.*)%22, dna);%0A%09%7D%0A%0A%09// Returns the underlying DNA sequence string.%0A%09public String toString() %7B%0A%09%09return new String(dna);%0A%09%7D%0A%0A%7D%0A

Create DNAStrand.java