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...
Java Programming Using the class below, please ), write a static method called parse that parses...
Java Programming Using the class below, please ), write a static method called parse that parses a String for balanced parentheses. we seek only to determine that the symbol ‘{‘ is balanced with ‘}’. parse accepts a single String parameter and returns an int. If parse returns a minus 1, then there are no errors, otherwise, parse should return the position within the String where an error occurred. For example parse(“{3 + {4/2} }”)   would return -1 parse(“{ { 4*X}”)...
in Java language, in most simple algorithm Using a stack class, write a static method called...
in Java language, in most simple algorithm Using a stack class, write a static method called parse that parses a String for balanced parentheses. we seek only to determine that the symbol ‘{‘ is balanced with ‘}’. parse accepts a single String parameter and returns an int. If parse returns a minus 1, then there are no errors, otherwise, parse should return the position within the String where an error occurred. For example parse(“{3 + {4/2} }”)   would return -1...
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...
JAVA: USE SWITCH METHOD Write a Temperature class using the Demo below. The class will have...
JAVA: USE SWITCH METHOD Write a Temperature class using the Demo below. The class will have three conversion methods: toCelcius(), toKelvin and toFahrenheit(). These methods will return a Temperature in those three scales equal to this temperature. Note that the value of this is not changed int these coversions. In addition to these conversion methods the class will have add(Temperature), subtract(Temperature), multiply(Temperature) and divide(Temperature). These four methods all return a temperature equalled to the respective operation. Note that the this...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT