Question

In: Computer Science

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 the characters A, C, G and T
*
* @return a char array representation of the complement of the given sequence
*/
public static char[] complement(char[] dna) {
// TODO
}

/**
* 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 reverse complement of "GTCA" is "CAGT").
*
* @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 complement of the given sequence
*/
public static String complement(String dna) {
return new String(complement(dna.toCharArray())); // We just call the other complement method
}

/**
* The GC-content of a DNA sequence is given by the percentage of symbols in the sequence that are
* 'C' or 'G'. For example, the GC-content of "AGCTATAG" is .375 (37.5%).
*
* @param dna a char array representing a DNA sequence of arbitrary length,
* containing only the characters A, C, G and T
*
* @return the GC-content of the sequence, to double precision
*/
public static double gcContent(char[] dna) {
// TODO
}

/**
* The GC-content of a DNA sequence is given by the percentage of symbols in the sequence that are
* 'C' or 'G'. For example, the GC-content of "AGCTATAG" is .375 (37.5%).
*
* @param dna a String representing a DNA sequence of arbitrary length,
* containing only the characters A, C, G and T
*
* @return the GC-content of the sequence, to double precision
*/
public static double gcContent(String dna) {
return gcContent(dna.toCharArray()); // Let the other gcContent method do this work for us
}

/**
* Calculates and returns the Hamming distance between two DNA sequences of equal length. The
* Hamming distance between two sequences is the number of points in the sequences where the
* corresponding symbols differ. For example, the Hamming distance between "ATTATGC" and "ATGATCC"
* is 2.
*
* @param dna1 a char array representing a DNA sequence of arbitrary length (equal to dna2's
* length), containing only the characters A, C, G and T
* @param dna2 a char array representing a DNA sequence of arbitrary length (equal to dna1's
* length), containing only the characters A, C, G and T
*
* @return the Hamming distance between the two sequences
*/
public static int hammingDistance(char[] dna1, char[] dna2) {
// TODO
}

/**
* Calculates and returns the Hamming distance between two DNA sequences of equal length. The
* Hamming distance between two sequences is the number of points in the sequences where the
* corresponding symbols differ. For example, the Hamming distance between "ATTATGC" and "ATGATCC"
* is 2.
*
* @param dna1 a String representing a DNA sequence of arbitrary length (equal to dna2's
* length), containing only the characters A, C, G and T
* @param dna2 a String representing a DNA sequence of arbitrary length (equal to dna2's
* length), containing only the characters A, C, G and T
*
* @return the Hamming distance between the two sequences
*/
public static int hammingDistance(String dna1, String dna2) {
return hammingDistance(dna1.toCharArray(), dna2.toCharArray());
}

/**
* Calculates and returns where two DNA sequences of equal lengths differ. For example, given
* sequences "ATGT" and "GTGA", the result should be array { true, false, false, true }.
*
* @param dna1 a char array representing a DNA sequence, containing only the characters A, C, G
* and T, with the same length as parameter dna2
* @param dna2 a char array representing a DNA sequence, containing only the characters A, C, G
* and T, with the same length as parameter dna1
*
* @return an array of boolean values, of length equivalent to both parameters' lengths,
* containing true in each subscript where the parameter strings differ, and false where
* they do not differ
*/
public static boolean[] mutationPoints(char[] dna1, char[] dna2) {
// TODO
}

/**
* Calculates and returns where two DNA sequences of equal lengths differ. For example, given
* sequences "ATGT" and "GTGA", the result should be array { true, false, false, true }.
*
* @param dna1 a String representing a DNA sequence, containing only the characters A, C, G
* and T, with the same length as parameter dna2
* @param dna2 a String representing a DNA sequence, containing only the characters A, C, G
* and T, with the same length as parameter dna1
*
* @return an array of boolean values, of length equivalent to both parameters' lengths,
* containing true in each subscript where the parameter strings differ, and false where
* they do not differ
*/
public static boolean[] mutationPoints(String dna1, String dna2) {
return mutationPoints(dna1.toCharArray(), dna2.toCharArray());
}

