Skip to content

Commit

Permalink
Add genodsp (#51488)
Browse files Browse the repository at this point in the history
* adding genodsp -- General workbench for processing signals along genomic intervals

* adding run_exports

* sentralized safe_strncpy, using install

* forcing null-termination of string

* added rependency on stdlib('c')

* adding license_file

* Update meta.yaml

* Update recipes/genodsp/meta.yaml

* removing hardcoded gcc in the Makefile

* updating safe_strncpy

---------

Co-authored-by: Richard C. Burhans <[email protected]>
Co-authored-by: Björn Grüning <[email protected]>
  • Loading branch information
3 people authored Oct 22, 2024
1 parent 09c5347 commit b3727f2
Show file tree
Hide file tree
Showing 3 changed files with 232 additions and 0 deletions.
11 changes: 11 additions & 0 deletions recipes/genodsp/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash -e
set -uex

mkdir -vp "${PREFIX}/bin"

make VERBOSE=1 -j ${CPU_COUNT}

if ! install -v "$SRC_DIR/genodsp" "$PREFIX/bin/genodsp"; then
echo "Failed to install genodsp binary" >&2
exit 1
fi
36 changes: 36 additions & 0 deletions recipes/genodsp/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{% set name = "genodsp" %}
{% set version = "0.0.3" %}

package:
name: {{ name|lower }}
version: {{ version }}

source:
url: https://github.com/rsharris/genodsp/archive/refs/tags/v{{ version }}+.zip
sha256: a7fb2218311d1ae5231041863d28adb8b5fffe724fc5ff2422310ce90a9f894a
patches:
- stringop-truncation.patch

requirements:
build:
- {{ compiler('c') }}
- make

build:
number: 0
skip: True # [not linux or not x86_64]
run_exports:
- {{ pin_subpackage('genodsp', max_pin="x.x") }}

test:
commands:
- genodsp --help
- ls -l ${PREFIX}/bin/
- ${PREFIX}/bin/genodsp --help

about:
home: https://github.com/rsharris/genodsp
summary: General workbench for processing signals along genomic (chromosomal) intervals
license: GPL-3.0-only
license_file: LICENSE
license_url: https://github.com/rsharris/genodsp/blob/master/LICENSE
185 changes: 185 additions & 0 deletions recipes/genodsp/stringop-truncation.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
diff --git a/Makefile b/Makefile
index cf07368..d1dfb95 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,4 @@
CFLAGS = -O3 -Wall -Wextra -Werror
-CC = gcc
LDLIBS = -lm

operators = sum clump percentile add multiply mask logical minmax morphology map opio variables
diff --git a/add.c b/add.c
index 752dd5d..8fa4bad 100644
--- a/add.c
+++ b/add.c
@@ -240,7 +240,7 @@ void op_add_apply
v = NULL;
chromSpec = find_chromosome_spec (chrom);
if (chromSpec != NULL) v = chromSpec->valVector;
- strncpy (prevChrom, chrom, sizeof(prevChrom));
+ safe_strncpy (prevChrom, chrom, sizeof(prevChrom));
}

if (chromSpec == NULL) continue;
@@ -533,7 +533,7 @@ void op_subtract_apply
v = NULL;
chromSpec = find_chromosome_spec (chrom);
if (chromSpec != NULL) v = chromSpec->valVector;
- strncpy (prevChrom, chrom, sizeof(prevChrom));
+ safe_strncpy (prevChrom, chrom, sizeof(prevChrom));
}

if (chromSpec == NULL) continue;
diff --git a/genodsp.c b/genodsp.c
index ac1704e..dffd622 100644
--- a/genodsp.c
+++ b/genodsp.c
@@ -1229,7 +1229,7 @@ void read_intervals
v = NULL;
chromSpec = find_chromosome_spec (chrom);
if (chromSpec != NULL) v = chromSpec->valVector;
- strncpy (prevChrom, chrom, sizeof(prevChrom));
+ safe_strncpy (prevChrom, chrom, sizeof(prevChrom));
}

if (chromSpec == NULL) continue;
diff --git a/logical.c b/logical.c
index fb295e3..45e1c20 100644
--- a/logical.c
+++ b/logical.c
@@ -497,7 +497,7 @@ void op_or_apply
v = NULL;
chromSpec = find_chromosome_spec (chrom);
if (chromSpec != NULL) v = chromSpec->valVector;
- strncpy (prevChrom, chrom, sizeof(prevChrom));
+ safe_strncpy (prevChrom, chrom, sizeof(prevChrom));
}

