Skip to content

Commit 98854a7

Browse files
committed
Retrieve the SRA public dir from a configuration
1 parent 3548984 commit 98854a7

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

example.luigi.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ RSEM_DIR=contrib/RSEM
5454

5555
SLACK_WEBHOOK_URL=
5656

57+
[rnaseq_pipeline.sources.sra]
58+
# location where tools like prefetch and fastq-dump will store downloaded SRA files
59+
# you can get this value with vdb-config -p
60+
ncbi_public_dir=/cosmos/scratch/ncbi/public
61+
5762
[rnaseq_pipeline.gemma]
5863
cli_bin=gemma-cli
5964
# values for $JAVA_HOME and $JAVA_OPTS environment variables

rnaseq_pipeline/sources/sra.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828

2929
logger = logging.getLogger(__name__)
3030

31+
class sra(luigi.Config):
32+
task_namespace = 'rnaseq_pipeline.sources'
33+
ncbi_public_dir: str = luigi.Parameter()
34+
35+
sra_config = sra()
36+
3137
# columns to use when a runinfo file lacks a header
3238
SRA_RUNINFO_COLUMNS = ['Run', 'ReleaseDate', 'LoadDate', 'spots', 'bases', 'spots_with_mates', 'avgLength', 'size_MB',
3339
'AssemblyName', 'download_path', 'Experiment', 'LibraryName', 'LibraryStrategy',
@@ -164,12 +170,6 @@ class PrefetchSraRun(TaskWithMetadataMixin, luigi.Task):
164170

165171
retry_count = 3
166172

167-
@staticmethod
168-
def _get_ncbi_public_dir():
169-
ret = subprocess.run(['vdb-config', '-p'], stdout=subprocess.PIPE, universal_newlines=True)
170-
config_xml = ET.fromstring(ret.stdout)
171-
return config_xml.find('repository').find('user').find('main').find('public').find('root').text
172-
173173
def run(self):
174174
yield sratoolkit.Prefetch(srr_accession=self.srr,
175175
output_file=self.output().path,
@@ -179,7 +179,7 @@ def run(self):
179179
walltime=timedelta(hours=2))
180180

181181
def output(self):
182-
return luigi.LocalTarget(join(self._get_ncbi_public_dir(), 'sra', f'{self.srr}.sra'))
182+
return luigi.LocalTarget(join(sra_config.ncbi_public_dir, 'sra', f'{self.srr}.sra'))
183183

184184
@requires(PrefetchSraRun)
185185
class DumpSraRun(luigi.Task):

0 commit comments

Comments
 (0)