-/**************************************************************************************************/
-
-int FilterSeqsCommand::setLines(string filename) {
- try {
-
- vector<unsigned long int> positions;
- bufferSizes.clear();
-
- ifstream inFASTA;
- openInputFile(filename, inFASTA);
-
- string input;
- while(!inFASTA.eof()){
- input = getline(inFASTA);
-
- if (input.length() != 0) {
- if(input[0] == '>'){ unsigned long int pos = inFASTA.tellg(); positions.push_back(pos - input.length() - 1); }
- }
- }
- inFASTA.close();
-
- int numFastaSeqs = positions.size();
-
- FILE * pFile;
- unsigned long int size;
-
- //get num bytes in file
- pFile = fopen (filename.c_str(),"rb");
- if (pFile==NULL) perror ("Error opening file");
- else{
- fseek (pFile, 0, SEEK_END);
- size=ftell (pFile);
- fclose (pFile);
- }
-
- numSeqs += numFastaSeqs;
-
- int numSeqsPerProcessor = numFastaSeqs / processors;
-
- for (int i = 0; i < processors; i++) {
-
- unsigned long int startPos = positions[ i * numSeqsPerProcessor ];
- if(i == processors - 1){
- numSeqsPerProcessor = numFastaSeqs - i * numSeqsPerProcessor;
- bufferSizes.push_back(size - startPos);
- }else{
- unsigned long int myEnd = positions[ (i+1) * numSeqsPerProcessor ];
- bufferSizes.push_back(myEnd-startPos);
- }
- lines.push_back(new linePair(startPos, numSeqsPerProcessor));
- }
-
- return 0;
- }
- catch(exception& e) {
- m->errorOut(e, "FilterSeqsCommand", "setLines");
- exit(1);
- }
-}