Пример #1
0
def lims(context, limit, sample, start_date):
    """Load all samples from LIMS into the database."""
    if start_date:
        start_date = datetime.strptime(start_date, "%Y-%m-%d").date()
    start_date = start_date or context.obj.get('LIMS_START_DATE')

    lims_api = LimsAPI()
    lims_api.connect(**context.obj['LIMS_SETTINGS'])
    process_lims(context.obj['db'], lims_api, limit=limit, lims_ids=sample,
                 start_date=start_date)
Пример #2
0
def parse_payload(db, payload, config, force=False):
    """Analyze a family of samples.

    1. generates and writes a new pedigree file from LIMS data
    2. generates a start script for the analysis pipeline

    Args:
        db (Brain): Moneypenny database API
        payload (dict): specific data for the analysis mutation type
        config (dict): general config for Moneypenny
        force (Optional[bool]): not implemented, default: False
    """
    analysis_root = config['MIP_ANALYSIS_ROOT']
    mip_config = config['MIP_CONFIG_PATH']
    cust_id = payload['customer_id']
    family_id = payload['family_id']
    analysis_type = payload['analysis_type']
    gene_list = payload['gene_list']
    ccp = os.path.join(analysis_root, cust_id, family_id)

    # generate pedigree from LIMS
    if not payload.get('skip_pedigree'):
        lims_api = LimsAPI()
        lims_api.connect(**config['LIMS_SETTINGS'])
        ped_content = pedigree(lims_api, cust_id, family_id)
        file_name = "{}_pedigree.txt".format(family_id)
        ped_path = os.path.join(ccp, analysis_type, family_id, file_name)
        with open(ped_path, 'w') as handle:
            handle.write(ped_content)

    script = start(
        analysis_type,
        family_id,
        mip_config,
        ccp,
        executable=config['MIP_EXE_PATH'],
        customer=cust_id,
        gene_list=gene_list,
        conda_env=config.get('MIP_CONDA_ENV'),
        email=payload.get('email'),
    )

    script_name = "{}-{}.bash".format(cust_id, family_id)
    outfile = os.path.join(config['START_SCRIPTS_DIR'], script_name)
    with open(outfile, 'w') as handle:
        # overwrite if necessary
        handle.write(script)