static rc_t CC AlignAccessDBWhack(AlignAccessDB *self) { rc_t rc; rc = BAMFileRelease(self->innerSelf); if (rc) return rc; return AlignAccessMgrRelease(self->mgr); }
int LowLevelTest() { cout << "Running LowLevelTest()." << endl; const AlignAccessMgr* mgr = 0; CALL(AlignAccessMgrMake(&mgr)); VFSManager* vfs_mgr; CALL(VFSManagerMake(&vfs_mgr)); VPath* bam_path = 0; #ifdef _MSC_VER # define BAM_FILE "//traces04/1kg_pilot_data/ftp/pilot_data/data/NA10851/alignment/NA10851.SLX.maq.SRP000031.2009_08.bam" #else # define BAM_FILE "/netmnt/traces04/1kg_pilot_data/ftp/pilot_data/data/NA10851/alignment/NA10851.SLX.maq.SRP000031.2009_08.bam" #endif cout << "Testing BAM file: "<<BAM_FILE<<endl; CALL(VFSManagerMakeSysPath(vfs_mgr, &bam_path, BAM_FILE)); VPath* bai_path = 0; CALL(VFSManagerMakeSysPath(vfs_mgr, &bai_path, BAM_FILE ".bai")); const AlignAccessDB* bam = 0; CALL(AlignAccessMgrMakeIndexBAMDB(mgr, &bam, bam_path, bai_path)); #ifdef _MSC_VER InitializeCriticalSection(&sdk_mutex); #endif const size_t kNumCursors = 8; const size_t kNumThreads = 3; SThreadInfo tinfo[kNumCursors]; const char* ids[kNumCursors] = { "NT_113960", "NT_113945", "NT_113880", "NT_113960", "NT_113960", "NT_113960", "NT_113945", "NT_113880" }; for ( size_t i = 0; i < kNumThreads; ++i ) { tinfo[i].init(i, bam, ids[i]); } for ( size_t i = 0; i < kNumThreads; ++i ) { cout << "Starting thread " << i << " for " << ids[i] << endl; #ifdef _MSC_VER tinfo[i].thread_id = CreateThread(NULL, 0, read_thread_func, &tinfo[i], 0, NULL); #else pthread_create(&tinfo[i].thread_id, 0, read_thread_func, &tinfo[i]); #endif } for ( size_t i = 0; i < kNumThreads; ++i ) { cout << "Waiting for thread " << i << endl; void* ret = 0; #ifdef _MSC_VER WaitForSingleObject(tinfo[i].thread_id, INFINITE); CloseHandle(tinfo[i].thread_id); #else pthread_join(tinfo[i].thread_id, &ret); #endif cout << "Align count: " << tinfo[i].count << endl; } CALL(AlignAccessDBRelease(bam)); CALL(VPathRelease(bam_path)); CALL(VPathRelease(bai_path)); CALL(AlignAccessMgrRelease(mgr)); CALL(VFSManagerRelease(vfs_mgr)); cout << "Success." << endl; return 0; }