Commit 3d8d8743 authored by Rayan Chikhi's avatar Rayan Chikhi
Browse files

added Erwan's snippet do to multibank kmer counting and report list of kmers

also a small fix he suggested
parent 4ff3dcc3
#include <gatb/gatb_core.hpp>
using namespace std;
/********************************************************************************/
template<size_t span>
class CountProcessorCustom : public CountProcessorAbstract<span>
{
public:
// We need the kmer size to dump kmers values as nucl strings
CountProcessorCustom (size_t kmerSize) : kmerSize(kmerSize) {}
virtual ~CountProcessorCustom () {}
CountProcessorAbstract<span>* clone () { return new CountProcessorCustom<span>(kmerSize); }
virtual bool process (size_t partId, const typename Kmer<span>::Type& kmer, const CountVector& count, CountNumber sum)
{
cout << kmer.toString(kmerSize) << " ";
for (size_t i=0; i<count.size(); i++) { cout << count[i] << " "; }
cout << endl;
return true;
}
private:
size_t kmerSize;
};
/********************************************************************************/
template<size_t span> struct MainLoop { void operator () (IProperties* options)
{
// We force the solidity kind (otherwise default value "sum" will consider N banks as a single one)
options->setStr(STR_SOLIDITY_KIND, "all");
// We create a SortingCountAlgorithm instance.
SortingCountAlgorithm<span> algo (options);
// We create a custom count processor and give it to the sorting count algorithm
algo.addProcessor (new CountProcessorCustom<span> (options->getInt(STR_KMER_SIZE)));
// We launch the algorithm
algo.execute();
}};
/********************************************************************************/
int main (int argc, char* argv[])
{
// We create a command line parser for the sorting count algorithm
IOptionsParser* parser = SortingCountAlgorithm<>::getOptionsParser ();
parser->push_back (new OptionOneParam (STR_NB_CORES, "nb cores", false, "1"));
parser->push_back (new OptionOneParam (STR_VERBOSE, "verbosity", false, "1"));
// We launch our functor
return Algorithm::mainloop <MainLoop> (parser, argc, argv);
}
......@@ -416,7 +416,8 @@ void RepartitorAlgorithm<span>::computeRepartition (Repartitor& repartitor)
u_int64_t nbseq_sample = (_config._estimateSeqNb / _config._nb_banks) * 0.01;
nbseq_sample = max((u_int64_t)nbseq_sample, (u_int64_t)100000);
std::vector<Iterator<Sequence>*> itBanks = _bank->iterator()->getComposition();
Iterator<Sequence>* it = _bank->iterator(); LOCAL (it);
std::vector<Iterator<Sequence>*> itBanks = it->getComposition();
bool dummyBoolean = false;
SampleRepart<span> sampleRepart (
......@@ -473,7 +474,8 @@ void RepartitorAlgorithm<span>::computeRepartition (Repartitor& repartitor)
}
else{
CancellableIterator<Sequence>* cancellable_it = new CancellableIterator<Sequence> (*(_bank->iterator()));
Iterator<Sequence>* it = _bank->iterator(); LOCAL (it);
CancellableIterator<Sequence>* cancellable_it = new CancellableIterator<Sequence> (*(it));
LOCAL(cancellable_it);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment