Пример #1
0
def test_commandline(capsys,bamFile):
    countbases.main(['-s',str(bamFile)])
    out, err=capsys.readouterr()
    out2 = subprocess.check_output("countbases -s "+str(bamFile), shell=True)
    out3 = subprocess.check_output("python -m dnapy.countbases -s "+str(bamFile), shell=True)
    for ii,jj,kk in zip(out.split('\n'),out2.decode().split('\n'),out3.decode().split('\n')): 
        print(ii)
        print(jj)
        assert ii==jj==kk
Пример #2
0
def test_commandline(capsys,bamFile):
    countbases.main(['-s',str(bamFile)])
    out, err=capsys.readouterr()
    out2 = subprocess.check_output("countbases -s "+str(bamFile), shell=True)
    out3 = subprocess.check_output("python -m dnapy.countbases -s "+str(bamFile), shell=True)
    for ii,jj,kk in zip(out.split('\n'),out2.decode().split('\n'),out3.decode().split('\n')): 
        print(ii)
        print(jj)
        assert ii==jj==kk
Пример #3
0
def test_main(capsys,tmpdir,bamFile):
    with pytest.raises(SystemExit):
        countbases.main()
    out, err=capsys.readouterr()
    assert 'usage' in err
    with pytest.raises(SystemExit):
        countbases.main(['-h'])
    out, err=capsys.readouterr()
    assert 'usage' in out

    countbases.main(['-v',str(bamFile)])
    out, err=capsys.readouterr()
    assert 'Arguments' in err
    compare=countbases.countBasesInFile(str(bamFile))

    for ii,jj in zip(out.split('\n')[1:],compare): 
        ii=ii.split(',')
        assert ii[0]==jj['ref']
        assert int(ii[1])==jj['pos']
        assert int(ii[2])==jj['n']
        assert int(ii[3])==jj['+']['A']+jj['-']['A']
        assert int(ii[4])==jj['+']['C']+jj['-']['C']
        assert int(ii[5])==jj['+']['G']+jj['-']['G']
        assert int(ii[6])==jj['+']['T']+jj['-']['T']

    countbases.main(['-s',str(bamFile)])
    out, err=capsys.readouterr()

    for ii,jj in zip(out.split('\n')[1:],compare): 
        ii=ii.split(',')
        assert ii[0]==jj['ref']
        assert int(ii[1])==jj['pos']
        assert int(ii[2])==jj['n']
        assert int(ii[3])==jj['+']['A']
        assert int(ii[5])==jj['+']['C']
        assert int(ii[7])==jj['+']['G']
        assert int(ii[9])==jj['+']['T']
        assert int(ii[4])==jj['-']['A']
        assert int(ii[6])==jj['-']['C']
        assert int(ii[8])==jj['-']['G']
        assert int(ii[10])==jj['-']['T']
Пример #4
0
def test_main(capsys, tmpdir, bamFile):
    with pytest.raises(SystemExit):
        countbases.main()
    out, err = capsys.readouterr()
    assert 'usage' in err
    with pytest.raises(SystemExit):
        countbases.main(['-h'])
    out, err = capsys.readouterr()
    assert 'usage' in out

    countbases.main(['-v', str(bamFile)])
    out, err = capsys.readouterr()
    assert 'Arguments' in err
    compare = countbases.countBasesInFile(str(bamFile))

    for ii, jj in zip(out.split('\n')[1:], compare):
        ii = ii.split(',')
        assert ii[0] == jj['ref']
        assert int(ii[1]) == jj['pos']
        assert int(ii[2]) == jj['n']
        assert int(ii[3]) == jj['+']['A'] + jj['-']['A']
        assert int(ii[4]) == jj['+']['C'] + jj['-']['C']
        assert int(ii[5]) == jj['+']['G'] + jj['-']['G']
        assert int(ii[6]) == jj['+']['T'] + jj['-']['T']

    countbases.main(['-s', str(bamFile)])
    out, err = capsys.readouterr()

    for ii, jj in zip(out.split('\n')[1:], compare):
        ii = ii.split(',')
        assert ii[0] == jj['ref']
        assert int(ii[1]) == jj['pos']
        assert int(ii[2]) == jj['n']
        assert int(ii[3]) == jj['+']['A']
        assert int(ii[5]) == jj['+']['C']
        assert int(ii[7]) == jj['+']['G']
        assert int(ii[9]) == jj['+']['T']
        assert int(ii[4]) == jj['-']['A']
        assert int(ii[6]) == jj['-']['C']
        assert int(ii[8]) == jj['-']['G']
        assert int(ii[10]) == jj['-']['T']