Example #1
0
def test_uas_all(tmp_path):
    inputdb = data_file('snps')
    exp_out = data_file('snps_uas_all.txt')
    obs_out = str(tmp_path / 'uas.txt')
    arglist = ['snps', inputdb, '-o', obs_out, '--type', 'all', '--uas']
    args = lusSTR.cli.get_parser().parse_args(arglist)
    lusSTR.snps.main(args)
    assert filecmp.cmp(exp_out, obs_out) is True
Example #2
0
def test_format_straitrazor(input, testoutput):
    with NamedTemporaryFile() as outfile:
        inputdb = data_file(input)
        testformat = data_file(testoutput)
        arglist = ['format', inputdb, '-o', outfile.name]
        args = lusSTR.cli.get_parser().parse_args(arglist)
        lusSTR.format.main(args)
        assert filecmp.cmp(testformat, outfile.name) is True
Example #3
0
def test_format_sex_loci_straitrazor(tmp_path):
    inputdb = data_file('STRait_Razor_test_output')
    exp_out = data_file('testformat_sr_sexloci.csv')
    obs_out = str(tmp_path / 'sr.csv')
    obs_out_sex = str(tmp_path / 'sr_sexloci.csv')
    arglist = ['format', inputdb, '-o', obs_out, '--include-sex']
    args = lusSTR.cli.get_parser().parse_args(arglist)
    lusSTR.format.main(args)
    assert filecmp.cmp(exp_out, obs_out_sex) is True
Example #4
0
def test_format():
    UAStestfile = data_file(
        'snps/Positive Control Sample Details Report 2315.xlsx')
    formatoutput = data_file('testformat.csv')
    with NamedTemporaryFile(suffix='.csv') as outfile:
        arglist = ['format', UAStestfile, '-o', outfile.name, '--uas']
        args = lusSTR.cli.get_parser().parse_args(arglist)
        lusSTR.format.main(args)
        assert filecmp.cmp(formatoutput, outfile.name) is True
Example #5
0
def test_powerseq_flanking_anno():
    with NamedTemporaryFile(suffix='.txt') as outfile:
        input = data_file('powerseq_flanking_anno_test.csv')
        test_powerseq = data_file(
            'powerseq_flanking_anno_test_flanks_anno.txt')
        arglist = ['annotate', input, '-o', outfile.name, '--kit', 'powerseq']
        args = lusSTR.cli.get_parser().parse_args(arglist)
        lusSTR.annot.main(args)
        outfile_name = os.path.splitext(outfile.name)[0]
        outfile_name_output = f'{outfile_name}_flanks_anno.txt'
        assert filecmp.cmp(test_powerseq, outfile_name_output) is True
Example #6
0
def test_sr_all(tmp_path):
    inputdb = data_file('snps')
    exp_out = data_file('snps_sr_all.txt')
    exp_out_full = data_file('snps_sr_all_full_output.txt')
    obs_out = str(tmp_path / 'sr.txt')
    obs_out_full = str(tmp_path / 'sr_full_output.txt')
    arglist = ['snps', inputdb, '-o', obs_out, '--type', 'all']
    args = lusSTR.cli.get_parser().parse_args(arglist)
    lusSTR.snps.main(args)
    assert filecmp.cmp(exp_out, obs_out) is True
    assert filecmp.cmp(exp_out_full, obs_out_full) is True
Example #7
0
def test_uas_directory_with_xy(tmp_path):
    inputdb = data_file('UAS_bulk_input')
    exp_out_auto = data_file('UAS_bulk_test.csv')
    exp_out_sex = data_file('UAS_bulk_test_sexloci.csv')
    obs_out_auto = str(tmp_path / 'format_output.csv')
    obs_out_sex = str(tmp_path / 'format_output_sexloci.csv')
    arglist = ['format', '-o', obs_out_auto, '--uas', '--include-sex', inputdb]
    args = lusSTR.cli.get_parser().parse_args(arglist)
    lusSTR.format.main(args)
    assert filecmp.cmp(exp_out_auto, obs_out_auto) is True
    assert filecmp.cmp(exp_out_sex, obs_out_sex) is True
