Built with blockbuilder.org
forked from scresawn's block: sample problems for bioinformatics class
xxxxxxxxxx
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<body>
<h3>Here are a few practice problems. These don't involve SVG graphics, so you should open your developer console to debug them and see their output.</h3>
<script>
// Write a function called "count_purine()" that accepts a single argument (a string of A,C,G,T) and returns the number of purine bases (A or G) in a DNA sequence string. For this one, I'll get you started.
exampleInput = "CGATCGAGCTAGCTTACGTACCGGTCGTCGCGCGGGTGTATTAATGATTATATAT";
count_purine = function(dna) {
purine_count = 0;
dna=dna.split("");
dna.forEach (function (letter) {
if (letter == "A") {purine_count = purine_count + 1;}
else if (letter == "G") {purine_count == purine_count +1;}
})
return purine_count; }
purines1= count_purine (exampleInput);
console.log("purines1:", purines1 )
// Write a function called "percent_purine()" that accepts a single argument (a string of A,C,G,T) and returns the percentage of purine bases (A or G) in a DNA sequence string.
//var average = "A + G"/ total
// var total = "A + G + C +T"
// percent_purine = function (dna) {
// for (dna in exampleInput) {
// Write a function called "find_purine_rich()" that accepts a single argument (an array of strings of A,C,G,T) and returns a new array that contains only those strings from the input array that contain at least 10 purines and are composed of at least 75% purine bases.
</script>
</body>
https://d3js.org/d3.v4.min.js