commit 0303dbe85e154c607ae0e0f365b9c21c6a51f64f
Author: Florent Chuffart <florent.chuffart@ens-lyon.fr>
Date:   Thu Mar 6 10:24:40 2014 +0100

    Remove get_fuzzy fucntion

diff --git a/src/R/nucleominer.R b/src/R/nucleominer.R
index 25acf1c..16f1e94 100644
--- a/src/R/nucleominer.R
+++ b/src/R/nucleominer.R
@@ -819,6 +819,7 @@ union_regions = function(# Aggregate regions that intersect themnselves.
 ### This function is based on sort of lower bounds to detect regions that intersect. We compare lower bound and upper bound of the porevious item. This function embed a while loop and break break regions list become stable.
 regions ##<< The Regions to be aggregated
 ) {
+  if (nrow(regions) == 0) {return(regions)}
   old_length = length(regions[,1])
   new_length = 0
 
@@ -848,22 +849,22 @@ regions ##<< The Regions to be aggregated
   return(union)
 }
 
-remove_aligned_wp = function(# Remove wp nucs from common nucs list.
-### It is based on common wp nucs index on nucs and region.
-strain_maps, ##<< Nuc maps.
-roi_index, ##<< The region of interest index.
-tmp_common_nucs, ##<< the list of wp nucs.
-strain##<< The strain to consider.
-){
-  fuzzy_nucs = strain_maps[[strain]]
-  fuzzy_nucs = fuzzy_nucs[fuzzy_nucs$roi_index == roi_index,]
-  fuzzy_nucs = fuzzy_nucs[order(fuzzy_nucs$index_nuc),]
-  if (length(fuzzy_nucs[,1]) == 0) {return(fuzzy_nucs)}
-  if (sum(fuzzy_nucs$index_nuc == min(fuzzy_nucs$index_nuc):max(fuzzy_nucs$index_nuc)) != max(fuzzy_nucs$index_nuc)) {"Warning in index!"}
-  anti_index_1 = tmp_common_nucs[[paste("index_nuc", strain, sep="_")]]
-  fuzzy_nucs = fuzzy_nucs[-anti_index_1,]
-  return(fuzzy_nucs)
-}
+# remove_aligned_wp = function(# Remove wp nucs from common nucs list.
+# ### It is based on common wp nucs index on nucs and region.
+# strain_maps, ##<< Nuc maps.
+# roi_index, ##<< The region of interest index.
+# tmp_common_nucs, ##<< the list of wp nucs.
+# strain##<< The strain to consider.
+# ){
+#   fuzzy_nucs = strain_maps[[strain]]
+#   fuzzy_nucs = fuzzy_nucs[fuzzy_nucs$roi_index == roi_index,]
+#   fuzzy_nucs = fuzzy_nucs[order(fuzzy_nucs$index_nuc),]
+#   if (length(fuzzy_nucs[,1]) == 0) {return(fuzzy_nucs)}
+#   if (sum(fuzzy_nucs$index_nuc == min(fuzzy_nucs$index_nuc):max(fuzzy_nucs$index_nuc)) != max(fuzzy_nucs$index_nuc)) {"Warning in index!"}
+#   anti_index_1 = tmp_common_nucs[[paste("index_nuc", strain, sep="_")]]
+#   fuzzy_nucs = fuzzy_nucs[-anti_index_1,]
+#   return(fuzzy_nucs)
+# }
 
 translate_regions = function(# Translate a list of regions from a strain ref to another.
 ### This function is an eloborated call to translate_roi.
@@ -941,79 +942,79 @@ config=NULL ##<< GLOBAL config variable
 }
 
 
-get_fuzzy = function(# Compute the fuzzy nucs.
-### This function aggregate non common wp nucs for each strain and substract common wp nucs. It does not take care about the size of the resulting fuzzy regions. It will be take into account in the count read part og the pipeline.
-combi, ##<< The strain combination to consider.
-roi, ##<< The region of interest.
-roi_index, ##<< The region of interest index.
-strain_maps, ##<< Nuc maps.
-common_nuc_results, ##<< Common wp nuc maps
-config=NULL ##<< GLOBAL config variable
-) {
-  print(roi_index)
-  PLOT = FALSE
-  tmp_common_nucs = common_nuc_results[[paste(combi[1], combi[2], sep="_")]]
-  tmp_common_nucs = tmp_common_nucs[tmp_common_nucs$roi_index == roi_index, ]
-
-  print(paste("Dealing with fuzzy from", combi[1]))
-  tmp_fuzzy_nucs_1 = remove_aligned_wp(strain_maps, roi_index, tmp_common_nucs, combi[1])
-  tmp_fuzzy_nucs_1 = crop_fuzzy(tmp_fuzzy_nucs_1, roi, combi[1], config)
-  if (length(tmp_fuzzy_nucs_1[,1]) == 0) {return(NULL)}
-  agg_fuzzy_1 = union_regions(tmp_fuzzy_nucs_1)
-  if (PLOT) for (i in 1:length(agg_fuzzy_1[,1])) {
-    lines(c(agg_fuzzy_1[i,]$lower_bound, agg_fuzzy_1[i,]$upper_bound), c(+3.1,+3.1), col=2)
-  }
-
-  print(paste("Dealing with fuzzy from ", combi[2]))
-  tmp_fuzzy_nucs_2 = remove_aligned_wp(strain_maps, roi_index, tmp_common_nucs, combi[2])
-  if (length(tmp_fuzzy_nucs_2[,1]) == 0) {return(NULL)}
-  agg_fuzzy_2 = union_regions(tmp_fuzzy_nucs_2)
-  agg_fuzzy_2 = crop_fuzzy(agg_fuzzy_2, roi, combi[2], config)
-  tr_agg_fuzzy_2 = translate_regions(agg_fuzzy_2, combi, roi_index, roi=roi, config=config)
-  tr_agg_fuzzy_2 = crop_fuzzy(tr_agg_fuzzy_2, roi, combi[2], config)
-  # tr_agg_fuzzy_2 = union_regions(tr_agg_fuzzy_2)
-  if (PLOT) for (i in 1:length(tr_agg_fuzzy_2[,1])) {
-    lines(c(tr_agg_fuzzy_2[i,]$lower_bound, tr_agg_fuzzy_2[i,]$upper_bound), c(+3.3,+3.3), col=2)
-  }
-
-  print("Dealing with fuzzy from both...")
-  all_fuzzy = union_regions(rbind(agg_fuzzy_1, tr_agg_fuzzy_2))
-  if (PLOT) for (i in 1:length(all_fuzzy[,1])) {
-    lines(c(all_fuzzy[i,]$lower_bound, all_fuzzy[i,]$upper_bound), c(+3.2, +3.2), col=1)
-  }
-
-  print(paste("Dealing with wp from", combi[1]))
-  wp_nucs_1 = extract_wp(strain_maps, roi_index, combi[1], tmp_common_nucs)
-  if (PLOT) for (i in 1:length(wp_nucs_1[,1])) {
-    lines(c(wp_nucs_1[i,]$lower_bound, wp_nucs_1[i,]$upper_bound), c(+3.5,+3.5), col=3)
-  }
-
-  print(paste("Dealing with wp from", combi[2]))
-  wp_nucs_2 = extract_wp(strain_maps, roi_index, combi[2], tmp_common_nucs)
-  tr_wp_nucs_2 = translate_regions(wp_nucs_2, combi, roi_index, roi=roi, config=config)
-  if (PLOT) for (i in 1:length(tr_wp_nucs_2[,1])) {
-    lines(c(tr_wp_nucs_2[i,]$lower_bound, tr_wp_nucs_2[i,]$upper_bound), c(+3.7,+3.7), col=3)
-  }
-
-  print("Dealing with wp from both...")
-  all_wp = union_regions(rbind(wp_nucs_1[,1:4], tr_wp_nucs_2))
-  if (PLOT) for (i in 1:length(all_wp[,1])) {
-    lines(c(all_wp[i,]$lower_bound, all_wp[i,]$upper_bound), c(+3.6, +3.6), col=1)
-  }
-
-  print("Dealing with fuzzy and wp...")
-  non_inter_fuzzy = substract_region(all_fuzzy, all_wp)
-  if (is.null(non_inter_fuzzy)) { return(NULL) }
-
-  non_inter_fuzzy$len = non_inter_fuzzy$upper_bound - non_inter_fuzzy$lower_bound
-  # non_inter_fuzzy = non_inter_fuzzy[non_inter_fuzzy$len >= min_fuzz_width,]
-  if (PLOT) for (i in 1:length(non_inter_fuzzy[,1])) {
-    lines(c(non_inter_fuzzy[i,]$lower_bound, non_inter_fuzzy[i,]$upper_bound), c(+3.9, +3.9), col=1)
-  }
-
-  non_inter_fuzzy$index_nuc = 1:length(non_inter_fuzzy[,1])
-  return (non_inter_fuzzy)
-}
+# get_fuzzy = function(# Compute the fuzzy nucs.
+# ### This function aggregate non common wp nucs for each strain and substract common wp nucs. It does not take care about the size of the resulting fuzzy regions. It will be take into account in the count read part og the pipeline.
+# combi, ##<< The strain combination to consider.
+# roi, ##<< The region of interest.
+# roi_index, ##<< The region of interest index.
+# strain_maps, ##<< Nuc maps.
+# common_nuc_results, ##<< Common wp nuc maps
+# config=NULL ##<< GLOBAL config variable
+# ) {
+#   print(roi_index)
+#   PLOT = FALSE
+#   tmp_common_nucs = common_nuc_results[[paste(combi[1], combi[2], sep="_")]]
+#   tmp_common_nucs = tmp_common_nucs[tmp_common_nucs$roi_index == roi_index, ]
+# 
+#   print(paste("Dealing with fuzzy from", combi[1]))
+#   tmp_fuzzy_nucs_1 = remove_aligned_wp(strain_maps, roi_index, tmp_common_nucs, combi[1])
+#   tmp_fuzzy_nucs_1 = crop_fuzzy(tmp_fuzzy_nucs_1, roi, combi[1], config)
+#   if (length(tmp_fuzzy_nucs_1[,1]) == 0) {return(NULL)}
+#   agg_fuzzy_1 = union_regions(tmp_fuzzy_nucs_1)
+#   if (PLOT) for (i in 1:length(agg_fuzzy_1[,1])) {
+#     lines(c(agg_fuzzy_1[i,]$lower_bound, agg_fuzzy_1[i,]$upper_bound), c(+3.1,+3.1), col=2)
+#   }
+# 
+#   print(paste("Dealing with fuzzy from ", combi[2]))
+#   tmp_fuzzy_nucs_2 = remove_aligned_wp(strain_maps, roi_index, tmp_common_nucs, combi[2])
+#   if (length(tmp_fuzzy_nucs_2[,1]) == 0) {return(NULL)}
+#   agg_fuzzy_2 = union_regions(tmp_fuzzy_nucs_2)
+#   agg_fuzzy_2 = crop_fuzzy(agg_fuzzy_2, roi, combi[2], config)
+#   tr_agg_fuzzy_2 = translate_regions(agg_fuzzy_2, combi, roi_index, roi=roi, config=config)
+#   tr_agg_fuzzy_2 = crop_fuzzy(tr_agg_fuzzy_2, roi, combi[2], config)
+#   # tr_agg_fuzzy_2 = union_regions(tr_agg_fuzzy_2)
+#   if (PLOT) for (i in 1:length(tr_agg_fuzzy_2[,1])) {
+#     lines(c(tr_agg_fuzzy_2[i,]$lower_bound, tr_agg_fuzzy_2[i,]$upper_bound), c(+3.3,+3.3), col=2)
+#   }
+# 
+#   print("Dealing with fuzzy from both...")
+#   all_fuzzy = union_regions(rbind(agg_fuzzy_1, tr_agg_fuzzy_2))
+#   if (PLOT) for (i in 1:length(all_fuzzy[,1])) {
+#     lines(c(all_fuzzy[i,]$lower_bound, all_fuzzy[i,]$upper_bound), c(+3.2, +3.2), col=1)
+#   }
+# 
+#   print(paste("Dealing with wp from", combi[1]))
+#   wp_nucs_1 = extract_wp(strain_maps, roi_index, combi[1], tmp_common_nucs)
+#   if (PLOT) for (i in 1:length(wp_nucs_1[,1])) {
+#     lines(c(wp_nucs_1[i,]$lower_bound, wp_nucs_1[i,]$upper_bound), c(+3.5,+3.5), col=3)
+#   }
+# 
+#   print(paste("Dealing with wp from", combi[2]))
+#   wp_nucs_2 = extract_wp(strain_maps, roi_index, combi[2], tmp_common_nucs)
+#   tr_wp_nucs_2 = translate_regions(wp_nucs_2, combi, roi_index, roi=roi, config=config)
+#   if (PLOT) for (i in 1:length(tr_wp_nucs_2[,1])) {
+#     lines(c(tr_wp_nucs_2[i,]$lower_bound, tr_wp_nucs_2[i,]$upper_bound), c(+3.7,+3.7), col=3)
+#   }
+# 
+#   print("Dealing with wp from both...")
+#   all_wp = union_regions(rbind(wp_nucs_1[,1:4], tr_wp_nucs_2))
+#   if (PLOT) for (i in 1:length(all_wp[,1])) {
+#     lines(c(all_wp[i,]$lower_bound, all_wp[i,]$upper_bound), c(+3.6, +3.6), col=1)
+#   }
+# 
+#   print("Dealing with fuzzy and wp...")
+#   non_inter_fuzzy = substract_region(all_fuzzy, all_wp)
+#   if (is.null(non_inter_fuzzy)) { return(NULL) }
+# 
+#   non_inter_fuzzy$len = non_inter_fuzzy$upper_bound - non_inter_fuzzy$lower_bound
+#   # non_inter_fuzzy = non_inter_fuzzy[non_inter_fuzzy$len >= min_fuzz_width,]
+#   if (PLOT) for (i in 1:length(non_inter_fuzzy[,1])) {
+#     lines(c(non_inter_fuzzy[i,]$lower_bound, non_inter_fuzzy[i,]$upper_bound), c(+3.9, +3.9), col=1)
+#   }
+# 
+#   non_inter_fuzzy$index_nuc = 1:length(non_inter_fuzzy[,1])
+#   return (non_inter_fuzzy)
+# }
 
 
 
