Skip to content

Commit 96699cd

Browse files
authored
EdgeR: Long contrasts don't produce file names > 255 characters. (#7361)
* Long contrasts don't produce file names > 255 characters. * Remove whitelines
1 parent 76bd257 commit 96699cd

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

tools/edger/edger.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,17 @@ unmake_names <- function(string) {
8888
# Sanitise file base names coming from factors or contrasts
8989
sanitise_basename <- function(string) {
9090
string <- gsub("[/^]", "_", string)
91+
# If string is longer than 200 characters, truncate intelligently
92+
if (nchar(string) > 200) {
93+
# Keep first 80 characters, last 80 characters, and add hash in middle
94+
start_part <- substr(string, 1, 80)
95+
end_part <- substr(string, nchar(string) - 79, nchar(string))
96+
# Create a simple hash of the full string using built-in functions
97+
hash_input <- utf8ToInt(string)
98+
hash_value <- sum(hash_input * seq_along(hash_input)) %% 99999999
99+
hash_str <- sprintf("%08d", hash_value)
100+
string <- paste0(start_part, "_", hash_str, "_", end_part)
101+
}
91102
return(string)
92103
}
93104

tools/edger/edger.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</description>
55
<macros>
66
<token name="@TOOL_VERSION@">3.36.0</token>
7-
<token name="@VERSION_SUFFIX@">6</token>
7+
<token name="@VERSION_SUFFIX@">7</token>
88
</macros>
99
<edam_topics>
1010
<edam_topic>topic_3308</edam_topic>

0 commit comments

Comments
 (0)