getopt|sys|open|print文件|main()|if __name__ == "__main__"|getline()

#!/usr/bin/python

import sys
import getopt
import re

def compare(f1,f2,o1,o2,si_line): 
    lines_count=0;
    in1 = open(f1,"r")
    in2 = open(f2,"r")
    ou1 = open(o1,"w")
    ou2 = open(o2,"w")
    while 1:
        line1 = in1.readline()
        line2 = in2.readline()
        if line1 and line2:
            lines_count=lines_count+1
            print >>ou1,re.sub(r'
',"",line1)
            ou2.write(line2)
            if si_line<lines_count:
                break
        else:
            break
    f1.close()
    f2.close()
    o1.close()
    o2.close()
    return lines_count

def main():
    opts,args = getopt.getopt(sys.argv[1:],'h:',['fq1=','fq2=','out1=','out2=','Rlen=','Dataset='])
    fq1=opts[0][1]
    fq2=opts[1][1]
    out1=opts[2][1]
    out2=opts[3][1]
    readlength = opts[4][1]
    datasize = opts[5][1]
    size_lines = 4*int(datasize)*1e9/(int(readlength)*2)
    count = compare(fq1,fq2,out1,out2,size_lines)-1
    real_size = (count/4)*2*int(readlength)/1e9
    print datasize
    print real_size

if __name__ == "__main__":
    main()
原文地址:https://www.cnblogs.com/yuanjingnan/p/11164858.html