def testrun(self): # self.testtable() print ('test 1') d = {'a': 1, 'b': 1, 'c':1, 'd':7} ind = dictinvert(d) ind2 = dictinvert(ind) print (d) print (ind) print (ind2) d = {1: ['a', 'b', 'b'], 7: ['d']} ind = dictinvert(d) ind2 = dictinvert(ind) print (d) print (ind) print (ind2) d = {1: ['ahh', 'bjjj', 'bjjj'], 7: ['oood']} ind = dictinvert(d) ind2 = dictinvert(ind) print (d) print (ind) print (ind2) a = ['ver-1.3.12', 'ver-1.3.3', 'ver-1.2.5', 'ver-1.2.15', 'ver-1.2.3', 'ver-1.2.1'] b = natsorted(a) print (a,'\n',b) tulis=[('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)] d=keylis2dic(tulis) print (d['blue']) self.assertEqual (list(d.items()),[('blue', [2, 4]), ('red', [1]), ('yellow', [1, 3])]) confirmed = filterconsecutive(mtchlis = [0,1,2,5,6,7,10,12,13]) self.assertEqual(confirmed,[(0,2),(5,7),(10,10),(12,13)]) print (renamefilename(os.path.join('','oop.GRF.fastaR'),'hih','iii')) print(renamefilename('/llll/kllklkkl/annotationfilename.txt', prefix='txt')) import logging setup_logging() logger = logging.getLogger('fhstandard') logger.info('info message') logger.error('error message') execwrapper('ls -alt') # execwrapper('ls --alt') print ('ALL TESTS RUN')
def sqltab2dic(self, tabinfo, filterinfo=None, ignoreinfo=None, distinct=True): """ retrieving python dictionary from table tabinfo: tuple with table name and following column names (key,value; only two allowed) ignore,ignorecolumn: optional parameter - if set SQL: ...WHERE ignorecolumn != 'ignore' distinct: if true : SQL: SELECT DISTINCT ... dic: dictionary """ if not ignoreinfo: ignoreinfo = [] if not filterinfo: filterinfo = [] newtable = self.sql2tab(tabinfo, filterinfo=filterinfo, ignoreinfo=ignoreinfo, distinct=distinct) tulis = newtable.data dic = keylis2dic(tulis) if len(tulis) != len(dic): print '\nsqltab2dic: duplicates eliminated uncontrolled in {0} in database {1}'.format(newtable.tablename, self.database) val = [item[0] for item in tulis] valset = set(val) infos = [(item, val.count(item)) for item in valset if val.count(item) > 1] print infos[0] return dic
def testrun(self): # self.testtable() print('test 1') d = {'a': 1, 'b': 1, 'c': 1, 'd': 7} ind = dictinvert(d) ind2 = dictinvert(ind) print(d) print(ind) print(ind2) d = {1: ['a', 'b', 'b'], 7: ['d']} ind = dictinvert(d) ind2 = dictinvert(ind) print(d) print(ind) print(ind2) d = {1: ['ahh', 'bjjj', 'bjjj'], 7: ['oood']} ind = dictinvert(d) ind2 = dictinvert(ind) print(d) print(ind) print(ind2) a = [ 'ver-1.3.12', 'ver-1.3.3', 'ver-1.2.5', 'ver-1.2.15', 'ver-1.2.3', 'ver-1.2.1' ] b = natsorted(a) print(a, '\n', b) tulis = [('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)] d = keylis2dic(tulis) print(d['blue']) self.assertEqual(list(d.items()), [('blue', [2, 4]), ('red', [1]), ('yellow', [1, 3])]) confirmed = filterconsecutive(mtchlis=[0, 1, 2, 5, 6, 7, 10, 12, 13]) self.assertEqual(confirmed, [(0, 2), (5, 7), (10, 10), (12, 13)]) print(renamefilename(os.path.join('', 'oop.GRF.fastaR'), 'hih', 'iii')) print( renamefilename('/llll/kllklkkl/annotationfilename.txt', prefix='txt')) import logging setup_logging() logger = logging.getLogger('fhstandard') logger.info('info message') logger.error('error message') execwrapper('ls -alt') # execwrapper('ls --alt') print('ALL TESTS RUN')