Example #8
0
def test_format_stdout(capsys):
    UAStestfile = data_file(
        'snps/Positive Control Sample Details Report 2315.xlsx')
    formatoutput = data_file('testformat.csv')
    arglist = ['format', UAStestfile, '--uas']
    args = lusSTR.cli.get_parser().parse_args(arglist)
    lusSTR.format.main(args)
    with open(formatoutput, 'r') as fh:
        exp_out = fh.read().strip()
    terminal = capsys.readouterr()
    obs_out = terminal.out.strip()
    assert obs_out == exp_out
Example #9
0
def test_annotate_uas():
    with NamedTemporaryFile() as outfile:
        os.unlink(outfile.name)
        inputfile = data_file('2800M_formatted_uas.csv')
        testanno = data_file('2800M_uas_anno.txt')
        arglist = [
            'annotate', inputfile, '-o', outfile.name, '--kit', 'forenseq',
            '--uas'
        ]
        args = lusSTR.cli.get_parser().parse_args(arglist)
        lusSTR.annot.main(args)
        assert filecmp.cmp(testanno, outfile.name) is True
Example #10
0
def test_format_sexloci_uas():
    UAStestfile = data_file(
        'snps/Positive Control Sample Details Report 2315.xlsx')
    formatoutput = data_file('testformat_uas_sexloci.csv')
    with NamedTemporaryFile(suffix='.csv') as outfile:
        arglist = [
            'format', UAStestfile, '-o', outfile.name, '--uas', '--include-sex'
        ]
        args = lusSTR.cli.get_parser().parse_args(arglist)
        lusSTR.format.main(args)
        outfile_name = os.path.splitext(outfile.name)[0]
        outfile_name_output = f'{outfile_name}_sexloci.csv'
        assert filecmp.cmp(formatoutput, outfile_name_output) is True
Example #11
0
def test_uas_directory_autosomal_only(tmp_path):
    inputdb = data_file('UAS_bulk_input')
    copydb = str(tmp_path / 'UAS_bulk_input')
    copytree(inputdb, copydb)
    bogusfile = os.path.join(copydb, 'bogusfile.txt')
    with open(bogusfile, 'w') as fh:
        pass
    exp_out_auto = data_file('UAS_bulk_test.csv')
    obs_out_auto = str(tmp_path / 'format_output.csv')
    arglist = ['format', '-o', obs_out_auto, '--uas', copydb]
    args = lusSTR.cli.get_parser().parse_args(arglist)
    lusSTR.format.main(args)
    assert filecmp.cmp(exp_out_auto, obs_out_auto) is True
Example #12
0
def test_annotate_uas_sexloci():
    with NamedTemporaryFile() as outfile:
        os.unlink(outfile.name)
        inputfile = data_file('testformat_uas.csv')
        testanno = data_file('testformat_uas_sexloci.txt')
        arglist = [
            'annotate', inputfile, '-o', outfile.name, '--kit', 'forenseq',
            '--uas', '--include-sex'
        ]
        args = lusSTR.cli.get_parser().parse_args(arglist)
        lusSTR.annot.main(args)
        outfile_name = os.path.splitext(outfile.name)[0]
        outfile_name_output = f'{outfile_name}_sexloci.txt'
        assert filecmp.cmp(testanno, outfile_name_output) is True
