def test_gt_call_no_header(): """Test to get the raw chromosome""" plugin = Plugin(name='gt_call', field='sample_id', gt_key='GT') variant_line = get_variant_line() with pytest.raises(IOError): plugin.get_raw_entry(variant_line=variant_line, individual_id='ADM1003A3')
def test_rank_models(): """Test to get the raw chromosome""" variant_dict = get_variant_dict(info="GeneticModels=1:AD|AD_dn,2:AR_hom") variant_line = get_variant_line(info="GeneticModels=1:AD|AD_dn,2:AR_hom") plugin = Plugin( name='genetic_models', field='INFO', data_type='string', info_key="GeneticModels", separators=[',', ':', '|'], dict_entry=True, string_rules={ 'AD_dn':1, 'AD':2 } ) dict_entry = plugin.get_value( variant_dict=variant_dict, dict_key='1' ) line_entry = plugin.get_value( variant_line=variant_line, dict_key='1' ) assert dict_entry == 'AD' assert line_entry == 'AD'
def test_non_existing(): """Test to get the raw chromosome""" plugin = Plugin(name='non_existing', field='INFO', info_key="non", separators=[',']) variant_line = get_variant_line() variant_dict = get_variant_dict() assert plugin.get_entry(variant_line=variant_line) == [] assert plugin.get_entry(variant_dict=variant_dict) == []
def test_ref(): """Test to get the raw chromosome""" plugin = Plugin(name='ref', field='REF') ref = 'rs001' variant_line = get_variant_line(ref=ref) variant_dict = get_variant_dict(ref=ref) assert plugin.get_raw_entry(variant_line=variant_line) == ref assert plugin.get_raw_entry(variant_dict=variant_dict) == ref
def test_alt(): """Test to get the raw chromosome""" plugin = Plugin(name='alt', field='ALT') alt = 'A' variant_line = get_variant_line(alt=alt) variant_dict = get_variant_dict(alt=alt) assert plugin.get_raw_entry(variant_line=variant_line) == alt assert plugin.get_raw_entry(variant_dict=variant_dict) == alt
def test_qual(): """Test to get the raw chromosome""" plugin = Plugin(name='QUAL', field='QUAL') qual = '1234.5' variant_line = get_variant_line(qual=qual) variant_dict = get_variant_dict(qual=qual) assert plugin.get_raw_entry(variant_line=variant_line) == qual assert plugin.get_raw_entry(variant_dict=variant_dict) == qual
def test_filter(): """Test to get the raw chromosome""" plugin = Plugin(name='Filter', field='FILTER') filt = 'PASS' variant_line = get_variant_line(filt=filt) variant_dict = get_variant_dict(filt=filt) assert plugin.get_raw_entry(variant_line=variant_line) == filt assert plugin.get_raw_entry(variant_dict=variant_dict) == filt
def test_CLNSIG(): """Test to get the raw chromosome""" plugin = Plugin(name='Clnsig', field='INFO', info_key="CLNSIG") test_value = '255,10' variant_line = get_variant_line() variant_dict = get_variant_dict() assert plugin.get_raw_entry(variant_line=variant_line) == test_value assert plugin.get_raw_entry(variant_dict=variant_dict) == test_value
def test_format(): """Test to get the raw chromosome""" plugin = Plugin(name='Format', field='FORMAT') form = 'GT:AD:GQ:PL' variant_line = get_variant_line(form=form) variant_dict = get_variant_dict(form=form) assert plugin.get_raw_entry(variant_line=variant_line) == form assert plugin.get_raw_entry(variant_dict=variant_dict) == form
def test_chrom(): """Test to get the raw chromosome""" plugin = Plugin(name='Chrom', field='CHROM') test_chrom = '10' variant_line = get_variant_line(chrom=test_chrom) variant_dict = get_variant_dict(chrom=test_chrom) assert plugin.get_raw_entry(variant_line=variant_line) == test_chrom assert plugin.get_raw_entry(variant_dict=variant_dict) == test_chrom
def test_pos(): """Test to get the raw chromosome""" plugin = Plugin(name='Pos', field='POS') test_pos = '1000' variant_line = get_variant_line(pos=test_pos) variant_dict = get_variant_dict(pos=test_pos) assert plugin.get_raw_entry(variant_line=variant_line) == test_pos assert plugin.get_raw_entry(variant_dict=variant_dict) == test_pos
def test_id(): """Test to get the raw chromosome""" plugin = Plugin(name='ID', field='ID') db_id = 'rs001' variant_line = get_variant_line(db_id=db_id) variant_dict = get_variant_dict(db_id=db_id) assert plugin.get_raw_entry(variant_line=variant_line) == db_id assert plugin.get_raw_entry(variant_dict=variant_dict) == db_id
def test_1000G(): """Test to get the raw chromosome""" plugin = Plugin(name='thousand_g', field='INFO', info_key="1000GAF", separators=[',']) test_value = '0.744609' variant_line = get_variant_line() variant_dict = get_variant_dict() assert plugin.get_entry(variant_line=variant_line) == [test_value] assert plugin.get_entry(variant_dict=variant_dict) == [test_value]
def test_1000G(): """Test to get the raw chromosome""" plugin = Plugin(name='thousand_g', field='INFO', info_key="1000GAF") variant_line = get_variant_line() variant_dict = get_variant_dict() test_value = '0.744609' assert plugin.get_raw_entry(variant_line=variant_line) == test_value assert plugin.get_raw_entry(variant_dict=variant_dict) == test_value
def test_CLNSIG(): """Test to get the raw chromosome""" plugin = Plugin(name='Clnsig', field='INFO', info_key="CLNSIG", separators=[',']) test_value = ['255','10'] variant_line = get_variant_line() variant_dict = get_variant_dict() assert plugin.get_entry(variant_line=variant_line) == test_value assert plugin.get_entry(variant_dict=variant_dict) == test_value
def test_multiple_id_no_rule(): """Test to get the raw chromosome""" plugin = Plugin(name='ID', field='ID', data_type='flag') db_id_1 = 'rs001' db_id_2 = 'rs002' db_id = "{0};{1}".format(db_id_1, db_id_2) variant_line = get_variant_line(db_id=db_id) variant_dict = get_variant_dict(db_id=db_id) assert plugin.get_value(variant_line=variant_line) == True assert plugin.get_value(variant_dict=variant_dict) == True
def test_multiple_alt(): """Test to get the raw chromosome""" plugin = Plugin(name='alt', field='ALT') alt_1 = 'A' alt_2 = 'T' alt = "{0},{1}".format(alt_1, alt_2) variant_line = get_variant_line(alt=alt) variant_dict = get_variant_dict(alt=alt) assert plugin.get_entry(variant_line=variant_line) == [alt_1, alt_2] assert plugin.get_entry(variant_dict=variant_dict) == [alt_1, alt_2]
def test_multiple_filter(): """Test to get the raw chromosome""" plugin = Plugin(name='Filter', field='FILTER') filt_1 = 'PASS' filt_2 = 'low_qual' filt = "{0};{1}".format(filt_1, filt_2) variant_line = get_variant_line(filt=filt) variant_dict = get_variant_dict(filt=filt) assert plugin.get_entry(variant_line=variant_line) == [filt_1, filt_2] assert plugin.get_entry(variant_dict=variant_dict) == [filt_1, filt_2]
def test_multiple_id(): """Test to get the raw chromosome""" plugin = Plugin(name='ID', field='ID') db_id_1 = 'rs001' db_id_2 = 'rs002' db_id = "{0};{1}".format(db_id_1, db_id_2) variant_line = get_variant_line(db_id=db_id) variant_dict = get_variant_dict(db_id=db_id) assert plugin.get_entry(variant_line=variant_line) == [db_id_1, db_id_2] assert plugin.get_entry(variant_dict=variant_dict) == [db_id_1, db_id_2]
def test_CLNSIG(): """Test to get the raw chromosome""" plugin = Plugin(name='Clnsig', field='INFO', info_key="CLNSIG", separators=[',']) test_value = ['255', '10'] variant_line = get_variant_line() variant_dict = get_variant_dict() assert plugin.get_entry(variant_line=variant_line) == test_value assert plugin.get_entry(variant_dict=variant_dict) == test_value
def test_CSQ(): """Test to get the raw chromosome""" plugin = Plugin(name='CSQ', field='INFO', info_key="CSQ", csq_key="Gene", separators=['&']) variant_line = get_variant_line() variant_dict = get_variant_dict() test_value = [ 'ENSG00000138378', 'ENSG00000138378' ] assert plugin.get_entry(variant_line=variant_line, csq_format=csq_format) == test_value assert plugin.get_entry(variant_dict=variant_dict, csq_format=csq_format) == test_value
def test_dict_two_separators_no_key(): """Test to get the raw chromosome""" variant_dict = get_variant_dict(info="RankScore=1:12,2:11") variant_line = get_variant_line(info="RankScore=1:12,2:11") plugin = Plugin(name='rank_score', field='INFO', info_key="RankScore", separators=[',', ':'], dict_entry=True) dict_entry = plugin.get_entry(variant_dict=variant_dict) line_entry = plugin.get_entry(variant_line=variant_line) assert dict_entry == ['11'] assert line_entry == ['11']
def test_flag(): """Test to get the raw chromosome""" plugin = Plugin( name='DB', field='INFO', info_key="DB", data_type='flag', ) variant_line = get_variant_line() variant_dict = get_variant_dict() assert plugin.get_value(variant_line=variant_line) == True assert plugin.get_value(variant_dict=variant_dict) == True
def test_1000G_float(): """Test to get the raw chromosome""" plugin = Plugin( name='thousand_g', field='INFO', info_key="1000GAF", separators=[','], data_type='float', ) test_value = 0.744609 variant_line = get_variant_line() variant_dict = get_variant_dict() assert plugin.get_value(variant_line=variant_line) == test_value assert plugin.get_value(variant_dict=variant_dict) == test_value
def test_dict_two_separators_no_key(): """Test to get the raw chromosome""" variant_dict = get_variant_dict(info="RankScore=1:12,2:11") variant_line = get_variant_line(info="RankScore=1:12,2:11") plugin = Plugin( name='rank_score', field='INFO', info_key="RankScore", separators=[',', ':'], dict_entry=True ) dict_entry = plugin.get_raw_entry(variant_dict=variant_dict) line_entry = plugin.get_raw_entry(variant_line=variant_line) assert dict_entry == '11' assert line_entry == '11'
def test_dict_three_separators_with_key(): """Test to get the raw chromosome""" variant_dict = get_variant_dict(info="GeneticModels=1:AD|AD_dn,2:AR_hom") variant_line = get_variant_line(info="GeneticModels=1:AD|AD_dn,2:AR_hom") plugin = Plugin(name='genetic_models', field='INFO', info_key="GeneticModels", separators=[',', ':', '|'], dict_entry=True) dict_entry = plugin.get_entry(variant_dict=variant_dict, dict_key='1') line_entry = plugin.get_entry(variant_line=variant_line, dict_key='1') assert dict_entry == ['AD', 'AD_dn'] assert line_entry == ['AD', 'AD_dn']
def test_1000G_record_rule(): """Test to get the raw chromosome""" plugin = Plugin( name='thousand_g', field='INFO', info_key="1000GAF", separators=[','], data_type='float', record_rule='min', ) info = "1000GAF=0.744609,0.02;AC=2;AF=1.00;AN=2" variant_line = get_variant_line(info=info) variant_dict = get_variant_dict(info=info) assert plugin.get_value(variant_line=variant_line) == 0.02 assert plugin.get_value(variant_dict=variant_dict) == 0.02
def test_CSQ(): """Test to get the raw chromosome""" plugin = Plugin(name='CSQ', field='INFO', info_key="CSQ", csq_key="Gene", separators=['&']) variant_line = get_variant_line() variant_dict = get_variant_dict() test_value = ['ENSG00000138378', 'ENSG00000138378'] assert plugin.get_entry(variant_line=variant_line, csq_format=csq_format) == test_value assert plugin.get_entry(variant_dict=variant_dict, csq_format=csq_format) == test_value
def test_gt_call(): """Test to get the raw chromosome""" plugin = Plugin(name='gt_call', field='sample_id', gt_key='GT') vcf_header = ['CHROM', 'POS', 'ID', 'REF', 'ALT', 'QUAL', 'FILTER', 'INFO', 'FORMAT', 'ADM1003A3'] variant_line = get_variant_line() variant_dict = get_variant_dict() assert plugin.get_raw_entry( variant_line=variant_line, vcf_header=vcf_header, individual_id='ADM1003A3') == '1/1' assert plugin.get_raw_entry( variant_dict=variant_dict, vcf_header=vcf_header, individual_id='ADM1003A3') == '1/1'
def test_dict_three_separators_no_key(): """Test to get the raw chromosome""" variant_dict = get_variant_dict(info="GeneticModels=1:AD|AD_dn,2:AR_hom") variant_line = get_variant_line(info="GeneticModels=1:AD|AD_dn,2:AR_hom") plugin = Plugin( name='genetic_models', field='INFO', info_key="GeneticModels", separators=[',', ':', '|'], dict_entry=True ) dict_entry = plugin.get_raw_entry(variant_dict=variant_dict) line_entry = plugin.get_raw_entry(variant_line=variant_line) assert dict_entry == 'AR_hom' assert line_entry == 'AR_hom'
def test_filter_min_rule(): """Test to get the raw chromosome""" plugin = Plugin( name='Filter', field='FILTER', data_type='string', string_rules={ 'PASS':2, 'NOT_PASS':1 }, record_rule='min' ) filt = "PASS;NOT_PASS" variant_line = get_variant_line(filt=filt) variant_dict = get_variant_dict(filt=filt) assert plugin.get_value(variant_line=variant_line) == 'NOT_PASS' assert plugin.get_value(variant_dict=variant_dict) == 'NOT_PASS'
def test_rank_score_with_key(): """Test to get the raw chromosome""" variant_dict = get_variant_dict(info="RankScore=1:12,2:11") variant_line = get_variant_line(info="RankScore=1:12,2:11") plugin = Plugin( name='rank_score', data_type='integer', field='INFO', info_key="RankScore", separators=[',', ':'], dict_entry=True ) dict_entry = plugin.get_value( variant_dict=variant_dict, dict_key='1' ) line_entry = plugin.get_value( variant_line=variant_line, dict_key='1' ) assert dict_entry == 12 assert line_entry == 12
def test_gt_call_no_individual(): """Test to get the raw chromosome""" plugin = Plugin(name='gt_call', field='sample_id', gt_key='GT') vcf_header = ['CHROM', 'POS', 'ID', 'REF', 'ALT', 'QUAL', 'FILTER', 'INFO', 'FORMAT', 'ADM1003A3'] variant_line = get_variant_line() variant_dict = get_variant_dict() with pytest.raises(IOError): plugin.get_raw_entry(variant_line=variant_line, vcf_header=vcf_header) with pytest.raises(IOError): plugin.get_raw_entry(variant_dict=variant_dict, vcf_header=vcf_header)
def test_gt_call_no_header_dict(): """Test to get the raw chromosome""" plugin = Plugin(name='gt_call', field='sample_id', gt_key='GT') variant_dict = get_variant_dict() assert plugin.get_raw_entry(variant_dict=variant_dict, individual_id='ADM1003A3') == '1/1'