| 1 |
#include <gatb/debruijn/impl/GraphUnitigs.hpp> |
| 2 |
#include <bcalm_1.hpp> |
| 3 |
|
| 4 |
using namespace std; |
| 5 |
|
| 6 |
/* |
| 7 |
* where did all the code go? now it's mostly in ../gatb-core/gatb-core/src/gatb/bcalm/ |
| 8 |
*/ |
| 9 |
|
| 10 |
/********************************************************************************/ |
| 11 |
|
| 12 |
|
| 13 |
bcalm_1::bcalm_1 () : Tool ("bcalm_1"){ |
| 14 |
// old options, now using GATB's built-in options for kmer counting and graph creation |
| 15 |
// but TODO would be nice to integrate --nb-glue-partitions in gatb someday |
| 16 |
/* getParser()->push_back (new OptionOneParam ("-in", "input file", true)); |
| 17 |
getParser()->push_back (new OptionOneParam ("-out", "output prefix", false, "unitigs")); |
| 18 |
getParser()->push_back (new OptionOneParam ("-k", "kmer size", false,"31")); |
| 19 |
getParser()->push_back (new OptionOneParam ("-m", "minimizer size", false,"8")); |
| 20 |
getParser()->push_back (new OptionOneParam ("-abundance", "abundance threshold", false,"1")); |
| 21 |
getParser()->push_back (new OptionOneParam ("-minimizer-type", "use lexicographical minimizers (0) or frequency based (1)", false,"1")); |
| 22 |
getParser()->push_back (new OptionOneParam ("-dsk-memory", "max memory for kmer counting (MB)", false, "1500")); |
| 23 |
getParser()->push_back (new OptionOneParam ("-dsk-disk", "max disk space for kmer counting (MB)", false, "default")); |
| 24 |
|
| 25 |
// glue options |
| 26 |
getParser()->push_front (new OptionNoParam ("--only-uf", "(for debugging only) stop after UF construction", false)); |
| 27 |
getParser()->push_front (new OptionNoParam ("--uf-stats", "display UF statistics", false)); |
| 28 |
getParser()->push_back (new OptionOneParam ("--nb-glue-partitions", "number of glue files on disk", false,"200")); |
| 29 |
*/ |
| 30 |
|
| 31 |
IOptionsParser* graphParser = GraphUnitigsTemplate<32>::getOptionsParser(false); |
| 32 |
|
| 33 |
// hiding options |
| 34 |
if (IOptionsParser* p = graphParser->getParser(STR_KMER_ABUNDANCE_MIN_THRESHOLD)) { p->setVisible(false); } |
| 35 |
if (IOptionsParser* p = graphParser->getParser(STR_HISTOGRAM_MAX)) { p->setVisible(false); } |
| 36 |
if (IOptionsParser* p = graphParser->getParser(STR_SOLIDITY_KIND)) { p->setVisible(false); } // oohh. multi-sample dbg construction someday maybe? |
| 37 |
if (IOptionsParser* p = graphParser->getParser(STR_URI_SOLID_KMERS)) { p->setVisible(false); } |
| 38 |
|
| 39 |
// setting defaults |
| 40 |
if (Option* p = dynamic_cast<Option*> (graphParser->getParser(STR_REPARTITION_TYPE))) { p->setDefaultValue ("1"); } |
| 41 |
if (Option* p = dynamic_cast<Option*> (graphParser->getParser(STR_MINIMIZER_TYPE))) { p->setDefaultValue ("1"); } |
| 42 |
|
| 43 |
getParser()->push_back(graphParser); |
| 44 |
|
| 45 |
|
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
template <size_t span> |
| 50 |
struct Functor { void operator () (bcalm_1 *bcalm) |
| 51 |
{ |
| 52 |
typedef GraphUnitigsTemplate<span> GraphType; |
| 53 |
GraphType graph; |
| 54 |
|
| 55 |
if (bcalm->getInput()->get(STR_URI_INPUT) != 0) |
| 56 |
{ |
| 57 |
graph = GraphType::create (bcalm->getInput(), false /* do not load unitigs after*/); |
| 58 |
} |
| 59 |
else |
| 60 |
{ |
| 61 |
throw OptionFailure (bcalm->getParser(), "Specifiy -in"); |
| 62 |
} |
| 63 |
|
| 64 |
// delete the .h5 file |
| 65 |
bool delete_h5_file = true; |
| 66 |
if (delete_h5_file) |
| 67 |
{ |
| 68 |
// copies the h5 naming mechanism in GraphUnitigs.cpp |
| 69 |
string input = bcalm->getInput()->getStr(STR_URI_INPUT); |
| 70 |
string prefix; |
| 71 |
if (bcalm->getInput()->get(STR_URI_OUTPUT)) |
| 72 |
prefix = bcalm->getInput()->getStr(STR_URI_OUTPUT); |
| 73 |
else |
| 74 |
prefix = System::file().getBaseName (input) + prefix; |
| 75 |
|
| 76 |
System::file().remove (prefix + ".h5"); |
| 77 |
} |
| 78 |
|
| 79 |
} |
| 80 |
}; |
| 81 |
|
| 82 |
void bcalm_1::execute (){ |
| 83 |
|
| 84 |
#ifdef GIT_SHA1 |
| 85 |
std::cout << "BCALM 2, version " << VERSION << ", git commit " << GIT_SHA1 << std::endl; |
| 86 |
#endif |
| 87 |
|
| 88 |
|
| 89 |
/** we get the kmer size chosen by the end user. */ |
| 90 |
size_t kmerSize = getInput()->getInt (STR_KMER_SIZE); |
| 91 |
|
| 92 |
/** We launch Minia with the correct Integer implementation according to the choosen kmer size. */ |
| 93 |
Integer::apply<Functor,bcalm_1*> (kmerSize, this); |
| 94 |
|
| 95 |
} |
| 96 |
|
| 97 |
|