Skip to content

Commit a00034d

Browse files
authored
Merge pull request #4 from refresh-bio/splash2.1.4
Splash2.1.4
2 parents 15719c9 + c353f3a commit a00034d

33 files changed

+1940
-373
lines changed

Makefile

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
all: satc satc_dump satc_merge sig_anch download_kmc nomad
1+
all: satc satc_dump satc_merge sig_anch download_kmc splash supervised_test
22

3-
NOMAD_LIBS_DIR = libs
3+
SPLASH_LIBS_DIR = libs
44
LIBS_DIR = . #/usr/local/lib
55
INCLUDE_DIR= libs
66
MIMALLOC_INLUCDE_DIR = libs/mimalloc/include
@@ -14,14 +14,16 @@ COMMON_DIR=src/common
1414
OUT_BIN_DIR=bin
1515

1616
CC = g++
17-
CFLAGS = -fPIC -Wall -O3 -m64 -std=c++17 -mavx -pthread -I $(INCLUDE_DIR) -I $(MIMALLOC_INLUCDE_DIR) -fpermissive
18-
CLINK = -lm -std=c++17 -lpthread -static-libstdc++ -lgfortran
17+
CFLAGS = -fPIC -Wall -O3 -m64 -std=c++17 -pthread -I $(INCLUDE_DIR) -I $(MIMALLOC_INLUCDE_DIR) -fpermissive
18+
CLINK = -lm -std=c++17 -lpthread -static-libstdc++
1919

20-
release: CLINK = -lm -std=c++17 -static -lgfortran -lquadmath -Wl,--whole-archive -lpthread -Wl,--no-whole-archive
21-
release: CFLAGS = -fPIC -Wall -O3 -DNDEBUG -m64 -std=c++17 -mavx -pthread -I $(INCLUDE_DIR) -I $(MIMALLOC_INLUCDE_DIR) -fpermissive
20+
MIMALLOC_OBJ=libs/mimalloc/mimalloc.o
21+
22+
release: CLINK = -lm -std=c++17 -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive
23+
release: CFLAGS = -fPIC -Wall -O3 -DNDEBUG -m64 -std=c++17 -pthread -I $(INCLUDE_DIR) -I $(MIMALLOC_INLUCDE_DIR) -fpermissive
2224
release: all
2325

24-
debug: CFLAGS = -fPIC -Wall -O0 -g -m64 -std=c++17 -mavx -pthread -I $(INCLUDE_DIR) -I $(MIMALLOC_INLUCDE_DIR) -fpermissive
26+
debug: CFLAGS = -fPIC -Wall -O0 -g -m64 -std=c++17 -pthread -I $(INCLUDE_DIR) -I $(MIMALLOC_INLUCDE_DIR) -fpermissive
2527
debug: all
2628

2729
ifdef MSVC # Avoid the MingW/Cygwin sections
@@ -47,18 +49,22 @@ prefix = /usr/local
4749
# optional install location
4850
exec_prefix = $(prefix)
4951

52+
$(MIMALLOC_OBJ):
53+
$(CC) -DMI_MALLOC_OVERRIDE -O3 -DNDEBUG -fPIC -Wall -Wextra -Wno-unknown-pragmas -fvisibility=hidden -ftls-model=initial-exec -fno-builtin-malloc -c -I libs/mimalloc/include libs/mimalloc/src/static.c -o $(MIMALLOC_OBJ)
54+
5055
%.o: %.cpp
5156
$(CC) $(CFLAGS) -c $< -o $@
5257

5358
satc: $(OUT_BIN_DIR)/satc
5459

