I have two fastq files. I would like to choose reads from the second file, if the id of the read matches the id of the read in the first file. My script looks like this :
read1_in_handle = open("new_read1.fastq","rU")
read2_handle = open("read2.fastq","rU")
read2_out_handle = open("new_read2.fastq","w")
read1_dict = {}
read1_record_iter = SeqIO.parse(read1_in_handle,"fastq")
for read_record in SeqIO.parse(read2_handle, "fastq"):
read1_record = next(read1_record_iter)
if read_record.id in read1_dict:
print >> read2_out_handle,read_record.format("fastq")
read1_dict[read1_record.id] = read1_dict[read1_record.id] + 1
else:
read1_dict[read1_record.id] = 1
I am not able to resolve the errors this gives. Pl suggest edits
what is the error you're getting?