cluster-junctions.h 1.71 KB
Newer Older
Mathieu Giraud's avatar
Mathieu Giraud committed
1 2
#ifndef CLUSTER_JUNCTIONS_H
#define CLUSTER_JUNCTIONS_H
Mikaël Salson's avatar
Mikaël Salson committed
3 4 5 6 7 8 9 10

#include <fstream>
#include <iostream>
#include <string>
#include <map>
#include <list>
#include <ctime>
#include "dynprog.h"
Mathieu Giraud's avatar
Mathieu Giraud committed
11
#include "windows.h"
Mikaël Salson's avatar
Mikaël Salson committed
12 13 14 15 16 17 18 19 20

using namespace std ;

#define SIMILAR_JUNCTIONS_THRESHOLD 1


class comp_matrix {
  public:
    char ** m;
Mathieu Giraud's avatar
Mathieu Giraud committed
21
    WindowsStorage &windows;
Mikaël Salson's avatar
Mikaël Salson committed
22 23 24 25 26 27 28
    map <string, int> count;
    int n_j;
    int n_j2;
    
    /**
    * create new distance matrix
    */
Mathieu Giraud's avatar
Mathieu Giraud committed
29
    comp_matrix(WindowsStorage &windows);
Mikaël Salson's avatar
Mikaël Salson committed
30 31 32
        
    /**
    * init matrix with a KmerStore and compute distance value between sequences
WebTogz's avatar
WebTogz committed
33
    * @param cluster_cost
Mikaël Salson's avatar
Mikaël Salson committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
    * @param out: exit for log
    */
    void compare(ostream &out, Cost cluster_cost);
    
    /**
    * init matrix with a previous run stored 
    * @param file: a file containing the distance value between sequences
    */
    void load(string file);
    
    /**
    * store matrix in a file for future use
    * @param file: a filename to store the distance value between sequences
    */
    void save( string file);
    
    /**
    * @return cluster 
    * @param forced_edges: force some sequences to be in the same cluster
    * @param w: junctions size
    * @param out: exit for log
    * @param epsilon: maximum neighborhood distance 
    * @param minPts: minimum neighbors required 
    */
    list<list<junction> >  cluster(string forced_edges="",
					int w=0,ostream &out=cout,
					int epsilon=1, int minPts=10);
    
    list<list<junction> >  nocluster();
    
    /**
    * reset state 
    */
    void del();
    
69
    void stat_cluster( list<list<junction> > cluster, ostream &out=cout);
Mikaël Salson's avatar
Mikaël Salson committed
70

Mathieu Giraud's avatar
Mathieu Giraud committed
71 72 73 74 75 76 77
 private:
    
    /**
     * Allocates a matrix of size s * s bytes
     */
    char **alloc_matrix(size_t s);
};
Mikaël Salson's avatar
Mikaël Salson committed
78

Mathieu Giraud's avatar
Mathieu Giraud committed
79
#endif