示例#1
0
def test_parse_filename():
    excel_file = 'ID8_FM3_SUMMARY_150422_AF_ML.xlsx'
    data = parse_filname(excel_file)
    assert data['id'] == 'ID8'
    assert data['date'].year == 15
    assert data['date'].month == 4
    assert data['date'].day == 22
示例#2
0
文件: samples.py 项目: CGHQ/genotype
def post_samples(input_type, input_path, rs_stream, prepend=None,
                 include_key=None, force=False):
    """Add samples from VCF or Excel sheet."""
    if input_type == 'vcf':
        logger.info("loading genotypes from VCF: {}".format(input_path))
        gt_samples = load_vcf(db, input_path, rs_stream,
                              experiment='sequencing', force=force)
        source_id = input_path
    elif input_type == 'excel':
        logger.info("loading genotypes from Excel: {}".format(input_path))
        file_name = path(input_path).normpath().basename()
        source_data = parse_filname(file_name)
        source_id = source_data['id']
        sample_prepend = prepend or "{}-{}".format(source_id, include_key or '')
        gt_samples = maf_results(db, input_path, prepend=sample_prepend,
                                 include_key=include_key)
    else:
        raise ValueError("'input_type' must be either 'vcf' or 'excel'")

    return dict(samples=gt_samples, source_id=source_id)