cluster-junctions.h 1.86 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"
12
#include "../lib/json_fwd.hpp"
Mikaël Salson's avatar
Mikaël Salson committed
13 14

using namespace std ;
15
using json = nlohmann::json;
Mikaël Salson's avatar
Mikaël Salson committed
16 17

#define SIMILAR_JUNCTIONS_THRESHOLD 1
18
#define JUNCTION_LIMIT 200
Mikaël Salson's avatar
Mikaël Salson committed
19 20 21 22 23


class comp_matrix {
  public:
    char ** m;
24
    list<pair <junction, size_t> > sort_clones;
Mikaël Salson's avatar
Mikaël Salson committed
25 26 27
    map <string, int> count;
    int n_j;
    int n_j2;
28
    size_t matrix_size;
Mikaël Salson's avatar
Mikaël Salson committed
29 30 31 32
    
    /**
    * create new distance matrix
    */
33
    comp_matrix(list<pair <junction, size_t> > sc);
Mikaël Salson's avatar
Mikaël Salson committed
34 35 36
        
    /**
    * init matrix with a KmerStore and compute distance value between sequences
WebTogz's avatar
WebTogz committed
37
    * @param cluster_cost
Mikaël Salson's avatar
Mikaël Salson committed
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 69 70
    * @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);
    
    /**
    * reset state 
    */
    void del();
    
71
    void stat_cluster( list<list<junction> > cluster, ostream &out=cout);
72
    
73
    json toJson( list<list<junction> > cluster);
74
  
Mikaël Salson's avatar
Mikaël Salson committed
75

Mathieu Giraud's avatar
Mathieu Giraud committed
76 77 78 79 80 81 82
 private:
    
    /**
     * Allocates a matrix of size s * s bytes
     */
    char **alloc_matrix(size_t s);
};
Mikaël Salson's avatar
Mikaël Salson committed
83

Mathieu Giraud's avatar
Mathieu Giraud committed
84
#endif