def filter_genes(gene_table,limits=[2900,3100]):
    """Leave genes whose lengthsa re within the lmit"""
    
    chroms=gene_table.get_chroms()
    new_gt=GeneTable()
    new_gt.table={}
    new_gt.columns=gene_table.columns[:]
    for chrom in chroms:
        new_gt[chrom]={}
        columns=gene_table[chrom].keys()
        for col in columns:
            new_gt[chrom][col]=[]
        for i in xrange(0,len(gene_table[chrom]['txStart'])):
            length=gene_table[chrom]['txEnd'][i]-gene_table[chrom]['txStart'][i]  
            if length>=limits[0] and length<=limits[1]:
                for col in columns:
                    new_gt[chrom][col].append(gene_table[chrom][col][i])
    
    return new_gt
dataset/ETHPy150Open taoliu/taolib/Assoc/inout.py/filter_genes/original