Computational biology PhD researcher. Interested in science, software development, and machine learning. I write about medical research at BioSky.co and contribute content to a variety of additional publications.CVAbout
Python’s random module makes it extremely easy to generate random DNA bases.
import random dna = ["A","G","C","T"] #output a random base print(random.choice(dna))
Now to generate a specific number of random bases, all we have to do is use Python’s range function:
import random dna = ["A","G","C","T"] #initialise empty string #this is where the bases will be added as they are generated random_sequence='' # We'll create a string of 100 random bases for i in range(0,100): random_sequence+=random.choice(dna) print(random_sequence)
The following two tabs change content below.
Computational biology PhD candidate at the Australian National University. I love writing (both articles and software), learning more about the world around us, and beekeeping. I also write for BioSky.co
Latest posts by Jack Simpson (see all)
- Fruit flies, honeybees, and alcohol - October 18, 2017
- I’m going to Silicon Valley! - October 15, 2017
- Sometimes working in the biology department is pretty neat - October 10, 2017