/**
* 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) {
// TODO
}

/**
* 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());
}

/**
* 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) {
// TODO
}

/**
* 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

Implementation of above code in JAVA:


public class BasicBioinformatics {
  
  
//   return a String representation of the complement of the given sequence
   public static char[] complement(char[] dna) {
      
       for(int i=0;i<dna.length;i++) {
          
           if(dna[i]=='C') {
               dna[i]='G';
           }
           else if(dna[i]=='G') {
               dna[i]='C';
           }
           else if(dna[i]=='A') {
               dna[i]='T';
           }
           else if(dna[i]=='T') {
               dna[i]='A';
           }
          
          
       }
      
       return dna;
      
       }
  
//   return a String representation of the complement of the given sequence
   public static String complement(String dna) {
      
       return new String(complement(dna.toCharArray()));
      
       }
  
  
//   return the GC-content of the sequence, to double precision
   public static double gcContent(char[] dna) {
      
       int count=0;
      
       for(int i=0;i<dna.length;i++) {
           if(dna[i]=='C') {
               count++;
           }
           else if(dna[i]=='G') {
               count++;
           }
       }
      
       double content=(count*100)/dna.length;
      
       return content;
      
      
       }
  
//   return the GC-content of the sequence, to double precision
   public static double gcContent(String dna) {
       return gcContent(dna.toCharArray());
       }
  
  
//   return the Hamming distance between the two sequences
   public static int hammingDistance(char[] dna1, char[] dna2) {
      
       int count=0;
      
       for(int i=0;i<dna1.length;i++) {
          
           if(dna1[i]!=dna2[i]) {
               count++;
           }
       }
      
       return count;
      
       }
  
// return the Hamming distance between the two sequences
   public static int hammingDistance(String dna1, String dna2) {
      
       return hammingDistance(dna1.toCharArray(), dna2.toCharArray());
      
       }
  
  
//   return an array of boolean values, of length equivalent to both parameters' lengths,
//   containing true in each subscript where the parameter strings differ, and false where
//   they do not differ
   public static boolean[] mutationPoints(char[] dna1, char[] dna2) {
  
       boolean arr[]= new boolean[dna1.length];
      
for(int i=0;i<dna1.length;i++) {
          
           if(dna1[i]!=dna2[i]) {
               arr[i]=true;
           }
          
           else {
               arr[i]=false;
           }
           }

return arr;
  
       }
  
//   return an array of boolean values, of length equivalent to both parameters' lengths,
// containing true in each subscript where the parameter strings differ, and false where
//   they do not differ
  
   public static boolean[] mutationPoints(String dna1, String dna2) {
      
       return mutationPoints(dna1.toCharArray(), dna2.toCharArray());
      
       }
  
  
//   Calculates and returns the number of times
//   each type of nucleotide occurs in a DNA sequence.
  
   public static int[] nucleotideCounts(char[] dna) {
      
       int arr[]= new int[dna.length];
      
       for(int i=0;i<dna.length;i++) {
          
           arr[i]=(int)dna[i];
          
       }
       return arr;
      
       }
  
//   Calculates and returns the number of times
//   each type of nucleotide occurs in a DNA sequence.
  
   public static int[] nucleotideCounts(String dna) {
      
       return nucleotideCounts(dna.toCharArray());
      
       }
  
  
//   return a char array representation of the reverse
//   complement of the given sequence
  
   public static char[] reverseComplement(char[] dna) {
       
for(int i=0;i<dna.length;i++) {
          
           if(dna[i]=='C') {
               dna[i]='A';
           }
           else if(dna[i]=='G') {
               dna[i]='T';
           }
           else if(dna[i]=='A') {
               dna[i]='C';
           }
           else if(dna[i]=='T') {
               dna[i]='G';
           }
          
          
       }

return dna;
      
       }
  
  
//   return a String representation of the reverse
//   complement of the given sequence
  
   public static String reverseComplement(String dna) {
      
       return new String(reverseComplement(dna.toCharArray()));
      
       }
  
  
   // driver function or main metjoh
   public static void main(String[] args) {
          
           System.out.println("----------- Some following operations are performed below : ------------");
           System.out.println();
          
   char [] dna= {'G','T','C','A'};
   char [] dna1= {'A','T','T','A','T','G','C'};
   char [] dna2= {'A','T','G','A','T','C','C'};
     
   System.out.print("Complement of ");
   print(dna);
   System.out.print(" is : ");
   print(complement(dna));
  
   System.out.println();
     
   System.out.print("The content of ");
   print(dna);
   System.out.print(" is :"+gcContent(dna)+"%");
     
   System.out.println();
     
   System.out.print("The hamming Distance between ");
   print(dna1);
   System.out.print(" and ");
   print(dna2);
   System.out.print(" is :"+hammingDistance(dna1,dna2));
     
   System.out.println();
     
   System.out.print("The mutation between ");
   print(dna1);
   System.out.print(" and ");
   print(dna2);
   System.out.print(" is : ");
   boolean arr[]=mutationPoints(dna1,dna2);
   for(int i=0;i<arr.length;i++) {
       System.out.print(arr[i]+",");
   }
     
   System.out.println();
     
   System.out.print("The nucleotide Counts of ");
   print(dna1);
   System.out.print(" is : ");
   int[] arr2=nucleotideCounts(dna1);
   for(int i=0;i<arr2.length;i++) {
       System.out.print(arr2[i]+",");
   }
     
   System.out.println();
          
   System.out.print("The Reverse Complement of ");
   print(dna);
   System.out.print(" is : ");
   print(reverseComplement(dna));
     
     
     
       }
      
       static void print(char arr[]) {
          
           for(int i=0;i<arr.length;i++) {
              
               System.out.print(arr[i]);
              
           }
          
       }
  
   }

SAMPLE OUTPUT:

If you have any doubt regarding this question please ask me in comments

// THANK YOU:-)
  



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...
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...
public class Sum2 { // TODO - write your code below this comment. } Download the...
public class Sum2 { // TODO - write your code below this comment. } Download the Sum2.java file, and open it in jGrasp (or a text editor of your choice). This program takes two values as command-line arguments, converts them to ints via Integer.parseInt, and adds them together. Example output of this program is shown below, with the command-line arguments 3 4: Sum: 7
public class FirstChar { // TODO - write your code below this comment. } Download the...
public class FirstChar { // TODO - write your code below this comment. } Download the FirstChar.java file, and open it in jGrasp (or a text editor of your choice). This program takes a single command-line argument and prints out the first character of this argument, using String's charAt() method. If you're unsure how to pass command-line arguments to a program with jGrasp, see this tutorial. Example output of this program with the command-line argument foo is shown below: First...
COMPLETE JAVA CODE: public final class Vector2 {       // NOTE:    Before you get...
COMPLETE JAVA CODE: public final class Vector2 {       // NOTE:    Before you get started with the constructors, implement the class variables and    // =====   the accessor methods (getX,getY). The tester for the constructors relies on these    //           methods being implemented. After this, move ahead with the constructors          // class variables here       COMPLETE JAVA CODE: /** * Creates the vector <code>(0.0, 0.0)</code>. */ public Vector2() {       COMPLETE...
COMPLETE JAVA CODE public class Point2 { private double x; private double y;    /** *...
COMPLETE JAVA CODE public class Point2 { private double x; private double y;    /** * Create a point with coordinates <code>(0, 0)</code>. */ public Point2() { complete JAVA code this.set(0.0, 0.0); COMPLETE CODE }    /** * Create a point with coordinates <code>(newX, newY)</code>. * * @param newX the x-coordinate of the point * @param newY the y-coordinate of the point */ public Point2(double newX, double newY) { complete Java code this.set(newX, newY); }    /** * Create a...
I needv pseudocode and a flowchart for the following java code public class AcmePay { public...
I needv pseudocode and a flowchart for the following java code public class AcmePay { public static void main(String[] args) throws Exception { Scanner scanner = new Scanner(System.in); int hours, shift, retirement = 0; do { System.out.print("Enter the number of hours worked (>0): "); hours = scanner.nextInt(); } while (hours <= 0); do { System.out.print("Enter shift [1 2 or 3]: "); shift = scanner.nextInt(); } while (shift < 1 || shift > 3); if (shift == 2 || shift ==...
Fix the following java code package running; public class Run {    public double distance; //in...
Fix the following java code package running; public class Run {    public double distance; //in kms    public int time; //in seconds    public Run prev;    public Run next;    //DO NOT MODIFY - Parameterized constructor    public Run(double d, int t) {        distance = Math.max(0, d);        time = Math.max(1, t);    }       //DO NOT MODIFY - Copy Constructor to create an instance copy    //NOTE: Only the data section should be...
The following code is included for the java programming problem: public class Bunny {        private...
The following code is included for the java programming problem: public class Bunny {        private int bunnyNum;        public Bunny(int i) {               bunnyNum = i;        }        public void hop() {               System.out.println("Bunny " + bunnyNum + " hops");        } } Create an ArrayList <????> with Bunny as the generic type. Use an index for-loop to build (use .add(….) ) the Bunny ArrayList. From the output below, you need to have 5. Use an index for-loop...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT