Skip to content

Commit cc9ed1f

Browse files
committed
add: cxx
1 parent 4c28e1f commit cc9ed1f

File tree

167 files changed

+92268
-922
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+92268
-922
lines changed

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# GenoBoost v1.1.0
1+
# GenoBoost
22

33
[![GenoBoost](https://github.com/rickyota/genoboost/actions/workflows/genoboost.yml/badge.svg)](https://github.com/rickyota/genoboost/actions/workflows/genoboost.yml)
44
[![Release](https://github.com/rickyota/genoboost/actions/workflows/publish.yml/badge.svg)](https://github.com/rickyota/genoboost/actions/workflows/publish.yml)
@@ -22,15 +22,16 @@ $ genoboost train \
2222

2323
## Table of Contents
2424

25-
- [GenoBoost v1.1.0](#genoboost-v110)
25+
- [GenoBoost](#genoboost)
2626
- [Getting Started](#getting-started)
2727
- [Table of Contents](#table-of-contents)
2828
- [News](#news)
2929
- [Introduction](#introduction)
3030
- [Users' Guide](#users-guide)
3131
- [Installation](#installation)
3232
- [Plink1 Input](#plink1-input)
33-
- [Plink2 Input](#plink2-input)
33+
- [Plink2 Input (compile)](#plink2-input-compile)
34+
- [Plink2 Input (docker)](#plink2-input-docker)
3435
- [Advanced Install](#advanced-install)
3536
- [Train GenoBoost Model](#train-genoboost-model)
3637
- [Simplest Usage](#simplest-usage)
@@ -52,6 +53,8 @@ $ genoboost train \
5253

5354
## <a name="news"></a>News
5455

56+
- [v1.2.0](https://github.com/rickyota/genoboost/releases/tag/v1.2.0) (Dec 28, 2024)
57+
- Clean code and remove some requirements for plink2.
5558
- [v1.1.0](https://github.com/rickyota/genoboost/releases/tag/v1.1.0) (May 23, 2024)
5659
- Clean code.
5760
- [v1.0.8](https://github.com/rickyota/genoboost/releases/tag/v1.0.8) (Nov 25, 2023)
@@ -84,11 +87,11 @@ For now, the input genotype format is allowed for plink1 or plink2 only.
8487

8588
If you want to input plink1, download a compiled program for Linux (tested on Rocky Linux<=8.9), macOS (tested on <=14.3.1), and Windows (not tested) from [here][release]. This should take less than 1 minute.
8689

87-
#### <a name="install-plink2"></a>Plink2 Input
90+
#### <a name="install-plink2-compile"></a>Plink2 Input (compile)
8891

89-
If you want to input plink2 genotype file, you have to compile it by yourself as below. You can use plink1 format as well.
92+
If you want to input plink2 genotype file, you can compile program by yourself as below or [use docker or singularity](#advanced-installation). You can use plink1 format as well.
9093

91-
First, install `rust` as instructed [here][rust-install], `cmake>=3.14`, and `clang` if not installed. Then,
94+
First, install `rust` as instructed [here][rust-install] if not installed. Then,
9295

9396
```bash
9497
git clone https://github.com/rickyota/genoboost.git
@@ -99,10 +102,6 @@ cp ./projects_rust/target/release/genoboost ./genoboost
99102

100103
and you can use `genoboost` program. This should take less than 5 minutes.
101104

102-
#### <a name="install-advanced"></a>Advanced Install
103-
104-
See [Advanced Guide](#advanced-guide) for docker or singularity users.
105-
106105
Using arm architecture, including Macbook M1 and M2 chips, will stop or slow down the software due to the unavailability of SIMD.
107106
I plan to deal with it in the future.
108107

lib/pgenlib_rust/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ name = "pgenlib_rust"
33
version = "0.1.0"
44
authors = ["name"]
55
edition = "2021"
6-
build = "build.rs"
6+
#build = "build.rs"
77
#crate-type = ["staticlib"]
88

99
[dependencies]
10-
libc = "0.2.94"
10+
cxx = "1.0"
1111

12+
# for build.rs
1213
[build-dependencies]
13-
cmake = "0.1.50"
14-
bindgen = "0.65.1"
15-
#cmake = "0.1"
14+
cxx-build = "1.0"
15+
walkdir = "2"

lib/pgenlib_rust/build.rs

Lines changed: 61 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,70 @@
1-
// https://rendered-obsolete.github.io/2018/09/30/rust-ffi-ci.html
1+
use walkdir::WalkDir;
22

3-
// later: https://rust-lang.github.io/rust-bindgen/non-system-libraries.html
4-
// if you have .o : https://rust-lang.github.io/rust-bindgen/tutorial-3.html
3+
fn main() {
4+
let dirs = ["./lib/pgenlib/"];
5+
// exclude src/unuse
6+
//let dirs = [
7+
// "./lib/pgenlib/src/",
8+
// "./lib/pgenlib/src/include/",
9+
// "./lib/pgenlib/src/simde/",
10+
// "./lib/pgenlib/src/simde/x86",
11+
// "./lib/pgenlib/src/simde/x86/avx512",
12+
//];
513

6-
// unnecessary?
7-
//extern crate bindgen;
8-
//use bindgen;
14+
// all files with .cc or .cpp
15+
let cpps: Vec<String> = dirs
16+
.map(|dir| {
17+
WalkDir::new(dir)
18+
.into_iter()
19+
.map(|x| x.unwrap().path().display().to_string())
20+
})
21+
.into_iter()
22+
.flatten()
23+
.filter(|x| x.ends_with(".cpp") || x.ends_with(".cc"))
24+
.collect();
925

10-
use std::env;
11-
use std::path::PathBuf;
26+
// cannot print in build.rs
27+
//println!("cpps: {:?}", cpps);
1228

13-
use bindgen::CargoCallbacks;
14-
use cmake;
29+
// how to add openmp?
30+
// https://users.rust-lang.org/t/binding-openmp-c-function/40196/4
1531

16-
fn main() {
32+
// should be .rs with #[cxx::bridge]
33+
cxx_build::bridge("src/lib.rs")
34+
.files(&cpps)
35+
.flag_if_supported("-fopenmp")
36+
.compile("pgenlib-bridge");
37+
38+
//.flag_if_supported("-static")
1739

18-
// cmake
19-
let dst = cmake::build("src/pgenlib");
20-
println!("cargo:rustc-link-search=native={}", dst.display());
21-
println!("cargo:rustc-link-lib=dylib=stdc++");
22-
// ok?
23-
// should be same as project name in CMakeLists.txt
24-
println!("cargo:rustc-link-lib=static=pgenlib");
25-
26-
// [ref](https://stackoverflow.com/questions/50642574/how-can-i-specify-linker-flags-arguments-in-a-build-script)
40+
// seems not necessary
41+
//.flag_if_supported("-std=c++")
42+
//.flag_if_supported("-std=c++11")
43+
44+
// seems not necessary
45+
//.flag_if_supported("-lgomp")
46+
47+
// arg for rustc compile
48+
// This is same as
49+
// $ export RUSTFLAGS='-C link-args=-fopenmp'
50+
// Better use build.rs to make build.sh simple
51+
//
2752
println!("cargo:rustc-link-arg=-fopenmp");
53+
// seems not necessary
54+
// [ref](https://github.com/rust-lang/cc-rs/issues/266)
55+
//println!("cargo:rustc-link-lib=gomp");
2856

29-
println!("cargo:rustc-link-lib=gomp");
30-
// added 230823
31-
// [ref](https://github.com/rust-or/highs-sys/blob/master/build.rs)
32-
//println!("cargo:rustc-link-lib=dylib=gomp");
33-
34-
35-
36-
// binding
37-
let bindings = bindgen::Builder::default()
38-
.header("src/pgenlib/pgenlibr_wrapc.hpp")
39-
.parse_callbacks(Box::new(CargoCallbacks))
40-
.clang_arg("-xc++")
41-
.clang_arg("-std=c++11")
42-
.clang_arg("-stdlib=libc++")
43-
.allowlist_file("src/pgenlib/pgenlibr_wrapc.hpp")
44-
.generate()
45-
.expect("Unable to generate bindings");
46-
//let bindings = bindgen::Builder::default()
47-
// .header("src/pgenlib/pgenlibr_wrapc.h")
48-
// .parse_callbacks(Box::new(CargoCallbacks))
49-
// .clang_arg("-xc++")
50-
// .clang_arg("-std=c++11")
51-
// .allowlist_file("src/pgenlib/pgenlibr_wrapc.h")
52-
// .generate()
53-
// .expect("Unable to generate bindings");
54-
55-
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
56-
bindings
57-
.write_to_file(out_path.join("bindings.rs"))
58-
.expect("Couldn't write bindings");
57+
println!("cargo:rerun-if-changed=src/lib.rs");
58+
// all cpp and h
59+
dirs.map(|dir| {
60+
WalkDir::new(dir)
61+
.into_iter()
62+
.map(|x| x.unwrap().path().display().to_string())
63+
})
64+
.into_iter()
65+
.flatten()
66+
.filter(|x| {
67+
x.ends_with(".cpp") || x.ends_with(".cc") || x.ends_with(".hpp") || x.ends_with(".h")
68+
})
69+
.for_each(|x| println!("cargo:rerun-if-changed={:?}", x));
5970
}
60-

lib/pgenlib_rust/lib/pgenlib/LICENSE

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
GNU LESSER GENERAL PUBLIC LICENSE
2+
Version 3, 29 June 2007
3+
4+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5+
Everyone is permitted to copy and distribute verbatim copies
6+
of this license document, but changing it is not allowed.
7+
8+
9+
This version of the GNU Lesser General Public License incorporates
10+
the terms and conditions of version 3 of the GNU General Public
11+
License, supplemented by the additional permissions listed below.
12+
13+
0. Additional Definitions.
14+
15+
As used herein, "this License" refers to version 3 of the GNU Lesser
16+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
17+
General Public License.
18+
19+
"The Library" refers to a covered work governed by this License,
20+
other than an Application or a Combined Work as defined below.
21+
22+
An "Application" is any work that makes use of an interface provided
23+
by the Library, but which is not otherwise based on the Library.
24+
Defining a subclass of a class defined by the Library is deemed a mode
25+
of using an interface provided by the Library.
26+
27+
A "Combined Work" is a work produced by combining or linking an
28+
Application with the Library. The particular version of the Library
29+
with which the Combined Work was made is also called the "Linked
30+
Version".
31+
32+
The "Minimal Corresponding Source" for a Combined Work means the
33+
Corresponding Source for the Combined Work, excluding any source code
34+
for portions of the Combined Work that, considered in isolation, are
35+
based on the Application, and not on the Linked Version.
36+
37+
The "Corresponding Application Code" for a Combined Work means the
38+
object code and/or source code for the Application, including any data
39+
and utility programs needed for reproducing the Combined Work from the
40+
Application, but excluding the System Libraries of the Combined Work.
41+
42+
1. Exception to Section 3 of the GNU GPL.
43+
44+
You may convey a covered work under sections 3 and 4 of this License
45+
without being bound by section 3 of the GNU GPL.
46+
47+
2. Conveying Modified Versions.
48+
49+
If you modify a copy of the Library, and, in your modifications, a
50+
facility refers to a function or data to be supplied by an Application
51+
that uses the facility (other than as an argument passed when the
52+
facility is invoked), then you may convey a copy of the modified
53+
version:
54+
55+
a) under this License, provided that you make a good faith effort to
56+
ensure that, in the event an Application does not supply the
57+
function or data, the facility still operates, and performs
58+
whatever part of its purpose remains meaningful, or
59+
60+
b) under the GNU GPL, with none of the additional permissions of
61+
this License applicable to that copy.
62+
63+
3. Object Code Incorporating Material from Library Header Files.
64+
65+
The object code form of an Application may incorporate material from
66+
a header file that is part of the Library. You may convey such object
67+
code under terms of your choice, provided that, if the incorporated
68+
material is not limited to numerical parameters, data structure
69+
layouts and accessors, or small macros, inline functions and templates
70+
(ten or fewer lines in length), you do both of the following:
71+
72+
a) Give prominent notice with each copy of the object code that the
73+
Library is used in it and that the Library and its use are
74+
covered by this License.
75+
76+
b) Accompany the object code with a copy of the GNU GPL and this license
77+
document.
78+
79+
4. Combined Works.
80+
81+
You may convey a Combined Work under terms of your choice that,
82+
taken together, effectively do not restrict modification of the
83+
portions of the Library contained in the Combined Work and reverse
84+
engineering for debugging such modifications, if you also do each of
85+
the following:
86+
87+
a) Give prominent notice with each copy of the Combined Work that
88+
the Library is used in it and that the Library and its use are
89+
covered by this License.
90+
91+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
92+
document.
93+
94+
c) For a Combined Work that displays copyright notices during
95+
execution, include the copyright notice for the Library among
96+
these notices, as well as a reference directing the user to the
97+
copies of the GNU GPL and this license document.
98+
99+
d) Do one of the following:
100+
101+
0) Convey the Minimal Corresponding Source under the terms of this
102+
License, and the Corresponding Application Code in a form
103+
suitable for, and under terms that permit, the user to
104+
recombine or relink the Application with a modified version of
105+
the Linked Version to produce a modified Combined Work, in the
106+
manner specified by section 6 of the GNU GPL for conveying
107+
Corresponding Source.
108+
109+
1) Use a suitable shared library mechanism for linking with the
110+
Library. A suitable mechanism is one that (a) uses at run time
111+
a copy of the Library already present on the user's computer
112+
system, and (b) will operate properly with a modified version
113+
of the Library that is interface-compatible with the Linked
114+
Version.
115+
116+
e) Provide Installation Information, but only if you would otherwise
117+
be required to provide such information under section 6 of the
118+
GNU GPL, and only to the extent that such information is
119+
necessary to install and execute a modified version of the
120+
Combined Work produced by recombining or relinking the
121+
Application with a modified version of the Linked Version. (If
122+
you use option 4d0, the Installation Information must accompany
123+
the Minimal Corresponding Source and Corresponding Application
124+
Code. If you use option 4d1, you must provide the Installation
125+
Information in the manner specified by section 6 of the GNU GPL
126+
for conveying Corresponding Source.)
127+
128+
5. Combined Libraries.
129+
130+
You may place library facilities that are a work based on the
131+
Library side by side in a single library together with other library
132+
facilities that are not Applications and are not covered by this
133+
License, and convey such a combined library under terms of your
134+
choice, if you do both of the following:
135+
136+
a) Accompany the combined library with a copy of the same work based
137+
on the Library, uncombined with any other library facilities,
138+
conveyed under the terms of this License.
139+
140+
b) Give prominent notice with the combined library that part of it
141+
is a work based on the Library, and explaining where to find the
142+
accompanying uncombined form of the same work.
143+
144+
6. Revised Versions of the GNU Lesser General Public License.
145+
146+
The Free Software Foundation may publish revised and/or new versions
147+
of the GNU Lesser General Public License from time to time. Such new
148+
versions will be similar in spirit to the present version, but may
149+
differ in detail to address new problems or concerns.
150+
151+
Each version is given a distinguishing version number. If the
152+
Library as you received it specifies that a certain numbered version
153+
of the GNU Lesser General Public License "or any later version"
154+
applies to it, you have the option of following the terms and
155+
conditions either of that published version or of any later version
156+
published by the Free Software Foundation. If the Library as you
157+
received it does not specify a version number of the GNU Lesser
158+
General Public License, you may choose any version of the GNU Lesser
159+
General Public License ever published by the Free Software Foundation.
160+
161+
If the Library as you received it specifies that a proxy can decide
162+
whether future versions of the GNU Lesser General Public License shall
163+
apply, that proxy's public statement of acceptance of any version is
164+
permanent authorization for you to choose that version for the
165+
Library.

lib/pgenlib_rust/lib/pgenlib/Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# Makefile to compile PGEN library
3+
#
4+
AR ?= ar
5+
CXX ?= g++
6+
CXXFLAGS = -O3 -Wall -std=c++11
7+
CFLAGS =
8+
9+
OBJECTS = $(patsubst %.cc,%.o,$(wildcard ./include/*.cc)) $(patsubst %.cpp,%.o,$(wildcard *.cpp)) $(patsubst %.cc,%.o,$(wildcard *.cc))
10+
INC = -I./simde/ -I./include/
11+
12+
pgenlib.a: ${OBJECTS}
13+
${AR} rcs $@ $^
14+
15+
%.o: %.cpp
16+
${CXX} ${CXXFLAGS} -o $@ -c $< ${INC}
17+
18+
%.o: %.cc
19+
${CXX} ${CXXFLAGS} -o $@ -c $< ${INC}
20+
21+
clean:
22+
rm -f *.o *.a ./include/*.o

0 commit comments

Comments
 (0)