<div dir="ltr"><div>I don't think code like this is exactly what's meant by bioinformatics, which is more statistical in nature.  </div><div><br></div><div>However as a way of reinforcing both knowledge domain content and learning Python concepts, I think it has utility.  If you're already familiar with some cell biology, this would be a useful way to hammer home Python.</div><div><br></div><div>I tossed up a simple 7 minute Youtube on the code below, talking mostly about Inheritance & Composition in the OO sense.  </div><div><br></div><div><a href="https://youtu.be/UoHJdQeYa8k">https://youtu.be/UoHJdQeYa8k</a>  (sound not so great, just using laptap microphone).<br></div><div><br></div><div>I encourage others to do something more produced.</div><div><br></div><div>Example usage:</div><div><br></div><div><div><br></div><div>In [3]: the_cell = Eukaryote(0, 'GATACA')</div><div><br></div><div>In [4]: the_cell.nucleus.dna</div><div>Out[4]: ('GATACA', '')</div><div><br></div><div>In [5]: the_cell.nucleus.dna[0]</div><div>Out[5]: 'GATACA'</div><div><br></div><div>In [6]: the_cell.S_phase()  # this is when DNA replicates</div><div><br></div><div>In [7]: the_cell.nucleus.dna   # cell is now "mature" (ready to divide)</div><div>Out[7]: ('GATACA', 'CTATGT')</div><div><br></div><div>In [8]: new_cell = the_cell.divide()  </div><div><br></div><div>In [9]: new_cell.nucleus.dna</div><div>Out[9]: ('GATACA', '')</div></div><div><br></div><div>Related:</div><div><a href="https://mail.python.org/pipermail/edu-sig/2012-December/010709.html">https://mail.python.org/pipermail/edu-sig/2012-December/010709.html</a><br></div><div><br></div><div>Kirby</div><div><br></div><div><br></div><br><div><br></div><div><div># -*- coding: utf-8 -*-</div><div>"""</div><div>Created on Sat Oct 10 12:02:55 2015</div><div><br></div><div>@author: Kirby Urner, MIT License</div><div>"""</div><div><br></div><div>class Mitochondrion:</div><div>    """Cell Battery"""</div><div>    pass</div><div><br></div><div>class Golgi:</div><div>    """Router"""</div><div>    pass</div><div><br></div><div>class Nucleus:</div><div>    """DNA Hut"""</div><div>    </div><div>    def __init__(self, dna_A):</div><div>        """Get half the DNA"""</div><div>        self.dna = dna_A, ''</div><div>        </div><div>    def mitosis(self):</div><div>        """Split DNA in two"""</div><div>        return self.dna[0], self.dna[1]</div><div><br></div><div>class Cell:</div><div>    </div><div>    def __init__(self, gen=0):</div><div>        """Age"""</div><div>        self.gen = gen + 1</div><div><br></div><div>class Prokaryote(Cell):</div><div>    pass  # won't have a nucleus</div><div>        </div><div>class Eukaryote(Cell):</div><div>    </div><div>    def __init__(self, gen, dna):</div><div>        super().__init__(gen) # get older</div><div>        self.nucleus = Nucleus(dna) # store DNA</div><div>        self.organelles = [Golgi(), Mitochondrion()]</div><div>        self.mature = False</div><div>     </div><div>    def S_phase(self):</div><div>        """Make other half of DNA"""</div><div>        </div><div>        dna_B = []</div><div>        dna_A = self.nucleus.dna[0]</div><div>        </div><div>        for base in dna_A:</div><div>            if base=='A': </div><div>                dna_B.append('T')</div><div>            elif base=='T':</div><div>                dna_B.append('A')</div><div>            elif base=='G':</div><div>                dna_B.append('C')</div><div>            elif base=='C':</div><div>                dna_B.append('G')</div><div>                </div><div>        dna_B = "".join(dna_B)       </div><div>        self.nucleus.dna = (dna_A, dna_B)</div><div>        self.mature = True  # I'm ready for sex!</div><div>        </div><div>    def divide(self):</div><div>        if not self.mature:  # don't try it!</div><div>            raise ValueError </div><div>            </div><div>        dna_A, dna_B = self.nucleus.mitosis()</div><div>        new_cell = Eukaryote(self.gen, dna_A)</div><div>        </div><div>        # next generation of me</div><div>        self.gen += 1  # should be an upper limit</div><div>        self.nucleus.dna = '', dna_B</div><div>        self.mature = False</div><div>        return new_cell  # spawn of me</div></div></div>