I have two fastq files A.fastq and B.fastq. I want to 1. choose reads from B.fastq if the read_id is present in A.fastq 2. If a read is chosen in B.fastq, I want to modify the read_id of that read by appending to it the (after an underscore) sequence of the correspondig read in A.fastq
I wrote the following which accomplishes task 1 but not task 2.
results = []
chosen = set()
for s in Bio.SeqIO.parse("A.fastq","fastq"):
chosen.adds.id)
for s in Bio.SeqIO.parse("B.fastq","fastq"):
if s.id in chosen:
#####HOW TO MODIFY s.id here to s.id+"_"+sequence from A.fastq for that read_id
results.append(s)
output_handle = open("B_filt.fastq","w")
SeqIO.write(results,output_handle,"fastq")
output_handle.close()
Please suggest a fix.