5560
$(OUT_BIN_DIR)/satc: $(SATC_MAIN_DIR)/satc.o \
56-
$(SATC_MAIN_DIR)/kmc_api/kmc_file.o \
57-
$(SATC_MAIN_DIR)/kmc_api/mmer.o \
58-
$(SATC_MAIN_DIR)/kmc_api/kmer_api.o
61+
$(COMMON_DIR)/kmc_api/kmc_file.o \
62+
$(COMMON_DIR)/kmc_api/mmer.o \
63+
$(COMMON_DIR)/kmc_api/kmer_api.o \
64+
$(COMMON_DIR)/illumina_adapters_static.o
5965
-mkdir -p $(OUT_BIN_DIR)
6066
$(CC) -o $@ $^ \
61-
$(NOMAD_LIBS_DIR)/$(LIB_ZSTD) \
67+
$(SPLASH_LIBS_DIR)/$(LIB_ZSTD) \
6268
$(CLINK)
6369

6470
satc_merge: $(OUT_BIN_DIR)/satc_merge
@@ -69,15 +75,15 @@ $(OUT_BIN_DIR)/satc_merge: $(SATC_MERGE_MAIN_DIR)/satc_merge.o \
6975
$(SATC_MERGE_MAIN_DIR)/extra_stats.o
7076
-mkdir -p $(OUT_BIN_DIR)
7177
$(CC) -o $@ $^ \
72-
$(NOMAD_LIBS_DIR)/$(LIB_ZSTD) \
78+
$(SPLASH_LIBS_DIR)/$(LIB_ZSTD) \
7379
$(CLINK)
7480

7581
satc_dump: $(OUT_BIN_DIR)/satc_dump
7682

7783
$(OUT_BIN_DIR)/satc_dump: $(SATC_DUMP_MAIN_DIR)/satc_dump.o
7884
-mkdir -p $(OUT_BIN_DIR)
7985
$(CC) -o $@ $^ \
80-
$(NOMAD_LIBS_DIR)/$(LIB_ZSTD) \
86+
$(SPLASH_LIBS_DIR)/$(LIB_ZSTD) \
8187
$(CLINK)
8288

8389
sig_anch: $(OUT_BIN_DIR)/sig_anch
@@ -92,24 +98,26 @@ download_kmc:
9298
-mkdir -p $(OUT_BIN_DIR)
9399
./download_kmc.sh $(OUT_BIN_DIR)
94100

95-
nomad:
96-
cp src/nomad.py bin/nomad
101+
splash:
102+
cp src/splash.py bin/splash
103+
supervised_test:
104+
cp src/supervised_test/supervised_test.R bin
97105

