Skip to content

Commit

Permalink
Fix rename of GemmaTask to GemmaTaskMixin and GemmaCliTask
Browse files Browse the repository at this point in the history
  • Loading branch information
arteymix committed May 17, 2024
1 parent ab6b567 commit cdbe165
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
23 changes: 18 additions & 5 deletions rnaseq_pipeline/webviewer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@

from rnaseq_pipeline.config import rnaseq_pipeline
from rnaseq_pipeline.tasks import GenerateReportForExperiment, CountExperiment, ExtractGeoSeriesBatchInfo, SubmitExperimentDataToGemma, SubmitExperimentBatchInfoToGemma
from rnaseq_pipeline.gemma import GemmaTask
from rnaseq_pipeline.gemma import GemmaTaskMixin

app = Flask('rnaseq_pipeline.webviewer')

cfg = rnaseq_pipeline()

references = ['hg38_ncbi', 'mm10_ncbi', 'm6_ncbi']

class FakeGemmaTask(GemmaTaskMixin, luigi.Task):
pass

@app.errorhandler(400)
def bad_request(e):
return render_template('400.html', e=e), 400
Expand Down Expand Up @@ -63,13 +66,18 @@ def experiment_batch_info(experiment_id):
@app.route('/experiment/<experiment_id>/by-reference-id/<reference_id>/quantifications/<mode>')
def experiment_quantifications(experiment_id, mode, reference_id=None):
if reference_id is None:
gemma_task = GemmaTask(experiment_id)
gemma_task = FakeGemmaTask(experiment_id)
reference_id = gemma_task.reference_id
taxon = gemma_task.taxon
source = 'gemma'
else:
taxon = 'human'
source = 'local'
try:
mode_ix = ['counts', 'fpkm'].index(mode)
except ValueError:
abort(400, f'Unknown mode {mode} for quantifications, try either counts or fpkm.')
count_experiment_task = CountExperiment(experiment_id, reference_id=reference_id, taxon=None)
count_experiment_task = CountExperiment(experiment_id, reference_id=reference_id, taxon=taxon, source=source)
if not count_experiment_task.complete():
abort(404, f'No quantifications available for {experiment_id} in {reference_id}.')
file_path = count_experiment_task.output()[mode_ix].path
Expand All @@ -79,9 +87,14 @@ def experiment_quantifications(experiment_id, mode, reference_id=None):
@app.route('/experiment/<experiment_id>/by-reference-id/<reference_id>/report')
def experiment_report(experiment_id, reference_id=None):
if reference_id is None:
gemma_task = GemmaTask(experiment_id)
gemma_task = FakeGemmaTask(experiment_id)
reference_id = gemma_task.reference_id
generate_report_task = GenerateReportForExperiment(experiment_id, reference_id=reference_id, taxon=None)
taxon = gemma_task.taxon
source = 'gemma'
else:
taxon = 'human'
source = 'local'
generate_report_task = GenerateReportForExperiment(experiment_id, reference_id=reference_id, taxon=taxon, source=source)
if not generate_report_task.complete():
abort(404, f'No report available for {experiment_id} in {reference_id}.')
return send_file(generate_report_task.output().path)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_gemma.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def test_gemma_api():
gemma_api.samples('GSE110256')

def test_gemma_task():
task = GemmaTask(experiment_id='GSE110256')
task = GemmaCliTask(experiment_id='GSE110256')
env = task.program_environment()
assert 'JAVA_OPTS' in env
assert 'JAVA_HOME' in env
Expand Down
6 changes: 5 additions & 1 deletion tests/test_tasks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import datetime
import pytest

import luigi

from rnaseq_pipeline.config import rnaseq_pipeline
from rnaseq_pipeline.tasks import *

Expand Down Expand Up @@ -42,7 +44,9 @@ def test_align_sample_task():
assert task.output().path == join(cfg.OUTPUT_DIR, cfg.ALIGNDIR, 'hg38_ncbi', 'GSE', 'GSM.genes.results')
assert task.walltime == datetime.timedelta(days=1)

def test_gemma_task():
def test_gemma_task_mixin():
class GemmaTask(GemmaTaskMixin, luigi.Task):
pass
gemma_task = GemmaTask('GSE110256')
assert gemma_task.taxon == 'mouse'
assert gemma_task.accession == 'GSE110256'
Expand Down

0 comments on commit cdbe165

Please sign in to comment.