Last active
October 17, 2018 02:50
-
-
Save Sarverott/873fa065bfe1b3d0441bd98736f1baa4 to your computer and use it in GitHub Desktop.
helper for molecular genetics
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
class DNA{ | |
constructor(mode, config){ | |
this.aminoAcidsArray=this.generateRandomDNA(config.len); | |
break; | |
} | |
generateRandomDNA(chainLength=20, allows=["A","C","G","T"]){ | |
var tmp=[]; | |
for(var i=0;i<chainLength;i++){ | |
tmp.push(allows[Math.floor(Math.random()*allows.length)]); | |
} | |
return tmp; | |
} | |
printGenotype(){ | |
return this.aminoAcidsArray.join(""); | |
} | |
} |
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
<script src="dna-random-examples-generator.js"></script> | |
<script> | |
var spicies=new DNA("randtest", {len:7}); | |
document.write(spicies.printGenotype()); | |
document.write("<br>"); | |
var spicies2=new DNA("randtest", {len:7}); | |
document.write(spicies2.printGenotype()); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment