From 35f58028e6870a7e4b581f56c1f005e9f11cd09a Mon Sep 17 00:00:00 2001 From: Denys Bulavka <dbulavka@kam-laptop.koleje.cuni.cz> Date: Wed, 17 Feb 2021 17:27:54 +0100 Subject: [PATCH] Fixed some bugs --- README.md | 14 ++++++++++++++ elm_processing/inc/Mdp_toolbox.hpp | 2 +- elm_processing/inc/Statistical_toolbox.hpp | 2 +- elm_processing/src/Mdp_toolbox.cpp | 2 +- elm_processing/src/Report_manager.cpp | 2 +- elm_processing/src/Statistical_toolbox.cpp | 2 +- elm_processing/src/main.cpp | 6 ++++-- 7 files changed, 23 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d0fb3f5..2527adc 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,17 @@ +"" +This repository contains the scripts and database used for the paper "Thousands of protein linear motif classes may still be undiscovered" +Below is an example of the usage to reproduce the results presented in the paper +For questions regarding the use of these scripts, please contact the authors of the paper. + +Copyright (C) 2021 by Denys Bulavka <dbulavka@gmail.com> + +Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +"" + Database description: The database was downloaded on the 22nd of May of 2015, named elm_original_20150522.csv, version history in http://elm.eu.org/infos/news.html. This file can be found in the folder 'database'. This file has 210 motifs. diff --git a/elm_processing/inc/Mdp_toolbox.hpp b/elm_processing/inc/Mdp_toolbox.hpp index 4c0b29f..72b5b72 100644 --- a/elm_processing/inc/Mdp_toolbox.hpp +++ b/elm_processing/inc/Mdp_toolbox.hpp @@ -26,7 +26,7 @@ private: public: Mdp_toolbox(); - Mdp_toolbox(std::string, bool, bool); + Mdp_toolbox(std::string, bool, std::string); std::vector<Motif_pair> get_pairs_k_discriminant_positions(int); int get_mdp(Motif_pair); std::vector<Motif_class> get_k_discriminant_motifs(Motif_class, int); diff --git a/elm_processing/inc/Statistical_toolbox.hpp b/elm_processing/inc/Statistical_toolbox.hpp index 216eeac..ca6458a 100644 --- a/elm_processing/inc/Statistical_toolbox.hpp +++ b/elm_processing/inc/Statistical_toolbox.hpp @@ -29,7 +29,6 @@ private: void count_sequences(); void compute_probability(); void compute_empiric_motif_numbers(); - float compute_empiric_based_probability(std::vector<int> &); void compute_empiric_motif_probabilities(); void compute_theoretic_motif_probabilities(); void iteration(std::vector<int> &); @@ -38,6 +37,7 @@ private: public: Statistical_toolbox(); Statistical_toolbox(Mdp_toolbox); + float compute_empiric_based_probability(std::vector<int> &); std::map<std::vector<int>, float> get_empiric_motif_probabilities(); std::map<std::vector<int>, float> get_theoretic_motif_probabilities(); }; diff --git a/elm_processing/src/Mdp_toolbox.cpp b/elm_processing/src/Mdp_toolbox.cpp index 5e58375..dc5201c 100644 --- a/elm_processing/src/Mdp_toolbox.cpp +++ b/elm_processing/src/Mdp_toolbox.cpp @@ -2,7 +2,7 @@ Mdp_toolbox::Mdp_toolbox(){} -Mdp_toolbox::Mdp_toolbox(std::string database_location, bool clean_ends, bool clean_marked_motifs) +Mdp_toolbox::Mdp_toolbox(std::string database_location, bool clean_ends, std::string clean_marked_motifs) { database = Database(database_location, clean_ends, clean_marked_motifs); diff --git a/elm_processing/src/Report_manager.cpp b/elm_processing/src/Report_manager.cpp index dc90872..f9d06d0 100644 --- a/elm_processing/src/Report_manager.cpp +++ b/elm_processing/src/Report_manager.cpp @@ -134,7 +134,7 @@ std::stringstream Report_manager::empiric_motif_probabilities() output << "Structure" << separator << "Probability" << std::endl; for(std::pair<std::vector<int>, float> element: statistical_toolbox.get_empiric_motif_probabilities()) - output << element.first << separator << element.second << std::endl; + output << element.first << separator << statistical_toolbox.compute_empiric_based_probability(element.first)<< separator << element.second << std::endl; return output; } diff --git a/elm_processing/src/Statistical_toolbox.cpp b/elm_processing/src/Statistical_toolbox.cpp index e6b187b..c624e80 100644 --- a/elm_processing/src/Statistical_toolbox.cpp +++ b/elm_processing/src/Statistical_toolbox.cpp @@ -5,6 +5,7 @@ Statistical_toolbox::Statistical_toolbox(){} Statistical_toolbox::Statistical_toolbox(Mdp_toolbox mdp_toolbox) { this->mdp_toolbox = mdp_toolbox; + count_sequences(); } void Statistical_toolbox::compute_empiric_motif_numbers() @@ -121,7 +122,6 @@ float Statistical_toolbox::compute_empiric_based_probability(std::vector<int> &s std::map<std::vector<int>, float> Statistical_toolbox::get_theoretic_motif_probabilities() { - count_sequences(); compute_theoretic_motif_probabilities(); return theoretic_motif_probabilities; } diff --git a/elm_processing/src/main.cpp b/elm_processing/src/main.cpp index 0d6227f..eac45c7 100644 --- a/elm_processing/src/main.cpp +++ b/elm_processing/src/main.cpp @@ -20,7 +20,7 @@ int main(int argc, char* argv[]) help_message << "-k: Discriminant index" << std::endl;; - if((option = getopt(argc, argv, "hd:cm:r:k:")) == -1) + if((option = getopt(argc, argv, ":hd:cm:r:k:")) == -1) { std::cout << help_message.str(); return 0; @@ -39,6 +39,8 @@ int main(int argc, char* argv[]) case 'd': database_location = optarg; break; + case ':': + throw std::invalid_argument("Option requires an operand"); case 'c': clean_ends = true; break; @@ -52,7 +54,7 @@ int main(int argc, char* argv[]) discriminant_index = std::atoi(optarg); break; } - }while((option = getopt(argc, argv, "hd:cmr:k:")) != -1); + }while((option = getopt(argc, argv, ":hd:cm:r:k:")) != -1); //Make sure that if report 3 or 4 is invoked we have specified the discriminant_index if((report == 3 or report == 4) and discriminant_index == -1) -- GitLab