コード例 #1
0
ファイル: projects.py プロジェクト: hammerlab/cycledash
def set_and_verify_project_id_on(data):
    project_name = data.get('project_name')
    if project_name:
        project_id = get_id_where('projects', db, name=project_name)
        data['project_id'] = project_id
        del data['project_name']
        if project_id is None:
            raise voluptuous.Invalid('no project with name {}'.format(project_name))
    else:
        project_id = data['project_id']
        if get_id_where('projects', db, id=project_id) is None:
            raise voluptuous.Invalid('no project with id {}'.format(project_id))
コード例 #2
0
ファイル: runs.py プロジェクト: hammerlab/cycledash
def _set_or_verify_bam_id_on(run, bam_type):
    """After calling this, run['(bam_type)_bam_id'] will be set to a valid BAM ID.

    If there is not a matching BAM, it will raise voluptuous.Invalid.
    """
    id_key = bam_type + '_bam_id'
    uri_key = bam_type + '_bam_uri'
    bam_id = run.get(id_key)
    if bam_id:
        if get_where('bams', db, id=bam_id) is None:
            raise voluptuous.Invalid(
                'bam with id "{}" does not exist'.format(bam_id))
    elif run.get(uri_key):
        bam_id = get_id_where('bams', db, uri=run[uri_key])
        if bam_id is None:
            raise voluptuous.Invalid(
                'bam with uri "{}" does not exist'.format(run[uri_key]))
        run[id_key] = bam_id
        del run[uri_key]