From: Josh T <spa...@us...> - 2007-03-26 19:52:42
|
Update of /cvsroot/sashimi/trans_proteomic_pipeline/src/Visualization/Comet/plot-msms In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv17315 Modified Files: plot-msms1.c Log Message: fixing scan-number extraction from dta filenames to allow for maldi-type names which include spot numbers. Index: plot-msms1.c =================================================================== RCS file: /cvsroot/sashimi/trans_proteomic_pipeline/src/Visualization/Comet/plot-msms/plot-msms1.c,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** plot-msms1.c 19 Mar 2007 20:23:32 -0000 1.33 --- plot-msms1.c 26 Mar 2007 19:52:35 -0000 1.34 *************** *** 218,221 **** --- 218,223 ---- void HIGHLIGHT(double dMass, int iWhichIonSeries); + int GET_SCANNUM_FROM_DTA_NAME(const char* dtaName); + #include "util.h" *************** *** 2319,2337 **** { /* mzXML file: read file index and parse scan # from encoded .dta file*/ ! ! char szTmp[500]; ! char *pStr; ! ! if ( (pStr = strchr(pEnvironment.szInputFile, '.'))==NULL) ! { ! printf(" Error - cannot get scan number from input file %s\n", pEnvironment.szInputFile); ! exit(1); ! } ! ! strcpy(szTmp, pStr+1); ! pStr = strchr(szTmp, '.'); ! *pStr = '\0'; ! ! sscanf(szTmp, "%d", &iScanNum); /* read mzXML file offset scan index */ --- 2321,2325 ---- { /* mzXML file: read file index and parse scan # from encoded .dta file*/ ! iScanNum = GET_SCANNUM_FROM_DTA_NAME(pEnvironment.szInputFile); /* read mzXML file offset scan index */ *************** *** 2861,2878 **** /* mzXML file: read file index and parse scan # from encoded .dta file*/ ! char szTmp[500]; ! char *pStr; ! ! if ( (pStr = strchr(pEnvironment.szInputFile, '.'))==NULL) ! { ! printf(" Error - cannot get scan number from input file %s\n", pEnvironment.szInputFile); ! exit(1); ! } ! ! strcpy(szTmp, pStr+1); ! pStr = strchr(szTmp, '.'); ! *pStr = '\0'; ! ! sscanf(szTmp, "%d", &iScanNum); /* read mzXML file offset scan index */ --- 2849,2853 ---- /* mzXML file: read file index and parse scan # from encoded .dta file*/ ! iScanNum = GET_SCANNUM_FROM_DTA_NAME(pEnvironment.szInputFile); /* read mzXML file offset scan index */ *************** *** 3146,3147 **** --- 3121,3164 ---- return (0); } /*SORT_LABELIONS_INTEN*/ + + + /* + * extract the scan number from the dta file name, which is expected be of the format + * xxxxxxxxxxxxxx.scanstart.scanend.charge + */ + int GET_SCANNUM_FROM_DTA_NAME(const char* dtaName) { + int scanNum = -1; + char szTmp[500]; + char *pStr; + + /* + assume dta filename format is xxxxxxxx.scanstart.scanend.charge.dta + + start from right to left, in order to avoid issues with messy naming schemes, + like maldi, which may have a format like xxxxxxx.SPOT_DESIGNATOR.xxxx.xxxx.xxx.dta + */ + + strcpy(szTmp, dtaName); + + int fieldCount=4; + while (fieldCount != 0) { + pStr = strrchr(szTmp, '.'); + if (pStr == NULL) { + printf(" Error - cannot get scan number from input file %s; unexpected dta name format\n", dtaName); + exit(1); + } + /* + first time here: pStr is one before 'dta' + second time: pStr is one before charge + third time: pStr is one before scanend + forth: one before scanstart (what we want) + */ + *pStr = '\0'; + --fieldCount; + } + /* szTemp is now xxxxxxx.scanstartNULLxxxxxx */ + pStr++; + sscanf(pStr, "%d", &scanNum); + + return scanNum; + } |