예제 #1
0
def test_plot():
    ac = ArrowCalc(**dataset1['config'])
    data = ac.calc([[6, 9, 0], [9, 6, 9]]) * 20
    elements = [dict(polygon=pts) for pts in arrows.format_points(data)]
    # print(data, file=sys.stderr)
    # print(elements, file=sys.stderr)

    kwargs = arrows.get_defaults()
    kwargs['elements'] = elements
    res = arrows.render_svg(**kwargs)
    print(res)
예제 #2
0
def test():
    path = locate_tests('data/lwcsample.tsv')
    elements = molbiox.io.arrows.read_lwcfile(path, 16, castfunc=list)

    arr = ([elem['head'], elem['tail'], 1000] for elem in elements)
    results = ArrowCalc().calc(arr) / 20

    polygons = arrows.format_points(results)

    for elem, pg in zip(elements, polygons):
        elem['polygon'] = pg
        elem['text_x'] = (elem['head'] + elem['tail']) / 2. / 20
        elem['text_y'] = 920 / 20
        # print(elem, file=sys.stderr)

    res = arrows.render_svg(elements=elements)
    print(res)
예제 #3
0
    def render(cls, args, outfile):
        calc = ArrowCalc(args.alpha, args.beta, args.h1, args.h2)
        for filename in args.filenames:
            elements = arrows.read_lwcfile(filename, args.scale, castfunc=list)
            # print('debug: elements', elements, file=sys.stderr)
            ypos = args.h2 * 4
            maxpos = max(max(elem['head'], elem['tail']) for elem in elements)
            arrpos = ([elem['head'], elem['tail'], ypos] for elem in elements)
            results = calc(arrpos)
            polygons = arrows.format_points(results)

            for elem, pg in zip(elements, polygons):
                elem['polygon'] = pg
                elem['text_x'] = (elem['head'] + elem['tail']) / 2.
                elem['text_y'] = args.h2 * 3
            res = arrows.render_svg(elements=elements, height=args.h2*5, width=maxpos)
            outfile.write(res)