# Main args parser.add_argument("file", type=pathlib.Path, help="A genome file in .sam format") parser.add_argument("genome_length", type=int, help="The genome length") # Options parser.add_argument("--verbose", default=False, dest="verbose", action="store_true", help="Verbose output") # Get args args = parser.parse_args() input_file = args.file genome_length = args.genome_length verbose = args.verbose # Set loggin level logging.basicConfig(level=(logging.DEBUG if verbose else None)) logging.debug(f"input_file = {input_file}") logging.debug(f"genome_length = {genome_length}") # Read mates mates = read_mates(input_file, keep_fields=["pos", "ma"]) # Get multiple aligment track multiple_alignments = get_multiple_alignments(mates, genome_length) # Print track to wig file to_wig(multiple_alignments)
if __name__ == "__main__": # Set verbose logging logging.basicConfig(level=logging.DEBUG) # Check args if len(sys.argv) != 1 + 2: print_usage(sys.argv) # Get args input_file = sys.argv[1] genome_length = int(sys.argv[2]) logging.debug(f"input_file = {input_file}") logging.debug(f"genome_length = {genome_length}") # Read mates mates = read_mates(input_file, keep_fields=["pos", "pnext", "tlen", "flag"]) mates = filter_out_invalid_mates(mates) # Compute single mates percentage relative_orientations = get_relative_orientations(mates, genome_length) assert len( relative_orientations ) == genome_length, f"Track length must be equal to genome lenth, but {len(relative_orientations)} != {genome_length}" # Print single_mates_percentage in wig format to_wig(relative_orientations)
""") # Main args parser.add_argument("file", type=pathlib.Path, help="A genome file in .sam format") parser.add_argument("genome_length", type=int, help="The genome length") # Options parser.add_argument("--verbose", default=False, dest="verbose", action="store_true", help="Verbose output") # Get args args = parser.parse_args() input_file = args.file genome_length = args.genome_length verbose = args.verbose # Set loggin level logging.basicConfig(level=(logging.DEBUG if verbose else None)) logging.debug(f"input_file = {input_file}") logging.debug(f"genome_length = {genome_length}") # Read mates mates = read_mates(input_file, keep_fields=["pos", "flag", "cigar"]) # Get multiple aligment track hard_soft_clippings = get_hard_soft_clippings(mates, genome_length) # Print track to wig file to_wig(hard_soft_clippings)
if __name__ == "__main__": # Set verbose logging logging.basicConfig(level=logging.DEBUG) # Check args if len(sys.argv) != 1 + 2: print_usage(sys.argv) # Get args input_file = sys.argv[1] genome_length = int(sys.argv[2]) logging.debug(f"input_file = {input_file}") logging.debug(f"genome_length = {genome_length}") # Read mates mates = read_mates(input_file, keep_fields=["pos", "pnext", "tlen", "flag"]) mates = filter_out_invalid_mates(mates) # Compute single mates percentage single_mates_percentage = get_single_mates_percentage(mates, genome_length) assert len( single_mates_percentage ) == genome_length, f"Track length must be equal to genome lenth, but {len(single_mates_percentage)} != {genome_length}" # Print single_mates_percentage in wig format to_wig(single_mates_percentage)
# Get tlen distribution params mu, std = get_tlen_distribution_params(mates) # Plot distribution if plot: x = get_distribution_space(mu, std) prob_insertion = get_probability_for_insertion(x, mu, std) prob_deletion = get_probability_for_deletion(x, mu, std) pdf = get_pdf(x, mu, std) plot_pdf(x, pdf, mu, std) plot_insertion_probability(x, prob_insertion) plot_deletion_probability(x, prob_deletion) if track == "insertion": logging.info("Computing insertion probabilities...") ls = get_avg_fragments_length(mates, genome_length) ls = get_probability_for_insertion(ls, mu, std) to_wig(ls) if track == "deletion": logging.info("Computing deletion probabilities...") ls = get_avg_fragments_length(mates, genome_length) ls = get_probability_for_deletion(ls, mu, std) to_wig(ls)
# Set verbose logging logging.basicConfig(level=logging.DEBUG) # Check args if len(sys.argv) != 1 + 2: print_usage() exit(1) # Get args input_file = sys.argv[1] genome_length = int(sys.argv[2]) logging.debug(f"input_file = {input_file}") logging.debug(f"genome_length = {genome_length}") # Get mates mates = read_mates(input_file, keep_fields=["pos", "pnext", "flag", "tlen"]) mates = filter_out_invalid_mates(mates) # Compute physical coverage physical_coverage_percentage = get_physical_coverage_percentage( mates, genome_length) assert len( physical_coverage_percentage ) == genome_length, f"Track length must be equal to genome lenth, but {len(physical_coverage_percentage)} != {genome_length}" # Print to wig file to_wig(physical_coverage_percentage)
avg_fragments_length[i] = int(result) return avg_fragments_length if __name__ == "__main__": # Set verbose logging logging.basicConfig(level=logging.DEBUG) # Check args if len(sys.argv) != 1 + 2: print_usage(sys.argv) # Get args input_file = sys.argv[1] genome_length = int(sys.argv[2]) logging.debug(f"input_file = {input_file}") logging.debug(f"genome_length = {genome_length}") # Read mates mates = read_mates(input_file, keep_fields=["pos", "pnext", "tlen", "flag"]) mates = filter_out_invalid_mates(mates) # Compute avg frag length avg_fragments_length = get_avg_fragments_length(mates, genome_length) # Print single_mates_percentage in wig format to_wig(avg_fragments_length)