Example #13
0
def test_annotate_full_nocombine(infile, len_sum, len_uncom, xy_len_sum,
                                 xy_len_uncom, kit):
    inputfile = data_file(infile)
    with NamedTemporaryFile() as outfile:
        arglist_nocomb = [
            'annotate', inputfile, '-o', outfile.name, '--kit', kit,
            '--nocombine', '--include-sex'
        ]
        args_nocomb = lusSTR.cli.get_parser().parse_args(arglist_nocomb)
        lusSTR.annot.main(args_nocomb)
        outfile_name = os.path.splitext(outfile.name)[0]
        with open(f'{outfile_name}_no_combined_reads.txt', 'r') as fh:
            assert len(fh.readlines()) == len_uncom
        with open(f'{outfile_name}_sexloci_no_combined_reads.txt', 'r') as fh:
            assert len(fh.readlines()) == xy_len_uncom
        arglist_comb = [
            'annotate', inputfile, '-o', outfile.name, '--kit', kit,
            '--include-sex'
        ]
        args_comb = lusSTR.cli.get_parser().parse_args(arglist_comb)
        lusSTR.annot.main(args_comb)
        with open(outfile.name, 'r') as fh:
            assert len(fh.readlines()) == len_sum
        with open(f'{outfile_name}_sexloci.txt', 'r') as fh:
            assert len(fh.readlines()) == xy_len_sum
Example #14
0
def test_annotate_sr_sexloci(inputfile, testoutput, flank_output, kit):
    with NamedTemporaryFile() as outfile:
        os.unlink(outfile.name)
        inputfile = data_file(inputfile)
        testanno = data_file(testoutput)
        flankanno = data_file(flank_output)
        arglist = [
            'annotate', inputfile, '-o', outfile.name, '--kit', kit,
            '--include-sex'
        ]
        args = lusSTR.cli.get_parser().parse_args(arglist)
        lusSTR.annot.main(args)
        outfile_name = os.path.splitext(outfile.name)[0]
        outfile_name_output = f'{outfile_name}_sexloci.txt'
        assert filecmp.cmp(testanno, outfile_name_output) is True
        flank_outfile = f'{outfile_name}_sexloci_flanks_anno.txt'
        assert filecmp.cmp(flankanno, flank_outfile) is True
Example #15
0
def test_uas_type(type, lines, tmp_path):
    inputdb = data_file('snps')
    obs_out = str(tmp_path / 'uas.txt')
    arglist = ['snps', inputdb, '-o', obs_out, '--type', type, '--uas']
    args = lusSTR.cli.get_parser().parse_args(arglist)
    lusSTR.snps.main(args)
    with open(obs_out, 'r') as fh:
        assert len(fh.readlines()) == lines
Example #16
0
def test_FGA_short_seq():
    with NamedTemporaryFile(suffix='.txt') as outfile:
        input = data_file('test_FGA_short_seq.csv')
        arglist = ['annotate', input, '-o', outfile.name, '--kit', 'forenseq']
        args = lusSTR.cli.get_parser().parse_args(arglist)
        lusSTR.annot.main(args)
        with open(outfile.name, 'r') as fh:
            assert len(fh.readlines()) == 1
Example #17
0
def test_annotate_combine():
    with NamedTemporaryFile() as outfile:
        inputfile = data_file('Flanks_testing_file.csv')
        arglist = [
            'annotate', inputfile, '-o', outfile.name, '--kit', 'forenseq'
        ]
        args = lusSTR.cli.get_parser().parse_args(arglist)
        lusSTR.annot.main(args)
        with open(outfile.name, 'r') as fh:
            assert len(fh.readlines()) == 952
Example #18
0
def test_sr_type(type, lines, full_lines, tmp_path):
    inputdb = data_file('snps')
    obs_out = str(tmp_path / 'sr.txt')
    obs_out_full = str(tmp_path / 'sr_full_output.txt')
    arglist = ['snps', inputdb, '-o', obs_out, '--type', type]
    args = lusSTR.cli.get_parser().parse_args(arglist)
    lusSTR.snps.main(args)
    with open(obs_out, 'r') as fh:
        assert len(fh.readlines()) == lines
    with open(obs_out_full, 'r') as fh:
        assert len(fh.readlines()) == full_lines