Browse files

work on multigene pipeline.

  • Loading branch information...
1 parent 448e1bc commit a722f68b3e74e48592a22a4fd599d81a2455d63c @sim82 committed Sep 21, 2012
Showing with 57 additions and 4 deletions.
  1. +3 −1 CMakeLists.txt
  2. +3 −3 blast_partassign.cpp
  3. +51 −0 phy_to_fasta.cpp
View
4 CMakeLists.txt
@@ -14,7 +14,7 @@ add_subdirectory(ublasJama-1.0.2.3)
# this is a hack: only add subdirectories if IVYMIKE_INCLUDE is not already set.
# IVYMIKE_INCLUDE is abused as a flag indicating that papara should be build in 'library-only' mode...
add_subdirectory(ivy_mike)
-# add_subdirectory(genassign_blast)
+add_subdirectory(genassign_blast)
# ENDIF()
include_directories( ${include_directories} ${IVYMIKE_INCLUDE} . ublasJama-1.0.2.3 )
@@ -49,11 +49,13 @@ ADD_LIBRARY( papara_core STATIC papara.cpp pvec.cpp pars_align_seq.cpp pars_alig
add_executable(papara papara2_main.cpp ${ALL_HEADERS})
add_executable(fasta_random_sample2 fasta_random_sample2.cpp ${ALL_HEADERS})
add_executable(fasta_to_phy fasta_to_phy.cpp ${ALL_HEADERS})
+add_executable(phy_to_fasta phy_to_fasta.cpp ${ALL_HEADERS})
# add_executable(pw_dist pw_dist.cpp pairwise_seq_distance.cpp )
# target_link_libraries(papara_nt ivymike ublas_jama ${SYSDEP_LIBS} )
target_link_libraries(papara papara_core ivymike ublas_jama ${SYSDEP_LIBS} )
+target_link_libraries(phy_to_fasta ivymike ${SYSDEP_LIBS} )
# target_link_libraries(pw_dist ivymike ${BOOST_LIBS} ${SYSDEP_LIBS})
View
6 blast_partassign.cpp
@@ -24,7 +24,7 @@ blast_hit partassign::next_hit( std::istream &is ) {
std::getline( is, line );
- std::istringstream ss(line);
+
// TODO: ok returning an default constructed blast_hit to signal EOF is not the best idea... I actually planned that EOF
// should be checked _before_ calling this function, but it didn't turn out to work...
@@ -48,8 +48,8 @@ blast_hit partassign::next_hit( std::istream &is ) {
blast_hit hit;
//bool valid = ss >> hit.qs_name >> hit.ref_name >> ident >> len >> mismatch >> gap_open >> hit.qs_start >> hit.qs_end >> hit.ref_start >> hit.ref_end >> evalue >> hit.bit_score;
-
- bool valid = !(std::istringstream(line) >> hit.qs_name >> hit.ref_name >> ident >> len >> mismatch >> gap_open >> hit.qs_start >> hit.qs_end >> hit.ref_start >> hit.ref_end >> evalue >> hit.bit_score).fail();
+ std::istringstream ss(line);
+ bool valid = !(ss >> hit.qs_name >> hit.ref_name >> ident >> len >> mismatch >> gap_open >> hit.qs_start >> hit.qs_end >> hit.ref_start >> hit.ref_end >> evalue >> hit.bit_score).fail();
// convert indices into proper form
hit.ref_start -= 1;
View
51 phy_to_fasta.cpp
@@ -0,0 +1,51 @@
+#include <iostream>
+#include <algorithm>
+#include "ivymike/fasta.h"
+#include "ivymike/multiple_alignment.h"
+#include "ivymike/algorithm.h"
+#include "ivymike/tree_traversal_utils.h"
+
+static bool nogap( char c ) {
+ c = toupper(c);
+ return c != '-' && c != 'N';
+}
+
+#if __cplusplus >= 199711L
+namespace std {
+// OH NOES, copy_if is c++11... rip it from gnu
+ template<typename _InputIterator, typename _OutputIterator,
+ typename _Predicate>
+_OutputIterator copy_if(_InputIterator __first, _InputIterator __last,
+ _OutputIterator __result, _Predicate __pred)
+{
+
+ for (; __first != __last; ++__first)
+ if (__pred(*__first))
+ {
+ *__result = *__first;
+ ++__result;
+ }
+ return __result;
+}
+}
+#endif
+
+int main() {
+ ivy_mike::multiple_alignment ma;
+ ma.load_phylip( std::cin );
+
+ for( size_t i = 0; i < ma.names.size(); ++i ) {
+ std::cout << ">" << ma.names[i] << "\n";
+
+
+ const std::vector< uint8_t > &d = ma.data.at(i);
+
+
+ std::copy_if( d.begin(), d.end(), std::ostream_iterator<char>(std::cout), nogap );
+ std::cout << "\n";
+
+ }
+
+
+ return 1;
+}

0 comments on commit a722f68

Please sign in to comment.