Question

In: Computer Science

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 of length 4, where subscripts 0, 1, 2 and 3 contain the number of 'A',
* 'C', 'G' and 'T' characters (respectively) in the given sequence
*/
public static int[] nucleotideCounts(char[] dna) {
// INPUT CODE HERE
}

/**
* Calculates and returns the number of times each type of nucleotide occurs in a DNA sequence.
*
* @param dna a String representing a DNA sequence of arbitrary length, containing only the
* characters A, C, G and T
*
* @return an int array of length 4, where subscripts 0, 1, 2 and 3 contain the number of 'A',
* 'C', 'G' and 'T' characters (respectively) in the given sequence
*/
public static int[] nucleotideCounts(String dna) {
return nucleotideCounts(dna.toCharArray());
}

Solutions

Expert Solution

Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. If not, PLEASE let me know before you rate, I’ll help you fix whatever issues. Thanks


/**
 * 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 of length 4, where subscripts 0, 1, 2 and 3 contain
         *         the number of 'A', 'C', 'G' and 'T' characters (respectively) in
         *         the given sequence
         */
        public static int[] nucleotideCounts(char[] dna) {
                // creating an int array of size 4, values will be 0 by default.
                int result[] = new int[4];
                // looping through dna array
                for (int i = 0; i < dna.length; i++) {
                        // if current char is A, incrementing array element at index 0
                        if (dna[i] == 'A') {
                                result[0]++;
                        }
                        // if current char is C, incrementing array element at index 1
                        else if (dna[i] == 'C') {
                                result[1]++;
                        }
                        // if current char is G, incrementing array element at index 2
                        else if (dna[i] == 'G') {
                                result[2]++;
                        }
                        // now only T is remaining, if the input is valid, then we don't
                        // need to check for T, simply increment element at index 3
                        else {
                                result[3]++;
                        }
                }
                return result;
        }

        /**
         * Calculates and returns the number of times each type of nucleotide occurs
         * in a DNA sequence.
         * 
         * @param dna
         *            a String representing a DNA sequence of arbitrary length,
         *            containing only the characters A, C, G and T
         * 
         * @return an int array of length 4, where subscripts 0, 1, 2 and 3 contain
         *         the number of 'A', 'C', 'G' and 'T' characters (respectively) in
         *         the given sequence
         */
        public static int[] nucleotideCounts(String dna) {
                return nucleotideCounts(dna.toCharArray());
        }
}

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...
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...
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...
Complete java program below. Complete non-recursive version nthFibonacciWithLoop() method. Complete recursive version nthFibonacciWithRecursion() method. public class...
Complete java program below. Complete non-recursive version nthFibonacciWithLoop() method. Complete recursive version nthFibonacciWithRecursion() method. public class Fibonacci { // Fib(N): N N = 0 or N = 1 // Fib(N-1) + Fib(N-2) N > 1 // For example, // Fib(0) = 0 // Fib(1) = 1 // Fib(2) = Fib(1) + Fib(0) = 1 + 0 = 1 // Fib(3) = Fib(2) + Fib(1) = Fib(2) + 1 = (Fib(1) + Fib(0)) + 1 = 1 + 0 + 1...
You shall implement six static methods in a class named BasicBioinformatics. Each of the methods will...
You shall implement six static methods in a class named BasicBioinformatics. Each of the methods will perform some analysis of data considered to be DNA. DNA shall be represented arrays of chars containing only the characters A, C, G and T. In addition to the six methods you will implement, six other methods exist in the class, which use Strings instead of char arrays to represent DNA. These other methods simply invoke the methods you are to implement, so all...
Question 3 A java source module contains the following class with the static methods main and...
Question 3 A java source module contains the following class with the static methods main and procedure1, and the instance method procedure2 (assume given the bodies of procedure1 and procedure2): public class TestQuestion3             {                         static int result, num1 = 10;                         public static void Main( String [ ] args )                         {                                     int [ ] list1 =   { 2, 4, 6, 8, 10}, list2;                                     .    .    .                         }                         static void procedure1( void )                         {                                     .   .   .                         } void procedure2( void )...
PLEASE CODE THIS IN JAVA Create a driver class Playground that contains the function, public static...
PLEASE CODE THIS IN JAVA Create a driver class Playground that contains the function, public static void main(String[] args) {}. Create 2 SportsCar and 2 Airplane instances using their constructors. (SPORTSCAR AND AIRPLANE CLASSES LISTED BELOW THIS QUESTION. Add all 4 instances into a single array called, “elements.” Create a loop that examines each element in the array, “elements.” If the elements item is a SportsCar, run the sound method and if the item is an Aeroplane, run it’s ChangeSpeed...
Using maps in Java. Make a public class called ExampleOne that provides a single class (static)...
Using maps in Java. Make a public class called ExampleOne that provides a single class (static) method named firstOne. firstOne accepts a String array and returns a map from Strings to Integer. The map must count the number of passed Strings based on the FIRST letter. For example, with the String array {“banana”, “apples”, “blueberry”, “orange”}, the map should return {“b”:2, “a”:1, “o”:1}. Disregard empty Strings and zero counts. Retrieve first character of String as a char using charAt, or,...
Java program Write a class called Animal that contains a static variable called count to keep...
Java program Write a class called Animal that contains a static variable called count to keep track of the number of animals created. Your class needs a getter and setter to manage this resource. Create another variable called myCount that is assigned to each animal for each animal to keep track of its own given number. Write a getter and setter to manage the static variable count so that it can be accessed as a class resource
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)...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT