From: David S. <ds...@us...> - 2006-12-08 20:26:50
|
Update of /cvsroot/sashimi/trans_proteomic_pipeline/src/Parsers/Algorithm2XML/Sequest2XML In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv32661/Parsers/Algorithm2XML/Sequest2XML Modified Files: CombineOut.cxx Log Message: New code for processing TGZ files (not yet functional). Index: CombineOut.cxx =================================================================== RCS file: /cvsroot/sashimi/trans_proteomic_pipeline/src/Parsers/Algorithm2XML/Sequest2XML/CombineOut.cxx,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CombineOut.cxx 29 Nov 2006 20:58:29 -0000 1.2 --- CombineOut.cxx 8 Dec 2006 20:26:47 -0000 1.3 *************** *** 20,29 **** outpath_[strlen(outpath_)-1] = '\0'; } sprintf(pepXmlPath_, "%s.xml", outpath_); sprintf(paramsPath_, "%s/sequest.params", outpath_); ! strcpy(inpath1_, path1); ! strcpy(inpath2_, path1); ! readOutDir(path1, outFiles1_, seqParams1_); ! readOutDir(path2, outFiles2_, seqParams2_); } --- 20,55 ---- outpath_[strlen(outpath_)-1] = '\0'; } + + strcpy(inpath1_, path1); + strcpy(inpath2_, path2); + + tgzfile1_ = False; + tgzfile2_ = False; + + if (strstr(inpath1_, ".tgz") != NULL) { + tgzfile1_ = True; + } + if (strstr(inpath2_, ".tgz") != NULL) { + tgzfile2_ = True; + } + + if (tgzfile1_) { + readTgzFile(path1, outFiles1_, seqParams1_); + } + else { + readOutDir(path1, outFiles1_, seqParams1_); + } + + if (tgzfile2_) { + readTgzFile(path2, outFiles2_, seqParams2_); + } + else { + readOutDir(path2, outFiles2_, seqParams2_); + } + sprintf(pepXmlPath_, "%s.xml", outpath_); + sprintf(mzXmlPath_, "%s.mzXML", outpath_); sprintf(paramsPath_, "%s/sequest.params", outpath_); ! sprintf(baseName_, "%s", outpath_); } *************** *** 359,369 **** } ! sprintf(baseName_, "%s", pathName); sprintf(baseDir_, "%s", pathName); ! baseName_[strlen(baseName_)-1] = '\0'; ! //sprintf(pepXmlPath_, "%s.xml", baseName_); ! sprintf(mzXmlPath_, "%s.mzXML", baseName_); //TODO: need an option for this --- 385,395 ---- } ! // sprintf(baseName_, "%s", pathName); sprintf(baseDir_, "%s", pathName); ! // baseName_[strlen(baseName_)-1] = '\0'; ! // sprintf(pepXmlPath_, "%s.xml", baseName_); ! // sprintf(mzXmlPath_, "%s.mzXML", baseName_); //TODO: need an option for this *************** *** 407,408 **** --- 433,491 ---- delete [] paramsFile; } + + + void CombineOut::readTgzFile(char* path, hash_map<const char*, SequestOut*, hash<const char*>, eqstr>& outFiles, SequestParams*& seqParam) + { + struct stat fileStat; + FILE *tgzpipe, *outpipe; + #ifdef WINDOWS_CYGWIN + char SEP = '\\'; + #else + char SEP = '/'; + #endif + char * pathName = new char [4086]; + char * fileName = new char [4086]; + char * paramsFile = new char [4086]; + char * command = new char [4086]; + char * next = new char [4086]; + if (!stat(path, &fileStat)) + { + if (S_ISREG(fileStat.st_mode)) + { + sprintf(command, "tar tfz %s *.out", path); + if ((tgzpipe = popen(command, "r"))!=NULL) { + while (fgets(next, 4086, tgzpipe)!=NULL) { + next[strlen(next)-1] = '\0'; + sprintf(command, "tar Oxfz %s %s", path, next); + if ((outpipe = popen(command, "r"))!=NULL) { + SequestOut* tmp = new SequestOut(); + struct HeaderStruct * hdr = (HeaderStruct *)malloc(sizeof(HeaderStruct)); + this->readOutFile(outpipe, tmp, hdr, seqParam); + char* key = new char[4086]; + sprintf(key, "%s", next); + hash_map<const char*, SequestOut*, hash<const char*>, eqstr>::iterator curr; + hash_map<const char*, SequestOut*, hash<const char*>, eqstr>::iterator end = outFiles.end(); + outFiles.insert(pair<const char*, SequestOut*>(key, tmp)); + } + pclose(outpipe); + } + } + else + { + //Do nothing right now + //TODO: do something meaningful + } + } + else + { + //Do nothing right now + //TODO: do something meaningful + } + + } + delete [] next; + delete [] command; + delete [] pathName; + delete [] fileName; + delete [] paramsFile; + } |