Example #1
0
def read_lwcfile(infile, scale, normalize=True):
    """
    Cannot handle very large file
    :param infile: a string for path, or file object
    :param normalize: boolean. If true, shift to make leftmost point 0
    :param scale: a number. All head and tail values will be divided by this num
    :return:
    """
    items = tabular.read(infile, LWC_TABLE, castfunc=list)

    if normalize:
        minpos = min(min(item['head'], item['tail']) for item in items)
    else:
        minpos = 0.

    for item in items:
        element = get_defaults(polygon_style=dict(fill=item['color']))
        # print(element, file=sys.stderr)
        head = min(item['head'], item['tail'])
        tail = max(item['head'], item['tail'])
        if item['strand'] == '-':
            element['head'] = (tail - minpos) * 1. / scale
            element['tail'] = (head - minpos) * 1. / scale
        else:
            element['head'] = (head - minpos) * 1. / scale
            element['tail'] = (tail - minpos) * 1. / scale
        # element['']
        element['text'] = item['name']
        yield element
Example #2
0
    def render(cls, args, outfile):
        recgens = [tabular.read(fn) for fn in args.filenames]
        records = itertools.chain(*recgens)
        aggregator = tabular.Aggregator(aggregator)

        if args.function == 'count':
            # groups = aggregator
            pass
Example #3
0
def read_tblout(infile):
    """
    Read tabfile generated by `hmmscan --tblout`
    :param infile: a string or a file like opject
    """
    return tabular.read(infile, TBLOUT_FIELDS)
Example #4
0
def read_fmt6(infile):
    return tabular.read(infile, fieldlist_default, sep='\t')
Example #5
0
def read_fmt6m(infile):
    return tabular.read(infile, fieldlist_mini)
Example #6
0
def read_fmt7a(infile):
    return tabular.read(infile, fieldlist_all, sep='\t')