void DVDWorker::ScanDVDContents() { XamSetDvdSpindleSpeed(DVD_SPEED_12X); WIN32_FIND_DATA findFileData; memset(&findFileData,0,sizeof(WIN32_FIND_DATA)); string searchcmd = "dvd:\\*"; searchcmd = str_replaceallA(searchcmd,"\\\\","\\"); HANDLE hFind = FindFirstFile(searchcmd.c_str(), &findFileData); if (hFind != INVALID_HANDLE_VALUE) { do { if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if (strcmp(findFileData.cFileName, "$SystemUpdate") != 0) { string source = sprintfaA("dvd:\\%s", findFileData.cFileName); string dest = sprintfaA("%s\\%s", m_CurrentItem->getDestPath().c_str(), findFileData.cFileName); RecursiveMkdir(dest); m_CurrentItem->setCurrentFile(source); m_CurrentItem->requester->UpdateFileCount(m_CurrentItem); RecursiveScan(source, dest); } else if (strcmp(findFileData.cFileName, "$SystemUpdate") == 0 && m_CurrentItem->getIncludeUpdate()) { string source = sprintfaA("dvd:\\%s", findFileData.cFileName); string dest = sprintfaA("%s\\%s", m_CurrentItem->getDestPath().c_str(), findFileData.cFileName); RecursiveMkdir(dest); m_CurrentItem->setCurrentFile(source); m_CurrentItem->requester->UpdateFileCount(m_CurrentItem); RecursiveScan(source, dest); } } else { string source = sprintfaA("dvd:\\%s", findFileData.cFileName); string dest = sprintfaA("%s\\%s", m_CurrentItem->getDestPath().c_str(), findFileData.cFileName); m_CurrentItem->setCurrentFile(source); m_CurrentItem->requester->UpdateFileCount(m_CurrentItem); FileOperationManager::getInstance().AddFileOperation(source, dest, false); } } while (FindNextFile(hFind, &findFileData)); }FindClose(hFind); m_CurrentItem->setScanComplete(true); m_CurrentItem->requester->UpdateFileCount(m_CurrentItem); FileOperationManager::getInstance().DoWork(); }
int PDMlib::Write(const std::string& Name, const size_t& ContainerLength, T* Container, T MinMax[8], const int& NumComp, const int& TimeStep, const double& Time) { if(!pImpl->Initialized) { std::cerr<<"PDMlib::Write() called before Init()"<<std::endl; return -1; } if(!pImpl->wMetaData->FindContainerInfo(Name)) { std::cerr<<"PDMlib::Write(): "<<Name<<" is not found in MetaDataFile"<<std::endl; return -2; } if(Container == NULL) { std::cerr<<"PDMlib::Write(): Null pointer is passed as Container pointer of pointer"<<std::endl; return -4; } if((NumComp != 1) && (NumComp != 3)) { std::cerr<<"PDMlib::Write(): NumComp must be 1 or 3 ("<<NumComp<<")"<<std::endl; return -5; } if(TimeStep < 0) { std::cerr<<"PDMlib::Write(): TimeStep must be positive number ("<<TimeStep<<")"<<std::endl; return -6; } if(pImpl->FirstCall) { pImpl->wMetaData->SetReadOnly(); pImpl->wMetaData->Write(); pImpl->FirstCall = false; // create directory by atomic operation in MPI world for ( int i=0; i<pImpl->wMetaData->GetNumProc(); i++) { MPI_Barrier(pImpl->wMetaData->GetComm()); if(i != pImpl->wMetaData->GetMyRank()) continue; if(!RecursiveMkdir(pImpl->wMetaData->GetPath())) { std::cerr<<"mkdir faild! field data will be output to current directory!"<<std::endl; pImpl->wMetaData->SetPath("./"); } } } //タイムスライス情報の出力 pImpl->wMetaData->WriteTimeSlice(TimeStep, Time, MinMax, ContainerLength, Name); std::string filename; pImpl->wMetaData->GetFileName(&filename, Name, pImpl->wMetaData->GetMyRank(), TimeStep); //出力するデータサイズが0の時はタイムスライスだけ出力して終了 if(ContainerLength == 0) { return 0; } //フィールドデータの出力 ContainerInfo container_info; pImpl->wMetaData->GetContainerInfo(Name, &container_info); BaseIO::Write* writer = BaseIO::WriteFactory::create(container_info.Compression, enumType2string(container_info.Type), container_info.nComp); int write_size = writer->write(filename.c_str(), ContainerLength*NumComp*sizeof(T), ContainerLength*NumComp*sizeof(T), (char*)Container); delete writer; return write_size; }
int processAssemblyOptions(int argc, char * argv[], assemblyOptions& opts) { int c; int index; static struct option assemblyLongOptions [] = { {"segments", required_argument, NULL, 's'}, {"group", required_argument, NULL, 'g'}, {"logLevel", required_argument, NULL, 'l'}, {"version", no_argument, NULL, 'V'}, {"inDir", required_argument, NULL, 'i'}, {"outDir", required_argument, NULL, 'o'}, {"help", no_argument, NULL, 'h'}, {"pairedEnd", no_argument, NULL, 'p'}, {"insertSize", required_argument, NULL, 'I'}, {"logToScreen", no_argument, NULL, 0}, {"xml",required_argument,NULL,'x'}, {"velvet",no_argument,NULL,0}, {"cap3",no_argument,NULL,0}, {NULL, no_argument, NULL, 0} }; try { while( (c = getopt_long(argc, argv, "g:hi:I:l:o:ps:Vx:", assemblyLongOptions, &index)) != -1 ) { switch(c) { case 'g': { from_string<int>(opts.group, optarg, std::dec); break; } case 'h': { assemblyUsage(); exit(1); break; } case 'i': { // Test to see if the file is ok. struct stat inputDirStatus; int iStat = stat(optarg, &inputDirStatus); // stat failed switch (iStat) { case -1: { switch (errno) { case ENOENT: { throw ( std::runtime_error("Input directory path does not exist, or path is an empty string.") ); break; } case ELOOP: { throw ( std::runtime_error("Too many symbolic links encountered while traversing the input directory path.")); break; } case EACCES: { throw ( std::runtime_error("You do not have permission to access the input directory.")); break; } case ENOTDIR: { throw ( std::runtime_error("Input is not a directory\n")); break; } default: { throw (std::runtime_error("An error occured when reading the input directory")); break; } } break; } default: { opts.inputDirName = optarg; break; } } break; } case 'I': { from_string<int>(opts.insertSize, optarg, std::dec); break; } case 'l': { from_string<int>(opts.logLevel, optarg, std::dec); if(opts.logLevel > CRASS_DEF_MAX_LOGGING) { std::cerr<<PACKAGE_NAME<<" [WARNING]: Specified log level higher than max. Changing log level to "<<CRASS_DEF_MAX_LOGGING<<" instead of "<<opts.logLevel<<std::endl; opts.logLevel = CRASS_DEF_MAX_LOGGING; } break; } case 'o': { // Test to see if the file is ok. struct stat outputDirStatus; int oStat = stat(optarg, &outputDirStatus); switch (oStat) { case -1: { switch (errno) { case ENOENT: { RecursiveMkdir(optarg); break; } case ELOOP: { throw ( std::runtime_error("Too many symbolic links encountered while traversing the output directory path.")); break; } case EACCES: { throw ( std::runtime_error("You do not have permission to access the output directory.")); break; } case ENOTDIR: { throw ( std::runtime_error("Output path is not a directory\n")); break; } default: { throw std::runtime_error("An error occurred when accessing the output directory"); break; } } } default: { opts.outputDirName = optarg; break; } } break; } case 'p': { opts.pairedEnd = true; break; } case 's': { opts.segments = optarg; break; } case 'V': { assemblyVersionInfo(); exit(1); break; } case 'x': { // Test to see if the file is ok. struct stat inputDirStatus; int xStat = stat(optarg, &inputDirStatus); // stat failed switch (xStat) { case -1: { switch (errno) { case ENOENT: { throw ( std::runtime_error("Path to the XML file does not exist, or path is an empty string.") ); break; } case ELOOP: { throw ( std::runtime_error("Too many symbolic links encountered while traversing the path to the XML file.")); break; } case EACCES: { throw ( std::runtime_error("You do not have permission to access the XML file.")); break; } default: { throw (std::runtime_error("An error occured when reading the XML file")); break; } } break; } default: { opts.xmlFileName = optarg; break; } } break; } case 0: { if ( strcmp( "logToScreen", assemblyLongOptions[index].name ) == 0 ) opts.logToScreen = true; if (!strcmp("velvet",assemblyLongOptions[index].name)){ #ifdef HAVE_VELVET opts.assembler = velvet; #else throw std::runtime_error("crass-assembler cannot use velvet. Please re-compile with velvet in you PATH"); #endif } if (!strcmp("cap3",assemblyLongOptions[index].name)){ #ifdef HAVE_CAP3 opts.assembler = cap3; #else throw std::runtime_error("crass-assembler cannot use cap3. Please re-compile with cap3 in you PATH"); #endif } break; } default: { assemblyUsage(); exit(1); break; } } } // make sure that the required flags are set if (opts.xmlFileName.empty()) { throw (std::runtime_error("You must specify an xml file with -x")); } if (!(opts.group)) { throw (std::runtime_error("You must specify a group number with -g")); } if (opts.segments.empty()) { throw (std::runtime_error("You must specify a list of contigs with -s")); } if (opts.inputDirName.empty()) { throw (std::runtime_error("You must specify an input directory with -i")); } if (opts.outputDirName.empty()) { opts.outputDirName = "."; } } catch (std::exception& e) { std::cerr<<PACKAGE_NAME<<" [ERROR]: "<<e.what()<<std::endl; exit(1); } return optind; }
int processOptions(int argc, char *argv[], options *opts) { int c; int index; bool scalling = false; while( (c = getopt_long(argc, argv, "a:b:c:d:D:ef:gGhHk:K:l:Ln:o:rs:S:Vw:x:y:z", long_options, &index)) != -1 ) { switch(c) { case 'a': #if RENDERING if (strcmp(optarg, "dot") && strcmp(optarg, "neato") && strcmp(optarg, "fdp") && strcmp(optarg, "sfdp") && strcmp(optarg, "twopi") && strcmp(optarg, "circo")) { std::cerr<<PACKAGE_NAME<<" [WARNING]: '"<<optarg<<"' is not a recognised layout algorithm. Please choose from the following:"<<std::endl; #ifdef HAVE_NEATO std::cerr<<"\tneato"<<std::endl; #endif #ifdef HAVE_DOT std::cerr<<"\tdot"<<std::endl; #endif #ifdef HAVE_FDP std::cerr<<"\tfdp"<<std::endl; #endif #ifdef HAVE_SFDP std::cerr<<"\tsfdp"<<std::endl; #endif #ifdef HAVE_CIRCO std::cerr<<"\tcirco"<<std::endl; #endif #ifdef HAVE_TWOPI std::cerr<<"\ttwopi"<<std::endl; #endif } else { opts->layoutAlgorithm = optarg; } #else std::cerr<<PACKAGE_NAME<<" [WARNING]: Not compiled with the correct options to allow rendering of graphs.\nEither use the --enable-rendering option during ./configure and make sure that the graphviz layout programs are in your PATH"<<std::endl; #endif break; case 'b': from_string<int>(opts->coverageBins, optarg, std::dec); if (opts->coverageBins < 1) { std::cerr<<PACKAGE_NAME<<" [ERROR]: The number of bins for coverage cannot be less than 1"<<std::endl; usage(); exit(1); } break; case 'c': if (strcmp(optarg, "red-blue") == 0) { opts->graphColourType = RED_BLUE; } else if(strcmp(optarg, "read-blue-green") == 0) { opts->graphColourType = RED_BLUE_GREEN; } else if(strcmp(optarg, "blue-red") == 0) { opts->graphColourType = BLUE_RED; } else if(strcmp(optarg, "green-blue-red") == 0) { opts->graphColourType = GREEN_BLUE_RED; } else { std::cerr<<PACKAGE_NAME<<" [WARNING]: Unknown graph colour type "<<optarg<<" changing to default colour type (red-blue)"<<std::endl; opts->graphColourType = RED_BLUE; } break; case 'd': from_string<unsigned int>(opts->lowDRsize, optarg, std::dec); if (opts->lowDRsize < 8) { std::cerr<<PACKAGE_NAME<<" [WARNING]: The lower bound for direct repeat sizes cannot be "<<opts->lowDRsize<<" changing to "<<CRASS_DEF_MIN_DR_SIZE<<std::endl; opts->lowDRsize = CRASS_DEF_MIN_DR_SIZE; } break; case 'D': from_string<unsigned int>(opts->highDRsize, optarg, std::dec); break; case 'e': #ifdef DEBUG opts->noDebugGraph = true; #endif break; case 'f': from_string<int>(opts->covCutoff, optarg, std::dec); break; case 'g': opts->logToScreen = true; break; case 'G': opts->showSingles= true; break; case 'h': versionInfo(); usage(); exit(1); break; case 'H': opts->removeHomopolymers = true; break; case 'k': from_string<int>(opts->kmer_clust_size, optarg, std::dec); if (opts->kmer_clust_size < 4) { std::cerr<<PACKAGE_NAME<<" [WARNING]: Minimum value for kmer clustering size is: "<<4<<" changing to "<<CRASS_DEF_K_CLUST_MIN<<std::endl; opts->kmer_clust_size = CRASS_DEF_K_CLUST_MIN; } break; case 'K': from_string<int>(opts->cNodeKmerLength, optarg, std::dec); break; case 'l': from_string<int>(opts->logLevel, optarg, std::dec); if(opts->logLevel > CRASS_DEF_MAX_LOGGING) { std::cerr<<PACKAGE_NAME<<" [WARNING]: Specified log level higher than max. Changing log level to "<<CRASS_DEF_MAX_LOGGING<<" instead of "<<opts->logLevel<<std::endl; opts->logLevel = CRASS_DEF_MAX_LOGGING; } break; case 'L': opts->longDescription = true; break; case 'n': from_string<unsigned int>(opts->minNumRepeats, optarg, std::dec); if (opts->minNumRepeats < 2) { std::cerr<<PACKAGE_NAME<<" [ERROR]: The mininum number of repeats cannot be less than 2"<<std::endl; usage(); exit(1); } break; case 'o': opts->output_fastq = optarg; // just in case the user put '.' or '..' or '~' as the output directory if (opts->output_fastq[opts->output_fastq.length() - 1] != '/') { opts->output_fastq += '/'; } // check if our output folder exists struct stat file_stats; if (0 != stat(opts->output_fastq.c_str(),&file_stats)) { RecursiveMkdir(opts->output_fastq); } // check that the directory is writable else if(access(optarg, W_OK)) { std::cerr<<PACKAGE_NAME<<" [ERROR]: You do not have permission to write to "<<optarg<<std::endl; exit(1); } break; case 'r': #ifdef RENDERING opts->noRendering = true; #endif break; case 's': from_string<unsigned int>(opts->lowSpacerSize, optarg, std::dec); if (opts->lowSpacerSize < 8) { std::cerr<<PACKAGE_NAME<<" [WARNING]: The lower bound for spacer sizes cannot be "<<opts->lowSpacerSize<<" changing to "<<CRASS_DEF_MIN_SPACER_SIZE<<std::endl; opts->lowSpacerSize = CRASS_DEF_MIN_SPACER_SIZE; } break; case 'S': from_string<unsigned int>(opts->highSpacerSize, optarg, std::dec); break; case 'V': versionInfo(); exit(1); break; case 'w': from_string<unsigned int>(opts->searchWindowLength, optarg, std::dec); if ((opts->searchWindowLength < CRASS_DEF_MIN_SEARCH_WINDOW_LENGTH) || (opts->searchWindowLength > CRASS_DEF_MAX_SEARCH_WINDOW_LENGTH)) { std::cerr<<PACKAGE_NAME<<" [WARNING]: Specified window length higher than max. Changing window length to " << CRASS_DEF_OPTIMAL_SEARCH_WINDOW_LENGTH << " instead of " << opts->searchWindowLength<<std::endl; // Change window length opts->searchWindowLength = CRASS_DEF_OPTIMAL_SEARCH_WINDOW_LENGTH; } break; case 'x': from_string<double>(opts->averageSpacerScalling, optarg, std::dec); if (isNotDecimal(opts->averageSpacerScalling)) { std::cerr<<PACKAGE_NAME<<" [WARNING]: The average spacer scalling must be a decimal number. Changing to "<<CRASS_DEF_HOMOPOLYMER_SCALLING<<" instead of "<<opts->averageSpacerScalling<<std::endl; opts->averageSpacerScalling = CRASS_DEF_HOMOPOLYMER_SCALLING; } scalling = true; break; case 'y': from_string<double>(opts->averageDrScalling, optarg, std::dec); if (isNotDecimal(opts->averageDrScalling)) { std::cerr<<PACKAGE_NAME<<" [WARNING]: The average spacer scalling must be a decimal number. Changing to "<<CRASS_DEF_HOMOPOLYMER_SCALLING<<" instead of "<<opts->averageDrScalling<<std::endl; opts->averageDrScalling = CRASS_DEF_HOMOPOLYMER_SCALLING; } scalling = true; break; case 'z': opts->dontPerformScalling = true; break; case 0: #ifdef SEARCH_SINGLETON if (strcmp("searchChecker", long_options[index].name) == 0) opts->searchChecker = optarg; #endif break; default: versionInfo(); usage(); exit(1); break; } } // Sanity checks for the high and low dr size if (opts->lowDRsize >= opts->highDRsize) { std::cerr<<PACKAGE_NAME<<" [ERROR]: The lower direct repeat bound is bigger than the higher bound ("<<opts->lowDRsize<<" >= "<<opts->highDRsize<<")"<<std::endl; usage(); exit(1); } // Sanity checks for the high and low spacer size if (opts->lowSpacerSize >= opts->highSpacerSize) { std::cerr<<PACKAGE_NAME<<" [ERROR]: The lower spacer bound is bigger than the higher bound ("<<opts->lowSpacerSize<<" >= "<<opts->highSpacerSize<<")"<<std::endl; usage(); exit(1); } // sanity check so that the user doesn't specify scalling and no scalling simultaneously if (scalling & opts->dontPerformScalling) { std::cerr<<PACKAGE_NAME<<" [ERROR]: Cannot use scalling (-x -y) in conjunction with --noScalling"<<std::endl; usage(); exit(1); } // warn them if they try to scale without specifying to remove homopolymers if (scalling && !opts->removeHomopolymers) { std::cerr<<PACKAGE_NAME<<" [ERROR]: scalling (-x -y) can only be used in conjunction with --removeHomopolymers"<<std::endl; usage(); exit(1); } // scale the direct repeat and spacer lengths if we should if (opts->removeHomopolymers && !opts->dontPerformScalling) { opts->lowDRsize *= opts->averageDrScalling; opts->highDRsize *= opts->averageDrScalling; opts->lowSpacerSize *= opts->averageSpacerScalling; opts->highSpacerSize *= opts->averageSpacerScalling; } return optind; }