Skip to content

main

Call peaks for the given Calling Cards data.

Source code in callingcardstools/PeakCalling/yeast/call_peaks.py
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
def main(args: argparse.Namespace) -> None:
    """
    Call peaks for the given Calling Cards data.
    """
    # note the * -- unpack the list of paths
    check_files = [
        *args.experiment_data_paths,
        args.promoter_data_path,
        args.background_data_path,
        args.chrmap_data_path,
    ]
    for file in check_files:
        if not os.path.isfile(file):
            raise FileNotFoundError(f"The following path does not exist: {file}")

    try:
        result_df = call_peaks(
            args.experiment_data_paths,
            args.experiment_orig_chr_convention,
            args.promoter_data_path,
            args.promoter_orig_chr_convention,
            args.background_data_path,
            args.background_orig_chr_convention,
            args.chrmap_data_path,
            args.unified_chr_convention,
            args.deduplicate_experiment,
            genomic_only=args.genomic_only,
            pseudocount=args.pseudocount,
        )

        result_df.to_csv(
            args.output_path,
            compression="gzip" if args.compress_output else None,
            index=False,
        )
    except Exception as e:
        logger.error(
            "Error processing experiment files: %s. Error: %s",
            args.experiment_data_paths,
            e,
        )
        raise