Skip to content

Commit

Permalink
factor out new tx loading func
Browse files Browse the repository at this point in the history
  • Loading branch information
robinandeer committed Mar 4, 2016
1 parent ac80bec commit 9c26109
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions chanjo/cli/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,8 @@ def load(context, sample, group, transcripts, bed_stream):
try:
if only_tx:
source = os.path.abspath(bed_stream.name)
kwargs = dict(sample_id=sample, sequence=bed_stream,
group_id=group, source=source)
result = load_mod.load_transcripts(**kwargs)
with click.progressbar(result.models, length=result.count,
label='loading transcripts') as bar:
for tx_model in bar:
chanjo_db.session.add(tx_model)
chanjo_db.save()
load_transcripts(chanjo_db, bed_stream, sample=sample, group=group,
source=source)
else:
load_sambamba(chanjo_db, bed_stream, sample_id=sample,
group_id=group)
Expand All @@ -50,6 +44,18 @@ def load(context, sample, group, transcripts, bed_stream):
context.abort()


def load_transcripts(chanjo_db, bed_stream, sample=None, group=None,
source=None):
kwargs = dict(sample_id=sample, sequence=bed_stream,
group_id=group, source=source)
result = load_mod.load_transcripts(**kwargs)
with click.progressbar(result.models, length=result.count,
label='loading transcripts') as bar:
for tx_model in bar:
chanjo_db.session.add(tx_model)
chanjo_db.save()


def load_sambamba(chanjo_db, bed_iterable, sample_id=None, group_id=None):
"""Load Sambamba BED output from a stream."""
rows = sambamba.depth_output(bed_iterable)
Expand Down

0 comments on commit 9c26109

Please sign in to comment.