Louis BECQUEY

Folder structure

......@@ -6,6 +6,7 @@
*.lo
*.o
*.obj
obj/*
# Precompiled Headers
*.gch
......@@ -30,3 +31,4 @@
*.exe
*.out
*.app
bin/*
......
# ------------------------------------------------
# Generic Makefile
# ------------------------------------------------
# project name (generate executable with this name)
TARGET = motifscan
CC = g++
# compiling flags here
CFLAGS = -I. -O3
CXXFLAGS = -std=c++17 -Wall -Wpedantic -Wextra
LINKER = g++
# linking flags here
LDFLAGS = -lboost_system -lboost_filesystem -lboost_program_options
# change these to proper directories where each file should be
SRCDIR = src
OBJDIR = obj
BINDIR = bin
SOURCES := $(wildcard $(SRCDIR)/*.cpp)
INCLUDES := $(wildcard $(SRCDIR)/*.h)
OBJECTS := $(SOURCES:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)
rm = rm -f
$(BINDIR)/$(TARGET): $(OBJECTS)
@mkdir -p $(BINDIR)
$(LINKER) $(OBJECTS) $(LDFLAGS) -o $@
@echo "\033[00;32mLinking completed.\033[00m"
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.cpp $(INCLUDES)
@mkdir -p $(OBJDIR)
$(CC) -c $(CFLAGS) $(CXXFLAGS) $< -o $@
@echo "\033[00;32mCompiled "$<".\033[00m"
.PHONY: clean
clean:
$(rm) $(OBJECTS)
@echo "\033[00;32mCleanup completed.\033[00m"
.PHONY: remove
remove: clean
@$(rm) $(BINDIR)/$(TARGET)
@echo "\033[00;32mExecutable removed!\033[00m"
\ No newline at end of file
#ifndef COMPONENT_H
#define COMPONENT_H
#include <string>
class Component
{
public:
Component();
Component(std::string& cons_seq, uint k);
private:
std::string _cons_seq;
uint k;
};
istream& operator>>(istream& is, Component& m);
ostream& operator<<(ostream& os, const Component& m);
#endif
\ No newline at end of file
#include "Motif.h"
\ No newline at end of file
#ifndef MOTIF_H
#define MOTIF_H
#include <vector>
#include <string>
#include "Component.h"
class Motif
{
public:
Motif();
Motif(std::string filename);
~Motif();
std::vector<Component>& getComponents() const;
Component& getComponent(uint k) const;
std::string name;
private:
std::vector<Component> _comps;
};
istream& operator>>(istream& is, Motif& m);
ostream& operator<<(ostream& os, const Motif& m);
#endif
\ No newline at end of file
#include "RNA.h"
RNA::RNA() {}
RNA::~RNA() {}
RNA::RNA(std::string seq) : _seq(seq) { }
#ifndef RNA_H
#define RNA_H
#include <string>
class RNA {
public:
RNA();
RNA(std::string);
~RNA();
uint length() const;
std::string str() const;
// char seq(uint k) const;
// bool isConsensus() const;
// bool containsPseudoBases() const;
private:
std::string _seq;
// bool _coding;
// bool _consensus;
// bool _containsPseudoNTs;
};
inline uint RNA::length() const { return _seq.length(); }
inline std::string RNA::str() const { return _seq; }
#endif
\ No newline at end of file
#include "Motif.h"
#include <cstdlib>
#include <iostream>
#include <unistd.h>
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
#include "RNA.h"
using namespace std;
namespace bpo = boost::program_options;
namespace bf = boost::filesystem;
bool checkMotifFolder(bf::path & folder)
{
if (not(bf::is_directory(folder) and bf::exists(folder))) return false;
bf::directory_iterator end_itr;
uint Ndesc = 0;
for (bf::directory_iterator itr(folder); itr != end_itr; ++itr)
{
if (itr->path().leaf().string().find(string(".desc")) != std::string::npos)
Ndesc++;
}
cout << "Found " << Ndesc << " .desc files in " << folder.string() << endl;
if (Ndesc > 0)
return true;
return false;
}
int parseMotifs(bf::path & folder)
{
bf::directory_iterator end_itr;
for (bf::directory_iterator itr(folder); itr != end_itr; ++itr)
{
if (itr->path().leaf().string().find(string(".desc")) != std::string::npos)
{
}
}
}
int main(int argc, char** argv)
{
bf::path currentFolder(bf::current_path());
bf::path motifFolderPath(currentFolder); // By default, searching here...
bpo::options_description desc("Options");
bpo::variables_map options_map;
RNA querySequence;
desc.add_options()
("help", "Print this help message")
("seq,s", bpo::value<string>()->required(), "RNA sequence to find motives in.")
("motifs,m", bpo::value<bf::path>(), "Path to folder of DESC files describing the motifs to be used")
;
bpo::store(bpo::parse_command_line(argc, argv, desc), options_map);
bpo::notify(options_map);
if (options_map.count("help")) {
cout << desc << endl;
return EXIT_SUCCESS;
}
if (options_map.count("motifs")) {
motifFolderPath = options_map["motifs"].as<bf::path>();
if (not(checkMotifFolder(motifFolderPath))) { return EXIT_FAILURE; }
}
if (options_map.count("seq")) {
querySequence = RNA(options_map["seq"].as<string>());
}
cout << "Working with sequence " << querySequence.str() << " (length " << querySequence.length() << ")." << endl;
return EXIT_SUCCESS;
}