Cn-Bioinf

 view release on metacpan or  search on metacpan

t/checks.t  view on Meta::CPAN

	['{"BlastOutput2":[1]}', qr/^get_best_alignment_hit: report 1 of .+nosearch\.json has no report\.results\.search/, 'a report with no search'],
	['{"BlastOutput2":[{"report":{"results":{"search":{"hits":[]}}}}]}', qr/^get_best_alignment_hit: report 1 of .+noquery\.json names no query: it has no query_title or query_id/,
		'a report with no query'],
) {
	my ($json, $re, $name) = @{ $case };
	my ($file) = $re =~ /\.\+(\w+)\\\.json/;
	dies_like sub { get_best_alignment_hit(spew("$file.json", $json)) }, $re, "get_best_alignment_hit: $name dies";
}
# A query with no title is named by its query_id, where it used to be named
# "" with an "uninitialized" warning.
is_deeply [keys %{ get_best_alignment_hit(spew('untitled.json', '{"BlastOutput2":[{"report":{"results":{"search":{"query_id":"Query_1","hits":[]}}}}]}')) }],
	['Query_1'], 'get_best_alignment_hit: a query with no title is named by its query_id';

#  pgs_score 

# Added with pgs_score on 2026-10-17; t/pgs.t has the scores themselves. Every
# case that dies does so before PLINK 2 starts; the ones that score need it.
{
	my $v = { 'chr1:5:A:G' => { CHROM => 'chr1', POS => 5, ID => 'rs1', REF => 'A', ALT => 'G', 'S.GT' => '0/1' } };
	my $wrow = { rsID => 'rs1', chr_name => '1', chr_position => 5, effect_allele => 'G', other_allele => 'A', effect_weight => '0.5' };
	my $w = [$wrow];
	my $plink2 = eval { require Alien::Bioinf; -x Alien::Bioinf->plink2 };
	SKIP: {
		skip 'PLINK 2, which Alien::Bioinf installs, is not installed', 1 unless $plink2;
		is pgs_score(vcf => $v, weights => $w)->{S}{score}, 0.5, 'pgs_score: the arguments below differ from these only where they say';
	}
	my $head = "rsID\tchr_name\tchr_position\teffect_allele\teffect_weight\n";
	my @cases = (
		[[vcf => $v], qr/^pgs_score: needs "weights"/, 'no weights'],
		[[{ vcf => $v, weights => $w }], qr/^pgs_score: takes name => value pairs, not a hash ref/, 'a hash ref'],
		[[vcf => $v, weights => $w, matches => 'id'], qr/^pgs_score: doesn't know "matches"; it takes build, match, memory, threads, vcf, weights/, 'a misspelled option'],
		[[vcf => $v, weights => $w, match => 'rsid'], qr/^pgs_score: "match" must be "position" or "id", not "rsid"/, 'match "rsid"'],
		[[vcf => $v, weights => $w, build => 'GRCh37'], qr/^pgs_score: "build" must be hg19, b37, hg38 or b38, not "GRCh37"/, 'build "GRCh37"'],
		[[vcf => $v, weights => $w, memory => 639], qr/^pgs_score: "memory" must be 640 or more \(MiB\), the least PLINK 2 takes, not 639/, 'memory 639'],
		[[vcf => $v, weights => $w, memory => '2G'], qr/^pgs_score: "memory" must be a whole number, 1 or more, not "2G"/, 'memory "2G"'],
		[[vcf => $v, weights => $w, threads => 0], qr/^pgs_score: "threads" must be a whole number, 1 or more, not "0"/, 'threads 0'],
		[[vcf => \'calls', weights => $w], qr/^pgs_score: "vcf" must be a VCF, BCF or PLINK 2 \.pgen file, or a data frame, not a SCALAR ref/, 'a scalar ref'],
		[[vcf => catfile($dir, 'none.vcf.gz'), weights => $w], qr/^pgs_score: "vcf" file ".+none\.vcf\.gz" doesn't exist or isn't readable/, 'a VCF that is not there'],
		[[vcf => spew('calls.txt', ''), weights => $w], qr/^pgs_score: "vcf" file .+calls\.txt must end in \.vcf, \.vcf\.gz, \.vcf\.bgz, \.bcf or \.pgen/, 'a VCF named .txt'],
		[[vcf => spew('lone.pgen', ''), weights => $w], qr/^pgs_score: "vcf" .+lone\.pgen has no .+lone\.pvar \(or \.pvar\.zst\) beside it/, 'a .pgen with no .pvar'],
		[[vcf => $v, weights => catfile($dir, 'none.txt.gz')], qr/^pgs_score: "weights" file ".+none\.txt\.gz" doesn't exist or isn't readable/, 'a scoring file that is not there'],
		[[vcf => $v, weights => spew('comments.txt', "#pgs_id=X\n#genome_build=NR\n")], qr/^pgs_score: "weights" file .+comments\.txt has no header line/, 'a scoring file of comments alone'],
		[[vcf => $v, weights => spew('header.txt', $head)], qr/^pgs_score: "weights" has no rows/, 'a scoring file of a header alone'],
		[[vcf => $v, weights => spew('bad.txt', $head . "rs1\t1\t5\tG\t0.5\nrs2\t1\t6\tG\tx\n")], qr/^pgs_score: row 2 of "weights" has effect_weight "x", which isn't a number/, 'a bad weight in a scoring file'],
		[[vcf => $v, weights => [{ %{ $wrow }, chr_name => 'X' }]], qr/^pgs_score: "weights" has variants on X, which PLINK 2 reads only when "build" says where X's pseudo-autosomal regions are: hg19 \(b37\) or hg38 \(b38\)/, 'a variant on X without build'...
		[[vcf => $v, weights => []], qr/^pgs_score: "weights" has no rows/, 'an empty array'],
		[[vcf => {}, weights => $w], qr/^pgs_score: "vcf" has no rows/, 'an empty hash'],
		[[vcf => $v, weights => [['effect_allele']]], qr/^pgs_score: "weights" has a header and no rows/, 'an array of arrays of only a header'],
		[[vcf => $v, weights => [$wrow, undef]], qr/^pgs_score: row 2 of "weights" must be a hash ref, not undef/, 'an undef row'],
		[[vcf => $v, weights => [[qw(a b)], 'x']], qr/^pgs_score: row 1 of "weights" must be an array ref, as its header is, not "x"/, 'a string row of an aoa'],
		# the shape is taken from whichever column perl's hash order gives first
		[[vcf => $v, weights => { a => [1], b => 2 }],
			qr/^pgs_score: (?:column "b" of "weights" must be an array ref, as "a" is, not "2"|"weights" must be .+, not a hash whose "b" is "2")/,
			'a string column of a hoa'],
		[[vcf => $v, weights => [1]], qr/^pgs_score: "weights" must be .+, not an array whose first row is "1"/, 'an array of strings'],
		[[vcf => { a => 1 }, weights => $w], qr/^pgs_score: "vcf" must be .+, not a hash whose "a" is "1"/, 'a hash of strings'],
		[[vcf => $v, weights => [{ map { $_ => $wrow->{$_} } qw(rsID effect_allele effect_weight) }]],
			qr/^pgs_score: "weights" has no "chr_name", "chr_position" columns, which a PGS Catalog scoring file has/, 'no positions'],
		[[vcf => $v, weights => [{ map { $_ => $wrow->{$_} } qw(chr_name chr_position effect_allele effect_weight) }], match => 'id'],
			qr/^pgs_score: "weights" has no "rsID" column/, 'no rsID to match by ID'],
		[[vcf => $v, weights => [{ %{ $wrow }, effect_weight => 'NaN' }]], qr/^pgs_score: row 1 of "weights" has effect_weight "NaN", which isn't a number/, 'a NaN weight'],
		[[vcf => $v, weights => [$wrow, { %{ $wrow }, effect_weight => undef }]], qr/^pgs_score: row 2 of "weights" has effect_weight undef, which isn't a number/, 'an undef weight'],
		[[vcf => $v, weights => { k => { %{ $wrow }, effect_weight => '0,5' } }], qr/^pgs_score: row "k" of "weights" has effect_weight "0,5", which isn't a number/, 'a decimal comma, in a hoh'],
		[[vcf => $v, weights => [{ %{ $wrow }, effect_allele => '' }]], qr/^pgs_score: row 1 of "weights" has no effect_allele/, 'an empty effect allele'],
		[[vcf => $v, weights => [{ %{ $wrow }, chr_position => '1e5' }]], qr/^pgs_score: row 1 of "weights" has chr_position "1e5", which isn't a position/, 'a position in exponent form'],
		[[vcf => $v, weights => [{ %{ $wrow }, hm_chr => '1', hm_pos => 0 }]], qr/^pgs_score: row 1 of "weights" has hm_pos "0", which isn't a position/, 'position 0, in hm_pos'],
		[[vcf => $v, weights => [{ %{ $wrow }, is_dominant => 'True' }]], qr/^pgs_score: row 1 of "weights" has is_dominant "True", and only additive weights can be scored/, 'a dominant weight'],
		[[vcf => $v, weights => [{ %{ $wrow }, is_haplotype => 'TRUE' }]], qr/^pgs_score: row 1 of "weights" has is_haplotype "TRUE", and only/, 'a haplotype'],
		[[vcf => $v, weights => [{ %{ $wrow }, dosage_1_weight => '0.2' }]], qr/^pgs_score: row 1 of "weights" has a dosage_1_weight, and only additive weights can be scored/, 'a dosage weight'],
		[[vcf => { k => { CHROM => 'chr1', POS => 5, REF => 'A', ALT => 'G', FORMAT => 'GT', S => '0/1' } }, weights => $w],
			qr/^pgs_score: "vcf" has no <sample>\.GT column; read the VCF with read_table's default of explode => 1/, 'a VCF read with explode => 0'],
		[[vcf => { k => { CHROM => 'chr1', POS => 5, ALT => 'G', 'S.GT' => '0/1' } }, weights => $w], qr/^pgs_score: "vcf" has no "REF" column/, 'no REF'],
		[[vcf => { k => { CHROM => 'chr1', POS => 5, REF => 'A', ALT => 'G', 'S.GT' => '0/1' } }, weights => $w, match => 'id'], qr/^pgs_score: "vcf" has no "ID" column/, 'no ID to match by ID'],
	);
	foreach my $c (@cases) {
		my ($args, $re, $name) = @{ $c };
		dies_like sub { pgs_score(@{ $args }) }, $re, "pgs_score: $name dies";
	}
	SKIP: {
		skip 'PLINK 2, which Alien::Bioinf installs, is not installed', 3 unless $plink2;
		is pgs_score(vcf => $v, weights => $w, match => 'id')->{S}{score}, 0.5, 'pgs_score: rs1 is found by ID';
		is pgs_score(vcf => $v, weights => [{ %{ $wrow }, chr_name => undef, chr_position => undef }], match => 'id')->{S}{score}, 0.5,
			'pgs_score: matching by ID needs no position';
		is pgs_score(vcf => $v, weights => [{ %{ $wrow }, rsID => undef }])->{S}{score}, 0.5, 'pgs_score: matching by position needs no rsID';
	}
}

#  pca, fst, hardy_weinberg, ld, ld_prune and gwas

# Added with them on 2026-11-17; t/popgen.t has their results. Every case here
# dies before PLINK 2 is looked for, so they run where Alien::Bioinf is not
# installed.
{
	my $v = { 'chr1:5:A:G' => { CHROM => 'chr1', POS => 5, REF => 'A', ALT => 'G', 'S.GT' => '0/1', 'T.GT' => '1/1' } };
	my @p = ({ IID => 'S', y => '1.5', age => 30, site => 'north' }, { IID => 'T', y => '2.5', age => 40, site => 'south' });
	my $head = "#IID\ty\tage\n";
	my @cases = (
		[pca => [], qr/^pca: needs "vcf"/, 'no vcf'],
		[pca => [vcf => $v, pcs => 3], qr/^pca: doesn't know "pcs"; it takes memory, n, threads, vcf/, 'a misspelled option'],
		[pca => [vcf => $v, n => 0], qr/^pca: "n" must be a whole number, 1 or more, not "0"/, 'n 0'],
		[pca => [vcf => $v, n => '2.5'], qr/^pca: "n" must be a whole number, 1 or more, not "2\.5"/, 'n 2.5'],
		[pca => [vcf => $v, threads => 0], qr/^pca: "threads" must be a whole number, 1 or more, not "0"/, 'threads 0'],
		[pca => [vcf => $v, memory => 639], qr/^pca: "memory" must be 640 or more \(MiB\), the least PLINK 2 takes, not 639/, 'memory 639'],
		[pca => [vcf => \'calls'], qr/^pca: "vcf" must be a VCF, BCF or PLINK 2 \.pgen file, or a data frame, not a SCALAR ref/, 'a scalar ref'],
		[pca => [vcf => catfile($dir, 'none.vcf')], qr/^pca: "vcf" file ".+none\.vcf" doesn't exist or isn't readable/, 'a VCF that is not there'],
		[pca => [vcf => spew('calls.tsv', '')], qr/^pca: "vcf" file .+calls\.tsv must end in \.vcf, \.vcf\.gz, \.vcf\.bgz, \.bcf or \.pgen/, 'a VCF named .tsv'],
		[fst => [vcf => $v], qr/^fst: needs "populations"/, 'no populations'],
		[fst => [vcf => $v, populations => { S => 'A', T => 'B' }, method => 'nei'], qr/^fst: "method" must be "hudson" or "wc", not "nei"/, 'method "nei"'],
		[fst => [vcf => $v, populations => { S => 'A', T => 'B' }, per_variant => 2], qr/^fst: "per_variant" must be 0 or 1, not "2"/, 'per_variant 2'],
		[fst => [vcf => $v, populations => [S => 'A']], qr/^fst: "populations" must be a hash ref of sample => population, not an ARRAY ref/, 'populations as an array'],
		[fst => [vcf => $v, populations => {}], qr/^fst: "populations" names no population, and Fst is between two or more/, 'no populations named'],
		[fst => [vcf => $v, populations => { S => 'A', T => 'A' }], qr/^fst: "populations" names one population, and Fst is between two or more/, 'one population'],
		[fst => [vcf => $v, populations => { S => 'A', T => undef }], qr/^fst: "populations" gives "T" the population undef, where a population is a name/, 'an undef population'],
		[fst => [vcf => $v, populations => { S => 'A', T => '' }], qr/^fst: "populations" gives "T" the population "", where a population is a name/, 'an empty population'],
		[hardy_weinberg => [vcf => $v, midp => 'yes'], qr/^hardy_weinberg: "midp" must be 0 or 1, not "yes"/, 'midp "yes"'],
		[ld => [vcf => $v, window_kb => 0], qr/^ld: "window_kb" must be a number above 0, not "0"/, 'window_kb 0'],
		[ld => [vcf => $v, window => 0], qr/^ld: "window" must be a whole number, 1 or more, not "0"/, 'window 0'],
		[ld => [vcf => $v, min_r2 => 1.5], qr/^ld: "min_r2" must be a number from 0 to 1, not "1\.5"/, 'min_r2 1.5'],
		[ld => [vcf => $v, phased => 2], qr/^ld: "phased" must be 0 or 1, not "2"/, 'phased 2'],
		[ld_prune => [vcf => $v, window => 50, window_kb => 200], qr/^ld_prune: the window is given either in variants, as "window", or in kb, as "window_kb", not both/,
			'window and window_kb'],

t/checks.t  view on Meta::CPAN

			qr/^gwas: column "site" of "phenotypes" has "north side" for "S", and a covariate's values have no whitespace/, 'a covariate with a space'],
	);
	foreach my $c (@cases) {
		my ($sub, $args, $re, $name) = @{ $c };
		no strict 'refs';
		dies_like sub { &{"Cn::Bioinf::$sub"}(@{ $args }) }, $re, "$sub: $name dies";
	}
}


#  admixture

# Added with it on 2026-11-17; t/admixture.t has its fit.
{
	my $v = spew('admix.vcf', "##fileformat=VCFv4.2\n#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tA\tB\tC\n"
		. "1\t5\t.\tA\tG\t.\t.\t.\tGT\t0/1\t1/1\t0/0\n1\t9\t.\tC\tT\t.\t.\t.\tGT\t0/0\t0/1\t1/1\n");
	is scalar keys %{ admixture(vcf => $v, k => 2, starts => 1)->{samples} }, 3, 'admixture: the arguments below differ from these only where they say';
	my @cases = (
		[[k => 2], qr/^admixture: needs "vcf"/, 'no vcf'],
		[[vcf => $v], qr/^admixture: needs "k"/, 'no k'],
		[[vcf => $v, k => 2, K => 3], qr/^admixture: doesn't know "K"; it takes k, max_iterations, min_depth, seed, starts, tolerance, vcf/, 'a misspelled option'],
		[[vcf => $v, k => 1], qr/^admixture: "k" must be a whole number, 2 or more, not "1"/, 'k 1'],
		[[vcf => $v, k => '2.5'], qr/^admixture: "k" must be a whole number, 2 or more, not "2\.5"/, 'k 2.5'],
		[[vcf => $v, k => 3], qr/^admixture: "vcf" .+admix\.vcf has 3 samples, and "k" is 3; a sample's ancestry is a share of the k populations, which needs more samples than k/,
			'k as many as the samples'],
		[[vcf => $v, k => 2, starts => 0], qr/^admixture: "starts" must be a whole number, 1 or more, not "0"/, 'starts 0'],
		[[vcf => $v, k => 2, seed => -1], qr/^admixture: "seed" must be a whole number, 0 or more, not "-1"/, 'seed -1'],
		[[vcf => $v, k => 2, tolerance => 0], qr/^admixture: "tolerance" must be a number above 0, not "0"/, 'tolerance 0'],
		[[vcf => $v, k => 2, max_iterations => 0], qr/^admixture: "max_iterations" must be a whole number, 1 or more, not "0"/, 'max_iterations 0'],
		[[vcf => $v, k => 2, min_depth => 'deep'], qr/^admixture: "min_depth" must be a whole number, 0 or more, not "deep"/, 'min_depth "deep"'],
		[[vcf => [], k => 2], qr/^admixture: "vcf" must be a file name, not an ARRAY ref/, 'a vcf that is an array'],
		[[vcf => catfile($dir, 'none.vcf'), k => 2], qr/^admixture: "vcf" file ".+none\.vcf" doesn't exist or isn't readable/, 'a VCF that is not there'],
		[[vcf => spew('admix.txt', ''), k => 2], qr/^admixture: "vcf" file .+admix\.txt must end in \.vcf, \.vcf\.gz, \.vcf\.bgz or \.vcf\.bz2/, 'a VCF named .txt'],
	);
	foreach my $c (@cases) {
		my ($args, $re, $name) = @{ $c };
		dies_like sub { admixture(@{ $args }) }, $re, "admixture: $name dies";
	}
}

#  sex_check

# Added with sex_check on 2026-10-18; t/sex.t has the counts themselves, and the
# errors that come from reading the file.
{
	my $v = spew('sex.vcf', "#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tS\nchrX\t3000000\t.\tA\tG\t.\t.\t.\tGT\t0/1\n");
	is sex_check(vcf => $v, report => 0)->{S}{sex}, 'female', 'sex_check: the arguments below differ from these only where they say';
	is_deeply sex_check($v, report => 0), sex_check(vcf => $v, report => 0), 'sex_check: the file may come first, unnamed, before the options';
	{
		open my $save, '>&', \*STDOUT or die $!;
		open STDOUT, '>', File::Spec->devnull or die $!;
		my $r = eval { sex_check($v) };
		open STDOUT, '>&', $save or die $!;
		is_deeply $r, { S => sex_check(vcf => $v, report => 0)->{S} }, 'sex_check: or alone, as sex_check($file), rather than dying on an odd number of arguments';
	}
	my @cases = (
		[[], qr/^sex_check: needs "vcf"/, 'no vcf'],
		[[{ vcf => $v }], qr/^sex_check: takes name => value pairs, not a hash ref/, 'a hash ref'],
		[[vcf => $v, depth => 7], qr/^sex_check: doesn't know "depth"; it takes cutoff, min_depth, report, vcf/, 'a misspelled option'],
		[[vcf => $v, cutoff => 0], qr/^sex_check: "cutoff" must be a number above 0, not "0"/, 'cutoff 0'],
		[[vcf => $v, cutoff => 'NaN'], qr/^sex_check: "cutoff" must be a number above 0, not "NaN"/, 'cutoff NaN'],
		[[vcf => $v, cutoff => [0.6]], qr/^sex_check: "cutoff" must be a number above 0, not an ARRAY ref/, 'cutoff an array ref'],
		[[vcf => $v, min_depth => -1], qr/^sex_check: "min_depth" must be a whole number, 0 or more, not "-1"/, 'min_depth -1'],
		[[vcf => $v, min_depth => 7.5], qr/^sex_check: "min_depth" must be a whole number, 0 or more, not "7\.5"/, 'min_depth 7.5'],
		[[vcf => $v, report => 2], qr/^sex_check: "report" must be 0 or 1, not "2"/, 'report 2'],
		[['cutoff', 0.5, 'min_depth'], qr/^sex_check: takes name => value pairs, and was given an odd number of arguments/, 'an odd list that starts with an option'],
		[[$v, 'report'], qr/^sex_check: ".+sex\.vcf" is the file, so the options after it must be name => value pairs, and are an odd number/, 'the file and an option with no value, which is read as a pair'],
		[[vcf => $v, report => 'yes'], qr/^sex_check: "report" must be 0 or 1, not "yes"/, 'report "yes"'],
		[[vcf => \'calls'], qr/^sex_check: "vcf" must be a file name, not a SCALAR ref/, 'a scalar ref'],
		[[vcf => catfile($dir, 'none.vcf.bz2')], qr/^sex_check: "vcf" file ".+none\.vcf\.bz2" doesn't exist or isn't readable/, 'a VCF that is not there'],
		[[vcf => $dir], qr/^sex_check: "vcf" file ".+" doesn't exist or isn't readable/, 'a directory'],
		[[vcf => spew('sex.bcf', '')], qr/^sex_check: "vcf" file .+sex\.bcf must end in \.vcf, \.vcf\.gz, \.vcf\.bgz or \.vcf\.bz2/, 'a BCF'],
		[[vcf => spew('sex.vcf.zst', '')], qr/^sex_check: "vcf" file .+sex\.vcf\.zst must end in/, 'a .vcf.zst'],
	);
	foreach my $c (@cases) {
		my ($args, $re, $name) = @{ $c };
		dies_like sub { sex_check(@{ $args }) }, $re, "sex_check: $name dies";
	}
}

#  relatedness 

# Added with relatedness on 2026-10-19; t/relatedness.t has the counts
# themselves, and the errors that come from reading the files. Each case here
# dies before any file is opened.
{
	my $hdr = "#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT";
	my $two = spew('two.vcf', "$hdr\tA\tB\n1\t5\t.\tA\tG\t.\t.\t.\tGT\t0/1\t0/0\n");
	my $a = spew('a.vcf', "$hdr\tA\n1\t5\t.\tA\tG\t.\t.\t.\tGT\t0/1\n");
	my $b = spew('b.vcf', "$hdr\tB\n1\t6\t.\tA\tG\t.\t.\t.\tGT\t0/1\n");
	my @w;
	{
		local $SIG{__WARN__} = sub { push @w, $_[0] };
		is_deeply [sort keys %{ relatedness($two, report => 0) }], ['A', 'B'], 'relatedness: the arguments below differ from these only where they say';
		is relatedness($a, $b, report => 0)->{A}{B}{sites}, 2, 'relatedness: and two own VCFs';
	}
	is scalar(@w), 2, 'relatedness: which are undecided, with too few sites, and say so';
	my $none = catfile($dir, 'none.vcf');
	my @cases = (
		[[], qr/^relatedness: needs a VCF of several samples, or several VCFs of one/, 'nothing'],
		[[report => 0], qr/^relatedness: needs a VCF/, 'options and no VCF'],
		[[{ vcf => $two }], qr/^relatedness: takes name => value pairs, not a hash ref/, 'a hash ref'],
		[[$two, 'report'], qr/^relatedness: takes name => value pairs, and was given an odd number of arguments/, 'the file and an option with no value'],
		[[$two, depth => 7], qr/^relatedness: doesn't know "depth"; it takes max_ibs0, min_depth, report, vcf/, 'a misspelled option'],
		[[$a, vcf => $b], qr/^relatedness: the VCFs are given either first, unnamed, or as "vcf", not both/, 'files both first and as "vcf"'],
		[[vcf => []], qr/^relatedness: needs a VCF/, 'an empty array as "vcf"'],
		[[vcf => { a => $a }], qr/^relatedness: "vcf" must be a file name, not a HASH ref/, 'a hash ref as "vcf"'],
		[[vcf => [$a, undef]], qr/^relatedness: "vcf" must be a file name, not undef/, 'an undef among the files'],
		[[vcf => [$a, \'b']], qr/^relatedness: "vcf" must be a file name, not a SCALAR ref/, 'a scalar ref among the files'],
		[[$a, $none], qr/^relatedness: "vcf" file "\Q$none\E" doesn't exist or isn't readable/, 'a file that is not there'],
		[[$a, $dir], qr/^relatedness: "vcf" file ".+" doesn't exist or isn't readable/, 'a directory'],
		[[$a, spew('b.bcf', '')], qr/^relatedness: "vcf" file .+b\.bcf must end in \.vcf, \.vcf\.gz, \.vcf\.bgz or \.vcf\.bz2/, 'a BCF'],
		[[$a, $b, $a], qr/^relatedness: "\Q$a\E" is given twice/, 'one file twice'],
		[[$two, min_depth => -1], qr/^relatedness: "min_depth" must be a whole number, 0 or more, not "-1"/, 'min_depth -1'],
		[[$two, min_depth => 7.5], qr/^relatedness: "min_depth" must be a whole number, 0 or more, not "7\.5"/, 'min_depth 7.5'],
		[[$two, max_ibs0 => 0], qr/^relatedness: "max_ibs0" must be a number above 0, not "0"/, 'max_ibs0 0'],
		[[$two, max_ibs0 => 'NaN'], qr/^relatedness: "max_ibs0" must be a number above 0, not "NaN"/, 'max_ibs0 NaN'],
		[[$two, max_ibs0 => [0.01]], qr/^relatedness: "max_ibs0" must be a number above 0, not an ARRAY ref/, 'max_ibs0 an array ref'],
		[[$two, report => 'yes'], qr/^relatedness: "report" must be 0 or 1, not "yes"/, 'report "yes"'],
	);
	foreach my $c (@cases) {
		my ($args, $re, $name) = @{ $c };
		dies_like sub { relatedness(@{ $args }) }, $re, "relatedness: $name dies";
	}
}

# The XSUB's own checks of what perl hands it, which relatedness never gets
# wrong; they named XS_Cn__Bioinf__relatedness_own, __func__ in an XSUB, up to
# 2026-11-02.
{
	dies_like sub { Cn::Bioinf::_relatedness_own([sub { undef }], [], 0) },
		qr/^_relatedness_own: 1 readers for 0 files/, '_relatedness_own: names itself when its arrays differ in length';
	my @sparse;
	$sparse[1] = 'b.vcf'; # element 0 does not exist
	dies_like sub { Cn::Bioinf::_relatedness_own([sub { undef }, sub { undef }], \@sparse, 0) },
		qr/^_relatedness_own: file 0 has no reader/, '_relatedness_own: and when a file is missing';
}

#  concordance 

# Added with concordance on 2026-10-19; t/concordance.t has the counts
# themselves, and the errors that come from reading the files. Each case here
# dies before any file is opened.
{
	my $hdr = "#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT";
	my $truth = spew('conc.truth.vcf', "$hdr\tS\n1\t5\t.\tA\tG\t.\t.\t.\tGT\t0/1\n");
	my $test = spew('conc.test.vcf', "$hdr\tS\n1\t5\t.\tA\tG\t.\t.\t.\tGT\t1/1\n");
	is concordance(truth => $truth, test => $test, report => 0)->{S}{counts}{discordant_het_ref_to_hom_alt}, 1,
		'concordance: the arguments below differ from these only where they say';
	my %ok = (truth => $truth, test => $test);
	my $none = catfile($dir, 'none.vcf');
	my @cases = (
		[[], qr/^concordance: needs "test", "truth"/, 'nothing'],
		[[truth => $truth], qr/^concordance: needs "test"/, 'no test'],
		[[test => $test], qr/^concordance: needs "truth"/, 'no truth'],
		[[{ %ok }], qr/^concordance: takes name => value pairs, not a hash ref/, 'a hash ref'],
		[[%ok, 'report'], qr/^concordance: takes name => value pairs, and was given an odd number of arguments/, 'an option with no value'],
		[[%ok, depth => 7], qr/^concordance: doesn't know "depth"; it takes discordances, min_depth, report, test, truth/, 'a misspelled option'],
		[[%ok, truth => [$truth]], qr/^concordance: "truth" must be a file name, not an ARRAY ref/, 'an array ref as "truth"'],
		[[%ok, test => \'x'], qr/^concordance: "test" must be a file name, not a SCALAR ref/, 'a scalar ref as "test"'],
		[[%ok, test => $none], qr/^concordance: "test" file "\Q$none\E" doesn't exist or isn't readable/, 'a test that is not there'],
		[[%ok, truth => $dir], qr/^concordance: "truth" file ".+" doesn't exist or isn't readable/, 'a directory as "truth"'],
		[[%ok, truth => spew('conc.bcf', '')], qr/^concordance: "truth" file .+conc\.bcf must end in \.vcf, \.vcf\.gz, \.vcf\.bgz or \.vcf\.bz2/, 'a BCF'],
		[[%ok, min_depth => -1], qr/^concordance: "min_depth" must be a whole number, 0 or more, not "-1"/, 'min_depth -1'],
		[[%ok, min_depth => 7.5], qr/^concordance: "min_depth" must be a whole number, 0 or more, not "7\.5"/, 'min_depth 7.5'],
		[[%ok, min_depth => [7]], qr/^concordance: "min_depth" must be a whole number, 0 or more, not an ARRAY ref/, 'min_depth an array ref'],
		[[%ok, discordances => 2], qr/^concordance: "discordances" must be 0 or 1, not "2"/, 'discordances 2'],
		[[%ok, discordances => 'yes'], qr/^concordance: "discordances" must be 0 or 1, not "yes"/, 'discordances "yes"'],
		[[%ok, report => 'yes'], qr/^concordance: "report" must be 0 or 1, not "yes"/, 'report "yes"'],
	);
	foreach my $c (@cases) {
		my ($args, $re, $name) = @{ $c };
		dies_like sub { concordance(@{ $args }) }, $re, "concordance: $name dies";
	}
}

#  plot_msa 



( run in 1.791 second using v1.01-cache-2.11-cpan-60884a8df76 )