Commit 6bac82fa authored by Maria Bernard's avatar Maria Bernard
Browse files

add recover_mate_ok and recover_mate_discards functions

parent ff7b8a92
......@@ -30,6 +30,69 @@ import jflow.seqio as seqio
class Process_radtag (Analysis):
def recover_mate_discards (read1,read2, output_file):
# enregistrement des ID de squences 1
id_R1=[]
reader = seqio.SequenceReader(read1,fileformat="fastq")
for id, desc, seq, qual in reader :
id_R1.append(id)
# disctionnaire de squences 2 correspondant aux ID de lecures 1
dic_R2={}
reader = seqio.SequenceReader(read2,fileformat="fastq")
for id, desc, seq, qual in reader :
if id in id_R1:
dic_R2[id]=desc+"\n"+seq+"\n+\n"+qual+"\n"
# ecriture du fichier fastq de lectures 2 quivalent aux lectures 1
handle=open(output_file,"w")
string=""
i=0
for name in id_R1:
string=string+"@"+dic_R2[name]
i=i+4
if i==4000:
handle.write(string)
string=""
i=0
if string !="":
handle.write(string)
string=""
i=0
handle.close()
def recover_mate_ok (read1,read2,output_file):
# enregistrement des ID de squences 1
id_R1=[]
reader = seqio.SequenceReader(read1,fileformat="fastq")
for id, desc, seq, qual in reader :
id_R1.append(id[:-2])
# disctionnaire de squences 2 correspondant aux ID des lcures 1
dic_R2={}
reader = seqio.SequenceReader(read2,fileformat="fastq")
for id, desc, seq, qual in reader :
convert_id="_".join(id.split(":")[3:7])
if convert_id in id_R1:
dic_R2[convert_id]=convert_id+"_2\n"+seq+"\n+\n"+qual+"\n"
# ecriture du fichier fastq de lectures 2 quivalent aux lectures 1
handle=open(output_file,"w")
string=""
i=0
for name in id_R1:
string=string+"@"+dic_R2[name]
i=i+4
if i==4000:
handle.write(string)
string=""
i=0
if string !="":
handle.write(string)
string=""
i=0
handle.close()
def define_parameters(self, read1_files, read2_files, enzyme_name=None, limit_score=10, quality_encode = 'phred33', max_length=None, rescue_radtag=False, discard_low_qual=False, discard_read_files=False, archive_name=False):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment