Skip to content

Commit

Permalink
Relocate Gemma-specific configuration under [rnaseq_pipeline.gemma]
Browse files Browse the repository at this point in the history
  • Loading branch information
arteymix committed May 17, 2024
1 parent ac1da2a commit ab6b567
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
7 changes: 5 additions & 2 deletions example.luigi.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,14 @@ JAVA_HOME=
JAVA_OPTS=
GEMMACLI=gemma-cli

GEMMA_BASEURL=https://gemma.msl.ubc.ca

SLACK_WEBHOOK_URL=

[rnaseq_pipeline.gemma]
cli_bin=gemma-cli
# values for $JAVA_HOME and $JAVA_OPTS environment variables
cli_JAVA_HOME=
cli_JAVA_OPTS=
baseurl=https://gemma.msl.ubc.ca
appdata_dir=/space/gemmaData
human_reference_id=hg38_ncbi
mouse_reference_id=mm10_ncbi
Expand Down
9 changes: 0 additions & 9 deletions rnaseq_pipeline/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,4 @@ class rnaseq_pipeline(luigi.Config):

RSEM_DIR = luigi.Parameter()

GEMMACLI = luigi.Parameter()
JAVA_HOME = luigi.Parameter()
JAVA_OPTS = luigi.Parameter()

GEMMA_BASEURL = luigi.Parameter()

SLACK_WEBHOOK_URL = luigi.OptionalParameter(default=None)

def asenv(self, attrs):
return {attr: getattr(self, attr) for attr in attrs}
17 changes: 10 additions & 7 deletions rnaseq_pipeline/gemma.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@

class gemma(luigi.Config):
task_namespace = 'rnaseq_pipeline'
baseurl = luigi.Parameter()
appdata_dir = luigi.Parameter()
cli_bin = luigi.Parameter()
cli_JAVA_HOME = luigi.Parameter()
cli_JAVA_OPTS = luigi.Parameter()
human_reference_id = luigi.Parameter()
mouse_reference_id = luigi.Parameter()
rat_reference_id = luigi.Parameter()

cfg = rnaseq_pipeline()

gemma_cfg = gemma()
cfg = gemma()

class GemmaApi:
def __init__(self):
Expand All @@ -36,7 +38,7 @@ def _get_password(self):
return getpass()

def _query_api(self, endpoint):
res = self._session.get(join(cfg.GEMMA_BASEURL, 'rest/v2', endpoint))
res = self._session.get(join(cfg.baseurl, 'rest/v2', endpoint))
res.raise_for_status()
return res.json()['data']

Expand Down Expand Up @@ -91,7 +93,7 @@ def taxon(self):
@property
def reference_id(self):
try:
return {'human': gemma_cfg.human_reference_id, 'mouse': gemma_cfg.mouse_reference_id, 'rat': gemma_cfg.rat_reference_id}[self.taxon]
return {'human': cfg.human_reference_id, 'mouse': cfg.mouse_reference_id, 'rat': cfg.rat_reference_id}[self.taxon]
except KeyError:
raise ValueError('Unsupported Gemma taxon {}.'.format(self.taxon))

Expand All @@ -107,11 +109,12 @@ class GemmaCliTask(GemmaTaskMixin, ExternalProgramTask):

def program_environment(self):
env = super().program_environment()
env.update(cfg.asenv(['JAVA_HOME', 'JAVA_OPTS']))
env['JAVA_HOME'] = cfg.cli_JAVA_HOME
env['JAVA_OPTS'] = cfg.cli_JAVA_OPTS
return env

def program_args(self):
args = [cfg.GEMMACLI,
args = [cfg.cli_bin,
self.subcommand,
'-e', self.experiment_id]
args.extend(self.subcommand_args())
Expand Down

0 comments on commit ab6b567

Please sign in to comment.