testCluster.cpp 3.34 KB
Newer Older
Mikaël Salson's avatar
Mikaël Salson committed
1
#include "core/tools.h"
Mathieu Giraud's avatar
Mathieu Giraud committed
2
#include "core/windows.h"
Mikaël Salson's avatar
Mikaël Salson committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#include "core/fasta.h"
#include "core/segment.h"
#include "core/cluster-junctions.h"
#include "core/read_score.h"
#include "core/read_chooser.h"
#include "core/compare-all.h"
#include "core/mkdir.h"
#include "core/labels.h"
#include <iostream>
#include <fstream>
#include <cassert>
#include <string>
#include <cstdlib>
using namespace std;


void testCluster() {

  int w=40;
   string forced_edges = "" ;

Mathieu Giraud's avatar
Mathieu Giraud committed
24 25
   map<string, string> labels;
   WindowsStorage windows = WindowsStorage(labels);
Mikaël Salson's avatar
Mikaël Salson committed
26

27
   Sequence seq = {"", "", "", "", NULL};
Mikaël Salson's avatar
Mikaël Salson committed
28

Mathieu Giraud's avatar
Mathieu Giraud committed
29 30 31 32
   windows.add("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAT", seq, 0, 0);
   windows.add("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", seq, 0, 0);
   windows.add("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAG", seq, 0, 0);
   windows.add("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC", seq, 0, 0);
Mikaël Salson's avatar
Mikaël Salson committed
33
   
Mathieu Giraud's avatar
Mathieu Giraud committed
34 35 36 37
   windows.add("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT", seq, 0, 0);
   windows.add("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTAAA", seq, 0, 0);
   windows.add("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTGGG", seq, 0, 0);
   windows.add("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTCCC", seq, 0, 0);
Mikaël Salson's avatar
Mikaël Salson committed
38
   
Mathieu Giraud's avatar
Mathieu Giraud committed
39 40 41 42
   windows.add("GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGTTTTTTTT", seq, 0, 0);
   windows.add("GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGAAAAAAAA", seq, 0, 0);
   windows.add("GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG", seq, 0, 0);
   windows.add("GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGCCCCCCCC", seq, 0, 0);
Mikaël Salson's avatar
Mikaël Salson committed
43
   
Mathieu Giraud's avatar
Mathieu Giraud committed
44 45 46 47
   windows.add("CCCCCCCCCCCCCCCCCCCCCCCCCTTTTTTTTTTTTTTT", seq, 0, 0);
   windows.add("CCCCCCCCCCCCCCCCCCCCCCCCCAAAAAAGCTAAAAAA", seq, 0, 0);
   windows.add("CCCCCCCCCCCCCCCCCCCCCCCCCGGGGGGTCTAGGGGG", seq, 0, 0);
   windows.add("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCATGCCCCCC", seq, 0, 0);
Mikaël Salson's avatar
Mikaël Salson committed
48

49 50
   windows.sort();
   list<pair <junction, int> > sort_clones = windows.getSortedList();
Mikaël Salson's avatar
Mikaël Salson committed
51
   
52
   comp_matrix comp=comp_matrix(sort_clones);
Mikaël Salson's avatar
Mikaël Salson committed
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
   
   //create matrix using junctions 
   comp.compare( cout, Cluster);
   
   //save matrix file 
   comp.save("comp_matrix.data");
   
   //reset matrix 
   comp.del();
   
   //create matrix using matrix file 
   comp.load("comp_matrix.data");
 
   //save matrix file 
   comp.save("comp_matrix2.data");
  
   //test clustering

   list <list <junction> > cluster ;

   //0 différence admise / taille mini 10 / 0 cluster possible
   cluster = comp.cluster(forced_edges, w, cout, 0, 10) ;
Mathieu Giraud's avatar
Mathieu Giraud committed
75 76
   TAP_TEST(cluster.size()==0, TEST_CLUSTER, 
            "no cluster here (cluster.size()=" <<cluster.size() << ")" ) ;
Mikaël Salson's avatar
Mikaël Salson committed
77 78 79

   //epsilon 0// taille mini 1 / 16 cluster possible
   cluster = comp.cluster(forced_edges, w, cout, 0, 1) ;
Mathieu Giraud's avatar
Mathieu Giraud committed
80
   TAP_TEST(cluster.size()==16, TEST_CLUSTER, "expected 16 clusters (cluster.size()=" <<cluster.size() << ")") ;
Mikaël Salson's avatar
Mikaël Salson committed
81 82 83

   //epsilon 1// taille mini 3 / 1 cluster possible
   cluster = comp.cluster(forced_edges, w, cout, 1, 3) ;
Mathieu Giraud's avatar
Mathieu Giraud committed
84
   TAP_TEST(cluster.size()==1, TEST_CLUSTER, "expected 1 cluster (cluster.size()=" <<cluster.size() << ")") ;
Mikaël Salson's avatar
Mikaël Salson committed
85 86 87

   //epsilon 3// taille mini 3 / 2 cluster possible
   cluster = comp.cluster(forced_edges, w, cout, 3, 3) ;
Mathieu Giraud's avatar
Mathieu Giraud committed
88
   TAP_TEST(cluster.size()==2, TEST_CLUSTER, "expected 2 clusters (cluster.size()=" <<cluster.size() << ")") ;
Mikaël Salson's avatar
Mikaël Salson committed
89 90 91
   
   //epsilon 20 // taille mini 3 / 4 cluster possible
   cluster = comp.cluster(forced_edges, w, cout, 20, 3) ;
Mathieu Giraud's avatar
Mathieu Giraud committed
92
   TAP_TEST(cluster.size()==4, TEST_CLUSTER, "expected 4 clusters (cluster.size()=" <<cluster.size() << ")") ;
Mikaël Salson's avatar
Mikaël Salson committed
93 94 95 96 97 98

   //del matrix 
   comp.del();

}