本文整理汇总了C++中Kmer::pack方法的典型用法代码示例。如果您正苦于以下问题:C++ Kmer::pack方法的具体用法?C++ Kmer::pack怎么用?C++ Kmer::pack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kmer
的用法示例。
在下文中一共展示了Kmer::pack方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: work
/**
* work method.
*
* \author Sébastien Boisvert
*
* Code reviews
*
* 2011-09-02 -- Code review by Élénie Godzaridis (found bug with worker states)
*
*/
void FusionWorker::work(){
/*
used tags:
TODO: does the code pay attention when the coverage indicates a repeated k-mer ? repeats slow things down...
RAY_MPI_TAG_ASK_VERTEX_PATHS_SIZE
RAY_MPI_TAG_ASK_VERTEX_PATH
RAY_MPI_TAG_GET_PATH_LENGTH
*/
if(m_isDone)
return;
if(m_position < (int) m_path->size()){
/* get the number of paths */
if(!m_requestedNumberOfPaths){
/*
if(m_position % 1000 == 0){
cout<<"FusionWorker "<<m_workerIdentifier<<" position: ["<<m_position<<"/"<<m_path->size()<<endl;
}
*/
Kmer kmer;
m_path->at(m_position,&kmer);
if(m_reverseStrand)
kmer=kmer.complementVertex(m_parameters->getWordSize(),m_parameters->getColorSpaceMode());
Rank destination=kmer.vertexRank(m_parameters->getSize(),
m_parameters->getWordSize(),m_parameters->getColorSpaceMode());
int elementsPerQuery=m_virtualCommunicator->getElementsPerQuery(RAY_MPI_TAG_ASK_VERTEX_PATHS_SIZE);
MessageUnit*message=(MessageUnit*)m_outboxAllocator->allocate(elementsPerQuery);
int outputPosition=0;
kmer.pack(message,&outputPosition);
Message aMessage(message,elementsPerQuery,destination,
RAY_MPI_TAG_ASK_VERTEX_PATHS_SIZE,m_parameters->getRank());
m_virtualCommunicator->pushMessage(m_workerIdentifier,&aMessage);
m_requestedNumberOfPaths=true;
m_receivedNumberOfPaths=false;
if(m_parameters->hasOption("-debug-fusions2")){
cout<<"worker "<<m_workerIdentifier<<" send RAY_MPI_TAG_ASK_VERTEX_PATHS_SIZE"<<endl;
}
/* receive the number of paths */
}else if(m_requestedNumberOfPaths && !m_receivedNumberOfPaths && m_virtualCommunicator->isMessageProcessed(m_workerIdentifier)){
vector<MessageUnit> response;
m_virtualCommunicator->getMessageResponseElements(m_workerIdentifier,&response);
m_numberOfPaths=response[0];
if(m_parameters->hasOption("-debug-fusions2"))
cout<<"worker "<<m_workerIdentifier<<" Got "<<m_numberOfPaths<<endl;
m_receivedNumberOfPaths=true;
m_pathIndex=0;
m_requestedPath=false;
/* 2^5 */
int maximumNumberOfPathsToProcess=32;
/* don't process repeated stuff */
if(m_numberOfPaths> maximumNumberOfPathsToProcess)
m_numberOfPaths=0;
}else if(m_receivedNumberOfPaths && m_pathIndex < m_numberOfPaths){
/* request a path */
if(!m_requestedPath){
Kmer kmer;
m_path->at(m_position,&kmer);
if(m_reverseStrand)
kmer=kmer.complementVertex(m_parameters->getWordSize(),m_parameters->getColorSpaceMode());
Rank destination=kmer.vertexRank(m_parameters->getSize(),
m_parameters->getWordSize(),m_parameters->getColorSpaceMode());
int elementsPerQuery=m_virtualCommunicator->getElementsPerQuery(RAY_MPI_TAG_ASK_VERTEX_PATH);
MessageUnit*message=(MessageUnit*)m_outboxAllocator->allocate(elementsPerQuery);
int outputPosition=0;
kmer.pack(message,&outputPosition);
message[outputPosition++]=m_pathIndex;
Message aMessage(message,elementsPerQuery,destination,
RAY_MPI_TAG_ASK_VERTEX_PATH,m_parameters->getRank());
m_virtualCommunicator->pushMessage(m_workerIdentifier,&aMessage);
if(m_parameters->hasOption("-debug-fusions2")){
cout<<"worker "<<m_workerIdentifier<<" send RAY_MPI_TAG_ASK_VERTEX_PATH "<<m_pathIndex<<endl;
//.........这里部分代码省略.........
示例2: getPaths
/*
* get the Directions taken by a vertex.
*
* m_Machine_getPaths_INITIALIZED must be set to false before any calls.
* also, you must set m_Machine_getPaths_DONE to false;
*
* when done, m_Machine_getPaths_DONE is true
* and
* the result is in m_Machine_getPaths_result (a vector<Direction>)
*/
void FusionData::getPaths(Kmer vertex){
if(!m_Machine_getPaths_INITIALIZED){
m_Machine_getPaths_INITIALIZED=true;
m_FUSION_paths_requested=false;
m_Machine_getPaths_DONE=false;
m_Machine_getPaths_result.clear();
return;
}
if(m_cacheForRepeatedVertices.find(vertex,false)!=NULL){
SplayNode<Kmer ,Direction*>*node=m_cacheForRepeatedVertices.find(vertex,false);
#ifdef ASSERT
assert(node!=NULL);
#endif
Direction**ddirect=node->getValue();
#ifdef ASSERT
assert(ddirect!=NULL);
#endif
Direction*d=*ddirect;
while(d!=NULL){
m_Machine_getPaths_result.push_back(*d);
d=d->getNext();
}
m_Machine_getPaths_DONE=true;
}else if(!m_FUSION_paths_requested){
uint64_t*message=(uint64_t*)m_outboxAllocator->allocate(2*sizeof(uint64_t));
int bufferPosition=0;
vertex.pack(message,&bufferPosition);
message[bufferPosition++]=0;
Message aMessage(message,bufferPosition,
m_parameters->_vertexRank(&vertex),RAY_MPI_TAG_ASK_VERTEX_PATHS,getRank());
m_outbox->push_back(aMessage);
m_FUSION_paths_requested=true;
m_FUSION_paths_received=false;
m_FUSION_receivedPaths.clear();
}else if(m_FUSION_paths_received){
#ifdef ASSERT
for(int i=0;i<(int)m_FUSION_receivedPaths.size();i++){
assert(getRankFromPathUniqueId(m_FUSION_receivedPaths[i].getWave())<m_size);
}
#endif
// save the result in the cache.
#ifdef ASSERT
assert(m_cacheForRepeatedVertices.find(vertex,false)==NULL);
#endif
bool inserted;
SplayNode<Kmer ,Direction*>*node=m_cacheForRepeatedVertices.insert(vertex,&m_cacheAllocator,&inserted);
int i=0;
Direction*theDirection=NULL;
while(i<(int)m_Machine_getPaths_result.size()){
Direction*newDirection=(Direction*)m_cacheAllocator.allocate(sizeof(Direction)*1);
*newDirection=m_Machine_getPaths_result[i];
newDirection->setNext(theDirection);
theDirection=newDirection;
i++;
}
Direction**ddirect=node->getValue();
*ddirect=theDirection;
#ifdef ASSERT
if(m_Machine_getPaths_result.size()==0){
assert(*(m_cacheForRepeatedVertices.find(vertex,false)->getValue())==NULL);
}
#endif
m_Machine_getPaths_DONE=true;
}
}