Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Introduction Genomics DNA is the fundamental encoding of the instructions that g

ID: 3788373 • Letter: I

Question

Introduction Genomics DNA is the fundamental encoding of the instructions that govern the operation of living cells and by extension, biological organisms. You can think of DNA as a storage medium in which the pro- gram that executes within all of your cells is written. The "machine code" of DNA, corresponding to the byte-code of Java, consists of only four nucleotides: four amino acids that are arranged in a linear sequence along the DNA molecule. These four bases are: guanine (G, adenine (A), thymine (T), and cytosine (C). So, a DNA molecule can be represented as a string made up of those four letters. The science of bioinformatics is largely concerned with computations on such genetic strings, or sequences. There are a variety of computations that one might perform on genetic sequences. We will investigate two types: basic statistics of individual sequences and pairwise alignments used to compare pairs of sequences.

Explanation / Answer


import java.util.*;
public class DNAsequence {
   static Scanner sc=new Scanner(System.in);
static   int countc=0;
static   int countg=0;
static float fraction=0.0f;
   public static void main(String[] args) {
       boolean valid;
       String DNA;
       String DNA2;
  
       while(true)
       {
       System.out.println("Enter DNA Sequence: ");
       DNA = sc.nextLine();
       if(chkvalid(DNA))
       {   
       System.out.println("Sequence 1: " + DNA);
       countss(DNA);
       countgg(DNA);
       detfraction(DNA);
       System.out.print("Complement: ");   
       complement(DNA);
       break;
       }
       else
       {
       System.out.println("Please enter Valid DNA Sequence!");   
       }
         
             
         
       }      
       while(true)
       {
       System.out.println("Enter DNA2 Sequence: ");
       DNA2 = sc.nextLine();
       if(chkvalid(DNA2))
       {   
       System.out.println("Sequence 1: " + DNA2);
       countss(DNA2);
       countgg(DNA2);
       detfraction(DNA2);
       System.out.print("Complement: ");   
       complement(DNA2);
       break;
       }
       else
       {
       System.out.println("Please enter Valid DNA Sequence!");   
       }
         
             
         
       }      
      
       bestalignment(DNA,DNA2);
   }
   private static boolean chkvalid(String DNA) {
       if (DNA.matches("[ATGC]+")) {
           return true;
       }else
           return false;
      
   }
   public static void countss(String DNA){
       for(int i=0;i<DNA.length();i++){
           if(DNA.charAt(i)=='C')
               countc++;
      
       }
       System.out.println("count of c:"+countc);
  
   }
   public static void countgg(String DNA){
       for(int i=0;i<DNA.length();i++){
           if(DNA.charAt(i)=='G')
               countg++;
   }
       System.out.println("count of g:"+countg);
      
   }
   public static void detfraction(String DNA){
       if(countc >=DNA.length()/2||countg>=DNA.length()/2)
           fraction=0.5f;
           System.out.println("cg ratio:"+fraction);
   }
   public static void complement(String DNA){
       String cp="";
       for(int i=0;i<DNA.length();i++){
           if(DNA.charAt(i)=='A')
               cp+='T';
           else if(DNA.charAt(i)=='T')
               cp+='A';
           if(DNA.charAt(i)=='C')
               cp+='G';
           else if(DNA.charAt(i)=='G')
               cp+='C';
          
              
       }
       System.out.println(cp);
   }
   public static void bestalignment(String DNA,String DNA2){
       List<Integer>alist=new ArrayList<Integer>();
       int bigs=0;
       int add=0;
       int s1=DNA.length();
       int s2=DNA2.length();
       int diff1=0;
       int diff2=0;
       if(s1>s2)
       diff1=s1-s2;
       else
           diff1=s2-s1;
       diff2=diff1;
       int i=0;
       while(i<=diff2){
           for(int j=0;j<DNA2.length();j++){
               char a=DNA.charAt(j+i);
               char b=DNA2.charAt(j);
               if(a==b)
                   add++;
              
           }
           alist.add(add);
           add=0;
       i++;
      
   }
       //System.out.println(alist);
       for(int k=0;k<alist.size();k++){
           if(alist.get(k)>bigs)
               bigs=alist.get(k);
       }
       System.out.println("best alignment is:"+bigs);
          
   }
}

OUTPUT:
Enter DNA Sequence:
AATCTATA
Sequence 1: AATCTATA
count of c:1
count of g:0
cg ratio:0.0
Complement: TTAGATAT
Enter DNA2 Sequence:
AAGATA
Sequence 1: AAGATA
count of c:1
count of g:1
cg ratio:0.0
Complement: TTCTAT
[4, 1, 3]
best alignment is:4


OUTPUT:
Enter DNA Sequence:
CTAAGT
Sequence 1: CTAAGT
count of c:1
count of g:1
cg ratio:0.0
Complement: GATTCA
Enter DNA2 Sequence:
GT
Sequence 1: GT
count of c:1
count of g:2
cg ratio:0.5
Complement: CA
best alignment is:2

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote