Skip to content

Commit

Permalink
add check to skip parsing of blank lines in SampleSheets
Browse files Browse the repository at this point in the history
add a check to skip parsing of blank lines in SampleSheets.csv files,
and a unit test with a representative sample sheet
  • Loading branch information
tomkinsc committed Aug 17, 2016
1 parent 22ed89c commit ca78d0f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
3 changes: 3 additions & 0 deletions illumina.py
Expand Up @@ -461,6 +461,9 @@ def _detect_and_load_sheet(self, infile):
miseq_skip = False
row_num = 0
for line in inf:
# if this is a blank line, skip parsing and continue to the next line...
if len(line.rstrip('\n').rstrip('\r').strip()) == 0:
continue
csv.register_dialect('samplesheet', quoting=csv.QUOTE_MINIMAL, escapechar='\\')
row = next(csv.reader([line.strip().rstrip('\n')], dialect="samplesheet"))
row = [item.strip() for item in row] # remove leading/trailing whitespace from each item
Expand Down
35 changes: 35 additions & 0 deletions test/input/TestSampleSheet/SampleSheet-with-blanklines.csv
@@ -0,0 +1,35 @@
[Header],,,,,,,,,
IEMFileVersion,4,,,,,,,,
Investigator Name,Anne,,,,,,,,
Experiment Name,AP081616,,,,,,,,
Date,8/16/16,,,,,,,,
Workflow,GenerateFASTQ,,,,,,,,
Application,FASTQ Only,,,,,,,,
Assay,Nextera XT,,,,,,,,
Description,CSF,,,,,,,,
Chemistry,Amplicon,,,,,,,,
,,,,,,,,,
[Reads],,,,,,,,,
101,,,,,,,,,
101,,,,,,,,,
,,,,,,,,,
[Settings],,,,,,,,,
ReverseComplement,0,,,,,,,,
Adapter,CTGTCTCTTATACACATCT,,,,,,,,
,,,,,,,,,
[Data],,,,,,,,,
Sample_ID,Sample_Name,Sample_Plate,Sample_Well,I7_Index_ID,index,I5_Index_ID,index2,Sample_Project,Description
BWH001lib1,,,,N703,AGGCAGAA,S517,GCGTAAGA,,
BWH001lib2,,,,N705,GGACTCCT,S517,GCGTAAGA,,
NEGCSF3lib2,,,,N706,TAGGCATG,S502,CTCTCTAT,,
NS_guide2_2,,,,172,CCTACCAT,417,CGGTTCTT,,
C044_rs9283753,,,,44,CTGCGGAT,34,TCTTTCCC,,
C045_rs9283753,,,,45,TCGGAATG,34,TCTTTCCC,,
C066_rs9283753,,,,46,TCTGCAAG,34,TCTTTCCC,,
C067_rs9283753,,,,47,AACTTGAC,34,TCTTTCCC,,

C081_rs9283753,,,,66,TTGAGCCT,34,TCTTTCCC,,
C082_rs9283753,,,,67,GGTCCAGA,34,TCTTTCCC,,
NA12872_rs9283753,,,,68,CCAGTTAG,34,TCTTTCCC,,
NA12812_rs9283753,,,,69,CAATAGTC,34,TCTTTCCC,,

6 changes: 6 additions & 0 deletions test/unit/test_illumina.py
Expand Up @@ -66,6 +66,12 @@ def test_tabfile(self):
self.assertEqual(samples.num_indexes(), 2)
self.assertEqual(len(samples.get_rows()), 24)

def test_blank_line_in_tabular_section(self):
inDir = util.file.get_test_input_path(self)
samples = illumina.SampleSheet(os.path.join(inDir, 'SampleSheet-with-blanklines.csv'))
self.assertEqual(samples.num_indexes(), 2)
self.assertEqual(len(samples.get_rows()), 12)


class TestRunInfo(TestCaseWithTmp):

Expand Down

0 comments on commit ca78d0f

Please sign in to comment.