def _get_annotation(c, loci): """get annotation of transcriptional units""" data_ann_temp = {} data_ann = [] counts = Counter() for lid in c.loci2seq: # original Py 2.7 code #for dbi in loci[lid].db_ann.keys(): # data_ann_temp[dbi] = {dbi: map(lambda (x): loci[lid].db_ann[dbi].ann[x].name, loci[lid].db_ann[dbi].ann.keys())} # suggestion by 2to3 for dbi in list(loci[lid].db_ann.keys()): data_ann_temp[dbi] = { dbi: [ loci[lid].db_ann[dbi].ann[x].name for x in list(loci[lid].db_ann[dbi].ann.keys()) ] } logger.debug("_json_: data_ann_temp %s %s" % (dbi, data_ann_temp[dbi])) counts[dbi] += 1 # original Py 2.7 code #data_ann = data_ann + map(lambda (x): data_ann_temp[x], data_ann_temp.keys()) # suggestion by 2to3 data_ann = data_ann + [ data_ann_temp[x] for x in list(data_ann_temp.keys()) ] logger.debug("_json_: data_ann %s" % data_ann) counts = {k: v for k, v in iter(counts.items())} total_loci = sum([counts[db] for db in counts]) valid_ann = [ k for k, v in iter(counts.items()) if up_threshold(v, total_loci, 0.7) ] return data_ann, valid_ann
def _common(s1, s2, i1, i2): """calculate the common % percentage of sequences""" c = len(set(s1).intersection(s2)) t = min(len(s1), len(s2)) pct = 1.0 * c / t * t is_gt = up_threshold(pct, t * 1.0, parameters.similar) logger.debug("_common: pct %s of clusters:%s %s = %s" % (1.0 * c / t, i1, i2, is_gt)) if pct < parameters.similar and is_gt and pct > 0: pct = parameters.similar return pct / t
def _common(s1, s2, i1, i2): """calculate the common % percentage of sequences""" c = len(set(s1).intersection(s2)) t = min(len(s1), len(s2)) pct = 1.0 * c / t * t is_gt = up_threshold(pct, t * 1.0, parameters.similar) logger.debug("_common: pct %s of clusters:%s %s = %s" % (1.0 * c / t, i1, i2, is_gt)) if pct < parameters.similar and is_gt and pct > 0: pct = parameters.similar return pct / t
def _get_annotation(c, loci): """get annotation of transcriptional units""" data_ann_temp = {} data_ann = [] counts = Counter() for lid in c.loci2seq: # original Py 2.7 code #for dbi in loci[lid].db_ann.keys(): # data_ann_temp[dbi] = {dbi: map(lambda (x): loci[lid].db_ann[dbi].ann[x].name, loci[lid].db_ann[dbi].ann.keys())} # suggestion by 2to3 for dbi in list(loci[lid].db_ann.keys()): data_ann_temp[dbi] = {dbi: [loci[lid].db_ann[dbi].ann[x].name for x in list(loci[lid].db_ann[dbi].ann.keys())]} logger.debug("_json_: data_ann_temp %s %s" % (dbi, data_ann_temp[dbi])) counts[dbi] += 1 # original Py 2.7 code #data_ann = data_ann + map(lambda (x): data_ann_temp[x], data_ann_temp.keys()) # suggestion by 2to3 data_ann = data_ann + [data_ann_temp[x] for x in list(data_ann_temp.keys())] logger.debug("_json_: data_ann %s" % data_ann) counts = {k: v for k, v in iter(counts.items())} total_loci = sum([counts[db] for db in counts]) valid_ann = [k for k, v in iter(counts.items()) if up_threshold(v, total_loci, 0.7)] return data_ann, valid_ann