Last active
October 14, 2021 18:13
-
-
Save burdenless/8e420a981e3812ae6f3ad3ca3181833a to your computer and use it in GitHub Desktop.
File for Chris' project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Returns a random DNA base | |
const returnRandBase = () => { | |
const dnaBases = ['A', 'T', 'C', 'G'] // Adenine, Thymine, Cytosine, and Guanine. 4 Bases of DNA | |
return dnaBases[Math.floor(Math.random() * 4)] | |
} | |
// Returns a random single stand of DNA containing 15 bases | |
const mockUpStrand = () => { | |
const newStrand = [] | |
for (let i = 0; i < 15; i++) { | |
newStrand.push(returnRandBase()) | |
} | |
return newStrand | |
} | |
const pAequorFactory = (specimenNum, dna) => { | |
return { | |
specimenNum : specimenNum, | |
dna : dna | |
} | |
} | |
const mutate = (dna) => { | |
let randomIndex = Math.floor(Math.random() * dna.length); | |
let newBase = returnRandBase(); | |
while (newBase === dna[randomIndex]) { | |
newBase = returnRandBase(); | |
} | |
dna[randomIndex] = newBase; | |
return dna; | |
} | |
const compareDNA = (pAequorObject) => { | |
let total = 0 | |
for (let i = 0; i < this.dna.length; i++) { | |
if (pAequorObject.dna[i] === 'C' || this.dna[i] === 'G') { | |
total++; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To run this script, open a terminal and run:
This will open a Node environment, and then run:
Now the functions from your file
main.js
will be available to run, like this: