1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Maru [420]
3 years ago
5

DNA is the fundamental encoding of the instructions that govern the operation of living cells and, by extension, biological orga

nisms. You can think of DNA as a storage medium in which the program 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.
Your program will first prompt the user to enter a single DNA sequence, which it should validate for legality (i.e., only the four valid bases) — you might do this validation by writing a function that takes a String as a parameter and returns a boolean. Re-prompt the user if the input was invalid. Once you have a valid input, compute the following statistics (each should be implemented as a separate function, called from main()).
1. Count the number of occurrences of "C".
2. Determine the fraction of cytosine and guanine nucleotides. For example, if half of the nucleotides in the sequence are either "C" or "G", the fraction should be 0.5.
-A DNA strand is actually made up of pairs of bases — in effect, two strands that are cross-linked together. These two strands are complementary: if you know one, you can always determine the other, or complement, because each nucleotide only pairs up with one other. In particular, "A" and "T" are complements, as are "C" and "G". So, for example, the complement of the sequence "AAGGT" would be "TTCCA". Compute the complement of the input sequence.
Computers and Technology
1 answer:
saul85 [17]3 years ago
5 0

Answer:

See explaination

Explanation:

import java.util.*;

class Dna

{

public static void main(String args[])

{

Scanner sc = new Scanner(System.in);

boolean b = false; //boolean variable to check validity

String s1="",s2="";

//input 1st sequence from user

while(b != true)

{

System.out.print("Sequence 1: ");

s1 = sc.nextLine();

b = isValid(s1); //checks validity

}

int c = findCount(s1); //finds C-Count for 1st sequence

double ratio = findRatio(c, s1); //finds CG-Ratio for 1st sequence

String complement = findComplement(s1); //finds complement of 1st sequence

System.out.println("C-count: "+c);

System.out.println("CG-ratio: "+ratio);

System.out.println("Complement: "+complement+"\n");

b = false; //re-initialize for 2nd sequence

//input 2nd sequence from user

while(b != true)

{

System.out.print("Sequence 2: ");

s2 = sc.nextLine();

b = isValid(s2); //checks validity

}

c = findCount(s2); //finds C-Count for 2nd sequence

ratio = findRatio(c, s2); //finds CG-Ratio for 2nd sequence

complement = findComplement(s2); //finds complement of 2nd sequence

System.out.println("C-count: "+c);

System.out.println("CG-ratio: "+ratio);

System.out.println("Complement: "+complement+"\n");

findAlignment(s1, s2); //finds best alignment score

}

/* This function determines validity of a sequence */

public static boolean isValid(String s)

{

boolean b = true;

for(int i=0; i<s.length(); i++)

{

char c = s.charAt(i);

if(!(c=='A' || c=='C' || c=='G' || c=='T'))

{

b = false;

break;

}

}

return b;

}

/* This function finds count of 'C' by iterating over string */

public static int findCount(String s)

{

int count = 0;

for(int i=0; i<s.length(); i++)

{

if(s.charAt(i) == 'C')

count++;

}

return count;

}

/**

This function finds CG-Ratio by iterating over string

and finding count of 'C' and 'G' and dividing the count by

size of string

*/

public static double findRatio(int c, String s)

{

int count = 0;

int length = s.length();

for(int i=0; i<length; i++)

{

if(s.charAt(i) == 'C' || s.charAt(i) == 'G')

count++;

}

double ratio = (double)count/length;

ratio = (double) Math.round(ratio * 1000) / 1000;

return ratio;

}

/* This function finds complement of a sequence */

public static String findComplement(String s)

{

String sc = "";

for(int i=0; i<s.length(); i++)

{

char c = s.charAt(i);

if(c == 'A')

sc = sc + "T";

else if(c == 'T')

sc = sc + "A";

else if(c == 'C')

sc = sc + "G";

else if(c == 'G')

sc = sc + "C";

}

return sc;

}

/**

This function finds maximum Alignment score by shifting

the string with lower size by 1 until the difference

between the size of both strings and calculating count

of characters match

*/

public static void findAlignment(String s1, String s2)

{

int offset = 0; //highest shift upto which 2nd sequence need to be shifted

int maxOffset = 0; //the offset where we get maximum alignment score

int maxAllignment = 0; //stores max Alignment score

int l1 = s1.length(); //length of 1st sequence

int l2 = s2.length(); //length of 2nd sequence

int min = 0; //stores the length of sequence with smaller size

//calculate difference between size of both sequences

//to determine offset

if(l1>l2)

{

offset = l1 - l2;

min = l2;

}

else if(l1<l2)

{

offset = l2 - l1;

min = l1;

}

else

{

offset = 1; //ensures single iteration for equi-length sequences

min = l1;

}

//loop to find max alignment score

for(int i=0; i<offset; i++)

{

int count = 0; //counts alignment score for each offset

//This loop checks the count for each alignment

for(int j=0; j<min; j++)

{

if(s1.charAt(j+i) == s2.charAt(j))

count++;

}

//store highest alignment score in maxAlignment

//and shift of the smaller sequence in maxOffset

if(count > maxAllignment)

{

maxAllignment = count;

maxOffset = i;

}

}

//Print the alignment score and alignment of sequences

if(l1>l2)

{

System.out.println("Best alignment score: "+maxAllignment);

System.out.println(s1);

for(int i=0; i<maxOffset; i++)

System.out.print(" ");

System.out.println(s2);

}

else if(l2>l1)

{

System.out.println("Best alignment score: "+maxAllignment);

for(int i=0; i<maxOffset; i++)

System.out.print(" ");

System.out.println(s1);

System.out.println(s2);

}

else

{

System.out.println("Best alignment score: "+maxAllignment);

System.out.println(s1);

System.out.println(s2);

}

}

}

