Esempio n. 1
0
def convert_fastq(fq,ofq,out_lnum=4,out_baseQ=33,tickon = 10000):
    nreads = preprocess_radtag_lane.get_read_count(fq)
    lnum,baseQ = preprocess_radtag_lane.get_fastq_properties(fq)
    fh = preprocess_radtag_lane.smartopen(fq)
    ofh = preprocess_radtag_lane.smartopen(ofq,'w')
    for i in xrange(nreads):
        if i%tickon == 0:
            print >> sys.stderr, '\r%s / %s (%0.1f%%)' % (i,nreads,(float(i)/nreads)*100),
        n,s,qs = preprocess_radtag_lane.next_read_from_fh(fh, lnum)
        ofh.write(preprocess_radtag_lane.as_fq_line(n,s,qs_to_q(qs,baseQ),out_baseQ,out_lnum))
    print >> sys.stderr,'\n'
Esempio n. 2
0
def convert_fastq(fq, ofq, out_lnum=4, out_baseQ=33, tickon=10000):
    nreads = preprocess_radtag_lane.get_read_count(fq)
    lnum, baseQ = preprocess_radtag_lane.get_fastq_properties(fq)
    fh = preprocess_radtag_lane.smartopen(fq)
    ofh = preprocess_radtag_lane.smartopen(ofq, 'w')
    for i in xrange(nreads):
        if i % tickon == 0:
            print >> sys.stderr, '\r%s / %s (%0.1f%%)' % (i, nreads,
                                                          (float(i) / nreads) *
                                                          100),
        n, s, qs = preprocess_radtag_lane.next_read_from_fh(fh, lnum)
        ofh.write(
            preprocess_radtag_lane.as_fq_line(n, s, qs_to_q(qs, baseQ),
                                              out_baseQ, out_lnum))
    print >> sys.stderr, '\n'
Esempio n. 3
0
    if len(sys.argv) == 4:
        cutsite, fq, outfile = sys.argv[1:]
        rc = preprocess_radtag_lane.get_read_count(fq)
        lnum, baseQ = preprocess_radtag_lane.get_fastq_properties(fq)

        fh = preprocess_radtag_lane.smartopen(fq)
        ofh = preprocess_radtag_lane.smartopen(outfile, 'w')

        found = 0
        for i in range(rc):
            if i > 0 and i % tick == 0:
                print >> sys.stderr, '\r%s / %s (%0.1f%%) found %s (%0.1f%%)' % \
                      (i,rc,(float(i)/rc)*100,found,(float(found)/i)*100),
            n, s, q = preprocess_radtag_lane.next_read_from_fh(fh, lnum)
            if s[barcode_len:barcode_len + len(cutsite)] == cutsite:
                line = preprocess_radtag_lane.as_fq_line(n, s, q, None, lnum)
                ofh.write(line)
                found += 1
        ofh.close()
    elif len(sys.argv) == 6:
        cutsite, fq1, fq2, outfile1, outfile2 = sys.argv[1:]
        rc1 = preprocess_radtag_lane.get_read_count(fq1)
        rc2 = preprocess_radtag_lane.get_read_count(fq2)
        if rc1 != rc2:
            errstr = 'read count for %s = %s; %s = %s. counts must match' % (
                fq1, rc1, fq2.rc2)
            raise ValueError, errstr
        lnum, baseQ = preprocess_radtag_lane.get_fastq_properties(fq1)

        fh1 = preprocess_radtag_lane.smartopen(fq1)
        ofh1 = preprocess_radtag_lane.smartopen(outfile1, 'w')
Esempio n. 4
0
    if len(sys.argv) == 4:
        cutsite,fq,outfile = sys.argv[1:]
        rc = preprocess_radtag_lane.get_read_count(fq)
        lnum,baseQ = preprocess_radtag_lane.get_fastq_properties(fq)

        fh = preprocess_radtag_lane.smartopen(fq)
        ofh = preprocess_radtag_lane.smartopen(outfile,'w')

        found = 0
        for i in range(rc):
            if i>0 and i % tick == 0:
                print >> sys.stderr, '\r%s / %s (%0.1f%%) found %s (%0.1f%%)' % \
                      (i,rc,(float(i)/rc)*100,found,(float(found)/i)*100),
            n,s,q = preprocess_radtag_lane.next_read_from_fh(fh,lnum)
            if s[barcode_len:barcode_len+len(cutsite)] == cutsite:
                line = preprocess_radtag_lane.as_fq_line(n,s,q,None,lnum)
                ofh.write(line)
                found += 1
        ofh.close()
    elif len(sys.argv) == 6:
        cutsite,fq1,fq2,outfile1,outfile2 = sys.argv[1:]
        rc1 = preprocess_radtag_lane.get_read_count(fq1)
        rc2 = preprocess_radtag_lane.get_read_count(fq2)
        if rc1 != rc2:
            errstr = 'read count for %s = %s; %s = %s. counts must match' % (fq1,rc1,fq2.rc2)
            raise ValueError, errstr
        lnum,baseQ = preprocess_radtag_lane.get_fastq_properties(fq1)
        
        fh1 = preprocess_radtag_lane.smartopen(fq1)
        ofh1 = preprocess_radtag_lane.smartopen(outfile1,'w')
        fh2 = preprocess_radtag_lane.smartopen(fq2)