예제 #1
0
def test_blast(tmpdir):
    a = asm.Assembly([('aardvark',
                       asm.aflist(
                           0,
                           ''.join([
                               'tcatatctggcgttaatggagttcagtggtaatacaatgaccag',
                               'agatgcatccagagcagttctgcgttttgtcactgtcacagcag',
                               'aagccttacgcttcaggcagat'
                           ]),
                           '-',
                           trackclass='nucleotide')),
                      ('b',
                       asm.aflist(
                           2, 'GGATCCATC', '-', trackclass='nucleotide')),
                      ('c', asm.aflist(0, 'AAA', '-',
                                       trackclass='nucleotide'))])
    a.serialize(str(tmpdir.join('asm.json.bz2')))

    class Args:
        assembly = str(tmpdir.join('asm.json.bz2'))
        label = 'aardvark'
        json = 'data/blast_subcommand.json'
        xml = 'data/blast_subcommand.xml'
        n = 10

    assert seqlab.subcommands.blast.action(Args()) == 0
    assert os.path.exists('data/blast_subcommand.json')
    assert os.path.exists('data/blast_subcommand.xml')
    with open('data/blast_subcommand.json') as h:
        j = json.load(h)
        assert len(j) <= 10
예제 #2
0
def test_render(tmpdir):
    a = asm.Assembly([('a', asm.aflist(0, 'ATGGNTGG-TC', '-', trackclass='nucleotide')),
                      ('b', asm.aflist(2,   'GGATCCATC', '-', trackclass='nucleotide')),
                      ('c', asm.aflist(0, 'AAA', '-', trackclass='nucleotide'))])
    a.serialize(str(tmpdir.join('asm.json.bz2')))
    class Args:
        assembly = str(tmpdir.join('asm.json.bz2'))
        output = 'data/render_subcommand_test.html'
    assert seqlab.subcommands.render.action(Args()) == 0
    assert os.path.exists('data/render_subcommand_test.html')
예제 #3
0
def test_statistics(tmpdir):
    a = asm.Assembly([('a', asm.aflist(0, 'ATGGNTGG-TC', '-')),
                      ('b', asm.aflist(2,   'GGATCCATC', '-')),
                      ('c', asm.aflist(0, 'AAA', '-'))])
    a.serialize(str(tmpdir.join('asm.json.bz2')))
    class Args:
        assembly = str(tmpdir.join('asm.json.bz2'))
        label1 = 'a'
        label2 = 'b'
        fields = ','.join(['identities','mismatches','fracoverlap'])
        output = str(tmpdir.join('test.csv'))
    assert seqlab.subcommands.statistics.action(Args()) == 0
    with open(str(tmpdir.join('test.csv'))) as h:
        cr = csv.reader(h)
        assert cr.next() == ['5','3','0.9']
예제 #4
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', '-'))])
예제 #5
0
def test_blast(tmpdir):
    a = asm.Assembly([('aardvark', 
                       asm.aflist(0,
                                  ''.join(['tcatatctggcgttaatggagttcagtggtaatacaatgaccag',
                                           'agatgcatccagagcagttctgcgttttgtcactgtcacagcag',
                                           'aagccttacgcttcaggcagat']),
                                  '-',
                                  trackclass='nucleotide')),
                      ('b', asm.aflist(2,   'GGATCCATC', '-', trackclass='nucleotide')),
                      ('c', asm.aflist(0, 'AAA', '-', trackclass='nucleotide'))])
    a.serialize(str(tmpdir.join('asm.json.bz2')))
    class Args:
        assembly = str(tmpdir.join('asm.json.bz2'))
        label = 'aardvark'
        json = 'data/blast_subcommand.json'
        xml = 'data/blast_subcommand.xml'
        n = 10
    assert seqlab.subcommands.blast.action(Args()) == 0
    assert os.path.exists('data/blast_subcommand.json')
    assert os.path.exists('data/blast_subcommand.xml')
    with open('data/blast_subcommand.json') as h:
        j = json.load(h)
        assert len(j) <= 10