def main(argv): parser = argparse.ArgumentParser( description=__doc__, prog='svtest merged-depth', formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('test_bed', type=str) parser.add_argument('contig_list', type=str) parser.add_argument('type', type=str) parser.add_argument('--baseline-bed', type=str, default=None, help="Baseline bed file to evaluate against") parser.add_argument( '--test-hits', type=str, help= "List of test record ids that overlap baseline set (required if using --baseline-bed)" ) parser.add_argument( '--baseline-hits', type=str, help= "List of baseline record ids that overlap test set (required if using --baseline-bed)" ) # Print help if no arguments specified if len(argv) == 0: parser.print_help() sys.exit(1) args = parser.parse_args(argv) if (bool(args.baseline_bed) ^ bool(args.test_hits)) or \ (bool(args.baseline_bed) ^ bool(args.baseline_hits)) or \ (bool(args.test_hits) ^ bool(args.baseline_hits)): raise ValueError( "Inconsistent arguments specified: --baseline-bed, --test-hits, and --baseline-hits must be specified together." ) contigs = iou.read_contig_list(args.contig_list) # Read file with gzip.open(args.test_bed, mode='rb') as ftest: if args.baseline_bed is None: metrics = get_metrics(ftest, None, contigs, args.type, args.test_hits, args.baseline_hits) else: with gzip.open(args.baseline_bed, mode='rb') as fbase: metrics = get_metrics(ftest, fbase, contigs, args.type, args.test_hits, args.baseline_hits) # Write metrics write_metrics(metrics)
def main(argv): parser = argparse.ArgumentParser( description=__doc__, prog='svtest metrics-file', formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('metrics_file', type=str) parser.add_argument('contig_list', type=str) parser.add_argument('--common', action='store_true') # Print help if no arguments specified if len(argv) == 0: parser.print_help() sys.exit(1) args = parser.parse_args(argv) contigs = iou.read_contig_list(args.contig_list) tu.test_is_not_empty(contigs, "contigs") # Read file df = pd.read_csv(args.metrics_file, sep='\t') metrics = get_metrics(df, contigs, args.common) # Write metrics write_metrics(metrics)
def main(argv): parser = argparse.ArgumentParser( description=__doc__, prog='svtest vcf', formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('test_vcf', type=str) parser.add_argument('contig_list', type=str) parser.add_argument('sample_list', type=str) parser.add_argument( 'types', type=str, help='Comma-delimited list of variant types (case-sensitive)') parser.add_argument('metric_prefix', type=str) parser.add_argument( '--baseline-vcf', type=str, help='Baseline vcf to provide evaluation metrics against') parser.add_argument( '--baseline-bed', type=str, help= 'Baseline bed file to provide evaluation metrics against. Must have header beginning with "' + BED_FILE_HEADER_CHAR + '" and the following columns: "' + '", "'.join([ BED_FILE_CHROM_COL, BED_FILE_START_COL, BED_FILE_END_COL, BED_FILE_SVTYPE_COL ]) + '"') parser.add_argument( '--min-reciprocal-overlap', type=float, default=0.5, help='Minimum reciprocal overlap for validation metrics [0.5]') parser.add_argument('--padding', type=int, default=50, help='Interval padding for validation metrics [50]') parser.add_argument( '--max-warnings', type=int, default=50, help='Maximum number of records to print warnings for [50]') parser.add_argument('--fp-file', type=str, default=None, help='Write false positives to file') parser.add_argument('--fn-file', type=str, default=None, help='Write false negatives to file') parser.add_argument('--fp-pass-file', type=str, default=None, help='Write PASS false positives to file') parser.add_argument('--fn-pass-file', type=str, default=None, help='Write PASS false negatives to file') # Print help if no arguments specified if len(argv) == 0: parser.print_help() sys.exit(1) args = parser.parse_args(argv) if (args.baseline_vcf is None and args.baseline_bed is None) and (args.fp_file is not None or args.fn_file is not None): raise ValueError( "FP and FN files cannot be generated if --baseline-vcf and --baseline-bed aren't specified" ) if args.baseline_vcf is not None and args.baseline_bed is not None: raise ValueError( "Cannot specify both --baseline-vcf and --baseline-bed") types_list = args.types.split(',') contigs = iou.read_contig_list(args.contig_list) samples = iou.read_samples_list(args.sample_list) metrics, fp_intervals, fn_intervals, fp_intervals_pass, fn_intervals_pass = get_metrics( args.test_vcf, args.baseline_vcf, args.baseline_bed, contigs, types_list, args.min_reciprocal_overlap, args.padding, samples, args.metric_prefix, args.max_warnings) # Write metrics write_metrics(metrics) if args.fp_file is not None and fp_intervals is not None: write_intervals(args.fp_file, fp_intervals) if args.fn_file is not None and fn_intervals is not None: write_intervals(args.fn_file, fn_intervals) if args.fp_pass_file is not None and fp_intervals_pass is not None: write_intervals(args.fp_pass_file, fp_intervals_pass) if args.fn_pass_file is not None and fn_intervals_pass is not None: write_intervals(args.fn_pass_file, fn_intervals_pass)
def main(argv): parser = argparse.ArgumentParser( description=__doc__, prog='svtest vcf', formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('test_vcf', type=str) parser.add_argument('contig_list', type=str) parser.add_argument('sample_list', type=str) parser.add_argument( 'types', type=str, help='Comma-delimited list of variant types (case-sensitive)') parser.add_argument('metric_prefix', type=str) parser.add_argument( '--baseline-vcf', type=str, help='Baseline vcf to provide evaluation metrics against') parser.add_argument( '--min-reciprocal-overlap', type=float, default=0.5, help='Minimum reciprocal overlap for validation metrics [0.5]') parser.add_argument('--padding', type=int, default=50, help='Interval padding for validation metrics [50]') parser.add_argument( '--max-warnings', type=int, default=50, help='Maximum number of records to print warnings for [50]') parser.add_argument('--fp-file', type=str, default=None, help='Write false positives to file') parser.add_argument('--fn-file', type=str, default=None, help='Write false negatives to file') # Print help if no arguments specified if len(argv) == 0: parser.print_help() sys.exit(1) args = parser.parse_args(argv) if args.baseline_vcf is None and (args.fp_file is not None or args.fn_file is not None): raise ValueError( "FP and FN files cannot be generated if --baseline-vcf isn't specified" ) types_list = args.types.split(',') contigs = iou.read_contig_list(args.contig_list) samples = iou.read_samples_list(args.sample_list) metrics, fp_intervals, fn_intervals = get_metrics( args.test_vcf, args.baseline_vcf, contigs, types_list, args.min_reciprocal_overlap, args.padding, samples, args.metric_prefix, args.max_warnings) # Write metrics write_metrics(metrics) if args.fp_file is not None and fp_intervals is not None: write_intervals(args.fp_file, fp_intervals) if args.fn_file is not None and fn_intervals is not None: write_intervals(args.fn_file, fn_intervals)