MCPcopy Index your code
hub / github.com/openai/plugins / validate_inputs

Function validate_inputs

plugins/ngs-analysis/scripts/run_atacseq_peaks_qc.py:37–117  ·  view source on GitHub ↗
(args: argparse.Namespace)

Source from the content-addressed store, hash-verified

35
36
37def validate_inputs(args: argparse.Namespace) -> tuple[dict[str, Any], list[dict[str, str]]]:
38 sample_sheet = args.sample_sheet.expanduser().resolve()
39 errors: list[str] = []
40 warnings: list[str] = []
41 rows: list[dict[str, str]] = []
42 columns: list[str] = []
43 samples: list[dict[str, str]] = []
44 if not sample_sheet.exists():
45 errors.append(f"sample sheet does not exist: {sample_sheet}")
46 else:
47 rows, columns = read_table(sample_sheet)
48 if not args.bam_only and not args.bowtie2_index:
49 warnings.append(
50 "no --bowtie2-index was provided; FASTQ rows can only be planned, not aligned"
51 )
52 if not args.genome_size:
53 errors.append(
54 "--genome-size is required for MACS2 peak calling, e.g. hs, mm, or an effective genome size"
55 )
56 blacklist = args.blacklist_bed.expanduser().resolve() if args.blacklist_bed else None
57 if blacklist and not blacklist.exists():
58 errors.append(f"blacklist BED does not exist: {blacklist}")
59 tss_bed = args.tss_bed.expanduser().resolve() if args.tss_bed else None
60 if tss_bed and not tss_bed.exists():
61 warnings.append(
62 f"TSS BED does not exist; TSS enrichment commands will be skipped: {tss_bed}"
63 )
64 if getattr(args, "run_motifs", False) and not getattr(args, "motif_genome", None):
65 errors.append(
66 "--run-motifs requires --motif-genome, for example hg38, mm10, or a HOMER genome identifier"
67 )
68
69 for row_index, row in enumerate(rows, start=2):
70 sample = normalize_sample_name(
71 row.get("sample") or row.get("sample_id"), f"row_{row_index}"
72 )
73 bam = resolve_path(row.get("bam") or row.get("alignment"), sample_sheet.parent)
74 r1 = resolve_path(row.get("r1") or row.get("fastq_1"), sample_sheet.parent)
75 r2 = resolve_path(row.get("r2") or row.get("fastq_2"), sample_sheet.parent)
76 if bam:
77 if not bam.exists():
78 errors.append(f"row {row_index}: BAM does not exist: {bam}")
79 layout = "bam"
80 elif r1:
81 if not r1.exists():
82 errors.append(f"row {row_index}: R1 FASTQ does not exist: {r1}")
83 if r2 and not r2.exists():
84 errors.append(f"row {row_index}: R2 FASTQ does not exist: {r2}")
85 layout = "fastq_pe" if r2 else "fastq_se"
86 else:
87 errors.append(f"row {row_index}: provide bam/alignment or r1/fastq_1")
88 continue
89 samples.append(
90 {
91 "sample": sample,
92 "condition": row.get("condition", ""),
93 "replicate": row.get("replicate", ""),
94 "layout": layout,

Callers 1

mainFunction · 0.70

Calls 4

read_tableFunction · 0.90
normalize_sample_nameFunction · 0.90
resolve_pathFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected