Loading...
Searching...
No Matches
Cassiopee.h
#include <iostream>
#include <fstream>
#include <list>
#include <map>
#include "tree/tree.hh"
#include "CassiopeeConfig.h"
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>
// Provide an implementation of serialize for std::list
#include <boost/serialization/list.hpp>
using namespace std;
class Match {
public:
bool operator==(const Match& p) const {
return pos == p.pos && in+del == p.in + p.del;
}
int in;
int del;
int subst;
long pos;
Match();
};
class TreeNode {
public:
char c;
list<long> positions;
long next_pos;
long next_length;
TreeNode(char nc);
TreeNode(char nc, long pos);
TreeNode();
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int /*version*/)
{
ar & c;
ar & next_pos;
ar & next_length;
ar & positions;
}
};
#ifndef __CASSIOPEE_H_
#define __CASSIOPEE_H_
//inline std::ostream& operator<<(std::ostream &strm, const TreeNode &a) {
// return strm << "TreeNode(" << a.c << ")";
//}
#endif
class CassieIndexer {
public:
CassieIndexer(const char* path);
~CassieIndexer();
void save();
void load();
void graph();
void graph(int depth);
string getSuffix(long pos);
void index();
tree<TreeNode>* getTree();
list<Match> matches;
bool do_reduction;
char getCharAtSuffix(long pos);
void filltree(long pos);
long max_depth;
long max_index_depth;
long seq_length;
bool index_loaded_from_file();
private:
list<TreeNode> serialized_nodes;
bool loaded_from_file;
const char* filename;
ifstream seqstream;
tree<TreeNode> tr;
const long MAX_SUFFIX;
long suffix_position;
char* suffix;
long graphNode(tree<TreeNode>::iterator node, long counter, ofstream& myfile, int maxdepth);
char* loadSuffix(long pos);
void reset_suffix();
void fillTreeWithSuffix(tree<TreeNode>::iterator sib, long suffix_pos, long pos);
void fillTreeWithSuffix(long suffix_pos, long pos);
};
class CassiopeeUtils {
public:
static void transform_fasta(const string in, const string out);
};
class Ambiguous {
public:
static bool isequal(char a, char b);
private:
static bool ismatchequal(char a, const char b[], int len);
static const char K_MATCH[];
static const char M_MATCH[];
static const char R_MATCH[];
static const char Y_MATCH[];
static const char S_MATCH[];
static const char W_MATCH[];
static const char B_MATCH[];
static const char V_MATCH[];
static const char H_MATCH[];
static const char D_MATCH[];
static const char N_MATCH[];
};
struct per_position
{
inline bool operator() (const Match* struct1, const Match* struct2)
{
return (struct1->pos < struct2->pos);
}
};
class CassieSearch {
public:
CassieSearch(CassieIndexer* index_ref);
~CassieSearch();
void removeDuplicates();
map<std::string, string> morphisms;
Match* match_limits;
list<Match*> matches;
bool ambiguity;
int nmax;
int mode;
void search(string suffix, bool clear);
void search(string suffix);
void search(string suffixes[]);
bool isequal(char a,char b);
int max_indel;
int max_subst;
long pattern_length;
void sort();
private:
static bool same_match (Match* first, Match* second)
{ return ( *first == *second ); }
CassieIndexer* indexer;
void getMatchesFromNode(tree<TreeNode>::iterator sib, const int nbSubst, const int nbIn, const int nbDel);
void searchAtNode(string suffix, const long suffix_pos, const tree<TreeNode>::iterator root, int nbSubst, int nbIn, int nbDel, int nbN);
void searchAtNode(string suffix, const long suffix_pos, const tree<TreeNode>::iterator root, const tree<TreeNode>::iterator start_node, int nbSubst, int nbIn, int nbDel, int nbN);
bool searchAtreduction(const string suffix, const tree<TreeNode>::iterator sib, long counter, long tree_reducted_pos, int nbSubst, int nbIn, int nbDel, int nbN);
};
Ambiguous
Definition Cassiopee.h:290
Ambiguous::isequal
static bool isequal(char a, char b)
Definition cassiopee.cxx:77
CassieIndexer
Definition Cassiopee.h:136
CassieIndexer::graph
void graph()
Definition cassiopee.cxx:574
CassieIndexer::do_reduction
bool do_reduction
Definition Cassiopee.h:198
CassieIndexer::getTree
tree< TreeNode > * getTree()
Definition cassiopee.cxx:836
CassieIndexer::max_index_depth
long max_index_depth
Definition Cassiopee.h:221
CassieIndexer::filltree
void filltree(long pos)
Definition cassiopee.cxx:840
CassieIndexer::CassieIndexer
CassieIndexer(const char *path)
Definition cassiopee.cxx:504
CassieIndexer::max_depth
long max_depth
Definition Cassiopee.h:215
CassieIndexer::index
void index()
Definition cassiopee.cxx:621
CassieIndexer::getCharAtSuffix
char getCharAtSuffix(long pos)
Definition cassiopee.cxx:525
CassieIndexer::save
void save()
Definition cassiopee.cxx:666
CassieIndexer::index_loaded_from_file
bool index_loaded_from_file()
Definition cassiopee.cxx:660
CassieIndexer::matches
list< Match > matches
Definition Cassiopee.h:193
CassieIndexer::load
void load()
Definition cassiopee.cxx:710
CassieIndexer::getSuffix
string getSuffix(long pos)
Definition cassiopee.cxx:748
CassieSearch::sort
void sort()
Definition cassiopee.cxx:197
CassieSearch::nmax
int nmax
Definition Cassiopee.h:374
CassieSearch::match_limits
Match * match_limits
Definition Cassiopee.h:358
CassieSearch::isequal
bool isequal(char a, char b)
Definition cassiopee.cxx:127
CassieSearch::max_indel
int max_indel
Definition Cassiopee.h:418
CassieSearch::search
void search(string suffix, bool clear)
Definition cassiopee.cxx:216
CassieSearch::ambiguity
bool ambiguity
Definition Cassiopee.h:369
CassieSearch::removeDuplicates
void removeDuplicates()
Definition cassiopee.cxx:294
CassieSearch::matches
list< Match * > matches
Definition Cassiopee.h:363
CassieSearch::mode
int mode
Definition Cassiopee.h:383
CassieSearch::CassieSearch
CassieSearch(CassieIndexer *index_ref)
Definition cassiopee.cxx:117
CassieSearch::max_subst
int max_subst
Definition Cassiopee.h:422
CassiopeeUtils
Definition Cassiopee.h:279
CassiopeeUtils::transform_fasta
static void transform_fasta(const string in, const string out)
Definition cassiopee.cxx:16
Match
Definition Cassiopee.h:25
Match::operator==
bool operator==(const Match &p) const
Definition Cassiopee.h:31
Match::subst
int subst
Definition Cassiopee.h:46
Match::del
int del
Definition Cassiopee.h:42
Match::in
int in
Definition Cassiopee.h:38
TreeNode::TreeNode
TreeNode(char nc)
Definition cassiopee.cxx:44
TreeNode::c
char c
Definition Cassiopee.h:70
TreeNode::next_length
long next_length
Definition Cassiopee.h:88
TreeNode::positions
list< long > positions
Definition Cassiopee.h:76
TreeNode::next_pos
long next_pos
Definition Cassiopee.h:83
per_position
Definition Cassiopee.h:325