Skip to content

Commit

Permalink
bcftbx/IlluminaData: add 'complete' property to IlluminaRun (check if…
Browse files Browse the repository at this point in the history
… run is complete).
  • Loading branch information
pjbriggs committed Feb 16, 2024
1 parent cbe61e0 commit b9b968a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
22 changes: 21 additions & 1 deletion bcftbx/IlluminaData.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IlluminaData.py: module for handling data about Illumina sequencer runs
# Copyright (C) University of Manchester 2012-2022 Peter Briggs
# Copyright (C) University of Manchester 2012-2024 Peter Briggs
#
########################################################################
#
Expand Down Expand Up @@ -224,6 +224,26 @@ def cycles(self):
return None
return ncycles

@property
def complete(self):
"""
Check if run is complete
Returns:
Boolean: True if run is complete (i.e. all appropriate
sentinel files are present), False if not (i.e.
some sentiel files are missing).
"""
# Acquire run completion files
try:
files = platforms.RUN_COMPLETION_FILES[self.platform]
except KeyError:
# Fallback to default
files = platforms.RUN_COMPLETION_FILES['default']
# Check if all are present
return all([os.path.exists(os.path.join(self.run_dir,f))
for f in files])

class IlluminaRunInfo:
"""Class for examining Illumina RunInfo.xml file
Expand Down
26 changes: 25 additions & 1 deletion bcftbx/test/test_IlluminaData.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def test_illuminarun_miseq(self):
self.assertEqual(run.bcl_extension,".bcl")
self.assertEqual(run.lanes,[1,])
self.assertEqual(run.cycles,218)
self.assertEqual(run.complete,True)

def test_illuminarun_hiseq(self):
"""
Expand Down Expand Up @@ -114,6 +115,7 @@ def test_illuminarun_hiseq(self):
self.assertEqual(run.bcl_extension,".bcl.gz")
self.assertEqual(run.lanes,[1,2,3,4,5,6,7,8])
self.assertEqual(run.cycles,218)
self.assertEqual(run.complete,True)

def test_illuminarun_nextseq(self):
"""
Expand Down Expand Up @@ -153,12 +155,13 @@ def test_illuminarun_nextseq(self):
self.assertEqual(run.bcl_extension,".bcl.bgzf")
self.assertEqual(run.lanes,[1,2,3,4])
self.assertEqual(run.cycles,158)
self.assertEqual(run.complete,True)

def test_illuminarun_novaseq(self):
"""
IlluminaRun: test for NovaSeq run
"""
# Make a mock run directory for NextSeq format
# Make a mock run directory for NovaSeq format
self.mock_illumina_run = MockIlluminaRun(
'221125_A500968_0038_ABCDE1XX',
'novaseq',
Expand Down Expand Up @@ -194,6 +197,7 @@ def test_illuminarun_novaseq(self):
self.assertEqual(run.bcl_extension,".bcl.bgzf")
self.assertEqual(run.lanes,[1,2])
self.assertEqual(run.cycles,158)
self.assertEqual(run.complete,True)

def test_illuminarun_unknown_illumina_platform(self):
"""
Expand Down Expand Up @@ -236,6 +240,7 @@ def test_illuminarun_unknown_illumina_platform(self):
self.assertEqual(run.bcl_extension,".bcl")
self.assertEqual(run.lanes,[1,])
self.assertEqual(run.cycles,218)
self.assertEqual(run.complete,True)

def test_illuminarun_unknown_illumina_platform_generic_name(self):
"""
Expand Down Expand Up @@ -281,6 +286,7 @@ def test_illuminarun_unknown_illumina_platform_generic_name(self):
self.assertEqual(run.bcl_extension,".bcl")
self.assertEqual(run.lanes,[1,])
self.assertEqual(run.cycles,218)
self.assertEqual(run.complete,True)

def test_illuminarun_miseq_specify_platform(self):
"""
Expand Down Expand Up @@ -323,6 +329,24 @@ def test_illuminarun_miseq_specify_platform(self):
self.assertEqual(run.bcl_extension,".bcl")
self.assertEqual(run.lanes,[1,])
self.assertEqual(run.cycles,218)
self.assertEqual(run.complete,True)

def test_illuminarun_incomplete(self):
"""
IlluminaRun: test 'complete' property when completion files missing
"""
# Make a mock run directory for NovaSeq format
self.mock_illumina_run = MockIlluminaRun(
'221125_A500968_0038_ABCDE1XX',
'novaseq',
complete=False,
top_dir=self.top_dir)
self.mock_illumina_run.create()
# Load into an IlluminaRun object
run = IlluminaRun(self.mock_illumina_run.dirn,
platform="novaseq")
# Check that run is not complete
self.assertEqual(run.complete,False)

def test_illuminarun_miseq_missing_directory(self):
"""
Expand Down

0 comments on commit b9b968a

Please sign in to comment.