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
What will the following loop display? 0 1 2 3 4 5 0 1 2 3 4 0 1 2 3 4 The loop will display numbers starting at 0, for infinity.
Sidana [21]

Answer:

muestra números que comienzan en 0

Explanation:

7 0
3 years ago
The Internet began when a large company wanted to sell products online
aalyn [17]
No!The internet began in the 1950s when the US government was trying to use connected computers to compete with the Soviet Union's Sputnik. Hope this helps :)
6 0
2 years ago
A technician wants to replace a failing power supply on a high-end gaming computer. which form factor should the technician be l
Semmy [17]

A technician need to use the form factor or the  technician be looking for what we call EPS12V.

<h3>What is an EPS power connector?</h3>

The EPS connector is known to be used to supply power to the  motherboard CPU socket and the PCI is known to be one that functions to express connector.

Note that this is said to be a server standard (EPS12V) and it is also known to be one that can be said to be a desktop standard (ATX12V).

Note that the EPS12V is one that is known to always be seen in an 8-pin CPU connector and therefore, A technician need to use the form factor or the  technician be looking for what we call EPS12V.

Learn more about technician from

brainly.com/question/2328085

#SPJ1

5 0
1 year ago
Seven Features of computer aids design software
astra-53 [7]
Computer-aided engineering (CAE) and finite element analysis (FEA) Computer-aided manufacturing (CAM) including instructions to computer numerical control (CNC) machines. Photorealistic rendering and motion simulation. Document management and revision control using product data management (PDM).
3 0
3 years ago
Complete this truth Table. Write a program that you can enter from the keyboard, a 1 or 0 into three Boolean variables, A,B,C. W
SSSSS [86.1K]

Answer:

Following are the code to this question:

#include<stdio.h>//defining header file

int AND(int x,int y) //defining a method AND that hold two variable in its parameter

{

if(x==1 && y==1)//defining if block to check x and y value is equal to 1

{

return 1;//return value 1

}

else //defining else block

{

   return 0;//return value 0

}

}

int OR(int x,int y)//defining method OR that hold two variable in its parameter

{

if(x==0&&y==0)//defining if block to check x and y value is equal to 1

{

return 0;//return value 0

}

else //defining else block

{

   return 1;//return value 1

}

}

int main()//defining main method

{

int a,b,c;//defining integer variable  

int k=1;//defining integer variable k that holds a value 1

while(k<=8)//defining while loop for 8 time input

{

printf("Please insert 3 numbers in (0 0r 1):\n ");//print message

scanf("%d%d%d", &a, &b, &c);//input value

k++;//increment the value of k by 1

printf("value: %d\n",AND(OR(a,b),c));

}

return 0;

}

Output:

please find the attachment.

Explanation:

In the above-given C language code two methods "AND and OR" is declared, holds two integer variable "x and y" in its parameters, inside the method a conditional it used that can be defined as follows:

  • In the AND method, inside a conditional statement, if block check x and y both value is same that is 1 it will return 1 or it will goto else block in this it will return value 0.      
  • In the OR method, inside a conditional statement, if block check x and y both value is the same, that is 0 it will return 0 or it will goto else block in this it will return value 1.
  • In the main method, four integers "a,b,c, and k" is declared in which variable "a, b, c" is used in the loop for 8 times input values from the user and print method is used to call the method and prints its return values.

8 0
3 years ago
Other questions:
  • When a cache block has been modified since being read from main memory?
    10·2 answers
  • Using a wireless network without the network owner's permission is known as ________.
    15·1 answer
  • Jackson is teaching a class the concept of the binary number system. Which term will he use to refer to the leftmost bit of a bi
    7·1 answer
  • Enter a formula using a database function to calculate the total value in the Cost column for expenses that meet the criteria in
    12·1 answer
  • Deciding whether to explode a process further or determine that it is a functional primitive is a matter of experience, judgment
    8·1 answer
  • A ______ is a computer that controls access to the hardware, software, and other resources on a network. mainframe server workst
    10·1 answer
  • 120
    14·1 answer
  • in java Write a program with total change amount in pennies as an integer input, and output the change using the fewest coins, o
    13·1 answer
  • Different search engines available on the internet​
    7·1 answer
  • Greenpeace used "Mister Splashy Pants" to:
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!