From: <spa...@us...> - 2008-04-25 00:44:12
|
Revision: 3148 http://sashimi.svn.sourceforge.net/sashimi/?rev=3148&view=rev Author: spacepod Date: 2008-04-24 17:44:04 -0700 (Thu, 24 Apr 2008) Log Message: ----------- [trapper] improved error reporting Modified Paths: -------------- trunk/trans_proteomic_pipeline/src/mzXML/converters/trapper/MassHunterInterface.cpp Modified: trunk/trans_proteomic_pipeline/src/mzXML/converters/trapper/MassHunterInterface.cpp =================================================================== --- trunk/trans_proteomic_pipeline/src/mzXML/converters/trapper/MassHunterInterface.cpp 2008-04-25 00:05:46 UTC (rev 3147) +++ trunk/trans_proteomic_pipeline/src/mzXML/converters/trapper/MassHunterInterface.cpp 2008-04-25 00:44:04 UTC (rev 3148) @@ -40,6 +40,7 @@ hr = comcall; \ if (hr != S_OK) { \ cerr << "ERROR at " << __FILE__ << ", " << __LINE__ << ":" << endl; \ + cerr << "HR = " << hr << endl; \ cerr << errMsg << endl; \ action; \ } \ @@ -169,24 +170,25 @@ try { //IMsdrDataReaderPtr pMSDataReader; - hr = CoCreateInstance( + COMCHECK(CoCreateInstance( MH::CLSID_MassSpecDataReader, NULL, CLSCTX_INPROC_SERVER , MH::IID_IMsdrDataReader, - (void**)&pMSDataReader_); - if (hr != S_OK) { - cerr << "ERROR - CoCreateInstance failed." << endl; - return false; - } + (void**)&pMSDataReader_), + "ERROR - CoCreateInstance failed.", + return false); VARIANT_BOOL pRetVal = VARIANT_TRUE; CComBSTR fileName(inputFileName_.c_str()); - hr = pMSDataReader_->OpenDataFile( - fileName, - &pRetVal); + COMCHECK(pMSDataReader_->OpenDataFile( + fileName, + &pRetVal), + "OpenDataFile", + return false); //SysFreeString(fileName); - if (FAILED(hr) || pRetVal == VARIANT_FALSE) { + // also check return value + if (pRetVal == VARIANT_FALSE) { cerr << "Failed to open data folder" << endl; return false; } @@ -196,11 +198,10 @@ // get scan file information MH::BDA::IBDAFileInformationPtr pFileInfo; - hr = pMSDataReader_->get_FileInformation(&pFileInfo); - if (hr != S_OK) { - cerr << "ERROR at " << __FILE__ << ", " << __LINE__ << endl; - return false; - } + COMCHECK(pMSDataReader_->get_FileInformation(&pFileInfo), + "error getting file information", + return false); + DATE date; pFileInfo->get_AcquisitionTime(&date); COleDateTime dateTime(date); @@ -218,19 +219,15 @@ // Get MS scan file information MH::BDA::IBDAMSScanFileInformationPtr pScanInfo; - hr = pMSDataReader_->get_MSScanFileInformation(&pScanInfo); - if (hr != S_OK) { - cerr << "ERROR at " << __FILE__ << ", " << __LINE__ << endl; - return false; - } + COMCHECK(pMSDataReader_->get_MSScanFileInformation(&pScanInfo), + "get_MSScanFileInformation", + return false); // get total number of scans __int64 totalNumScans = 0; - hr = pScanInfo->get_TotalScansPresent(&totalNumScans); - if (hr != S_OK) { - cerr << "ERROR at " << __FILE__ << ", " << __LINE__ << endl; - return false; - } + COMCHECK(pScanInfo->get_TotalScansPresent(&totalNumScans), + "get_TotalScansPresent", + return false); totalNumScans_ = (long)totalNumScans; if (verbose_) { @@ -241,7 +238,7 @@ // dual-mode detection VARIANT_BOOL bDualMode = VARIANT_FALSE; COMCHECK(pScanInfo->IsMultipleSpectraPerScanPresent(&bDualMode), - cerr << "error checking if dual-mode" << endl, + "error in checking if file is dual-mode", return false); if (bDualMode == VARIANT_FALSE) { cout << "single mode file" << endl; @@ -252,7 +249,7 @@ // specifically record and detect if peak and/or profile data is present MH::MSStorageMode storageMode; COMCHECK(pScanInfo->get_SpectraFormat(&storageMode), - cerr << "get SpectraFormat error" << endl, + "get SpectraFormat error", return false); // TODO: record this info in mzXML header; @@ -301,11 +298,10 @@ // Get analyzer type MH::DeviceType devType; - hr = pScanInfo->get_DeviceType(&devType); - if (hr != S_OK) { - cerr << "ERROR at " << __FILE__ << ", " << __LINE__ << endl; - return false; - } + COMCHECK(pScanInfo->get_DeviceType(&devType), + "get_DeviceType", + return false); + if (verbose_) { cout << "Device Type: " << devType << endl; } @@ -331,11 +327,9 @@ // now that we have the device type, we can get the device name BSTR tempBstr=NULL; - hr=pFileInfo->GetDeviceName(devType, &tempBstr); - if (hr != S_OK) { - cerr << "ERROR at " << __FILE__ << ", " << __LINE__ << endl; - return false; - } + COMCHECK(pFileInfo->GetDeviceName(devType, &tempBstr), + "GetDeviceName", + return false); string modelName = convertBstrToString(tempBstr); // TODO: waiting for Agilent instrument types in order to fill in MSTypes corrects instrumentInfo_.instrumentModel_ = AGILENT_TOF; @@ -347,11 +341,10 @@ // get ionization mode MH::IonizationMode ionMode; - hr = pScanInfo->get_IonModes(&ionMode); - if (hr != S_OK) { - cerr << "ERROR at " << __FILE__ << ", " << __LINE__ << endl; - return false; - } + COMCHECK(pScanInfo->get_IonModes(&ionMode), + "get_IonModes", + return false); + // TODO: check with Agilent if correct MSIonizationType ionization; switch (ionMode) { @@ -418,7 +411,7 @@ CLSCTX_INPROC_SERVER , MH::BDA::IID_IBDAChromFilter, (void**)&pChromFilter), - cerr << "couldn't create chromfilter" << endl, + "couldn't create chromfilter", return (false) ); @@ -436,18 +429,16 @@ // extract the chromdata obj from the safearray-- I'm expecting only one COMCHECK(pMSDataReader_->GetChromatogram(pChromFilter, &pSafeArrayChromData_), - cerr << "Error getting TIC" << endl, + "Error getting TIC", return (false)); // check to make sure that exactly one TIC was returned from the call long numTIC = 0; - hr = SafeArrayGetUBound(pSafeArrayChromData_, 1, &numTIC); - if( S_OK != hr ) - { - cerr <<"ERROR - SafeArrayGetUBound failed " << hr << endl; - return false; - } + COMCHECK(SafeArrayGetUBound(pSafeArrayChromData_, 1, &numTIC), + "SafeArrayGetUBound failed.", + return false); + // TODO: check ubonds result for 0 entries if (numTIC < 0) { cerr << "ERROR: no TICs found" << endl; @@ -470,11 +461,10 @@ long dataPoints = 0; - hr = pChromData_->get_TotalDataPoints(&dataPoints); - if ( S_OK != hr ) { - cerr << "Error getting total data points from TIC." << endl; - return false; - } + COMCHECK(pChromData_->get_TotalDataPoints(&dataPoints), + "Error getting total data points from TIC.", + return false); + int numMSspectra = dataPoints; if (numMSspectra != totalNumScans_) { @@ -483,11 +473,9 @@ } // xArray is double[] - hr = pChromData_->get_xArray(&pSafeArrayRetentionTimes_); - if ( S_OK != hr ) { - cerr << "Error getting XArray of TIC." << endl; - return false; - } + COMCHECK(pChromData_->get_xArray(&pSafeArrayRetentionTimes_), + "Error getting XArray of TIC.", + return false); SafeArrayAccessData(pSafeArrayRetentionTimes_, reinterpret_cast<void**>(&retentionTimeArray_)); // pSafeArrayRetentionTimes_ is unaccessed in destructor // set start, end time from retention times @@ -495,27 +483,23 @@ endTimeInSec_ = retentionTimeArray_[totalNumScans_ - 1] * 60; // yArray is float[] - hr = pChromData_->get_yArray(&pSafeArrayTotalIonCurrents_); - if ( S_OK != hr ) { - cerr << "Error getting YArray of TIC." << endl; - return false; - } + COMCHECK(pChromData_->get_yArray(&pSafeArrayTotalIonCurrents_), + "Error getting YArray of TIC.", + return false); SafeArrayAccessData(pSafeArrayTotalIonCurrents_, reinterpret_cast<void**>(&totalIonCurrentArray_)); // pSafeArrayTotalIonCurrents_ is unaccessed in destructor // get base peak info //CComPtr<MH::BDA::IBDAChromData> pChromDataBasePeaks; - hr = pMSDataReader_->GetTIC(&pChromDataBasePeaks_); - if ( S_OK != hr ) { - cerr << "Error getting base peak chromatogram." << endl; - return false; - } + COMCHECK(pMSDataReader_->GetTIC(&pChromDataBasePeaks_), + "Error getting base peak chromatogram.", + return false); + // yArray is float[] - hr = pChromDataBasePeaks_->get_yArray(&pSafeArrayBasePeakIntensities_); - if ( S_OK != hr ) { - cerr << "Error getting YArray of TIC." << endl; - return false; - } + COMCHECK(pChromDataBasePeaks_->get_yArray(&pSafeArrayBasePeakIntensities_), + "Error getting YArray of TIC.", + return false); + SafeArrayAccessData(pSafeArrayBasePeakIntensities_, reinterpret_cast<void**>(&basePeakIntensityArray_)); // pSafeArrayBasePeakIntensities_ is unaccessed in destructor @@ -712,7 +696,7 @@ filter, filterOnCentroid, &pSpecData), - cerr << "error getting spectrum " << curScanNum_ << endl, + "error getting spectrum " << curScanNum_, return NULL); hr = pSpecData->ConvertDataToMassUnits(); if(S_OK != hr) @@ -726,7 +710,7 @@ // and record this info MH::MSStorageMode spectrumMode; // centroid or profile? COMCHECK(pSpecData->get_MSStorageMode(&spectrumMode), - cerr << "error getting spec. mode " << curScanNum_ << endl, + "error getting spec. mode " << curScanNum_, return NULL); // sanity check: if ((spectrumMode != MH::MSStorageMode_ProfileSpectrum) @@ -775,7 +759,7 @@ CLSCTX_INPROC_SERVER , MH::IID_IMsdrChargeStateAssignmentFilter, (void**)&pCsaFilter), - cerr << "CoCreateInstance for charge state assignment filter failed, hr = " << hr, + "CoCreateInstance for charge state assignment filter failed.", exit(1)); if (limitChargeState_) { @@ -798,7 +782,7 @@ } COMCHECK(pMSDataReader_->Deisotope(pSpecData, pCsaFilter), - cerr << "Error in deisotoping, hr = " << hr << endl, + "Error in deisotoping, hr = " << hr, exit(1)); } @@ -806,7 +790,7 @@ //get scan ID long scanID; COMCHECK(pSpecData->get_ScanId(&scanID), - cerr << "get ScanId error" << endl, + "get ScanId error", return(NULL)); nativeToSequentialScanNums_[scanID] = curScanNum_; curScan->nativeScanRef_.setCoordinateType(AGILENT); @@ -816,7 +800,7 @@ // get scan polarity MH::IonPolarity polarity; COMCHECK(pSpecData->get_IonPolarity(&polarity), - cerr << "ionpolarity error" << endl, + "ionpolarity error", return(NULL)); switch(polarity) { case MH::IonPolarity_Negative: @@ -905,7 +889,7 @@ VARIANT_BOOL chargeSuccess = VARIANT_TRUE; long charge = 0; COMCHECK(pSpecData->GetPrecursorCharge(&charge, &chargeSuccess), - cerr << "Error getting Precursor Charge for spectrum " << curScanNum_ << endl, + "Error getting Precursor Charge for spectrum " << curScanNum_, return(NULL)); if (chargeSuccess == VARIANT_TRUE ) { // record in our scan obj @@ -918,7 +902,7 @@ double intensity = 0; VARIANT_BOOL intSuccess = VARIANT_TRUE; COMCHECK(pSpecData ->GetPrecursorIntensity(&intensity, &intSuccess), - cerr << "error getting Precursor intensity for spectrum " << curScanNum_ << endl, + "error getting Precursor intensity for spectrum " << curScanNum_, return(NULL)); if (intSuccess == VARIANT_TRUE) { curScan->precursorIntensity_ = intensity; @@ -927,7 +911,7 @@ // parent scan ID long parentScanID; COMCHECK(pSpecData->get_ParentScanId(&parentScanID), - cerr << "get ParentScanId error" << endl, + "get ParentScanId error", return(NULL)); // TODO: error checking on map map<long,long>::iterator iter = nativeToSequentialScanNums_.find(parentScanID); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |