Example #1
0
def init(context, setup, reset, automate):
    """Walk user through setting up a new config file."""
    # print a nice welcome message
    click.echo(chanjo.__banner__)

    cov_tresholds = (context.obj.get('sambamba', {})
                                .get('cov_treshold', [10, 20]))
    defaults = {'sambamba.cov_treshold': {'value': cov_tresholds,
                                          'prompt': 'sufficient coverage'},
                'database': {'value': context.obj['database'],
                             'prompt': 'central database path/URI'}}

    if not automate:
        questions = [(key, value['prompt'], value['value'])
                     for key, value in iteritems(defaults)]
        # launch init pipeline
        init_pipeline('chanjo', context.obj, questions)
    else:
        logger.info('setting default config values')
        for key, value in iteritems(defaults):
            context.obj.set(key, value['value'], scope=context.obj.user_data)

    # write to the config file
    context.obj.save(default_flow_style=False)

    if setup:
        chanjo_db = Store(uri=context.obj.user_data['database'])
        if reset:
            chanjo_db.tear_down()
        chanjo_db.set_up()
Example #2
0
class TestSambamba:
    def setup(self):
        self.store = Store('sqlite://')
        self.store.set_up()
        self.row_data = parse_sambamba.depth_output(bed_lines)

    def teardown(self):
        self.store.tear_down()
        self.store.session.close()

    def test_connection(self):
        self.store.dialect == 'sqlite'

    def test_rows(self):
        stats = load_sambamba.rows(self.store.session, self.row_data)
        all_stats = [stat for stat in stats]
        assert len(all_stats) == 4
Example #3
0
def init(context, setup, reset, automate):
    """Walk user through setting up a new config file."""
    # print a nice welcome message
    click.echo(chanjo.__banner__)

    if not automate:
        questions = [('sambamba.cov_treshold', 'sufficient coverage',
                      context.obj.get('sambamba', {}).get('cov_treshold',
                                                          [10, 20])),
                     ('database', 'central database path/URI',
                      context.obj['database'])]
        # launch init pipeline
        init_pipeline('chanjo', context.obj, questions)

    if setup:
        chanjo_db = Store(uri=context.obj.user_data['database'])
        if reset:
            chanjo_db.tear_down()
        chanjo_db.set_up()
Example #4
0
def init(context, setup, reset, automate, transcripts):
    """Walk user through setting up a new config file."""
    # print a nice welcome message
    click.echo(chanjo.__banner__)

    cov_tresholds = (context.obj.get('sambamba',
                                     {}).get('cov_treshold', [10, 20]))
    defaults = {
        'sambamba.cov_treshold': {
            'value': cov_tresholds,
            'prompt': 'sufficient coverage'
        },
        'database': {
            'value': str(context.obj['database']),
            'prompt': 'central database path/URI'
        }
    }

    if not automate:
        questions = [(key, value['prompt'], value['value'])
                     for key, value in iteritems(defaults)]
        # launch init pipeline
        init_pipeline('chanjo', context.obj, questions)
    else:
        logger.info('setting default config values')
        for key, value in iteritems(defaults):
            context.obj.set(key, value['value'], scope=context.obj.user_data)

    # write to the config file
    context.obj.save(default_flow_style=False)

    if setup:
        only_tx = transcripts or context.obj.get('transcripts') or False
        base = TXBASE if only_tx else BASE
        chanjo_db = Store(uri=context.obj['database'], base=base)
        if reset:
            chanjo_db.tear_down()
        chanjo_db.set_up()