Skip to content

Commit bf0f832

Browse files
committed
qc/pipeline: fix bug locating reference data if organism name contains spaces.
Updates the QC pipeline driver to use the normalised organism name (converted to lower case and whitespace converted to underscores), otherwise reference data cannot be located for names which include whitespace.
1 parent 55f696e commit bf0f832

2 files changed

Lines changed: 91 additions & 4 deletions

File tree

auto_process_ngs/qc/pipeline.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ def add_project(self,project,protocol,qc_dir=None,organism=None,
452452
get_star_index = GetReferenceDataset(
453453
"%s: get STAR index for '%s'" % (project.name,
454454
organism),
455-
organism,
455+
organism_name,
456456
self.params.star_indexes,
457457
force_reference=self.params.force_star_index)
458458
self.add_task(get_star_index)
@@ -480,7 +480,7 @@ def add_project(self,project,protocol,qc_dir=None,organism=None,
480480
"%s: get RSeQC reference gene model for '%s'" %
481481
(project.name,
482482
organism),
483-
organism,
483+
organism_name,
484484
self.params.annotation_bed_files)
485485
self.add_task(get_reference_gene_model)
486486
qc_metadata['annotation_bed'] = \
@@ -490,7 +490,7 @@ def add_project(self,project,protocol,qc_dir=None,organism=None,
490490
get_annotation_gtf = GetReferenceDataset(
491491
"%s: get GTF annotation for '%s'" % (project.name,
492492
organism),
493-
organism,
493+
organism_name,
494494
self.params.annotation_gtf_files,
495495
force_reference=self.params.force_gtf_annotation)
496496
self.add_task(get_annotation_gtf)

auto_process_ngs/test/qc/protocols/test_standard_qc.py

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,4 +317,91 @@ def test_qcpipeline_standard_se(self):
317317
"multiqc_report.html"):
318318
self.assertTrue(os.path.exists(os.path.join(self.wd,
319319
"PJB",f)),
320-
"Missing %s" % f)
320+
"Missing %s" % f)
321+
322+
def test_qcpipeline_standard_paired_end_organism_with_whitespace(self):
323+
"""QCPipeline: standard QC run (paired-end data, organism name contains whitespace)
324+
"""
325+
# Make mock QC executables
326+
MockFastqScreen.create(os.path.join(self.bin,"fastq_screen"))
327+
MockFastQC.create(os.path.join(self.bin,"fastqc"))
328+
MockStar.create(os.path.join(self.bin,"STAR"))
329+
MockSamtools.create(os.path.join(self.bin,"samtools"))
330+
MockPicard.create(os.path.join(self.bin,"picard"))
331+
MockGtf2bed.create(os.path.join(self.bin,"gtf2bed"))
332+
MockRSeQC.create(os.path.join(self.bin,"infer_experiment.py"))
333+
MockRSeQC.create(os.path.join(self.bin,"geneBody_coverage.py"))
334+
MockQualimap.create(os.path.join(self.bin,"qualimap"))
335+
MockMultiQC.create(os.path.join(self.bin,"multiqc"))
336+
os.environ['PATH'] = "%s:%s" % (self.bin,
337+
os.environ['PATH'])
338+
# Make mock analysis project
339+
p = MockAnalysisProject("PJB",("PJB1_S1_R1_001.fastq.gz",
340+
"PJB1_S1_R2_001.fastq.gz",
341+
"PJB2_S2_R1_001.fastq.gz",
342+
"PJB2_S2_R2_001.fastq.gz"),
343+
metadata={ 'Organism': 'Chinese hamster' })
344+
p.create(top_dir=self.wd)
345+
# Set up and run the QC
346+
runqc = QCPipeline()
347+
runqc.add_project(AnalysisProject(os.path.join(self.wd,"PJB")),
348+
fetch_protocol_definition("standard"),
349+
multiqc=True)
350+
status = runqc.run(fastq_screens=self.fastq_screens,
351+
star_indexes=
352+
{ 'chinese_hamster': '/data/chok1/star_index' },
353+
annotation_bed_files=
354+
{ 'chinese_hamster': self.ref_data['chok1']['bed'] },
355+
annotation_gtf_files=
356+
{ 'chinese_hamster': self.ref_data['chok1']['gtf'] },
357+
poll_interval=POLL_INTERVAL,
358+
max_jobs=1,
359+
runners={ 'default': SimpleJobRunner(), })
360+
self.assertEqual(status,0)
361+
# Check QC metadata
362+
qc_info = AnalysisProjectQCDirInfo(
363+
os.path.join(self.wd,"PJB","qc","qc.info"))
364+
self.assertEqual(qc_info.protocol,"standard")
365+
self.assertEqual(qc_info.protocol_specification,
366+
"standard:'Standard QC for single and paired-end data':"
367+
"seq_reads=[r1,r2]:index_reads=[]:qc_modules=[fastq_screen,fastqc,picard_insert_size_metrics,"
368+
"qualimap_rnaseq,rseqc_genebody_coverage,rseqc_infer_experiment,sequence_lengths]")
369+
self.assertEqual(qc_info.organism,"Chinese hamster")
370+
self.assertEqual(qc_info.seq_data_samples,"PJB1,PJB2")
371+
self.assertEqual(qc_info.fastq_dir,
372+
os.path.join(self.wd,"PJB","fastqs"))
373+
self.assertEqual(qc_info.fastqs,
374+
"PJB1_S1_R1_001.fastq.gz,"
375+
"PJB1_S1_R2_001.fastq.gz,"
376+
"PJB2_S2_R1_001.fastq.gz,"
377+
"PJB2_S2_R2_001.fastq.gz")
378+
self.assertEqual(qc_info.fastqs_split_by_lane,False)
379+
self.assertEqual(qc_info.fastq_screens,
380+
"model_organisms,other_organisms,rRNA")
381+
self.assertEqual(qc_info.star_index,"/data/chok1/star_index")
382+
self.assertEqual(qc_info.annotation_bed,self.ref_data['chok1']['bed'])
383+
self.assertEqual(qc_info.annotation_gtf,self.ref_data['chok1']['gtf'])
384+
self.assertEqual(qc_info.cellranger_version,None)
385+
self.assertEqual(qc_info.cellranger_refdata,None)
386+
self.assertEqual(qc_info.cellranger_probeset,None)
387+
# Check output and reports
388+
for f in ("qc",
389+
"qc_report.html",
390+
"qc_report.PJB.zip",
391+
"multiqc_report.html"):
392+
self.assertTrue(os.path.exists(os.path.join(self.wd,
393+
"PJB",f)),
394+
"Missing %s" % f)
395+
# Check collated Picard insert sizes
396+
collated_insert_sizes = os.path.join(self.wd,
397+
"PJB",
398+
"qc",
399+
"insert_sizes.chinese_hamster.tsv")
400+
self.assertTrue(os.path.exists(collated_insert_sizes),
401+
"Missing collated insert sizes TSV")
402+
with open(collated_insert_sizes,'rt') as fp:
403+
self.assertEqual(fp.read(),
404+
"""#Bam file Mean insert size Standard deviation Median insert size Median absolute deviation
405+
PJB1_S1_001.bam 153.754829 69.675347 139 37
406+
PJB2_S2_001.bam 153.754829 69.675347 139 37
407+
""")

0 commit comments

Comments
 (0)