Browse code

hopefully fixed build problems

chakalakka authored on 22/02/2016 09:02:11
Showing1 changed files
... ...
@@ -7,7 +7,11 @@
7 7
 #include <sstream>
8 8
 #include <string>
9 9
 #include <stdio.h>
10
-// #include <omp.h>
10
+// #if defined TARGET_OS_MAC || defined __APPLE__
11
+// #include <libiomp/omp.h> // parallelization options on mac
12
+// #elif defined __linux__ || defined _WIN32 || defined _WIN64
13
+// #include <omp.h> // parallelization options
14
+// #endif
11 15
 
12 16
 // inline std::string NowTime();
13 17
 
Browse code

bugfix usage

chakalakka authored on 23/09/2015 12:42:18
Showing1 changed files
... ...
@@ -1,18 +1,3 @@
1
-//aneufinder - An R-package for CNV detection in whole-genome single cell sequencing data
2
-//Copyright (C) 2015  Aaron Taudt
3
-//
4
-//This program is free software: you can redistribute it and/or modify
5
-//it under the terms of the GNU General Public License as published by
6
-//the Free Software Foundation, either version 3 of the License, or
7
-//(at your option) any later version.
8
-//
9
-//This program is distributed in the hope that it will be useful,
10
-//but WITHOUT ANY WARRANTY; without even the implied warranty of
11
-//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
-//GNU General Public License for more details.
13
-//
14
-//You should have received a copy of the GNU General Public License
15
-//along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 1
 
17 2
 
18 3
 
Browse code

adjusted licensing to GPLv3

chakalakka authored on 19/09/2015 14:26:38
Showing1 changed files
... ...
@@ -1,3 +1,21 @@
1
+//aneufinder - An R-package for CNV detection in whole-genome single cell sequencing data
2
+//Copyright (C) 2015  Aaron Taudt
3
+//
4
+//This program is free software: you can redistribute it and/or modify
5
+//it under the terms of the GNU General Public License as published by
6
+//the Free Software Foundation, either version 3 of the License, or
7
+//(at your option) any later version.
8
+//
9
+//This program is distributed in the hope that it will be useful,
10
+//but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
+//GNU General Public License for more details.
13
+//
14
+//You should have received a copy of the GNU General Public License
15
+//along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
+
17
+
18
+
1 19
 #ifndef __LOG_H__
2 20
 #define __LOG_H__
3 21
 
Browse code

compile is passed without warnings

chakalakka authored on 16/02/2015 09:50:42
Showing1 changed files
... ...
@@ -8,7 +8,7 @@
8 8
 
9 9
 // inline std::string NowTime();
10 10
 
11
-enum TLogLevel {logNONE, logERROR, logWARNING, logINFO, logITERATION, logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4};
11
+enum TLogLevel {logERROR, logWARNING, logINFO, logITERATION, logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4};
12 12
 
13 13
 template <typename T>
14 14
 class Log
... ...
@@ -62,7 +62,7 @@ TLogLevel& Log<T>::ReportingLevel()
62 62
 template <typename T>
63 63
 std::string Log<T>::ToString(TLogLevel level)
64 64
 {
65
-	static const char* const buffer[] = {"NONE", "ERROR", "WARNING", "INFO", "ITERATION", "DEBUG", "DEBUG1", "DEBUG2", "DEBUG3", "DEBUG4"};
65
+	static const char* const buffer[] = {"ERROR", "WARNING", "INFO", "ITERATION", "DEBUG", "DEBUG1", "DEBUG2", "DEBUG3", "DEBUG4"};
66 66
     return buffer[level];
67 67
 }
68 68
 
... ...
@@ -87,8 +87,6 @@ TLogLevel Log<T>::FromString(const std::string& level)
87 87
         return logWARNING;
88 88
     if (level == "ERROR")
89 89
         return logERROR;
90
-		if (level == "NONE")
91
-				return logNONE;
92 90
     Log<T>().Get(logWARNING) << "Unknown logging level '" << level << "'. Using INFO level as default.";
93 91
     return logINFO;
94 92
 }
Browse code

improved error and warning handling