You might be interested in
Given variables first and last, each of which is associated with a str, representing a first and a last name, respectively. Writ
valentina_108 [34]

Answer:

The python code is attached

Explanation:

  1. I defined a function called Fullname
  2. The function accepts 2 parameters first and last
  3. last[0] gives the first letter of the last variable
  4. last[0].upper() modifies the first letter as upper letter
  5. same applied to variable first
  6. + sign concatenates strings and variables to the variable name
  7. the function returns the variable name

5 0
3 years ago
When using bits to represent fractions of a number, can you make all possible fractions?
saw5 [17]
This is your perfect answer

8 0
2 years ago
____________________ material is information, graphics, images, or any other physical or electronic item that could have value a
djverab [1.8K]

Answer:

Explanation:

Evidentiary material is information, graphics, images, or any other physical or electronic item that could have value as evidence in a legal proceeding, whether criminal or civil. Information of evidentiary value may be found on digital  media such as CDs,  (DVDs), floppy disks, thumb  drives, hard drives, and memory expansion cards found in digital cameras and mobile  phones.

7 0
3 years ago
Dashed lines that display on your slide when you are moving an object and that assist you with alignment are referred to as:
Umnica [9.8K]
Smart guides is the answer.
7 0
2 years ago
Read 2 more answers
What is the output of the following code snippet? int i = 1; while (i != 9) { System.out.print(i + " "); i++; if (i == 9) { Syst
Monica [59]

Answer:

1 2 3 4 5 6 7 8 End

Explanation:

int i = 1;

while (i != 9){

  System.out.print (i + " ");

  i ++;

  if (i == 9){

     System.out.println("End");

  }

}

7 0
2 years ago
Other questions:
  • A _____ is a machine that changes information from one form into another.
    7·1 answer
  • Which of the following journals is not aimed at the public as well as scientists?
    7·1 answer
  • Write a program that prints all the numbers from 0 to 6 except 3 and 6. Expected output: 0 1 2 4 5
    13·1 answer
  • TWO QUICK QUESTIONS
    12·1 answer
  • What is an elliptic curve cryptosystem (ECC)?
    8·1 answer
  • A home user reports to a network technician that the Internet is slow. The network administrator discovers that multiple unknown
    12·2 answers
  • Which procedure is recommended when cleaning inside a computer? Clean the hard drive heads with a cotton swab. Hold the CPU fan
    9·1 answer
  • Sites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program with two
    12·1 answer
  • A digital forensic analyst examines the original digital source (e.g. computer, flash drive, backup tape) suspected of being inv
    5·1 answer
  • Write a function called mul_time that takes a Time_Elapsed object and a number and returns a new Time_Elapsed object that contai
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!