When num_pos and num_total is relatively small, e.g. (5 replicates, 20 negcon), total combinations is 4845. Here, instead of building null_size=10,000 random ranks, p_val should be estimated by computing the 4,845 average precision scores.
In general, if math.comb(num_total, num_pos)<null_size then we should use exact p-value computation.