chakalakka authored on 06/12/2014 11:14:36
Showing1 changed files
... ...
@@ -8,7 +8,7 @@
8 8
 
9 9
 // inline std::string NowTime();
10 10
 
11
-enum TLogLevel {logERROR, logWARNING, logINFO, logITERATION, logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4};
11
+enum TLogLevel {logNONE, logERROR, logWARNING, logINFO, logITERATION, logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4};
12 12
 
13 13
 template <typename T>
14 14
 class Log
... ...
@@ -62,7 +62,7 @@ TLogLevel& Log<T>::ReportingLevel()
62 62
 template <typename T>
63 63
 std::string Log<T>::ToString(TLogLevel level)
64 64
 {
65
-	static const char* const buffer[] = {"ERROR", "WARNING", "INFO", "ITERATION", "DEBUG", "DEBUG1", "DEBUG2", "DEBUG3", "DEBUG4"};
65
+	static const char* const buffer[] = {"NONE", "ERROR", "WARNING", "INFO", "ITERATION", "DEBUG", "DEBUG1", "DEBUG2", "DEBUG3", "DEBUG4"};
66 66
     return buffer[level];
67 67
 }
68 68
 
... ...
@@ -87,6 +87,8 @@ TLogLevel Log<T>::FromString(const std::string& level)
87 87
         return logWARNING;
88 88
     if (level == "ERROR")
89 89
         return logERROR;
90
+		if (level == "NONE")
91
+				return logNONE;
90 92
     Log<T>().Get(logWARNING) << "Unknown logging level '" << level << "'. Using INFO level as default.";
91 93
     return logINFO;
92 94
 }
Browse code

read.cutoff changed, introduced several distributions (not used), windows compatible

chakalakka authored on 20/10/2014 07:10:07
Showing1 changed files
... ...
@@ -4,9 +4,9 @@
4 4
 #include <sstream>
5 5
 #include <string>
6 6
 #include <stdio.h>
7
-#include <omp.h>
7
+// #include <omp.h>
8 8
 
9
-inline std::string NowTime();
9
+// inline std::string NowTime();
10 10
 
11 11
 enum TLogLevel {logERROR, logWARNING, logINFO, logITERATION, logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4};
12 12
 
... ...
@@ -37,8 +37,8 @@ template <typename T>
37 37
 std::ostringstream& Log<T>::Get(TLogLevel level)
