Commit 23255cbc authored by Olivier Sallou's avatar Olivier Sallou

New upstream version 1.0.9

parent 2d903137
1.0.9: 16/08/18 O. Sallou
- Add new public method to CassieSearch vector<Match*> GetMatchList()
- Add morphism support (option -b) closes #2
1.0.8: 12/04/18 O. Sallou 1.0.8: 12/04/18 O. Sallou
- bug fix when searching with errors, some branches in tree were not analysed - bug fix when searching with errors, some branches in tree were not analysed
1.0.7: 11/12/17 O. Sallou 1.0.7: 11/12/17 O. Sallou
......
...@@ -12,7 +12,7 @@ target_link_libraries(cassiopeeknife cassie glog ${Boost_LIBRARIES} ) ...@@ -12,7 +12,7 @@ target_link_libraries(cassiopeeknife cassie glog ${Boost_LIBRARIES} )
# add the install targets # add the install targets
install (TARGETS cassiopee DESTINATION bin) install (TARGETS cassiopee DESTINATION bin)
install (TARGETS cassiopeeknife DESTINATION bin) install (TARGETS cassiopeeknife DESTINATION bin)
install (FILES "${PROJECT_BINARY_DIR}/CassiopeeConfig.h" install (FILES "${PROJECT_BINARY_DIR}/CassiopeeConfig.h"
DESTINATION include) DESTINATION include)
install (TARGETS cassie DESTINATION lib) install (TARGETS cassie DESTINATION lib)
...@@ -27,4 +27,3 @@ ENDFOREACH(HEADER) ...@@ -27,4 +27,3 @@ ENDFOREACH(HEADER)
ENDMACRO(INSTALL_HEADERS_WITH_DIRECTORY) ENDMACRO(INSTALL_HEADERS_WITH_DIRECTORY)
INSTALL_HEADERS_WITH_DIRECTORY(HS) INSTALL_HEADERS_WITH_DIRECTORY(HS)
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <list> #include <list>
#include <map>
#include "tree/tree.hh" #include "tree/tree.hh"
...@@ -349,6 +350,8 @@ public: ...@@ -349,6 +350,8 @@ public:
*/ */
void removeDuplicates(); void removeDuplicates();
map<std::string, string> morphisms;
/** /**
* Used to store max errors allowed * Used to store max errors allowed
*/ */
...@@ -481,6 +484,3 @@ private: ...@@ -481,6 +484,3 @@ private:
}; };
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <unistd.h> #include <unistd.h>
#include <libgen.h> #include <libgen.h>
#include <algorithm> #include <algorithm>
#include <map>
#include "Cassiopee.h" #include "Cassiopee.h"
...@@ -28,6 +29,7 @@ void showUsage() { ...@@ -28,6 +29,7 @@ void showUsage() {
fprintf(stdout,"\t-t: output format: 0:tsv (default), 1:json\n"); fprintf(stdout,"\t-t: output format: 0:tsv (default), 1:json\n");
fprintf(stdout,"\t-x: minimum position in sequence\n"); fprintf(stdout,"\t-x: minimum position in sequence\n");
fprintf(stdout,"\t-y: maximum position in sequence\n"); fprintf(stdout,"\t-y: maximum position in sequence\n");
fprintf(stdout,"\t-b: apply morphisms to pattern\n");
fprintf(stdout,"\t-v: show version\n"); fprintf(stdout,"\t-v: show version\n");
fprintf(stdout,"\t-h: show this message\n"); fprintf(stdout,"\t-h: show this message\n");
} }
...@@ -67,6 +69,10 @@ int main (int argc, char *argv[]) ...@@ -67,6 +69,10 @@ int main (int argc, char *argv[])
long max_index_depth = 0; long max_index_depth = 0;
bool hasMorphisms = false;
string morphisms;
map<std::string, string> mapOfMorph;
bool graph = false; bool graph = false;
long max_graph = 0; long max_graph = 0;
...@@ -76,9 +82,12 @@ int main (int argc, char *argv[]) ...@@ -76,9 +82,12 @@ int main (int argc, char *argv[])
bool save = false; bool save = false;
while ((c = getopt (argc, argv, "ud:ge:i:m:arhvs:p:n:t:o:f:x:y:l:")) != -1) while ((c = getopt (argc, argv, "ud:ge:i:m:arhvs:p:b:n:t:o:f:x:y:l:")) != -1)
switch (c) switch (c)
{ {
case 'b':
morphisms = string(optarg);
hasMorphisms = true;
case 'l': case 'l':
max_index_depth = atol(optarg); max_index_depth = atol(optarg);
case 'u': case 'u':
...@@ -168,6 +177,34 @@ int main (int argc, char *argv[]) ...@@ -168,6 +177,34 @@ int main (int argc, char *argv[])
google::InitGoogleLogging(sequence); google::InitGoogleLogging(sequence);
//google::SetLogDestination(google::GLOG_INFO,string(dirname(sequence)).c_str() ); //google::SetLogDestination(google::GLOG_INFO,string(dirname(sequence)).c_str() );
if(hasMorphisms){
DLOG(INFO) << "input morph " << morphisms;
//a,g,c,ta ==> a=>g,c=>ta
char* buf = strdup(morphisms.c_str());
char *pch;
char *key;
char *value;
pch = strtok (buf, ",");
key = pch;
pch = strtok (NULL, ",");
value = pch;
mapOfMorph[string(key)] = string(value);
//DLOG(INFO) << "insert " << key << ":" << value;
while (pch != NULL)
{
pch = strtok (NULL, ",");
if(pch == NULL) {
break;
}
key = pch;
pch = strtok (NULL, ",");
value = pch;
mapOfMorph[string(key)] = string(value);
//DLOG(INFO) << "insert " << key << ":" << value;
}
}
if(pattern_file!=NULL) { if(pattern_file!=NULL) {
ifstream pfile(pattern_file); ifstream pfile(pattern_file);
if(pfile.is_open()) { if(pfile.is_open()) {
...@@ -203,6 +240,9 @@ int main (int argc, char *argv[]) ...@@ -203,6 +240,9 @@ int main (int argc, char *argv[])
DLOG(INFO) << "Tree size: " <<indexer->getTree()->size(); DLOG(INFO) << "Tree size: " <<indexer->getTree()->size();
CassieSearch* searcher = new CassieSearch(indexer); CassieSearch* searcher = new CassieSearch(indexer);
if(hasMorphisms){
searcher->morphisms = mapOfMorph;
}
searcher->mode = mode; searcher->mode = mode;
// Allow 1 substitution for test // Allow 1 substitution for test
searcher->max_subst = max_subst; searcher->max_subst = max_subst;
......
...@@ -135,11 +135,24 @@ bool CassieSearch::isequal(char a, char b) { ...@@ -135,11 +135,24 @@ bool CassieSearch::isequal(char a, char b) {
return true; return true;
} }
if(this->ambiguity && this->mode!=2) { if(this->ambiguity && this->mode!=2) {
return Ambiguous::isequal(a,b); if(Ambiguous::isequal(a,b)) {
return true;
}
} }
else { if(this->morphisms.size() != 0){
return a==b; string s; s.push_back(b);
map<string,string>::iterator it=this->morphisms.find(string(s));
if ( it != this->morphisms.end() ) {
//Try morphisms
char* morphValues = strdup(it->second.c_str());
for(char* it = morphValues; *it; ++it) {
if(*it == a) {
return true;
}
}
}
} }
return false;
} }
void CassieSearch::getMatchesFromNode(tree<TreeNode>::iterator sib, const int nbSubsts, const int nbIn, const int nbDel) { void CassieSearch::getMatchesFromNode(tree<TreeNode>::iterator sib, const int nbSubsts, const int nbIn, const int nbDel) {
......
This diff is collapsed.
...@@ -186,6 +186,27 @@ void CassiopeeTest::testProtein() ...@@ -186,6 +186,27 @@ void CassiopeeTest::testProtein()
delete indexer; delete indexer;
} }
void CassiopeeTest::testSearchWithMorphism()
{
char sequence[] = "test/sequence.txt";
char* seq = sequence;
CassieIndexer* indexer = new CassieIndexer(seq);
indexer->do_reduction = true;
indexer->max_index_depth = 5;
indexer->index();
CassieSearch* searcher = new CassieSearch(indexer);
searcher->morphisms["g"] = "a";
searcher->search("tgtg");
searcher->sort();
list<Match*> matches = searcher->matches;
std::list<Match*>::iterator it = matches.begin();
if((*it)->pos != 71) {
CPPUNIT_FAIL( "wrong position" );
}
}
void CassiopeeTest::testSearchWithError() void CassiopeeTest::testSearchWithError()
{ {
......
...@@ -16,6 +16,7 @@ class CassiopeeTest : public CppUnit::TestFixture ...@@ -16,6 +16,7 @@ class CassiopeeTest : public CppUnit::TestFixture
CPPUNIT_TEST( testProtein ); CPPUNIT_TEST( testProtein );
CPPUNIT_TEST( testLoadSave ); CPPUNIT_TEST( testLoadSave );
CPPUNIT_TEST( testMultiIndex ); CPPUNIT_TEST( testMultiIndex );
CPPUNIT_TEST( testSearchWithMorphism );
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
public: public:
...@@ -27,6 +28,7 @@ public: ...@@ -27,6 +28,7 @@ public:
void testSearchInReduction(); void testSearchInReduction();
void testAmbiguity(); void testAmbiguity();
void testSearchWithError(); void testSearchWithError();
void testSearchWithMorphism();
void testSearchAfterN(); void testSearchAfterN();
void testSearchWithN(); void testSearchWithN();
void testReducedSearchAfterN(); void testReducedSearchAfterN();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment