Commit 6b4bd2a4 authored by Mikael Salson's avatar Mikael Salson

nb_reads: For consistency reasons the number of reads is stored eveywhere with...

nb_reads: For consistency reasons the number of reads is stored eveywhere with size_t instead of int
parent b13436cd
......@@ -28,7 +28,7 @@
return lh.second>rh.second;
}
comp_matrix::comp_matrix(list<pair <junction, int> > sc)
comp_matrix::comp_matrix(list<pair <junction, size_t> > sc)
{
sort_clones = sc;
matrix_size = sort_clones.size();
......@@ -53,14 +53,14 @@ void comp_matrix::compare(ostream &out, Cost cluster_cost)
int c2=0;
size_t i = 0;
for (list <pair<junction,int> >::const_iterator it0 = sort_clones.begin();
for (list <pair<junction,size_t> >::const_iterator it0 = sort_clones.begin();
(it0 != sort_clones.end()) & (i<matrix_size); ++it0)
{
i++;
j1=it0->first;
size_t k = 0;
for (list <pair<junction,int> >::const_iterator it1 = it0;
for (list <pair<junction,size_t> >::const_iterator it1 = it0;
(it1 != sort_clones.end()) & (k<matrix_size); ++it1)
{
k++;
......@@ -139,7 +139,7 @@ list<list<junction> > comp_matrix::cluster(string forced_edges, int w, ostream
int c2=0;
size_t i = 0;
for (list <pair<junction,int> >::const_iterator ite = sort_clones.begin();
for (list <pair<junction,size_t> >::const_iterator ite = sort_clones.begin();
(ite != sort_clones.end()) & (i<matrix_size); ++ite)
{
i++;
......@@ -150,7 +150,7 @@ list<list<junction> > comp_matrix::cluster(string forced_edges, int w, ostream
}
i = 0;
for (list <pair<junction,int> >::const_iterator it0 = sort_clones.begin();
for (list <pair<junction,size_t> >::const_iterator it0 = sort_clones.begin();
(it0 != sort_clones.end()) & (i<matrix_size); ++it0)
{
i++;
......@@ -160,7 +160,7 @@ list<list<junction> > comp_matrix::cluster(string forced_edges, int w, ostream
n_j2+=k;
size_t j = 0;
for (list <pair<junction,int> >::const_iterator it1 = sort_clones.begin();
for (list <pair<junction,size_t> >::const_iterator it1 = sort_clones.begin();
(it1 != sort_clones.end()) & (j<matrix_size); ++it1)
{
j++;
......@@ -231,7 +231,7 @@ list<list<junction> > comp_matrix::cluster(string forced_edges, int w, ostream
int noise = 0;
int nb_comp = 0 ;
i = 0;
for (list <pair<junction,int> >::const_iterator it0 = sort_clones.begin();
for (list <pair<junction,size_t> >::const_iterator it0 = sort_clones.begin();
(it0 != sort_clones.end()) & (i<matrix_size); ++it0)
{
i++;
......
......@@ -20,7 +20,7 @@ using namespace std ;
class comp_matrix {
public:
char ** m;
list<pair <junction, int> > sort_clones;
list<pair <junction, size_t> > sort_clones;
map <string, int> count;
int n_j;
int n_j2;
......@@ -29,7 +29,7 @@ class comp_matrix {
/**
* create new distance matrix
*/
comp_matrix(list<pair <junction, int> > sc);
comp_matrix(list<pair <junction, size_t> > sc);
/**
* init matrix with a KmerStore and compute distance value between sequences
......
......@@ -97,14 +97,14 @@ SimilarityMatrix compare_windows(WindowsStorage &windowsStorage, const Cost theC
return matrix;
//Creation of a pair list, which contains junctions/windows (index) and the number of occurences of this (value)
list<pair <junction, int> > sortedList = windowsStorage.getSortedList();
list<pair <junction, size_t> > sortedList = windowsStorage.getSortedList();
//Positions of the array
int positionIt1 = 0;
int positionIt2 = 0;
//Process of the junctions (windows)
for (list<pair <junction, int> >:: const_iterator it1 = sortedList.begin();
for (list<pair <junction, size_t> >:: const_iterator it1 = sortedList.begin();
it1 != sortedList.end(); ++it1) {
//We save the name of the junction
......@@ -114,7 +114,7 @@ SimilarityMatrix compare_windows(WindowsStorage &windowsStorage, const Cost theC
if (positionIt1 >= nb_clones) break;
//Process of the second junctions
for (list<pair <junction, int> >:: const_iterator it2 = sortedList.begin();
for (list<pair <junction, size_t> >:: const_iterator it2 = sortedList.begin();
it2 != sortedList.end(); ++it2) {
string win2 = it2->first;
......
......@@ -10,7 +10,7 @@
WindowsStorage::WindowsStorage(map<string, string> &labels):windows_labels(labels) {}
list<pair <junction, int> > &WindowsStorage::getSortedList() {
list<pair <junction, size_t> > &WindowsStorage::getSortedList() {
return sort_all_windows;
}
......@@ -88,7 +88,7 @@ set<Germline *> WindowsStorage::getTopGermlines(size_t top, size_t min_reads) {
set<Germline *> top_germlines;
size_t count = 0;
for (list<pair <junction, int> >::const_iterator it = sort_all_windows.begin();
for (list<pair <junction, size_t> >::const_iterator it = sort_all_windows.begin();
it != sort_all_windows.end() && count < top && (size_t)it->second >= min_reads;
++it, ++count) {
top_germlines.insert(getGermline(it->first));
......@@ -142,9 +142,9 @@ void WindowsStorage::fillStatsClones()
}
}
pair <int, int> WindowsStorage::keepInterestingWindows(size_t min_reads_window) {
pair <int, size_t> WindowsStorage::keepInterestingWindows(size_t min_reads_window) {
int removes = 0 ;
int nb_reads = 0 ;
size_t nb_reads = 0 ;
for (map <junction, list<Sequence> >::iterator it = seqs_by_window.begin();
it != seqs_by_window.end(); ) // We do not advance the iterator here because of the deletion
......@@ -185,7 +185,7 @@ void WindowsStorage::sort() {
ostream &WindowsStorage::printSortedWindows(ostream &os) {
int num_seq = 0 ;
for (list<pair <junction, int> >::const_iterator it = sort_all_windows.begin();
for (list<pair <junction, size_t> >::const_iterator it = sort_all_windows.begin();
it != sort_all_windows.end(); ++it)
{
num_seq++ ;
......@@ -200,7 +200,7 @@ JsonArray WindowsStorage::sortedWindowsToJsonArray(map <junction, JsonList> json
JsonArray windowsArray;
int top = 1;
for (list<pair <junction, int> >::const_iterator it = sort_all_windows.begin();
for (list<pair <junction, size_t> >::const_iterator it = sort_all_windows.begin();
it != sort_all_windows.end(); ++it)
{
......
......@@ -30,7 +30,7 @@ class WindowsStorage {
map<junction, Germline* > germline_by_window;
map<junction, size_t> reads_by_window;
map<string, string> windows_labels;
list<pair <junction, int> > sort_all_windows;
list<pair <junction, size_t> > sort_all_windows;
map<junction, int> id_by_window;
public:
/**
......@@ -98,7 +98,7 @@ class WindowsStorage {
* @pre sort() must have been called at least once and must have been called
* again after calling keepInterestingWindows()
*/
list<pair <junction, int> > &getSortedList();
list<pair <junction, size_t> > &getSortedList();
/**
* The number of windows stored
......@@ -147,7 +147,7 @@ class WindowsStorage {
* @return the number of windows removed as well as the number of
* reads finally kept.
*/
pair<int, int> keepInterestingWindows(size_t min_reads_window);
pair<int, size_t> keepInterestingWindows(size_t min_reads_window);
/**
* sort windows according to the number of reads they appear in
......
......@@ -47,7 +47,7 @@ void testCluster() {
windows.add("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCATGCCCCCC", seq, 0, 0);
windows.sort();
list<pair <junction, int> > sort_clones = windows.getSortedList();
list<pair <junction, size_t> > sort_clones = windows.getSortedList();
comp_matrix comp=comp_matrix(sort_clones);
......
......@@ -78,8 +78,8 @@ void testWSAdd() {
}
ws.sort();
list<pair<junction, int> >sorted = ws.getSortedList();
list<pair<junction, int> >::iterator it2 = sorted.begin();
list<pair<junction, size_t> >sorted = ws.getSortedList();
list<pair<junction, size_t> >::iterator it2 = sorted.begin();
TAP_TEST(ws.size() == 4, TEST_WS_SIZE, "");
TAP_TEST(sorted.size() == ws.size() , TEST_WS_SORT, "");
......
......@@ -995,7 +995,7 @@ int main (int argc, char **argv)
int min_reads_clone_final = max(min_reads_clone, min_reads_clone_ratio);
pair<int, int> info_remove = windowsStorage->keepInterestingWindows((size_t) min_reads_clone_final);
pair<int, size_t> info_remove = windowsStorage->keepInterestingWindows((size_t) min_reads_clone_final);
cout << " ==> keep " << windowsStorage->size() << " windows in " << info_remove.second << " reads" ;
cout << " (" << setprecision(3) << 100 * (float) info_remove.second / nb_total_reads << "%) " << endl ;
......@@ -1008,7 +1008,7 @@ int main (int argc, char **argv)
//////////////////////////////////
//$$ Clustering
windowsStorage->sort();
list<pair <junction, int> > sort_clones = windowsStorage->getSortedList();
list<pair <junction, size_t> > sort_clones = windowsStorage->getSortedList();
cout << " ==> " << sort_clones.size() << " clones" << endl ;
list <list <junction> > clones_windows;
......@@ -1094,10 +1094,10 @@ int main (int argc, char **argv)
cout << endl ;
for (list <pair<junction,int> >::const_iterator it = sort_clones.begin();
for (list <pair<junction,size_t> >::const_iterator it = sort_clones.begin();
it != sort_clones.end(); ++it) {
junction win = it->first;
int clone_nb_reads = it->second;
size_t clone_nb_reads = it->second;
++num_clone ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment