Skip to content

Commit

Permalink
*** empty log message ***
Browse files Browse the repository at this point in the history
  • Loading branch information
langmead committed Aug 15, 2009
1 parent 5bd36e6 commit 1ef6658
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
8 changes: 6 additions & 2 deletions ebwt_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ static const char * refMapFile = NULL; // file containing a map from index coo
static const char * annotMapFile= NULL; // file containing a map from reference coordinates to annotations
static size_t fastaContLen = 0;
static size_t fastaContFreq = 0;
static bool hadoopOut = false; // print Hadoop status and summary messages

// mating constraints

Expand Down Expand Up @@ -212,7 +213,8 @@ enum {
ARG_CHAININ,
ARG_REFMAP,
ARG_ANNOTMAP,
ARG_REPORTSE
ARG_REPORTSE,
ARG_HADOOPOUT
};

static struct option long_options[] = {
Expand Down Expand Up @@ -316,6 +318,7 @@ static struct option long_options[] = {
{(char*)"refmap", required_argument, 0, ARG_REFMAP},
{(char*)"annotmap", required_argument, 0, ARG_ANNOTMAP},
{(char*)"reportse", no_argument, 0, ARG_REPORTSE},
{(char*)"hadoopout", no_argument, 0, ARG_HADOOPOUT},
{(char*)0, 0, 0, 0} // terminator
};

Expand Down Expand Up @@ -1448,6 +1451,7 @@ static void parseOptions(int argc, char **argv) {
#endif
}
case ARG_MMSWEEP: mmSweep = true; break;
case ARG_HADOOPOUT: hadoopOut = true; break;
case ARG_DUMP_NOHIT: dumpNoHits = new ofstream(".nohits.dump"); break;
case ARG_DUMP_HHHIT: dumpHHHits = new ofstream(".hhhits.dump"); break;
case ARG_AL: dumpAlBase = optarg; break;
Expand Down Expand Up @@ -4484,7 +4488,7 @@ static void driver(const char * type,
delete ebwtBw;
}
if(!quiet) {
sink->finish(); // end the hits section of the hit file
sink->finish(hadoopOut); // end the hits section of the hit file
}
if(dumpHHHits != NULL) dumpHHHits->close();
if(dumpNoHits != NULL) dumpNoHits->close();
Expand Down
9 changes: 8 additions & 1 deletion hit.h
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ class HitSink {
* Called when all alignments are complete. It is assumed that no
* synchronization is necessary.
*/
void finish() {
void finish(bool hadoopOut) {
// Close output streams
closeOuts();
if(!quiet_) {
Expand Down Expand Up @@ -634,6 +634,13 @@ class HitSink {
<< " singleton alignments to " << _outs.size()
<< " output stream(s)" << endl;
}
if(hadoopOut) {
cerr << "reporter:counter:Bowtie,reads_with_at_least_1_alignment," << numAligned_ << endl;
cerr << "reporter:counter:Bowtie,reads_with_no_alignments," << numUnaligned_ << endl;
cerr << "reporter:counter:Bowtie,reads_over_dash_m_limit," << numMaxed_ << endl;
cerr << "reporter:counter:Bowtie,unpaired_alignments_reported," << numReported_ << endl;
cerr << "reporter:counter:Bowtie,paired_alignments_reported," << numReportedPaired_ << endl;
}
}
// Print the recalibration table.
if(recalTable_ != NULL) {
Expand Down
14 changes: 9 additions & 5 deletions shmem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

using namespace std;

#define SHMEM_UNINIT 0xafba4242
#define SHMEM_INIT 0xffaa6161

/**
* Tries to allocate a shared-memory chunk for a given file of a given size.
*/
Expand Down Expand Up @@ -95,14 +98,15 @@ bool allocSharedMem(string fname,
}
} // while(true)
*dst = ptr;
if(ds.shm_cpid == getpid()) {
bool initid = (((volatile uint32_t*)((char*)ptr + len))[0] == SHMEM_INIT);
if(ds.shm_cpid == getpid() && !initid) {
if(verbose) {
cerr << " I (pid = " << getpid() << ") created the "
<< "shared memory for " << memName << endl;
}
// Set this value just off the end of the chunk to
// indicate that the data hasn't been read yet.
((volatile uint32_t*)((char*)ptr + len))[0] = 0xffffffff;
((volatile uint32_t*)((char*)ptr + len))[0] = SHMEM_UNINIT;
return true;
} else {
if(verbose) {
Expand All @@ -119,16 +123,16 @@ bool allocSharedMem(string fname,
* finished initializing it.
*/
void notifySharedMem(void *mem, size_t len) {
((volatile uint32_t*)((char*)mem + len))[0] = 0x0f0f0f0f;
((volatile uint32_t*)((char*)mem + len))[0] = SHMEM_INIT;
}

/**
* Wait until the leader of a shared-memory chunk has finished
* initializing it.
*/
void waitSharedMem(void *mem, size_t len) {
while(((volatile uint32_t*)((char*)mem + len))[0] != 0x0f0f0f0f) {
// spin
while(((volatile uint32_t*)((char*)mem + len))[0] != SHMEM_INIT) {
sleep(1);
}
}

Expand Down
9 changes: 8 additions & 1 deletion str_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ hash_string(const std::string& s) {
int b = 378551;
for(size_t i = 0; i < s.length(); i++) {
ret = (ret * a) + (int)s[i];
a *= b;
if(a == 0) {
a += b;
} else {
a *= b;
}
if(a == 0) {
a += b;
}
}
return ret;
}
Expand Down

0 comments on commit 1ef6658

Please sign in to comment.