def popexist_db(existing_db, exon_lines): result = link_elements(exon_lines) existing_db.add(*result.models) result = load_transcripts(exon_lines, sample_id="sample", group_id="group") existing_db.add(result.sample) existing_db.add(*result.models) existing_db.save() yield existing_db
def popexist_db(existing_db, exon_lines): result = link_elements(exon_lines) existing_db.add(*result.models) result = load_transcripts(exon_lines, sample_id='sample', group_id='group') existing_db.add(result.sample) existing_db.add(*result.models) existing_db.save() yield existing_db
def populated_db(chanjo_db, exon_lines): exon_lines = list(exon_lines) result = link_elements(exon_lines) chanjo_db.add(*result.models) results = [ load_transcripts(exon_lines, sample_id="sample", group_id="group"), load_transcripts(exon_lines, sample_id="sample2", group_id="group"), ] for result in results: chanjo_db.add(result.sample) chanjo_db.add(*result.models) chanjo_db.save() yield chanjo_db
def populated_db(chanjo_db, exon_lines): exon_lines = list(exon_lines) result = link_elements(exon_lines) chanjo_db.add(*result.models) results = [ load_transcripts(exon_lines, sample_id='sample', group_id='group'), load_transcripts(exon_lines, sample_id='sample2', group_id='group') ] for result in results: chanjo_db.add(result.sample) chanjo_db.add(*result.models) chanjo_db.save() yield chanjo_db
def link(context, bed_stream): """Link related genomic elements.""" chanjo_db = ChanjoDB(uri=context.obj['database']) result = link_elements(bed_stream) with click.progressbar(result.models, length=result.count, label='adding transcripts') as bar: for tx_model in bar: chanjo_db.add(tx_model) try: chanjo_db.save() except IntegrityError: LOG.exception('elements already linked?') chanjo_db.session.rollback() click.echo("use 'chanjo db setup --reset' to re-build") context.abort()
def test_process(bed_lines): result = link.link_elements(bed_lines) models = list(result.models) assert result.count == 5 # 5 transcripts