def test_iter(self): assoc = InSqlAssoc(GAF20FIELDS, [1, 4], lambda x: x) with open('Ontology/GoaIO/no_ver.fb', 'r') as f: for r in TsvIterator(f): if len(r) == 17: assoc.add_row(r) self.assertEqual( [(u'FBgn0026619', [(u'FB', u'FBgn0026615', u'10-4', u'', u'GO:0005737', u'FB:FBrf0106275', u'IDA', u'', u'C', u'10-4', u'', u'gene_product', u'taxon:7227', u'20060803', u'FlyBase', u'', u''), (u'FB', u'FBgn0026615', u'10-4', u'', u'GO:0045177', u'FB:FBrf0106275', u'IDA', u'', u'C', u'10-4', u'', u'gene_product', u'taxon:7227', u'20060803', u'FlyBase', u'', u'')]), (u'FBgn0043467', [ (u'FB', u'FBgn0026619', u'10-4', u'', u'GO:0045177', u'FB:FBrf0106275', u'IDA', u'', u'C', u'10-4', u'', u'gene_product', u'taxon:7227', u'20060803', u'FlyBase', u'', u'') ]), (u'FBgn0043467', [ (u'FB', u'FBgn0043467', u'064Ya', u'', u'GO:0048149', u'FB:FBrf0131396|PMID:11086999', u'IMP', u'', u'P', u'064Ya', u'', u'gene_product', u'taxon:7227', u'20060803', u'FlyBase', u'', u''), (u'FB', u'FBgn0043467', u'064Ya', u'', u'GO:0005575', u'FB:FBrf0159398', u'ND', u'', u'C', u'064Ya', u'', u'gene_product', u'taxon:7227', u'20060803', u'FlyBase', u'', u'') ])], list(assoc))
def test_insert_get_len(self): assoc = InSqlAssoc(GAF20FIELDS, [1, 4], lambda x: x) self.assertEquals(0, len(assoc)) with open("Ontology/GoaIO/no_ver.fb", "r") as f: for r in TsvIterator(f): if len(r) == 17: assoc.add_row(r) self.assertEquals(3, len(assoc)) self.assertEquals( [ ( u"FB", u"FBgn0043467", u"064Ya", u"", u"GO:0005575", u"FB:FBrf0159398", u"ND", u"", u"C", u"064Ya", u"", u"gene_product", u"taxon:7227", u"20060803", u"FlyBase", u"", u"", ), ( u"FB", u"FBgn0043467", u"064Ya", u"", u"GO:0048149", u"FB:FBrf0131396|PMID:11086999", u"IMP", u"", u"P", u"064Ya", u"", u"gene_product", u"taxon:7227", u"20060803", u"FlyBase", u"", u"", ), ], sorted(assoc["FBgn0043467"]), ) self.assertTrue("FBgn0043467" in assoc)
def test_insert_get_len(self): assoc = InSqlAssoc(GAF20FIELDS, [1, 4], lambda x: x) self.assertEquals(0, len(assoc)) with open('Ontology/GoaIO/no_ver.fb', 'r') as f: for r in TsvIterator(f): if len(r) == 17: assoc.add_row(r) self.assertEquals(3, len(assoc)) self.assertEquals([ (u'FB', u'FBgn0043467', u'064Ya', u'', u'GO:0005575', u'FB:FBrf0159398', u'ND', u'', u'C', u'064Ya', u'', u'gene_product', u'taxon:7227', u'20060803', u'FlyBase', u'', u''), (u'FB', u'FBgn0043467', u'064Ya', u'', u'GO:0048149', u'FB:FBrf0131396|PMID:11086999', u'IMP', u'', u'P', u'064Ya', u'', u'gene_product', u'taxon:7227', u'20060803', u'FlyBase', u'', u'') ], sorted(assoc['FBgn0043467'])) self.assertTrue('FBgn0043467' in assoc)
def test_iter(self): assoc = InSqlAssoc(GAF20FIELDS, [1, 4], lambda x: x) with open("Ontology/GoaIO/no_ver.fb", "r") as f: for r in TsvIterator(f): if len(r) == 17: assoc.add_row(r) self.assertEqual( [ ( u"FBgn0026619", [ ( u"FB", u"FBgn0026615", u"10-4", u"", u"GO:0005737", u"FB:FBrf0106275", u"IDA", u"", u"C", u"10-4", u"", u"gene_product", u"taxon:7227", u"20060803", u"FlyBase", u"", u"", ), ( u"FB", u"FBgn0026615", u"10-4", u"", u"GO:0045177", u"FB:FBrf0106275", u"IDA", u"", u"C", u"10-4", u"", u"gene_product", u"taxon:7227", u"20060803", u"FlyBase", u"", u"", ), ], ), ( u"FBgn0043467", [ ( u"FB", u"FBgn0026619", u"10-4", u"", u"GO:0045177", u"FB:FBrf0106275", u"IDA", u"", u"C", u"10-4", u"", u"gene_product", u"taxon:7227", u"20060803", u"FlyBase", u"", u"", ) ], ), ( u"FBgn0043467", [ ( u"FB", u"FBgn0043467", u"064Ya", u"", u"GO:0048149", u"FB:FBrf0131396|PMID:11086999", u"IMP", u"", u"P", u"064Ya", u"", u"gene_product", u"taxon:7227", u"20060803", u"FlyBase", u"", u"", ), ( u"FB", u"FBgn0043467", u"064Ya", u"", u"GO:0005575", u"FB:FBrf0159398", u"ND", u"", u"C", u"064Ya", u"", u"gene_product", u"taxon:7227", u"20060803", u"FlyBase", u"", u"", ), ], ), ], list(assoc), )