main.cpp
2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#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;
}