Skip to content

Instantly share code, notes, and snippets.

@Sarverott
Last active October 17, 2018 02:50
Show Gist options
  • Save Sarverott/873fa065bfe1b3d0441bd98736f1baa4 to your computer and use it in GitHub Desktop.
Save Sarverott/873fa065bfe1b3d0441bd98736f1baa4 to your computer and use it in GitHub Desktop.
helper for molecular genetics
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("");
}
}
<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