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

New upstream version 1.0.9

parent 2d903137
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
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
+1 −2
Original line number Diff line number Diff line
@@ -27,4 +27,3 @@ ENDFOREACH(HEADER)
ENDMACRO(INSTALL_HEADERS_WITH_DIRECTORY)

INSTALL_HEADERS_WITH_DIRECTORY(HS)
+3 −3
Original line number Diff line number Diff line
#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:


};


+41 −1
Original line number Diff line number Diff line
@@ -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;
+16 −3
Original line number Diff line number Diff line
@@ -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) {
Loading