Question

In: Computer Science

JAVA PROGRAM: FINISH THE FOLLOWING METHOD IN THE CLASS BasicBioinformatics. public class BasicBioinformatics { /** *...

JAVA PROGRAM:
FINISH THE FOLLOWING METHOD IN THE CLASS BasicBioinformatics.
public class BasicBioinformatics {
/**
* Calculates and returns the reverse complement of a DNA sequence. In DNA sequences, 'A' and 'T'
* are complements of each other, as are 'C' and 'G'. The reverse complement is formed by
* reversing the symbols of a sequence, then taking the complement of each symbol (e.g., the
* reverse complement of "GTCA" is "TGAC").
*
* @param dna a char array representing a DNA sequence of arbitrary length, containing only the
* characters A, C, G and T
*
* @return a char array representation of the reverse complement of the given sequence
*/
public static char[] reverseComplement(char[] dna) {
// INPUT CODE
}
/**
* Calculates and returns the reverse complement of a DNA sequence. In DNA sequences, 'A' and 'T'
* are complements of each other, as are 'C' and 'G'. The reverse complement is formed by
* reversing the symbols of a sequence, then taking the complement of each symbol (e.g., the
* reverse complement of "GTCA" is "TGAC").
*
* @param dna a string representing a DNA sequence of arbitrary length, containing only the
* characters A, C, G and T
*
* @return a String representation of the reverse complement of the given sequence
*/
public static String reverseComplement(String dna) {
return new String(reverseComplement(dna.toCharArray()));
} }

Solutions

Expert Solution

Please find the answer below.
Please do comments in case of any issue. Also, don't forget to rate the question. Thank You So Much.

BasicBioinformatics.java

package staticclasses;
public class BasicBioinformatics {
   /**
   * Calculates and returns the reverse complement of a DNA sequence. In DNA sequences, 'A' and 'T'
   * are complements of each other, as are 'C' and 'G'. The reverse complement is formed by
   * reversing the symbols of a sequence, then taking the complement of each symbol (e.g., the
   * reverse complement of "GTCA" is "TGAC").
   *
   * @param dna a char array representing a DNA sequence of arbitrary length, containing only the
   * characters A, C, G and T
   *
   * @return a char array representation of the reverse complement of the given sequence
   */
   public static char[] reverseComplement(char[] dna) {
       char res[] = new char[dna.length];
       int count=0;
       for (int i =dna.length-1 ; i >= 0; i--) {
           if(dna[i]=='A') {
               res[count]='T';
           }else if(dna[i]=='T') {
               res[count]='A';
           }else if(dna[i]=='C') {
               res[count]='G';
           }else if(dna[i]=='G') {
               res[count]='C';
           }
           count++;
       }
       return res;
   }
   /**
   * Calculates and returns the reverse complement of a DNA sequence. In DNA sequences, 'A' and 'T'
   * are complements of each other, as are 'C' and 'G'. The reverse complement is formed by
   * reversing the symbols of a sequence, then taking the complement of each symbol (e.g., the
   * reverse complement of "GTCA" is "TGAC").
   *
   * @param dna a string representing a DNA sequence of arbitrary length, containing only the
   * characters A, C, G and T
   *
   * @return a String representation of the reverse complement of the given sequence
   */
   public static String reverseComplement(String dna) {
       return new String(reverseComplement(dna.toCharArray()));
   }

   public static void main(String[] args) {
       System.out.println("reverseComplement(\"GTCA\") converted to : "+reverseComplement("GTCA"));
       System.out.println("reverseComplement(\"TAAC\") converted to : "+reverseComplement("TAAC"));
      
   }
}


Related Solutions

