How to update the sample sheet object?
Closed this issue · 1 comments
vlakhujani commented
Hi
I am trying to write a simple logic to reverse complement the i5 index within the sample_sheet object using a custom reverse_complement
function
Can you let me know how can I update the object such as to accomodate the reverse complemented i5 index and then write an updated CSV sample sheet file ?
for sample in sample_sheet:
index_i5 = sample.index2
index_i5_rc = reverse_complement(index_i5)
sample.index2 = index_i5_rc
clintval commented
Sure thing:
import sys
from sample_sheet import SampleSheet
def reverse_complement(string: str) -> str:
return "<REVERSE_COMPLEMENTED_INDEX>"
url = 'https://raw.githubusercontent.com/clintval/sample-sheet/master/tests/resources/paired-end-single-index.csv'
sheet = SampleSheet(url)
for sample in sheet:
sample.index = reverse_complement(sample.index)
sheet.write(sys.stdout)
Which will output the following to STDOUT:
[Header],,,,,,,,
IEM1FileVersion,4,,,,,,,
Investigator Name,jdoe,,,,,,,
Experiment Name,exp001,,,,,,,
Date,11/16/2017,,,,,,,
Workflow,SureSelectXT,,,,,,,
Application,NextSeq FASTQ Only,,,,,,,
Assay,SureSelectXT,,,,,,,
Description,A description of this flow cell,,,,,,,
Chemistry,Default,,,,,,,
,,,,,,,,
[Reads],,,,,,,,
151,,,,,,,,
151,,,,,,,,
,,,,,,,,
[Settings],,,,,,,,
CreateFastqForIndexReads,1,,,,,,,
BarcodeMismatches,2,,,,,,,
,,,,,,,,
[Data],,,,,,,,
Sample_ID,Sample_Name,index,Description,Library_ID,Read_Structure,Reference_Name,Sample_Project,Target_Set
1823A,1823A-tissue,<REVERSE_COMPLEMENTED_INDEX>,0.5x treatment,2017-01-20,151T8B151T,mm10,exp001,Intervals-001
1823B,1823B-tissue,<REVERSE_COMPLEMENTED_INDEX>,0.5x treatment,2017-01-20,151T8B151T,mm10,exp001,Intervals-001
1824A,1824A-tissue,<REVERSE_COMPLEMENTED_INDEX>,1.0x treatment,2017-01-20,151T8B151T,mm10,exp001,Intervals-001
1825A,1825A-tissue,<REVERSE_COMPLEMENTED_INDEX>,10.0x treatment,2017-01-20,151T8B151T,mm10,exp001,Intervals-001
1826A,1826A-tissue,<REVERSE_COMPLEMENTED_INDEX>,100.0x treatment,2017-01-20,151T8B151T,mm10,exp001,Intervals-001
1826B,1823A-tissue,<REVERSE_COMPLEMENTED_INDEX>,0.5x treatment,2017-01-17,151T8B151T,mm10,exp001,Intervals-001
1829A,1823B-tissue,<REVERSE_COMPLEMENTED_INDEX>,0.5x treatment,2017-01-17,151T8B151T,mm10,exp001,Intervals-001
Replace sys.stdout
with an open file handle to write to a file.
Since you want to mutate I5 index. Reference index2
instead of index
.