Skip to content
Browse files

a few cleanups. (TODO: check if they broke anything...)

  • Loading branch information...
1 parent e0c6b83 commit 5ef2f6efb03e7875f2b057058436c653ebb3bbd4 @sim82 committed
Showing with 51 additions and 73 deletions.
  1. +3 −3 CMakeLists.txt
  2. +4 −51 align_utils.h
  3. +2 −1 blast_partassign.cpp
  4. +1 −1 ivy_mike
  5. +14 −1 papara.h
  6. +1 −1 pars_align_gapp_seq.h
  7. +1 −1 pars_align_seq.h
  8. +25 −14 vec_unit.h
View
6 CMakeLists.txt
@@ -4,7 +4,7 @@ project(papara_nt)
set( CMAKE_NO_VERBOSE yes )
add_subdirectory(ivy_mike)
add_subdirectory(ublasJama-1.0.2.3)
-add_subdirectory(genassign_blast)
+# add_subdirectory(genassign_blast)
IF( NOT IVYMIKE_INCLUDE )
SET( IVYMIKE_INCLUDE ./ivy_mike )
@@ -27,7 +27,7 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_SCL_SECURE_NO_WARNINGS")
file(GLOB ALL_HEADERS *.h)
ELSE()
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -march=native")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98 -pedantic -Wall -march=native")
set( BOOST_LIBS boost_thread boost_program_options)
set(SYSDEP_LIBS pthread)
#LINK_DIRECTORIES( ${LINK_DIRECTORIES} /usr/lib64/atlas-sse2 )
@@ -36,7 +36,7 @@ set( ALL_HEADERS )
ENDIF()
-ADD_LIBRARY( papara_core STATIC papara.cpp pvec.cpp pars_align_seq.cpp pars_align_gapp_seq.cpp parsimony.cpp sequence_model.cpp )
+ADD_LIBRARY( papara_core STATIC papara.cpp pvec.cpp pars_align_seq.cpp pars_align_gapp_seq.cpp parsimony.cpp sequence_model.cpp align_utils.cpp )
# add_executable(papara_nt main.cpp pvec.cpp pars_align_seq.cpp pars_align_gapp_seq.cpp parsimony.cpp ${ALL_HEADERS})
add_executable(papara papara2_main.cpp blast_partassign.cpp ${ALL_HEADERS})
View
55 align_utils.h
@@ -21,62 +21,15 @@
#ifndef __align_utils_h__
#define __align_utils_h__
-#include <cassert>
+
#include <vector>
#include <stdint.h>
namespace align_utils {
-static void trace_to_position_map( const std::vector< uint8_t >& gaps, std::vector< int > *map) {
-
- int seq_ptr = 0;
-
- for ( std::vector<uint8_t>::const_reverse_iterator git = gaps.rbegin(); git != gaps.rend(); ++git ) {
-
- if ( *git == 1) {
- ++seq_ptr;
- } else if ( *git == 0 ) {
-
- map->push_back(seq_ptr);
-
- ++seq_ptr;
- } else {
- map->push_back(seq_ptr);
-
- }
- }
-}
-
-
-static uint8_t decode_dna( int s ) {
- assert( s >= 0 && s < 4 );
- const static uint8_t map[4] = {'A','C','G','T'};
-
- return map[size_t(s)];
-}
-
-
-static void realize_trace( const std::vector<uint8_t> &seq, const std::vector<uint8_t> &tb, std::vector<uint8_t> *out ) {
- assert( out != 0 );
-
- std::vector<uint8_t>::const_reverse_iterator tb_it;
- std::vector<uint8_t>::const_iterator seq_it;
- for( tb_it = tb.rbegin(), seq_it = seq.begin(); tb_it != tb.rend(); ++tb_it ) {
- if( *tb_it == 0 ) {
- assert( seq_it != seq.end() );
-
- out->push_back(decode_dna(*seq_it));
- ++seq_it;
-
- } else if( *tb_it == 2 ) {
- assert( seq_it != seq.end() );
- ++seq_it;
- } else {
- out->push_back('-');
- }
- }
-}
-
+void trace_to_position_map( const std::vector< uint8_t >& gaps, std::vector< int > *map);
+uint8_t decode_dna( int s );
+void realize_trace( const std::vector<uint8_t> &seq, const std::vector<uint8_t> &tb, std::vector<uint8_t> *out );
}
View
3 blast_partassign.cpp
@@ -42,7 +42,8 @@ blast_hit partassign::next_hit( std::istream &is ) {
std::string qs, ref;
float ident;
- int len, mismatch, gap_open, qs_start, qs_end, ref_start, ref_end;
+ int len, mismatch, gap_open;
+
std::string evalue;
blast_hit hit;
2 ivy_mike
@@ -1 +1 @@
-Subproject commit b3cff8dd99217d66922feb81f8289e6b96641394
+Subproject commit d6b37234934303422149f258d2067c12b09a30f0
View
15 papara.h
@@ -656,6 +656,11 @@ class ref_gap_collector {
ref_gap_collector( size_t ref_len ) : ref_gaps_(ref_len + 1) {}
+ template <typename Tmax>
+ static inline Tmax wrap_max( const Tmax& a, const Tmax& b ) {
+ return std::max(a,b);
+ }
+
void add_trace( const std::vector<uint8_t> &gaps ) {
size_t ptr = ref_gaps_.size() - 1;
@@ -678,8 +683,16 @@ class ref_gap_collector {
}
}
+
+
// update the _global_ maximum 'gaps-per-ref-position' map
- std::transform( ref_gaps_.begin(), ref_gaps_.end(), ref_gaps.begin(), ref_gaps_.begin(), std::max<size_t> );
+ // FIXME: because std::max is now has an overloaded for initializer_list, this does not work without wrapper on gnuc++11.
+ // For me, this is a flaw in the standard as it is a redundant feature, that breaks functioning
+ // code (i.e., *max_element(list.begin(),list.end() would already do the trick, and is actually what std::max(list)
+ // does internally on gnu c++. Why make an exception for initializer_list but not other containers?).
+
+// std::transform( ref_gaps_.begin(), ref_gaps_.end(), ref_gaps.begin(), ref_gaps_.begin(), std::max<size_t> );
+ std::transform( ref_gaps_.begin(), ref_gaps_.end(), ref_gaps.begin(), ref_gaps_.begin(), wrap_max<size_t> );
}
// TODO: shouldn't it be possible to infer the state_type from oiter?
View
2 pars_align_gapp_seq.h
@@ -38,7 +38,7 @@ class pars_align_gapp_seq {
enum {
BT_STAY = 0x1,
BT_STAY_L = 0x2,
- BT_UP = 0x4,
+ BT_UP = 0x4
};
class arrays {
View
2 pars_align_seq.h
@@ -42,7 +42,7 @@ class pars_align_seq {
enum {
BT_STAY = 0x1,
BT_STAY_L = 0x2,
- BT_UP = 0x4,
+ BT_UP = 0x4
};
class arrays {
View
39 vec_unit.h
@@ -449,9 +449,13 @@ struct vector_unit<float, 4> {
const static int SIGN_MASK_INT = 0x7FFFFFFF;
- const static T LARGE_VALUE = 1e8;
- const static T SMALL_VALUE = -1e8;
- const static T BIAS = 0;
+// const static T LARGE_VALUE = 1e8;
+// const static T SMALL_VALUE = -1e8;
+// const static T BIAS = 0;
+ const static T LARGE_VALUE;
+ const static T SMALL_VALUE;
+ const static T BIAS;
+
const static size_t W = 4;
static inline vec_t cast_from_int( const __m128i &iv ) {
@@ -543,13 +547,14 @@ struct vector_unit<float, 4> {
return bit_and(sub(a,b), set1(SIGN_MASK) ); // TODO: could this case any alignment problems?
//return bit_and(sub(a,b), set1(*((float*)&SIGN_MASK_INT) )); // TODO: could this case any alignment problems?
- //return bit_and(sub(a,b), load((float*)SIGN_MASK ));
-
- }
-
-
+ //return bit_and(sub(a,b), load((float*)SIGN_MASK ));
+ }
};
+const vector_unit<float,4>::T vector_unit<float,4>::LARGE_VALUE = 1e8;
+const vector_unit<float,4>::T vector_unit<float,4>::SMALL_VALUE = -1e8;
+const vector_unit<float,4>::T vector_unit<float,4>::BIAS = 0;
+
template<>
struct vector_unit<double, 2> {
@@ -560,9 +565,9 @@ struct vector_unit<double, 2> {
// const static uint64_t SIGN_MASK_U64 = 0x7FFFFFFFFFFFFFFF;
- const static T LARGE_VALUE = 1e8;
- const static T SMALL_VALUE = -1e8;
- const static T BIAS = 0;
+ const static T LARGE_VALUE;// = 1e8;
+ const static T SMALL_VALUE;// = -1e8;
+ const static T BIAS;// = 0;
const static size_t W = 2;
static inline vec_t cast_from_int( const __m128i &iv ) {
@@ -645,7 +650,8 @@ struct vector_unit<double, 2> {
static inline const vec_t max( const vec_t &a, const vec_t &b ) {
return _mm_max_pd( a, b );
}
-
+ // deactivated for now, beacuse of the missing ULL suffix in pre c++11
+#if 0
static inline const vec_t abs_diff( const vec_t &a, const vec_t &b ) {
// i don't really like this function, as ideally this would just be abs(sub(a,b)),
// but there doesn't seem to be a fast way to implement abs on pre SSSSSSE3.
@@ -658,14 +664,14 @@ struct vector_unit<double, 2> {
const double *SIGN_MASK_PTR = (double*)&SIGN_MASK_U64x;
double SIGN_MASK = *SIGN_MASK_PTR;
- return bit_and(sub(a,b), set1(SIGN_MASK) ); // TODO: could this case any alignment problems?
+ return bit_and(sub(a,b), set1(SIGN_MASK) ); // TODO: could this cause any alignment problems?
//return bit_and(sub(a,b), set1(*((float*)&SIGN_MASK_INT) )); // TODO: could this case any alignment problems?
//return bit_and(sub(a,b), load((float*)SIGN_MASK ));
}
-
+#endif
static inline const vec_t abs( const vec_t &a ) {
// const uint64_t SIGN_MASK_U64x = 0x7fffffffffffffff;
//
@@ -689,6 +695,11 @@ struct vector_unit<double, 2> {
};
+const double vector_unit<double,2>::LARGE_VALUE = 1e8;
+const double vector_unit<double,2>::SMALL_VALUE = -1e8;
+const double vector_unit<double,2>::BIAS = 0;
+
+
#ifdef __clang__
#pragma clang diagnostic pop
#endif

0 comments on commit 5ef2f6e

Please sign in to comment.
Something went wrong with that request. Please try again.