if (chromSpec == NULL) continue;
@@ -810,7 +810,7 @@ void op_and_apply
if (chromSpec->flag) goto chrom_not_together;
}

- strncpy (prevChrom, chrom, sizeof(prevChrom));
+ safe_strncpy (prevChrom, chrom, sizeof(prevChrom));
}

// if the current chromosome is not of any interest, ignore this
diff --git a/mask.c b/mask.c
index 4fd5ebd..ddd068e 100644
--- a/mask.c
+++ b/mask.c
@@ -253,7 +253,7 @@ void op_mask_apply
v = NULL;
chromSpec = find_chromosome_spec (chrom);
if (chromSpec != NULL) v = chromSpec->valVector;
- strncpy (prevChrom, chrom, sizeof(prevChrom));
+ safe_strncpy (prevChrom, chrom, sizeof(prevChrom));
}

if (chromSpec == NULL) continue;
@@ -548,7 +548,7 @@ void op_mask_not_apply
if (chromSpec->flag) goto chrom_not_together;
}

- strncpy (prevChrom, chrom, sizeof(prevChrom));
+ safe_strncpy (prevChrom, chrom, sizeof(prevChrom));
}

// if the current chromosome is not of any interest, ignore this
diff --git a/minmax.c b/minmax.c
index c222bd0..eae69ab 100644
--- a/minmax.c
+++ b/minmax.c
@@ -261,7 +261,7 @@ void op_min_in_interval_apply
if (chromSpec->flag) goto chrom_not_together;
}

- strncpy (prevChrom, chrom, sizeof(prevChrom));
+ safe_strncpy (prevChrom, chrom, sizeof(prevChrom));
}

// if the current chromosome is not of any interest, ignore this
@@ -664,7 +664,7 @@ void op_max_in_interval_apply
if (chromSpec->flag) goto chrom_not_together;
}

- strncpy (prevChrom, chrom, sizeof(prevChrom));
+ safe_strncpy (prevChrom, chrom, sizeof(prevChrom));
}

// if the current chromosome is not of any interest, ignore this
@@ -1941,7 +1941,7 @@ void op_min_with_apply
v = NULL;
chromSpec = find_chromosome_spec (chrom);
if (chromSpec != NULL) v = chromSpec->valVector;
- strncpy (prevChrom, chrom, sizeof(prevChrom));
+ safe_strncpy (prevChrom, chrom, sizeof(prevChrom));
}

if (chromSpec == NULL) continue;
@@ -2227,7 +2227,7 @@ void op_max_with_apply
v = NULL;
chromSpec = find_chromosome_spec (chrom);
if (chromSpec != NULL) v = chromSpec->valVector;
- strncpy (prevChrom, chrom, sizeof(prevChrom));
+ safe_strncpy (prevChrom, chrom, sizeof(prevChrom));
}

if (chromSpec == NULL) continue;
diff --git a/multiply.c b/multiply.c
index 4c1b550..d04cc41 100644
--- a/multiply.c
+++ b/multiply.c
@@ -260,7 +260,7 @@ void op_multiply_apply
if (chromSpec->flag) goto chrom_not_together;
}

- strncpy (prevChrom, chrom, sizeof(prevChrom));
+ safe_strncpy (prevChrom, chrom, sizeof(prevChrom));
}

// if the current chromosome is not of any interest, ignore this
@@ -654,7 +654,7 @@ void op_divide_apply
if (chromSpec->flag) goto chrom_not_together;
}

- strncpy (prevChrom, chrom, sizeof(prevChrom));
+ safe_strncpy (prevChrom, chrom, sizeof(prevChrom));
}

// if the current chromosome is not of any interest, ignore this
diff --git a/utilities.c b/utilities.c
index 03d2ff1..3157538 100644
--- a/utilities.c
+++ b/utilities.c
@@ -493,3 +493,16 @@ char* ucommatize
return s;
}

+//
+void safe_strncpy
+ (char *dest, const char *src, size_t n)
+ {
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wstringop-truncation"
+ strncpy(dest, src, n);
+ #pragma GCC diagnostic pop
+ if (n > 0)
+ {
+ dest[n-1] = '\0'; // Ensure null-termination
+ }
+ }
diff --git a/utilities.h b/utilities.h
index ac9cef7..87cfc2d 100644
--- a/utilities.h
+++ b/utilities.h
@@ -31,6 +31,8 @@ char* skip_whitespace (char* s);
char* skip_darkspace (char* s);
char* duration_to_string (float seconds);
char* ucommatize (const u32 v);
+void safe_strncpy (char *dest, const char *src, size_t n);
+

// miscellany

0 comments on commit b3727f2

Please sign in to comment.