27. Python e bioinformatica Curva d'apprendimento ☺☺☺☺☺ Facile da imparare ma potente Leggibilitá ☺☺☺☺☺ Testing ☺☺☺☺☺ Doctest, unittest, nose Comunitá open source ☺☺☺ BioPerl e BioConductor sono piu' ampi Paradigmi di programmazione ☺☺☺☺☺ Multi paradigma, OO Velocitá di esecuzione Interpretato; Database ☺☺☺☺☺ Ottimi ORM (sqlalchemy), supporto ad altri tipi di db
41. Abbiamo scritto un programma per leggere il formato Fasta e convertirlo al formato GenBank, e testato il suo funzionamento corretto su un file con una sola sequenza, su un file con sequenze multiple, su un file corrotto.....
44. Nosetest -> individua tutte le funzioni che assomigliano a tests e le esegue
45. doctest >>> help (say_hello) Help on function say_hello in module __main__: say_hello(name) print hello <name> to the screen example: >>> say_hello('Albert Einstein') hello Albert Einstein!!!
46.
47. unittest From unittest import * class SimpleFastaSeqCase(unittest.TestCase): @classmethod def setUpClass(cls): ..... @classmethod def tearDownClass(cls): ..... def setUp(self): ..... def tearDown(self): ..... def testCondition1(self): ..... def testCondition2(self): ..... Istruzioni da eseguire prima/dopo tutti i test Istruzioni da eseguire prima/dopo ogni test Tests
48.
49. Su ogni cromosoma possiamo individuare diversi elementi, come geni, fattori di regolazione, etc..
50. Ogni gene codifica per più trascritti, che a loro volta possono dare origine a più proteine
51. > la programmazione a oggetti si presta molto bene a rappresentare dati di tipo biologico
52. Programmazione a oggetti - esempio genes = { 'gene1' : { 'position' : 10000, 'chromosome': 11, 'sequence' : 'GTAGCCTGATGAACGGGCTAGCATGC....' , 'transcripts' : { 'transcript1' : [......], 'transcript2' : [......], }, }, 'gene1' : { 'position' : ...........}, ..... } def get_subseq(genes, geneid, start, end): ''' get a subsequence of a gene, given a dictionary of gene annotations, a gene id, and start/end position ''' pass
53. Programmazione a oggetti - esempio genes = {'gene1': { 'position': 10000, 'chromosome': 11, 'sequence': 'GTAGCCTGATGAACGGGCTAGCATGC....', 'transcripts': { 'transcript1': [......], 'transcript2': [......], }, }, 'gene1': { 'position': ...........}, ..... } def get_subseq(genes, geneid, start, end): ''' get a subsequence of a gene, given a dictionary of gene annotations, a gene id, and start/end position ''' pass
54.
55. Più concisa di Java, inoltre non é obbligatorio usare OO
57. Python and Java classes public class Gene { public int position; public str chromosome; public str transcripts[]; public Gene(int pos){ position = pos } public void getSubseq(int start, int end) { pass } class gene: def __init__(self,pos): self.position = pos self.sequence = '' self.transcripts = [] def get_subseq(self, start, end): pass (Una classe in python) (Una classe in Java) (non sono un programmatore Java!)
82. Biopython Esempi # Leggere un file in formato fasta e salvarlo in un dizionario from Bio.SeqIO import SeqIO seqfile = open('fastafile.fa', 'r') sequences = SeqIO.to_dict(SeqIO.parse(seqfile)) # Query NCBI results = Entrez.esearch(db='nucleotide', term='cox2') Entrez.read(results)