38 38
 {
39 39
 	if (level >= logDEBUG) {
40
-		os << NowTime() << " - ";
41
-		os << "thread: " << omp_get_thread_num() << " - ";
40
+// 		os << NowTime() << " - ";
41
+// 		os << "thread: " << omp_get_thread_num() << " - ";
42 42
 	}
43 43
     os << ToString(level) << ": ";
44 44
     os << std::string(level > logDEBUG ? level - logDEBUG : 0, '\t');
... ...
@@ -137,42 +137,43 @@ class FILELOG_DECLSPEC FILELog : public Log<Output2FILE> {};
137 137
     else if (level > FILELog::ReportingLevel() || !Output2FILE::Stream()) ; \
138 138
     else FILELog().Get(level)
139 139
 
140
-#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
141
-
142
-#include <windows.h>
143
-
144
-inline std::string NowTime()
145
-{
146
-    const int MAX_LEN = 200;
147
-    char buffer[MAX_LEN];
148
-    if (GetTimeFormatA(LOCALE_USER_DEFAULT, 0, 0, 
149
-            "HH':'mm':'ss", buffer, MAX_LEN) == 0)
150
-        return "Error in NowTime()";
151
-
152
-    char result[100] = {0};
153
-    static DWORD first = GetTickCount();
154
-    std::sprintf(result, "%s.%03ld", buffer, (long)(GetTickCount() - first) % 1000); 
155
-    return result;
156
-}
157
-
158
-#else
159
-
160
-#include <sys/time.h>
161
-
162
-inline std::string NowTime()
163
-{
164
-    char buffer[11];
165
-    time_t t;
166
-    time(&t);
167
-    tm r = {0};
168
-    strftime(buffer, sizeof(buffer), "%T", localtime_r(&t, &r));
169
-    struct timeval tv;
170
-    gettimeofday(&tv, 0);
171
-    char result[100] = {0};
172
-    sprintf(result, "%s.%03ld", buffer, (long)tv.tv_usec / 1000); 
173
-    return result;
174
-}
175
-
176
-#endif //WIN32
140
+// #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
141
+// 
142
+// #include <windows.h>
143
+// 
144
+// inline std::string NowTime()
145
+// {
146
+//     const int MAX_LEN = 200;
147
+//     char buffer[MAX_LEN];
148
+//     if (GetTimeFormatA(LOCALE_USER_DEFAULT, 0, 0, 
149
+//             "HH':'mm':'ss", buffer, MAX_LEN) == 0)
150
+//         return "Error in NowTime()";
151
+// 
152
+//     char result[100] = {0};
153
+//     static DWORD first = GetTickCount();
154
+// //     std::sprintf(result, "%s.%03ld", buffer, (long)(GetTickCount() - first) % 1000); 
155
+//     sprintf(result, "%s.%03ld", buffer, (long)(GetTickCount() - first) % 1000); // Compiling on windows complains about the std::
156
+//     return result;
157
+// }
158
+// 
159
+// #else
160
+// 
161
+// #include <sys/time.h>
162
+// 
163
+// inline std::string NowTime()
164
+// {
165
+//     char buffer[11];
166
+//     time_t t;
167
+//     time(&t);
168
+//     tm r = {0};
169
+//     strftime(buffer, sizeof(buffer), "%T", localtime_r(&t, &r));
170
+//     struct timeval tv;
171
+//     gettimeofday(&tv, 0);
172
+//     char result[100] = {0};
173
+//     sprintf(result, "%s.%03ld", buffer, (long)tv.tv_usec / 1000); 
174
+//     return result;
175
+// }
176
+// 
177
+// #endif //WIN32
177 178
 
178 179
 #endif //__LOG_H__
Browse code

initial project version

chakalakka authored on 02/05/2014 11:14:29
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,178 @@
1
+#ifndef __LOG_H__
2
+#define __LOG_H__
3
+
4
+#include <sstream>
5
+#include <string>
6
+#include <stdio.h>
7
+#include <omp.h>
8
+
9
+inline std::string NowTime();
10
+
11
+enum TLogLevel {logERROR, logWARNING, logINFO, logITERATION, logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4};
12
+
13
+template <typename T>
14
+class Log
15
+{
16
+public:
17
+    Log();
18
+    virtual ~Log();
19
+    std::ostringstream& Get(TLogLevel level = logINFO);
20
+public:
21
+    static TLogLevel& ReportingLevel();
22
+    static std::string ToString(TLogLevel level);
23
+    static TLogLevel FromString(const std::string& level);
24
+protected:
25
+    std::ostringstream os;
26
+private:
27
+    Log(const Log&);
28
+    Log& operator =(const Log&);
29
+};
30
+
31
+template <typename T>
32
+Log<T>::Log()
33
+{
34
+}
35
+
36
+template <typename T>
37
+std::ostringstream& Log<T>::Get(TLogLevel level)
38
+{
39
+	if (level >= logDEBUG) {
40
+		os << NowTime() << " - ";
41
+		os << "thread: " << omp_get_thread_num() << " - ";
42
+	}
43
+    os << ToString(level) << ": ";
44
+    os << std::string(level > logDEBUG ? level - logDEBUG : 0, '\t');
45
+    return os;
46
+}
47
+
48
+template <typename T>
49
+Log<T>::~Log()
50
+{
51
+    os << std::endl;
52
+    T::Output(os.str());
53
+}
54
+
55
+template <typename T>
56
+TLogLevel& Log<T>::ReportingLevel()
57
+{
58
+    static TLogLevel reportingLevel = logDEBUG4;
59
+    return reportingLevel;
60
+}
61
+
62
+template <typename T>
63
+std::string Log<T>::ToString(TLogLevel level)
64
+{
65
+	static const char* const buffer[] = {"ERROR", "WARNING", "INFO", "ITERATION", "DEBUG", "DEBUG1", "DEBUG2", "DEBUG3", "DEBUG4"};
66
+    return buffer[level];
67
+}
68
+
69
+template <typename T>
70
+TLogLevel Log<T>::FromString(const std::string& level)
71
+{
72
+    if (level == "DEBUG4")
73
+        return logDEBUG4;
74
+    if (level == "DEBUG3")
75
+        return logDEBUG3;
76
+    if (level == "DEBUG2")
77
+        return logDEBUG2;
78
+    if (level == "DEBUG1")
79
+        return logDEBUG1;
80
+    if (level == "DEBUG")
81
+        return logDEBUG;
82
+    if (level == "ITERATION")
83
+        return logITERATION;
84
+    if (level == "INFO")
85
+        return logINFO;
86
+    if (level == "WARNING")
87
+        return logWARNING;
88
+    if (level == "ERROR")
89
+        return logERROR;
90
+    Log<T>().Get(logWARNING) << "Unknown logging level '" << level << "'. Using INFO level as default.";
91
+    return logINFO;
92
+}
93
+
94
+class Output2FILE
95
+{
96
+public:
97
+    static FILE*& Stream();
98
+    static void Output(const std::string& msg);
99
+};
100
+
101
+inline FILE*& Output2FILE::Stream()
102
+{
103
+    static FILE* pStream = stderr;
104
+    return pStream;
105
+}
106
+
107
+inline void Output2FILE::Output(const std::string& msg)
108
+{   
109
+    FILE* pStream = Stream();
110
+    if (!pStream)
111
+        return;
112
+    fprintf(pStream, "%s", msg.c_str());
113
+    fflush(pStream);
114
+}
115
+
116
+#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
117
+#   if defined (BUILDING_FILELOG_DLL)
118
+#       define FILELOG_DECLSPEC   __declspec (dllexport)
119
+#   elif defined (USING_FILELOG_DLL)
120
+#       define FILELOG_DECLSPEC   __declspec (dllimport)
121
+#   else
122
+#       define FILELOG_DECLSPEC
123
+#   endif // BUILDING_DBSIMPLE_DLL
124
+#else
125
+#   define FILELOG_DECLSPEC
126
+#endif // _WIN32
127
+
128
+class FILELOG_DECLSPEC FILELog : public Log<Output2FILE> {};
129
+//typedef Log<Output2FILE> FILELog;
130
+
131
+#ifndef FILELOG_MAX_LEVEL
132
+#define FILELOG_MAX_LEVEL logDEBUG4
133
+#endif
134
+
135
+#define FILE_LOG(level) \
136
+    if (level > FILELOG_MAX_LEVEL) ;\
137
+    else if (level > FILELog::ReportingLevel() || !Output2FILE::Stream()) ; \
138
+    else FILELog().Get(level)
139
+
140
+#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
141
+
142
+#include <windows.h>
143
+
144
+inline std::string NowTime()
145
+{
146
+    const int MAX_LEN = 200;
147
+    char buffer[MAX_LEN];
148
+    if (GetTimeFormatA(LOCALE_USER_DEFAULT, 0, 0, 
149
+            "HH':'mm':'ss", buffer, MAX_LEN) == 0)
150
+        return "Error in NowTime()";
151
+
152
+    char result[100] = {0};
153
+    static DWORD first = GetTickCount();
154
+    std::sprintf(result, "%s.%03ld", buffer, (long)(GetTickCount() - first) % 1000); 
155
+    return result;
156
+}
157
+
158
+#else
159
+
160
+#include <sys/time.h>
161
+
162
+inline std::string NowTime()
163
+{
164
+    char buffer[11];
165
+    time_t t;
166
+    time(&t);
167
+    tm r = {0};
168
+    strftime(buffer, sizeof(buffer), "%T", localtime_r(&t, &r));
169
+    struct timeval tv;
170
+    gettimeofday(&tv, 0);
171
+    char result[100] = {0};
172
+    sprintf(result, "%s.%03ld", buffer, (long)tv.tv_usec / 1000); 
173
+    return result;
174
+}
175
+
176
+#endif //WIN32
177
+
178
+#endif //__LOG_H__