...
 
Commits (3)
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
- bug fix when searching with errors, some branches in tree were not analysed
1.0.7: 11/12/17 O. Sallou
......
cassiopee (1.0.9-1) unstable; urgency=medium
* New upstream release
-- Olivier Sallou <osallou@debian.org> Thu, 23 Aug 2018 06:40:56 +0000
cassiopee (1.0.8-2) unstable; urgency=medium
* Fix libcassie-dev, wrong location for includes
......
......@@ -12,7 +12,7 @@ target_link_libraries(cassiopeeknife cassie glog ${Boost_LIBRARIES} )
# add the install targets
install (TARGETS cassiopee DESTINATION bin)
install (TARGETS cassiopeeknife DESTINATION bin)
install (FILES "${PROJECT_BINARY_DIR}/CassiopeeConfig.h"
install (FILES "${PROJECT_BINARY_DIR}/CassiopeeConfig.h"
DESTINATION include)
install (TARGETS cassie DESTINATION lib)
......@@ -27,4 +27,3 @@ ENDFOREACH(HEADER)
ENDMACRO(INSTALL_HEADERS_WITH_DIRECTORY)
INSTALL_HEADERS_WITH_DIRECTORY(HS)
#include <iostream>
#include <fstream>
#include <list>
#include <map>
#include "tree/tree.hh"
......@@ -349,6 +350,8 @@ public:
*/
void removeDuplicates();
map<std::string, string> morphisms;
/**
* Used to store max errors allowed
*/
......@@ -481,6 +484,3 @@ private:
};
......@@ -4,6 +4,7 @@
#include <unistd.h>
#include <libgen.h>
#include <algorithm>
#include <map>
#include "Cassiopee.h"
......@@ -28,6 +29,7 @@ void showUsage() {
fprintf(stdout,"\t-t: output format: 0:tsv (default), 1:json\n");
fprintf(stdout,"\t-x: minimum 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-h: show this message\n");
}
......@@ -67,6 +69,10 @@ int main (int argc, char *argv[])
long max_index_depth = 0;
bool hasMorphisms = false;
string morphisms;
map<std::string, string> mapOfMorph;
bool graph = false;
long max_graph = 0;
......@@ -76,9 +82,12 @@ int main (int argc, char *argv[])
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)
{
case 'b':
morphisms = string(optarg);
hasMorphisms = true;
case 'l':
max_index_depth = atol(optarg);
case 'u':
......@@ -168,6 +177,34 @@ int main (int argc, char *argv[])
google::InitGoogleLogging(sequence);
//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) {
ifstream pfile(pattern_file);
if(pfile.is_open()) {
......@@ -203,6 +240,9 @@ int main (int argc, char *argv[])
DLOG(INFO) << "Tree size: " <<indexer->getTree()->size();
CassieSearch* searcher = new CassieSearch(indexer);
if(hasMorphisms){
searcher->morphisms = mapOfMorph;
}
searcher->mode = mode;
// Allow 1 substitution for test
searcher->max_subst = max_subst;
......
......@@ -135,11 +135,24 @@ bool CassieSearch::isequal(char a, char b) {
return true;
}
if(this->ambiguity && this->mode!=2) {
return Ambiguous::isequal(a,b);
if(Ambiguous::isequal(a,b)) {
return true;
}
}
else {
return a==b;
if(this->morphisms.size() != 0){
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) {
......
This diff is collapsed.
......@@ -186,6 +186,27 @@ void CassiopeeTest::testProtein()
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()
{
......
......@@ -16,6 +16,7 @@ class CassiopeeTest : public CppUnit::TestFixture
CPPUNIT_TEST( testProtein );
CPPUNIT_TEST( testLoadSave );
CPPUNIT_TEST( testMultiIndex );
CPPUNIT_TEST( testSearchWithMorphism );
CPPUNIT_TEST_SUITE_END();
public:
......@@ -27,6 +28,7 @@ public:
void testSearchInReduction();
void testAmbiguity();
void testSearchWithError();
void testSearchWithMorphism();
void testSearchAfterN();
void testSearchWithN();
void testReducedSearchAfterN();
......