USING JAVA: complete these one method in the BasicBioinformatics class /** * Class BasicBioinformatics contains static...
USING JAVA: complete these one method in the BasicBioinformatics class /** * Class BasicBioinformatics contains static methods for performing common DNA-based operations in * bioinformatics. * * */ public class BasicBioinformatics { /** * Calculates and returns the reverse complement of a DNA sequence. In DNA sequences, 'A' and 'T' * are complements of each other, as are 'C' and 'G'. The reverse complement is formed by * reversing the symbols of a sequence, then taking the complement of each...
USING JAVA: complete the method below in the BasicBioinformatics class. /** * Class BasicBioinformatics contains static...
USING JAVA: complete the method below in the BasicBioinformatics class. /** * Class BasicBioinformatics contains static methods for performing common DNA-based operations in * bioinformatics. * * */ public class BasicBioinformatics { /** * Calculates and returns the number of times each type of nucleotide occurs in a DNA sequence. * * @param dna a char array representing a DNA sequence of arbitrary length, containing only the * characters A, C, G and T * * @return an int array...
USING JAVA: Complete the following class. input code where it says //TODO. public class BasicBioinformatics {...
USING JAVA: Complete the following class. input code where it says //TODO. public class BasicBioinformatics { /** * Calculates and returns the complement of a DNA sequence. In DNA sequences, 'A' and 'T' are * complements of each other, as are 'C' and 'G'. The complement is formed by taking the * complement of each symbol (e.g., the complement of "GTCA" is "CAGT"). * * @param dna a char array representing a DNA sequence of arbitrary length, * containing only...
Use BlueJ java to finish this PolkaDots class, class circle is included below as well. public...
Use BlueJ java to finish this PolkaDots class, class circle is included below as well. public class PolkaDots { private ArrayList<Circle> dots;// an arrayList field to hold an ArrayList. /** * Create a new list of Circles, starts with 5 default circles. */ public PolkaDots() { dots = new ArrayList<Circle>(); // an arrayList to hold a bunch of circles Circle circle1 = new Circle(30, 10, 10, "blue");//create the 1st circle dots.add(circle1);// add the 1st circle to the arrayList    Circle...
Java program Create a public method named saveData for a class named Signal that will hold...
Java program Create a public method named saveData for a class named Signal that will hold digitized acceleration data. Signal has the following field declarations private     double timeStep;               // time between each data point     int numberOfPoints;          // number of data samples in array     double [] acceleration = new double [1000];          // acceleration data     double [] velocity = new double [1000];        // calculated velocity data     double [] displacement = new double [1000];        // calculated disp...
The following Java program is NOT designed using class/object concept. public class demo_Program4_non_OOP_design { public static...
The following Java program is NOT designed using class/object concept. public class demo_Program4_non_OOP_design { public static void main(String[] args) { String bottle1_label="Milk"; float bottle1_volume=250; float bottle1_capacity=500; bottle1_volume=addVolume(bottle1_label, bottle1_volume,bottle1_capacity,200); System.out.println("bottle label: " + bottle1_label + ", volume: " + bottle1_volume + ", capacity: " +bottle1_capacity); String bottle2_label="Water"; float bottle2_volume=100; float bottle2_capacity=250; bottle2_volume=addVolume(bottle2_label, bottle2_volume,bottle2_capacity,500); System.out.println("bottle label: " + bottle2_label + ", volume: " + bottle2_volume + ", capacity: " +bottle2_capacity); } public static float addVolume(String label, float bottleVolume, float capacity, float addVolume)...
Java programming. Write a public Java class called DecimalTimer with public method displayTimer, that prints a...
Java programming. Write a public Java class called DecimalTimer with public method displayTimer, that prints a counter and then increments the number of seconds. The counter will start at 00:00 and each time the number of seconds reaches 60, minutes will be incremented. You will not need to implement hours or a sleep function, but if minutes or seconds is less than 10, make sure a leading zero is put to the left of the number. For example, 60 seconds:...
write program that develop a Java class Dictionary to support the following public methods of an...
write program that develop a Java class Dictionary to support the following public methods of an abstract data type: public class Dictionary { // insert a (key, value) pair into the Dictionary, key value must be unique, the value is associated with the key; only the last value inserted for a key will be kept public void insert(String key, String value); // return the value associated with the key value public String lookup(String key); // delete the (key, value) pair...
Program in Java Create a class and name it MyArray and implement following method. * NOTE:...
Program in Java Create a class and name it MyArray and implement following method. * NOTE: if you need more methods, including insert(), display(), etc. you can also implement those. Method name: getKthMin(int k) This method receives an integer k and returns k-th minimum value stored in the array. * NOTE: Items in the array are not sorted. If you need to sort them, you can implement any desired sorting algorithm (Do not use Java's default sorting methods). Example: Items...
Program in Java Create a class and name it MyArray and implement following method. * NOTE:...
Program in Java Create a class and name it MyArray and implement following method. * NOTE: if you need more methods, including insert(), display(), etc. you can also implement those. Method name: getKthMin(int k) This method receives an integer k and returns k-th minimum value stored in the array. * NOTE: Items in the array are not sorted. If you need to sort them, you can implement any desired sorting algorithm (Do not use Java's default sorting methods). Example: Items...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT