Beispiel #1
0
def action(args):
    if not os.path.exists(args.assembly):
        raise ValueError("No such file: %s" % (args.assembly,))
    asm = deserialize(args.assembly)
    s = "<!DOCTYPE html><html><body>" + renderassembly(asm) + "</body></html>"
    if args.output:
        with open(args.output, 'w') as out:
            print >>out, s
    else:
        print s
    return 0
Beispiel #2
0
def test_addsequences(tmpdir):
    a = asm.Assembly([('a', asm.aflist(0, 'ATGATGGA', '-'))])
    a.serialize(str(tmpdir.join('asm.json.bz2')))
    with open(str(tmpdir.join('a.fasta')), 'w') as h:
        print >>h, '>alpha omega\nTGATGGA\n'
    class Args:
        assembly=str(tmpdir.join('asm.json.bz2'))
        output=str(tmpdir.join('output.json.bz2'))
        align_to='a'
        fastas=[str(tmpdir.join('a.fasta'))]
        no_alignment=False
    assert seqlab.subcommands.addsequence.action(Args()) == 0
    assert os.path.exists(str(tmpdir.join('output.json.bz2')))
    asm2 = asm.deserialize(str(tmpdir.join('output.json.bz2')))
    assert asm2 == asm.Assembly([('a', asm.aflist(0, 'ATGATGGA', '-')),
                                 ('alpha omega', asm.aflist(1, 'TGATGGA', '-'))])