Skip to content

Commit 6916948

Browse files
committed
indexed_reads -> index_cycles
1 parent 2487fd3 commit 6916948

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/sequence_processing_pipeline/Pipeline.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -911,8 +911,8 @@ def is_sample_sheet(sample_sheet_path):
911911

912912
return False
913913

914-
def _generate_dummy_sample_sheet(self, read_len,
915-
indexed_reads, dummy_sample_id):
914+
def _generate_dummy_sample_sheet(self, index_cycles, non_index_cycles,
915+
len_index, dummy_sample_id):
916916
# create object and initialize header
917917
sheet = AmpliconSampleSheet()
918918
sheet.Header['IEMFileVersion'] = '4'
@@ -924,13 +924,13 @@ def _generate_dummy_sample_sheet(self, read_len,
924924
sheet.Header['Chemistry'] = 'Amplicon'
925925

926926
# generate override_cycles string
927-
tmp = [f"N{x['NumCycles']}" for x in indexed_reads]
927+
tmp = [f"N{index_cycles}" for i in range(len_index)]
928928
tmp = ';'.join(tmp)
929-
override_cycles = f"Y{read_len};{tmp};Y{read_len}"
929+
override_cycles = f"Y{non_index_cycles};{tmp};Y{non_index_cycles}"
930930

931931
# set Reads and Settings according to input values
932932
# we'll get this from the code on the server
933-
sheet.Reads = [read_len, read_len]
933+
sheet.Reads = [non_index_cycles, non_index_cycles]
934934
sheet.Settings['OverrideCycles'] = override_cycles
935935
sheet.Settings['MaskShortReads'] = '1'
936936
sheet.Settings['CreateFastqForIndexReads'] = '1'
@@ -975,18 +975,19 @@ def generate_dummy_sample_sheet(self, run_dir, output_fp):
975975

976976
# the assumptions are: if we have 3 reads we should only have 1
977977
# index; and if we have 4 reads, 2 should be index
978-
len_reads = len(reads)
979-
len_index_reads = len([r for r in reads if r['IsIndexedRead']])
980-
if (len_reads == 3 and len_index_reads != 1) or (
981-
len_reads == 4 and len_reads != 2):
978+
index_reads = [r for r in reads if r['IsIndexedRead']]
979+
non_index_reads = [r for r in reads if not r['IsIndexedRead']]
980+
len_index_reads = len(index_reads)
981+
len_non_index_reads = len(non_index_reads)
982+
if len_non_index_reads != 2 or (len_index_reads != 1 and
983+
len_index_reads != 2):
982984
raise ValueError("RunInfo.xml contains abnormal reads.")
983-
len_cycles = [r['NumCycles']
984-
for r in reads if not r['IsIndexedRead']][0]
985-
986985
dummy_sample_id = basename(run_dir) + '_SMPL1'
987986

988-
sheet = self._generate_dummy_sample_sheet(len_cycles,
989-
reads, dummy_sample_id)
987+
sheet = self._generate_dummy_sample_sheet(
988+
index_reads[0]['NumCycles'],
989+
non_index_reads[0]['NumCycles'],
990+
len_index_reads, dummy_sample_id)
990991

991992
with open(output_fp, 'w') as f:
992993
sheet.write(f, 1)

0 commit comments

Comments
 (0)