scout/commands/view/individuals.py
def individuals(context, institute, causatives, case_id):
    """Show all individuals from all cases in the database"""
    LOG.info("Running scout view individuals")
    adapter = context.obj['adapter']
    individuals = []

    if case_id:
        case = adapter.case(case_id=case_id)
        if case:
            cases = [case]
        else:
            LOG.info("Could not find case %s", case_id)
            return
    else:
        cases = [case_obj for case_obj in
                 adapter.cases(
                     collaborator=institute,
                     has_causatives=causatives)]
        if len(cases) == 0:
            LOG.info("Could not find cases that match criteria")
            return
        individuals = (ind_obj for case_obj in cases for ind_obj in case_obj['individuals'])

    click.echo("#case_id\tind_id\tdisplay_name\tsex\tphenotype\tmother\tfather")

    for case in cases:
        for ind_obj in case['individuals']:
            ind_info = [
                case['_id'], ind_obj['individual_id'],
                ind_obj['display_name'], SEX_MAP[int(ind_obj['sex'])],
                PHENOTYPE_MAP[ind_obj['phenotype']], ind_obj['mother'],
                ind_obj['father']
            ]
            click.echo('\t'.join(ind_info))
def individuals(context, institute, causatives, case_id):
    LOG.info("Running scout view individuals")
    adapter = context.obj['adapter']
    individuals = []

    if case_id:
        case = adapter.case(case_id=case_id)
        if case:
            cases = [case]
        else:
            LOG.info("Could not find case %s", case_id)
            return
    else:
        cases = [case_obj for case_obj in
                 adapter.cases(
                     collaborator=institute,
                     has_causatives=causatives)]
        if len(cases) == 0:
            LOG.info("Could not find cases that match criteria")
            return
        individuals = (ind_obj for case_obj in cases for ind_obj in case_obj['individuals'])

    click.echo("#case_id\tind_id\tdisplay_name\tsex\tphenotype\tmother\tfather")

    for case in cases:
        for ind_obj in case['individuals']:
            ind_info = [
                case['_id'], ind_obj['individual_id'],
                ind_obj['display_name'], SEX_MAP[int(ind_obj['sex'])],
                PHENOTYPE_MAP[ind_obj['phenotype']], ind_obj['mother'],
                ind_obj['father']
            ]
            click.echo('\t'.join(ind_info))
def individuals ( context , institute , causatives , case_id ) : LOG . info ( "Running scout view individuals" ) adapter = context . obj [ 'adapter' ] individuals = [ ] if case_id : case = adapter . case ( case_id = case_id ) if case : cases = [ case ] else : LOG . info ( "Could not find case %s" , case_id ) return else : cases = [ case_obj for case_obj in adapter . cases ( collaborator = institute , has_causatives = causatives ) ] if len ( cases ) == 0 : LOG . info ( "Could not find cases that match criteria" ) return individuals = ( ind_obj for case_obj in cases for ind_obj in case_obj [ 'individuals' ] ) click . echo ( "#case_id\tind_id\tdisplay_name\tsex\tphenotype\tmother\tfather" ) for case in cases : for ind_obj in case [ 'individuals' ] : ind_info = [ case [ '_id' ] , ind_obj [ 'individual_id' ] , ind_obj [ 'display_name' ] , SEX_MAP [ int ( ind_obj [ 'sex' ] ) ] , PHENOTYPE_MAP [ ind_obj [ 'phenotype' ] ] , ind_obj [ 'mother' ] , ind_obj [ 'father' ] ] click . echo ( '\t' . join ( ind_info ) )
Show all individuals from all cases in the database
Show all individuals from all cases in the database