98106
install: all
99107
install bin/* /usr/local/bin
100108

101109
uninstall:
102-
-rm /usr/local/bin/satc
110+
-rm /usr/local/bin/satc
103111
-rm /usr/local/bin/satc_dump
104112
-rm /usr/local/bin/satc_merge
105-
-rm /usr/local/bin/sig_anch
106-
-rm /usr/local/bin/nomad
113+
-rm /usr/local/bin/sig_anch
114+
-rm /usr/local/bin/splash
107115
-rm /usr/local/bin/kmc
108116
-rm /usr/local/bin/kmc_tools
109117

110-
clean:
118+
clean:
111119
-rm $(SATC_MAIN_DIR)/*.o
112-
-rm $(SATC_MAIN_DIR)/kmc_api/*.o
120+
-rm $(COMMON_DIR)/kmc_api/*.o
113121
-rm $(SATC_MERGE_MAIN_DIR)/*.o
114122
-rm $(SATC_DUMP_MAIN_DIR)/*.o
115123
-rm $(COMMON_DIR)/*.o

NOMAD_extendor_classification.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ riffle <- function(a, b) { # this function interleaves the elements of two vec
4141
##################################################
4242
############ input arguments #####################
4343
args <- commandArgs(trailingOnly = TRUE)
44-
directory = args[1] # the output directory used for the NOMAD run
44+
directory = args[1] # the output directory used for the SPLASH run
4545
which_anchors_file = args[2] # flag to decide which anchor file (after correction or all anchors) to use, could be "after_correction" or "all"
4646
effect_size_cutoff = args[3] # the effect size cutoff for significant anchors (default 0.2)
4747
num_samples_cutoff = args[4] # the minimum number of sampels for an anchor to be called (default 20)

README.md

Lines changed: 45 additions & 35 deletions
Large diffs are not rendered by default.

build_release.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,21 @@ def replace_in_file(file_path, search_text, new_text):
1111
new_line = line.replace(search_text, new_text)
1212
print(new_line, end='')
1313

14-
def get_ver(nomad_path):
15-
with open(nomad_path) as f:
14+
def get_ver(splash_path):
15+
with open(splash_path) as f:
1616
for line in f.readlines():
1717
line = line.strip()
18-
if "NOMAD_VERSION" in line:
18+
if "SPLASH_VERSION" in line:
1919
return line.split("=")[-1].strip().split("\"")[1]
20-
print("Error: cannot read NOMAD_VERSION")
20+
print("Error: cannot read SPLASH_VERSION")
2121
sys.exit(1)
2222

2323
def run_cmd(cmd):
2424
p = subprocess.Popen(cmd, shell=True)
2525
p.communicate()
2626

27+
run_cmd("git submodule init")
28+
run_cmd("git submodule update")
2729
run_cmd("make clean")
2830
run_cmd("make -j32 release")
2931

@@ -37,12 +39,12 @@ def run_cmd(cmd):
3739
with open("bin/example/run-example.sh", "w") as f:
3840
f.write("#!/bin/bash\n")
3941
f.write("./download.py\n")
40-
f.write("../nomad --bin_path .. input.txt\n")
42+
f.write("../splash --bin_path .. input.txt\n")
4143

4244
os.chmod("bin/example/run-example.sh", os.stat("bin/example/run-example.sh").st_mode | stat.S_IEXEC)
4345

4446

45-
ver = get_ver("bin/nomad")
47+
ver = get_ver("bin/splash")
4648

47-
run_cmd(f"cd bin; tar -c * | pigz > ../nomad-{ver}.linux.x64.tar.gz; cd ..;")
49+
run_cmd(f"cd bin; tar -c * | pigz > ../splash-{ver}.linux.x64.tar.gz; cd ..;")
4850
run_cmd("rm -rf bin")

example/analysis_scripts/c_analysis.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"metadata": {},
3131
"outputs": [],
3232
"source": [
33-
"NOMAD2_result_folder=''"
33+
"SPLASH2_result_folder=''"
3434
]
3535
},
3636
{
@@ -41,7 +41,7 @@
4141
"outputs": [],
4242
"source": [
4343
"### read in p-values, afetr_correction.scores.csv file\n",
44-
"fname=NOMAD2_result_folder+'/result.after_correction.scores.tsv'\n",
44+
"fname=SPLASH2_result_folder+'/result.after_correction.scores.tsv'\n",
4545
"df = pd.read_csv(fname,sep='\\t')"
4646
]
4747
},
@@ -95,7 +95,7 @@
9595
"dfArr = []\n",
9696
"\n",
9797
"##### path to intermediary_files output folder\n",
98-
"fldrName= NOMAD2_result_folder+'/result_Cjs/'\n",
98+
"fldrName= SPLASH2_result_folder+'/result_Cjs/'\n",
9999
"\n",
100100
"for fname in tqdm(glob.glob(fldrName+'bin*.cjs')):\n",
101101
" dfArr.append(\n",

example/analysis_scripts/plotGeneration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def get_args():
6666
parser.add_argument(
6767
"--satc_dump_file",
6868
type=str,
69-
help='Path to satc_dump utility file (within NOMAD2, /bin/satc_dump)'
69+
help='Path to satc_dump utility file (within SPLASH2, /bin/satc_dump)'
7070
)
7171

7272
args = parser.parse_args()

libs/refresh/deterministic_random.h

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#pragma once
2+
#include <random>
3+
#include <tuple>
4+
#include <iostream>
5+
6+
#undef min
7+
#undef max
8+
9+
template<class IntType = int>
10+
class det_uniform_int_distribution {
11+
public:
12+
// types
13+
typedef IntType result_type;
14+
typedef std::pair<int, int> param_type;
15+
16+
// constructors and reset functions
17+
explicit det_uniform_int_distribution(IntType a = 0, IntType b = std::numeric_limits<IntType>::max());
18+
explicit det_uniform_int_distribution(const param_type& parm);
19+
void reset();
20+
21+
// generating functions
22+
template<class URNG>
23+
result_type operator()(URNG& g);
24+
template<class URNG>
25+
result_type operator()(URNG& g, const param_type& parm);
26+
27+
// property functions
28+
result_type a() const;
29+
result_type b() const;
30+
param_type param() const;
31+
void param(const param_type& parm);
32+
result_type min() const;
33+
result_type max() const;
34+
35+
private:
36+
typedef typename std::make_unsigned<IntType>::type diff_type;
37+
38+
IntType lower;
39+
IntType upper;
40+
};
41+
42+
template<class IntType>
43+
det_uniform_int_distribution<IntType>::det_uniform_int_distribution(IntType a, IntType b) {
44+
lower = a;
45+
upper = b;
46+
}
47+
48+
template<class IntType>
49+
det_uniform_int_distribution<IntType>::det_uniform_int_distribution(const param_type& parm) {
50+
param(parm);
51+
}
52+
53+
template<class IntType>
54+
void det_uniform_int_distribution<IntType>::reset() {}
55+
56+
template<class IntType>
57+
template<class URNG>
58+
auto det_uniform_int_distribution<IntType>::operator()(URNG& g) -> result_type {
59+
return operator()(g, param());
60+
}
61+
62+
template<class IntType>
63+
template<class URNG>
64+
auto det_uniform_int_distribution<IntType>::operator()(URNG& g, const param_type& parm) -> result_type {
65+
diff_type diff = (diff_type)parm.second - (diff_type)parm.first + 1;
66+
if (diff == 0) // If the +1 overflows we are using the full range, just return g()
67+
return g();
68+
69+
diff_type badDistLimit = std::numeric_limits<diff_type>::max() / diff;
70+
do {
71+
diff_type generatedRand = g();
72+
73+
if (generatedRand / diff < badDistLimit)
74+
return (IntType)((generatedRand % diff) + (diff_type)parm.first);
75+
} while (true);
76+
}
77+
78+
template<class IntType>
79+
auto det_uniform_int_distribution<IntType>::a() const -> result_type {
80+
return lower;
81+
}
82+
83+
template<class IntType>
84+
auto det_uniform_int_distribution<IntType>::b() const -> result_type {
85+
return upper;
86+
}
87+
88+
template<class IntType>
89+
auto det_uniform_int_distribution<IntType>::param() const -> param_type {
90+
return param_type(lower, upper);
91+
}
92+
93+
template<class IntType>
94+
void det_uniform_int_distribution<IntType>::param(const param_type& parm) {
95+
std::tie(lower, upper) = parm;
96+
if (upper < lower)
97+
throw std::exception();
98+
}
99+
100+
template<class IntType>
101+
auto det_uniform_int_distribution<IntType>::min() const -> result_type {
102+
return lower;
103+
}
104+
105+
template<class IntType>
106+
auto det_uniform_int_distribution<IntType>::max() const -> result_type {
107+
return upper;
108+
};
109+
110+
111+
112+
113+
template<class RandomIt, class URBG>
114+
void partial_shuffle(RandomIt first, RandomIt middle, RandomIt last, URBG&& g)
115+
{
116+
typedef typename std::iterator_traits<RandomIt>::difference_type diff_t;
117+
typedef det_uniform_int_distribution<diff_t> distr_t;
118+
typedef typename distr_t::param_type param_t;
119+
120+
distr_t D;
121+
diff_t n = middle - first;
122+
diff_t N = last - first - 1;
123+
for (diff_t i =0; i < n; ++i) {
124+
using std::swap;
125+
swap(first[i], first[D(g, param_t(i, N))]);
126+
}
127+
}
128+
129+

libs/refresh/parallel-queues.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ namespace refresh {
187187
}
188188
}
189189

190+
bool check_completed() {
191+
std::lock_guard<std::mutex> lck(mtx);
192+
return is_completed;
193+
}
194+
190195
void cancel()
191196
{
192197
std::lock_guard<std::mutex> lck(mtx);

0 commit comments

Comments
 (0)