From nobody Thu Jan 13 19:00:43 2022 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8D72519675B1; Thu, 13 Jan 2022 19:00:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JZYfg1xDhz3pX2; Thu, 13 Jan 2022 19:00:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642100443; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=way8DKMMbsWmGgbR+S2q53ZUSAuHdWJ/f7cCAR7wFcQ=; b=xmLUias1uzFvslThTnb0vQS1td3u4tT+Kx7wk6wD93FiNAXN2J+xkLuQi+NoozcZfGREuu KNZqqS90emRrSFgl/K9277OY7JWtCjjAKzEgbNPoGT01qt7mxIYtqonjCniRKhUj3iv0O9 CHGfiwAXv9x8gMNhsuhEAFUVL2os3gxmylBbKvpxwByVKexHLKX9B9jhmHrrl0WNdsOyv6 2dMcINa0FQvltXS+6cX9JmlZ6iYygt7U7ivURBoQ5pWCOZLLNvZ54Es9esJ4Tx2mvz85uT I6ZwbudAwv3DBS1dGb9TOLGdCmkS82h6P20+Laz6qvQdzuPGNPOkoHgZrx0yOg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1BA3B25957; Thu, 13 Jan 2022 19:00:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20DJ0hbg039568; Thu, 13 Jan 2022 19:00:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20DJ0hfU039567; Thu, 13 Jan 2022 19:00:43 GMT (envelope-from git) Date: Thu, 13 Jan 2022 19:00:43 GMT Message-Id: <202201131900.20DJ0hfU039567@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: "Jason W. Bacon" Subject: git: e33f72037a79 - main - biology/bio-mocha: Update to 1.14-20220112 List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jwb X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e33f72037a797431e5c4d89d1d222c5d5d92eb27 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642100443; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=way8DKMMbsWmGgbR+S2q53ZUSAuHdWJ/f7cCAR7wFcQ=; b=qLNIUpte26cV5exevfMqd8GtuvA6sdHN+4JaZbT4WJ617IjJ/uraqRmrbK3DvS0oW3Rjdf WZT69mod6AdASRUUTEcWnJuEyv7vfTgJs0M7s3E7a0ENUQ5R/ki93Lw7t5XO2BpmrSQ1Cd 1wiIX86qe4UW6109YnH6crwDbzAxm8xatiiT7rCMeYNVr6oMjrOl4bB0P30ql9HnjQCqdY 5m8gRf2T67AqZFOOeTUkihiUWOPGnoYL5Mvw+qFer6hZx8frjT8drPza6wekHm4bjRcLMI Glp3bO17ZkkjWIy2kw5Lyw9UNyUk/J95CCc7BLUx5CzuvPhX1mOzL8xQLrIKiQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642100443; a=rsa-sha256; cv=none; b=iHeU61m+FEYSqbNIR0Hcc3GFhR2UECyVuLVrEdZV0E49HC0tK0HrjwImnyn1FNrrD/MuWA YQFTlXicthGVjnM/FuEI7A3MBbJm21mxR1aaJ94pjL60xzx9o7W3T++OXPTlpIYuDrMIuw 2K+24VPAFlRfTNkgGKxwy7jnuKIO16oGaqjBUQIakH6v36uTI7/eRqsDTAy6Ze5hYk/inX mM83v76YlCfxxKf/uW+wtHuPlnjOAJ6gBRNZBVE2UdER7VEHlEfhTb7TCirA0Qw4zpdxmO HOOFdLjRF7JARTuF/sfJ29kh2NIndubr8tYsBIvJr5+sjR4Mcwr/AhXDYuZjqw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jwb: URL: https://cgit.FreeBSD.org/ports/commit/?id=e33f72037a797431e5c4d89d1d222c5d5d92eb27 commit e33f72037a797431e5c4d89d1d222c5d5d92eb27 Author: Jason W. Bacon AuthorDate: 2022-01-13 18:58:35 +0000 Commit: Jason W. Bacon CommitDate: 2022-01-13 19:00:41 +0000 biology/bio-mocha: Update to 1.14-20220112 Upstream incorporated my patches to eliminate nested functions, which are not standard C and pose security risks. A few other minor updated. --- biology/bio-mocha/Makefile | 5 +- biology/bio-mocha/distinfo | 10 +- .../bio-mocha/files/patch-plugins_beta__binom.h | 19 - biology/bio-mocha/files/patch-plugins_mocha.c | 479 --------------------- biology/bio-mocha/pkg-plist | 2 +- 5 files changed, 8 insertions(+), 507 deletions(-) diff --git a/biology/bio-mocha/Makefile b/biology/bio-mocha/Makefile index ec134d0530bb..f7191a9f286b 100644 --- a/biology/bio-mocha/Makefile +++ b/biology/bio-mocha/Makefile @@ -1,9 +1,8 @@ PORTNAME= bio-mocha -DISTVERSION= 1.13 -PORTREVISION= 1 +DISTVERSION= 1.14 CATEGORIES= biology MASTER_SITES= https://software.broadinstitute.org/software/mocha/ -DISTFILES+= ${PORTNAME}_${DISTVERSION}-20211015.tar.gz +DISTFILES+= ${PORTNAME}_${DISTVERSION}-20220112.tar.gz MAINTAINER= jwb@FreeBSD.org COMMENT= Bcftools plugin for mosaic chromosomal alteration analysis diff --git a/biology/bio-mocha/distinfo b/biology/bio-mocha/distinfo index ee4554ecbe66..392157da945c 100644 --- a/biology/bio-mocha/distinfo +++ b/biology/bio-mocha/distinfo @@ -1,5 +1,5 @@ -TIMESTAMP = 1640100283 -SHA256 (bio-mocha_1.13-20211015.tar.gz) = e145bb48fea347202e16395ab7d78e7e7314749b8d472a2071f8074004cd63a5 -SIZE (bio-mocha_1.13-20211015.tar.gz) = 73627 -SHA256 (samtools-bcftools-1.13-1.14_GH0.tar.gz) = c9a814b1f0a13af19b45283f039d01b524e011d870ac95cd92e6907c3d1db6d1 -SIZE (samtools-bcftools-1.13-1.14_GH0.tar.gz) = 3326994 +TIMESTAMP = 1642078792 +SHA256 (bio-mocha_1.14-20220112.tar.gz) = 189a522418f12cbb04e6c5ccae130dbae1682907808f4cb594af4ff386651068 +SIZE (bio-mocha_1.14-20220112.tar.gz) = 75910 +SHA256 (samtools-bcftools-1.14_GH0.tar.gz) = c9a814b1f0a13af19b45283f039d01b524e011d870ac95cd92e6907c3d1db6d1 +SIZE (samtools-bcftools-1.14_GH0.tar.gz) = 3326994 diff --git a/biology/bio-mocha/files/patch-plugins_beta__binom.h b/biology/bio-mocha/files/patch-plugins_beta__binom.h deleted file mode 100644 index a6804a6dc9f4..000000000000 --- a/biology/bio-mocha/files/patch-plugins_beta__binom.h +++ /dev/null @@ -1,19 +0,0 @@ ---- plugins/beta_binom.h.orig 2021-11-30 13:41:36 UTC -+++ plugins/beta_binom.h -@@ -137,14 +137,14 @@ void beta_binom_update(beta_binom_t *self, double p, d - * Returns the equivalent of dbeta_binom(a, a+b, p, (1 - rho) / rho, log=TRUE) from R package - * rmutil - */ --inline double beta_binom_log_unsafe(const beta_binom_t *self, int a, int b) { -+static inline double beta_binom_log_unsafe(const beta_binom_t *self, int a, int b) { - return self->log_gamma_alpha[a] + self->log_gamma_beta[b] - self->log_gamma_alpha_beta[a + b]; - } - - /** - * Same as before but it performs boundary checking before computing the log likelihood - */ --inline double beta_binom_log(beta_binom_t *self, int a, int b) { -+static inline double beta_binom_log(beta_binom_t *self, int a, int b) { - if (a < 0 || b < 0) return NAN; - if (a > self->n1 || b > self->n1 || a + b > self->n2) - beta_binom_update(self, self->p, self->rho, a > b ? a : b, a + b); diff --git a/biology/bio-mocha/files/patch-plugins_mocha.c b/biology/bio-mocha/files/patch-plugins_mocha.c deleted file mode 100644 index 665d785c00f3..000000000000 --- a/biology/bio-mocha/files/patch-plugins_mocha.c +++ /dev/null @@ -1,479 +0,0 @@ ---- plugins/mocha.c.orig 2021-10-15 02:37:57 UTC -+++ plugins/mocha.c -@@ -705,6 +705,44 @@ static double baf_phase_lod(const float *baf_arr, cons - return (double)ret * M_LOG10E; - } - -+typedef struct -+{ -+ const float *baf; -+ const int8_t *gt_phase; -+ int n; -+ const int *imap; -+ int8_t *path; -+ float err_log_prb; -+ float baf_sd; -+} f1_data_t; -+ -+double f1(double x, void *data) -+{ -+ f1_data_t *d = data; -+ -+ return -baf_phase_lod(d->baf, d->gt_phase, d->n, d->imap, d->path, -+ d->err_log_prb, d->baf_sd, x); -+} -+ -+static inline f1_data_t *f1_pack(const float *baf, const int8_t *gt_phase, int n, -+ const int *imap, int8_t *path, float err_log_prb, -+ float baf_sd) -+{ -+ // Switch to malloc() and free() if more than one object must exist at -+ // any given time -+ f1_data_t *d = malloc(sizeof(f1_data_t)); -+ -+ d->baf = baf; -+ d->gt_phase = gt_phase; -+ d->n = n; -+ d->imap = imap; -+ d->path = path; -+ d->err_log_prb = err_log_prb; -+ d->baf_sd = baf_sd; -+ -+ return d; -+} -+ - // TODO find a better title for this function - static float compare_models(const float *baf, const int8_t *gt_phase, int n, const int *imap, float xy_log_prb, - float err_log_prb, float flip_log_prb, float tel_log_prb, float baf_sd, const float *bdev, -@@ -716,8 +754,11 @@ static float compare_models(const float *baf, const in - int n_flips = 0; - for (int i = 1; i < n; i++) - if (path[i - 1] && path[i] && path[i - 1] != path[i]) n_flips++; -- double f(double x, void *data) { return -baf_phase_lod(baf, gt_phase, n, imap, path, err_log_prb, baf_sd, x); } -- double x, fx = kmin_brent(f, 0.1, 0.2, NULL, KMIN_EPS, &x); -+ double x; -+ f1_data_t *f1_data = f1_pack(baf, gt_phase, n, imap, path, err_log_prb, -+ baf_sd); -+ double fx = kmin_brent(f1, 0.1, 0.2, f1_data, KMIN_EPS, &x); -+ free(f1_data); - free(path); - return -(float)fx + (float)n_flips * flip_log_prb * (float)M_LOG10E; - } -@@ -750,6 +791,34 @@ static float get_sample_mean(const float *v, int n, co - return mean /= (float)j; - } - -+typedef struct -+{ -+ const float *baf_arr; -+ int n; -+ const int *imap; -+ float baf_sd; -+} f7_data_t; -+ -+double f7(double x, void *data) -+{ -+ f7_data_t *d = data; -+ -+ return -baf_log_lkl(d->baf_arr, d->n, d->imap, d->baf_sd, x); -+} -+ -+static inline f7_data_t *f7_pack(const float *baf_arr, int n, const int *imap, -+ float baf_sd) -+{ -+ f7_data_t *d = malloc(sizeof(f7_data_t)); -+ -+ d->baf_arr = baf_arr; -+ d->n = n; -+ d->imap = imap; -+ d->baf_sd = baf_sd; -+ -+ return d; -+} -+ - static float get_baf_bdev(const float *baf_arr, int n, const int *imap, float baf_sd) { - double bdev = 0.0; - int j = 0; -@@ -763,8 +832,9 @@ static float get_baf_bdev(const float *baf_arr, int n, - bdev /= j; - // simple method to compute bdev should work well for germline duplications - if ((float)bdev > 2.0f * baf_sd) return (float)bdev; -- double f(double x, void *data) { return -baf_log_lkl(baf_arr, n, imap, baf_sd, x); } -- kmin_brent(f, 0.1, 0.2, NULL, KMIN_EPS, &bdev); -+ f7_data_t *f7_data = f7_pack(baf_arr, n, imap, baf_sd); -+ kmin_brent(f7, 0.1, 0.2, f7_data, KMIN_EPS, &bdev); -+ free(f7_data); - return (float)bdev < 1e-4 ? (float)NAN : (float)bdev; - } - -@@ -801,10 +871,41 @@ static double ad_log_lkl(const int16_t *ad0_arr, const - return (double)ret * M_LOG10E; - } - -+typedef struct -+{ -+ const int16_t *ad0_arr; -+ const int16_t *ad1_arr; -+ int n; -+ const int *imap; -+ float ad_rho; -+} f5_data_t; -+ -+double f5(double x, void *data) -+{ -+ f5_data_t *d = data; -+ -+ return -ad_log_lkl(d->ad0_arr, d->ad1_arr, d->n, d->imap, d->ad_rho, x); -+} -+ -+static inline f5_data_t *f5_pack(const int16_t *ad0_arr, -+ const int16_t *ad1_arr, int n, const int *imap, float ad_rho) -+{ -+ f5_data_t *d = malloc(sizeof(f5_data_t)); -+ -+ d->ad0_arr = ad0_arr; -+ d->ad1_arr = ad1_arr; -+ d->n = n; -+ d->imap = imap; -+ d->ad_rho = ad_rho; -+ -+ return d; -+} -+ - static float get_ad_bdev(const int16_t *ad0_arr, const int16_t *ad1_arr, int n, const int *imap, float ad_rho) { - double bdev = 0.0; -- double f(double x, void *data) { return -ad_log_lkl(ad0_arr, ad1_arr, n, imap, ad_rho, x); } -- kmin_brent(f, 0.1, 0.2, NULL, KMIN_EPS, &bdev); -+ f5_data_t *f5_data = f5_pack(ad0_arr, ad1_arr, n, imap, ad_rho); -+ kmin_brent(f5, 0.1, 0.2, f5_data, KMIN_EPS, &bdev); -+ free(f5_data); - return (float)bdev < 1e-4 ? (float)NAN : (float)bdev; - } - -@@ -986,6 +1087,44 @@ static double ad_phase_lod(const int16_t *ad0_arr, con - return (double)ret * M_LOG10E; - } - -+typedef struct -+{ -+ const int16_t *ad0; -+ const int16_t *ad1; -+ const int8_t *gt_phase; -+ int n; -+ const int *imap; -+ int8_t *path; -+ float err_log_prb; -+ float ad_rho; -+} f4_data_t; -+ -+double f4(double x, void *data) -+{ -+ f4_data_t *d = data; -+ -+ return -ad_phase_lod(d->ad0, d->ad1, d->gt_phase, d->n, d->imap, d->path, -+ d->err_log_prb, d->ad_rho, x); -+} -+ -+static inline f4_data_t *f4_pack(const int16_t *ad0, const int16_t *ad1, -+ const int8_t *gt_phase, int n, const int *imap, int8_t *path, -+ float err_log_prb, float ad_rho) -+{ -+ f4_data_t *d = malloc(sizeof(f4_data_t)); -+ -+ d->ad0 = ad0; -+ d->ad1 = ad1; -+ d->gt_phase = gt_phase; -+ d->n = n; -+ d->imap = imap; -+ d->path = path; -+ d->err_log_prb = err_log_prb; -+ d->ad_rho = ad_rho; -+ -+ return d; -+} -+ - // TODO find a better title for this function - static float compare_wgs_models(const int16_t *ad0, const int16_t *ad1, const int8_t *gt_phase, int n, const int *imap, - float xy_log_prb, float err_log_prb, float flip_log_prb, float tel_log_prb, -@@ -998,8 +1137,9 @@ static float compare_wgs_models(const int16_t *ad0, co - int n_flips = 0; - for (int i = 1; i < n; i++) - if (path[i - 1] && path[i] && path[i - 1] != path[i]) n_flips++; -- double f(double x, void *data) { return -ad_phase_lod(ad0, ad1, gt_phase, n, imap, path, err_log_prb, ad_rho, x); } -- double x, fx = kmin_brent(f, 0.1, 0.2, NULL, KMIN_EPS, &x); -+ f4_data_t *f4_data = f4_pack(ad0, ad1, gt_phase, n, imap, path, err_log_prb, ad_rho); -+ double x, fx = kmin_brent(f4, 0.1, 0.2, f4_data, KMIN_EPS, &x); -+ free(f4_data); - free(path); - return -(float)fx + (float)n_flips * flip_log_prb * (float)M_LOG10E; - } -@@ -1485,6 +1625,129 @@ static float get_path_segs(const int8_t *path, const f - return 0; - } - -+typedef struct -+{ -+ float *lrr; -+ int a; -+ int16_t *ad0; -+ int16_t *ad1; -+ mocha_t *mocha; -+ const model_t *model; -+ sample_t *self; -+ float *baf; -+} f3_data_t; -+ -+double f3(double x, void *data) -+{ -+ f3_data_t *d = data; -+ -+ if (d->model->flags & WGS_DATA) -+ return -lrr_ad_lod(d->lrr + d->a, d->ad0 + d->a, d->ad1 + d->a, -+ d->mocha->n_sites, NULL, NAN, d->model->lrr_bias, -+ d->model->lrr_hap2dip, d->self->adjlrr_sd, -+ d->self->stats.dispersion, x); -+ else -+ return -lrr_baf_lod(d->lrr + d->a, d->baf + d->a, d->mocha->n_sites, -+ NULL, NAN, d->model->lrr_bias, d->model->lrr_hap2dip, -+ d->self->adjlrr_sd, d->self->stats.dispersion, x); -+} -+ -+static inline f3_data_t *f3_pack(float *lrr, int a, int16_t *ad0, int16_t *ad1, -+ mocha_t *mocha, const model_t *model, sample_t *self, float *baf) -+ -+{ -+ f3_data_t *d = malloc(sizeof(f3_data_t)); -+ -+ d->lrr = lrr; -+ d->a = a; -+ d->ad0 = ad0; -+ d->ad1 = ad1; -+ d->mocha = mocha; -+ d->model = model; -+ d->self = self; -+ d->baf = baf; -+ -+ return d; -+} -+ -+typedef struct -+{ -+ int16_t *ad0; -+ int16_t *ad1; -+ int8_t *gt_phase; -+ mocha_t *mocha; -+ int *imap_arr; -+ int *beg; -+ int i; -+ int8_t *path; -+ sample_t *self; -+} f6_data_t; -+ -+double f6(double x, void *data) -+{ -+ f6_data_t *d = data; -+ -+ return -ad_phase_lod(d->ad0, d->ad1, d->gt_phase, d->mocha->n_hets, -+ d->imap_arr + d->beg[d->i], d->path + d->beg[d->i], NAN, d->self->stats.dispersion, x); -+} -+ -+static inline f6_data_t *f6_pack(int16_t *ad0, int16_t *ad1, int8_t *gt_phase, -+ mocha_t *mocha, int *imap_arr, int *beg, int i, int8_t *path, sample_t *self) -+ -+{ -+ f6_data_t *d = malloc(sizeof(f6_data_t)); -+ -+ d->ad0 = ad0; -+ d->ad1 = ad1; -+ d->gt_phase = gt_phase; -+ d->mocha = mocha; -+ d->imap_arr = imap_arr; -+ d->beg = beg; -+ d->i = i; -+ d->path = path; -+ d->self = self; -+ -+ return d; -+} -+ -+typedef struct -+{ -+ float *baf; -+ int8_t *gt_phase; -+ mocha_t *mocha; -+ int *imap_arr; -+ int *beg; -+ int i; -+ int8_t *path; -+ sample_t *self; -+} f8_data_t; -+ -+double f8(double x, void *data) -+{ -+ f8_data_t *d = data; -+ -+ return -baf_phase_lod(d->baf, d->gt_phase, d->mocha->n_hets, -+ d->imap_arr + d->beg[d->i], d->path + d->beg[d->i], NAN, -+ d->self->stats.dispersion, x); -+} -+ -+static inline f8_data_t *f8_pack(float *baf, int8_t *gt_phase, mocha_t *mocha, -+ int *imap_arr, int *beg, int i, int8_t *path, sample_t *self) -+{ -+ f8_data_t *d = malloc(sizeof(f8_data_t)); -+ -+ d->baf = baf; -+ d->gt_phase = gt_phase; -+ d->mocha = mocha; -+ d->imap_arr = imap_arr; -+ d->beg = beg; -+ d->i = i; -+ d->path = path; -+ d->self = self; -+ -+ return d; -+} -+ - // process one contig for one sample - static void sample_run(sample_t *self, mocha_table_t *mocha_table, const model_t *model) { - // do nothing if chromosome Y or MT are being tested -@@ -1735,16 +1998,11 @@ static void sample_run(sample_t *self, mocha_table_t * - mocha.ldev = get_median(lrr + a, b + 1 - a, NULL); - get_mocha_stats(pos, lrr, baf, gt_phase, n, a, b, cen_beg, cen_end, length, self->stats.baf_conc, &mocha); - -- double f(double x, void *data) { -- if (model->flags & WGS_DATA) -- return -lrr_ad_lod(lrr + a, ad0 + a, ad1 + a, mocha.n_sites, NULL, NAN, model->lrr_bias, -- model->lrr_hap2dip, self->adjlrr_sd, self->stats.dispersion, x); -- else -- return -lrr_baf_lod(lrr + a, baf + a, mocha.n_sites, NULL, NAN, model->lrr_bias, model->lrr_hap2dip, -- self->adjlrr_sd, self->stats.dispersion, x); -- } - double bdev_lrr_baf; -- kmin_brent(f, -0.15, 0.15, NULL, KMIN_EPS, &bdev_lrr_baf); -+ f3_data_t *f3_data = f3_pack(lrr, a, ad0, ad1, &mocha, model, -+ self, baf); -+ kmin_brent(f3, -0.15, 0.15, f3_data, KMIN_EPS, &bdev_lrr_baf); -+ free(f3_data); - if (model->flags & WGS_DATA) - mocha.lod_lrr_baf = - lrr_ad_lod(lrr + a, ad0 + a, ad1 + a, mocha.n_sites, NULL, model->err_log_prb, model->lrr_bias, -@@ -1796,23 +2054,21 @@ static void sample_run(sample_t *self, mocha_table_t * - if (path[j] != path[j + 1]) mocha.n_flips++; - - if (model->flags & WGS_DATA) { -- double f(double x, void *data) { -- return -ad_phase_lod(ad0, ad1, gt_phase, mocha.n_hets, imap_arr + beg[i], path + beg[i], NAN, -- self->stats.dispersion, x); -- } - double bdev; -- kmin_brent(f, 0.1, 0.2, NULL, KMIN_EPS, &bdev); -+ f6_data_t *f6_data = f6_pack(ad0, ad1, gt_phase, &mocha, -+ imap_arr, beg, i, path, self); -+ kmin_brent(f6, 0.1, 0.2, f6_data, KMIN_EPS, &bdev); -+ free(f6_data); - mocha.bdev = fabsf((float)bdev); - mocha.lod_baf_phase = - ad_phase_lod(ad0, ad1, gt_phase, mocha.n_hets, imap_arr + beg[i], path + beg[i], - model->err_log_prb, self->stats.dispersion, mocha.bdev); - } else { -- double f(double x, void *data) { -- return -baf_phase_lod(baf, gt_phase, mocha.n_hets, imap_arr + beg[i], path + beg[i], NAN, -- self->stats.dispersion, x); -- } - double bdev; -- kmin_brent(f, 0.1, 0.2, NULL, KMIN_EPS, &bdev); -+ f8_data_t *f8_data = f8_pack(baf, gt_phase, &mocha, -+ imap_arr, beg, i, path, self); -+ kmin_brent(f8, 0.1, 0.2, f8_data, KMIN_EPS, &bdev); -+ free(f8_data); - mocha.bdev = fabsf((float)bdev); - mocha.lod_baf_phase = baf_phase_lod(baf, gt_phase, mocha.n_hets, imap_arr + beg[i], path + beg[i], - model->err_log_prb, self->stats.dispersion, mocha.bdev); -@@ -1923,6 +2179,60 @@ static float get_lrr_cutoff(const float *v, int n) { - return cutoff; - } - -+typedef struct -+{ -+ int16_t *ad0; -+ int16_t *ad1; -+ int n; -+} f2_data_t; -+ -+double f2(double x, void *data) -+{ -+ f2_data_t *d = data; -+ -+ return -lod_lkl_beta_binomial(d->ad0, d->ad1, d->n, NULL, x); -+} -+ -+static inline f2_data_t *f2_pack(int16_t *ad0, int16_t *ad1, int n) -+ -+{ -+ f2_data_t *d = malloc(sizeof(f2_data_t)); -+ -+ d->ad0 = ad0; -+ d->ad1 = ad1; -+ d->n = n; -+ -+ return d; -+} -+ -+typedef struct -+{ -+ int16_t *ad0; -+ int16_t *ad1; -+ int n_imap; -+ int *imap_arr; -+} f9_data_t; -+ -+double f9(double x, void *data) -+{ -+ f9_data_t *d = data; -+ -+ return -lod_lkl_beta_binomial(d->ad0, d->ad1, d->n_imap, d->imap_arr, x); -+} -+ -+static inline f9_data_t *f9_pack(int16_t *ad0, int16_t *ad1, int n_imap, -+ int *imap_arr) -+{ -+ f9_data_t *d = malloc(sizeof(f9_data_t)); -+ -+ d->ad0 = ad0; -+ d->ad1 = ad1; -+ d->n_imap = n_imap; -+ d->imap_arr = imap_arr; -+ -+ return d; -+} -+ - // this function computes several contig stats and then clears the contig data from the sample - static void sample_stats(sample_t *self, const model_t *model) { - int n = self->n; -@@ -1968,9 +2278,10 @@ static void sample_stats(sample_t *self, const model_t - self->x_nonpar_lrr_median = get_median(lrr, n_imap, imap_arr); - - if (model->flags & WGS_DATA) { -- double f(double x, void *data) { return -lod_lkl_beta_binomial(ad0, ad1, n_imap, imap_arr, x); } -+ f9_data_t *f9_data = f9_pack(ad0, ad1, n_imap, imap_arr); - double x; -- kmin_brent(f, 0.1, 0.2, NULL, KMIN_EPS, &x); // dispersions above 0.5 are not allowed -+ kmin_brent(f9, 0.1, 0.2, f9_data, KMIN_EPS, &x); // dispersions above 0.5 are not allowed -+ free(f9_data); - self->x_nonpar_dispersion = (float)x; - } else { - self->x_nonpar_dispersion = get_sample_sd(baf, n_imap, imap_arr); -@@ -1995,9 +2306,10 @@ static void sample_stats(sample_t *self, const model_t - hts_expand(stats_t, self->n_stats, self->m_stats, self->stats_arr); - - if (model->flags & WGS_DATA) { -- double f(double x, void *data) { return -lod_lkl_beta_binomial(ad0, ad1, n, NULL, x); } - double x; -- kmin_brent(f, 0.1, 0.2, NULL, KMIN_EPS, &x); // dispersions above 0.5 are not allowed -+ f2_data_t *f2_data = f2_pack(ad0, ad1, n); -+ kmin_brent(f2, 0.1, 0.2, f2_data, KMIN_EPS, &x); // dispersions above 0.5 are not allowed -+ free(f2_data); - self->stats_arr[self->n_stats - 1].dispersion = (float)x; - } else { - self->stats_arr[self->n_stats - 1].dispersion = get_sample_sd(baf, n, NULL); diff --git a/biology/bio-mocha/pkg-plist b/biology/bio-mocha/pkg-plist index b7be082bf4e3..4604936e8e0f 100644 --- a/biology/bio-mocha/pkg-plist +++ b/biology/bio-mocha/pkg-plist @@ -3,7 +3,7 @@ libexec/bcftools/mocha.so libexec/bcftools/mochatools.so libexec/bcftools/score.so libexec/bcftools/trio-phase.so +%%DATADIR%%/assoc_plot.R %%DATADIR%%/mocha_plot.R %%DATADIR%%/pileup_plot.R -%%DATADIR%%/shift_plot.R %%DATADIR%%/summary_plot.R