def main(argv): try: opts, args = getopt.getopt(argv, "i:") except getopt.GetoptError: usage() sys.exit(2) # Get parameters from command line for opt, arg in opts: if opt == "-h": usage() sys.exit() elif opt == '-i': bam_file_name = arg bam_reader = BamReader(bam_file_name, None) bam_reader.output_repetitive_reads()
rlen_mean = stats["read_length"] rlen_sdev = stats["read_length_SD"] print "mean fragment length taken from config file: %.2f" % ( isize_mean) print "standard deviation of fragment_length: %.2f" % (isize_sdev) print "mean read length: %.2f" % (rlen_mean) print "standard deviation of read length: %.2f" % (rlen_sdev) else: # disable this calculation for the time being for the streaming analysis -- require a conf file # print "error! must supply configuration file of library stats" # sys.exit(1) # Get the mean and sdev of insert size from the ORIGINAL bam file psorted_bam_reader = BamReader(psorted_bamfile_name, output_prefix) print "calculating mean insert size..." iterations = 1000000 (isize_mean, isize_sdev, rlen_mean, rlen_sdev) = psorted_bam_reader.calculate_mean_sdev_isize(iterations) print "mean fragment length over %d reads: %.2f" % (iterations, isize_mean) print "standard deviation of fragment_length: %.2f" % (isize_sdev) print "mean read length: %.2f" % (rlen_mean) print "standard deviation of read length: %.2f" % (rlen_sdev) stats_file = open(output_prefix + ".read_stats.txt", "w") stats_file.write("fragment_length\t%.2f\n" % (isize_mean)) stats_file.write("fragment_length_SD\t%.2f\n" % (isize_sdev)) stats_file.write("read_length\t%.2f\n" % (rlen_mean)) stats_file.write("read_length_SD\t%.2f" % (rlen_sdev))
def RunReader(): infile = str(e3) outfile = str(e4) BamReader.BamReader(infile, outfile)