int CoreBioComponent :: AnalyzeGridSM (SampleData& fileData, GridDataStruct* gridData) { // // This is ladder stage 1 // Endl endLine; RGString Notice; smTestForColorCorrectionMatrixPreset testForColorCorrectionMatrixPreset; int status = InitializeSM (fileData, gridData->mCollection, gridData->mMarkerSetName, TRUE); if (status < 0) { Notice << "BioComponent could not initialize:"; cout << Notice << endl; gridData->mExcelText << CLevel (1) << Notice << "\n" << ErrorString << "Skipping...\n" << PLevel (); gridData->mText << Notice << "\n" << ErrorString << "Skipping\n"; return -1; } if (CoreBioComponent::UseRawData) { if (GetMessageValue (testForColorCorrectionMatrixPreset)) status = SetAllRawDataWithMatrixSM (fileData, gridData->mTestControlPeak, gridData->mTestControlPeak); else status = SetAllRawDataSM (fileData, gridData->mTestControlPeak, gridData->mTestControlPeak); } else status = SetAllDataSM (fileData, gridData->mTestControlPeak, gridData->mTestControlPeak); if (status < 0) { Notice << "BioComponent could not set data:"; cout << Notice << endl; gridData->mExcelText << CLevel (1) << Notice << "\n" << ErrorString << "Skipping...\n" << PLevel (); gridData->mText << Notice << "\n" << ErrorString << "Skipping...\n"; return -2; } if (CoreBioComponent::UseRawData) FindAndRemoveFixedOffsets (); status = AnalyzeGridSM (gridData->mText, gridData->mExcelText, gridData->mMsg); if (status < 0) { Notice << "BioComponent could not analyze grid. Skipping..."; cout << Notice << endl; Notice << "\n"; gridData->mExcelText.Write (1, Notice); gridData->mText << Notice; return -3; } return 0; }
void DataSignal :: WriteSmartTableArtifactInfoToXML (RGTextOutput& text, RGTextOutput& tempText, const RGString& indent, const RGString& bracketTag, const RGString& locationTag) { int peak; Endl endLine; RGString suffix; RGString label; SmartMessageReporter* notice; int i; RGString virtualAllele; SmartMessageReporter* nextNotice; text.SetOutputLevel (1); int msgNum; smAcceptedOLLeft acceptedOLLeft; smAcceptedOLRight acceptedOLRight; int reportedMessageLevel = GetHighestMessageLevelWithRestrictionSM (); //bool hasThreeLoci; //bool needLocus0; if ((!DontLook ()) && (NumberOfSmartNoticeObjects () != 0)) { bool firstNotice = true; peak = (int) floor (Peak () + 0.5); virtualAllele = GetVirtualAlleleName (); text << indent << "<" << bracketTag << ">" << endLine; // Should be <Artifact> text << indent << "\t<Id>" << GetSignalID () << "</Id>" << endLine; text << indent << "\t<Level>" << reportedMessageLevel << "</Level>" << endLine; text << indent << "\t<RFU>" << peak << "</RFU>" << endLine; text << indent << "\t<" << locationTag << ">" << GetApproximateBioID () << "</" << locationTag << ">" << endLine; text << indent << "\t<PeakArea>" << TheoreticalArea () << "</PeakArea>" << endLine; text << indent << "\t<Time>" << GetMean () << "</Time>" << endLine; text << indent << "\t<Fit>" << GetCurveFit () << "</Fit>" << endLine; if (!mAllowPeakEdit) text << indent << "\t<AllowPeakEdit>false</AllowPeakEdit>" << endLine; RGDListIterator it (*mSmartMessageReporters); i = 0; while (notice = (SmartMessageReporter*) it ()) { if (!notice->GetDisplayOsirisInfo ()) continue; if (firstNotice) { label = indent + "\t<Label>"; firstNotice = false; } if (i > 0) label << " "; label += notice->GetMessage (); label += notice->GetMessageData (); i++; } if (i > 0) { label << "</Label>"; text << label << endLine; } // Now add list of notices... it.Reset (); while (nextNotice = (SmartMessageReporter*) it ()) { msgNum = Notice::GetNextMessageNumber (); nextNotice->SetMessageCount (msgNum); text << indent << "\t<MessageNumber>" << msgNum << "</MessageNumber>" << endLine; tempText << "\t\t<Message>\n"; tempText << "\t\t\t<MessageNumber>" << msgNum << "</MessageNumber>\n"; tempText << "\t\t\t<Text>" << nextNotice->GetMessage () << nextNotice->GetMessageData () << "</Text>\n"; if (nextNotice->HasViableExportInfo ()) { if (nextNotice->IsEnabled ()) tempText << "\t\t\t<Hidden>false</Hidden>\n"; else tempText << "\t\t\t<Hidden>true</Hidden>\n"; if (!nextNotice->IsCritical ()) tempText << "\t\t\t<Critical>false</Critical>\n"; if (nextNotice->IsEnabled ()) tempText << "\t\t\t<Enabled>true</Enabled>\n"; else tempText << "\t\t\t<Enabled>false</Enabled>\n"; if (!nextNotice->IsEditable ()) tempText << "\t\t\t<Editable>false</Editable>\n"; if (nextNotice->GetDisplayExportInfo ()) tempText << "\t\t\t<DisplayExportInfo>true</DisplayExportInfo>\n"; else tempText << "\t\t\t<DisplayExportInfo>false</DisplayExportInfo>\n"; if (!nextNotice->GetDisplayOsirisInfo ()) tempText << "\t\t\t<DisplayOsirisInfo>false</DisplayOsirisInfo>\n"; tempText << "\t\t\t<MsgName>" << nextNotice->GetMessageName () << "</MsgName>\n"; //tempText << "\t\t\t<ExportProtocolList>"; //tempText << "\t\t\t" << nextNotice->GetExportProtocolInformation (); //tempText << "\t\t\t</ExportProtocolList>\n"; } tempText << "\t\t</Message>\n"; } // Now add list of alleles //hasThreeLoci = (mLocus != NULL) && (mLeftLocus != NULL) && (mRightLocus != NULL); //if (mLocus != NULL) { // if ((mLeftLocus == NULL) && (mRightLocus == NULL)) // needLocus0 = true; // else // needLocus0 = false; //} //else // needLocus0 = false; //needLocus0 = (!hasThreeLoci) && ((mLocus != mLeftLocus) || (mLocus != mRightLocus)); if (mLocus != NULL) { //testing RGString locusName = mLocus->GetLocusName (); suffix = GetAlleleName (0); if ((suffix.Length () > 0) || (virtualAllele.Length () > 0)) { text << indent << "\t<Allele>" << endLine; if (suffix.Length () > 0) text << indent << "\t\t<Name>" << suffix << "</Name>" << endLine; else text << indent << "\t\t<Name>" << virtualAllele << "</Name>" << endLine; if (mOffGrid) suffix = "true"; else if (mAcceptedOffGrid) suffix = "accepted"; else suffix = "false"; text << indent << "\t\t<OffLadder>" << suffix << "</OffLadder>" << endLine; text << indent << "\t\t<BPS>" << GetBioID (0) << "</BPS>" << endLine; text << indent << "\t\t<Locus>" << mLocus->GetLocusName () << "</Locus>" << endLine; text << indent << "\t\t<Location>0</Location>" << endLine; text << indent << "\t</Allele>" << endLine; } } if ((mLeftLocus != NULL) && (mLeftLocus != mLocus)) { if (mAlleleNameLeft.Length () > 0) { text << indent << "\t<Allele>" << endLine; text << indent << "\t\t<Name>" << mAlleleNameLeft << "</Name>" << endLine; if (mIsOffGridLeft) suffix = "true"; else if (GetMessageValue (acceptedOLLeft)) suffix = "accepted"; else suffix = "false"; text << indent << "\t\t<OffLadder>" << suffix << "</OffLadder>" << endLine; text << indent << "\t\t<BPS>" << GetBioID (-1) << "</BPS>" << endLine; text << indent << "\t\t<Locus>" << mLeftLocus->GetLocusName () << "</Locus>" << endLine; text << indent << "\t\t<Location>-1</Location>" << endLine; text << indent << "\t</Allele>" << endLine; } } if ((mRightLocus != NULL) && (mRightLocus != mLocus)) { if (mAlleleNameRight.Length () > 0) { text << indent << "\t<Allele>" << endLine; text << indent << "\t\t<Name>" << mAlleleNameRight << "</Name>" << endLine; if (mIsOffGridRight) suffix = "true"; else if (GetMessageValue (acceptedOLRight)) suffix = "accepted"; else suffix = "false"; text << indent << "\t\t<OffLadder>" << suffix << "</OffLadder>" << endLine; text << indent << "\t\t<BPS>" << GetBioID (1) << "</BPS>" << endLine; text << indent << "\t\t<Locus>" << mRightLocus->GetLocusName () << "</Locus>" << endLine; text << indent << "\t\t<Location>1</Location>" << endLine; text << indent << "\t</Allele>" << endLine; } } text << indent << "</" + bracketTag << ">" << endLine; } text.ResetOutputLevel (); }
bool CoreBioComponent :: GetIgnoreNoiseAboveDetectionInSmoothingFlag () const { smIgnoreNoiseAnalysisAboveDetectionThresholdInSmoothing ignore; return GetMessageValue (ignore); }
int CoreBioComponent :: PreliminarySampleAnalysisSM (RGDList& gridList, SampleDataStruct* sampleData) { // // This is sample stage 1 // smAssociatedLadderIsCritical associatedLadderIsCritical; // CoreBioComponent* grid = GetBestGridBasedOnTimeForAnalysis (gridList); const double* characteristicArray; mLSData->GetCharacteristicArray (characteristicArray); smUseMaxSecondDerivativesForSampleToLadderFit use2ndDeriv; bool useSecondDerivative = GetMessageValue (use2ndDeriv); CSplineTransform* timeMap; CoreBioComponent* grid; // CoreBioComponent* grid = GetBestGridBasedOnMaxDelta3DerivForAnalysis (gridList, timeMap); if (useSecondDerivative) { cout << "Using 2nd derivative criterion for ladder fit..." << endl; grid = GetBestGridBasedOnMax2DerivForAnalysis (gridList, timeMap); } else { cout << "Using minimum error criterion for ladder fit..." << endl; grid = GetBestGridBasedOnLeastTransformError (gridList, timeMap, characteristicArray); } if (grid == NULL) return -1; // // Get other fit data from timeMap // timeMap->OutputHighDerivativesAndErrors (characteristicArray); //smTempUseNaturalCubicSplineForTimeTransform useNaturalCubicSpline; //smTempUseChordalDerivApproxHermiteSplinesForTimeTransform useChordalDerivsForHermiteSpline; //bool useHermite = !GetMessageValue (useNaturalCubicSpline); //bool useChords = GetMessageValue (useChordalDerivsForHermiteSpline); bool useHermite = !UseNaturalCubicSplineTimeTransform; bool useChords = false; int gridArtifactLevel = grid->GetHighestMessageLevelWithRestrictionSM (); if ((gridArtifactLevel > 0) && (gridArtifactLevel <= Notice::GetSeverityTrigger ())) SetMessageValue (associatedLadderIsCritical, true); // CSplineTransform* timeMap = TimeTransform (*this, *grid); CSplineTransform* InverseTimeMap = TimeTransform (*grid, *this, useHermite, useChords); // Could augment calling sequence to use Hermite Cubic Spline transform 04/10/2014 if (InverseTimeMap != NULL) { mAssociatedGrid = grid->CreateNewTransformedBioComponent (*grid, InverseTimeMap); // if (!ComputeExtendedLocusTimes (grid, InverseTimeMap)) // cout << "Could not compute extended locus times..." << endl; delete InverseTimeMap; } Endl endLine; RGString Notice; Notice << "ANALYSIS WILL USE GRID NAMED " << grid->GetSampleName () << "\n"; sampleData->mExcelText.Write (1, Notice); RemoveAllSignalsOutsideLaneStandardSM (); // ValidateAndCorrectCrossChannelAnalysesSM (); int status = AssignSampleCharacteristicsToLociSM (grid, timeMap); delete timeMap; // Added 09/26/2014 to prevent memory leak return status; }
int CoreBioComponent :: PrepareSampleForAnalysisSM (SampleData& fileData, SampleDataStruct* sampleData) { // // This is sample stage 1 // Endl endLine; smTestForColorCorrectionMatrixPreset testForColorCorrectionMatrixPreset; RGString notice; notice << "Analyzing sample named " << GetSampleName () << "\n"; sampleData->mExcelText.Write (1, notice); sampleData->mText << notice; notice = ""; // Notice* newNotice; // BlobFound newNotice; smILSFailed ilsRequiresReview; smNormalizeRawDataRelativeToBaselinePreset normalizeRawData; smEnableRawDataFilterForNormalizationPreset enableFilteringForNormalization; Progress = 0; int j; int status = InitializeSM (fileData, sampleData->mCollection, sampleData->mMarkerSetName, FALSE); if (status < 0) { notice << "BIOCOMPONENT COULD NOT INITIALIZE:"; cout << notice << endl; sampleData->mExcelText.Write (1, notice); sampleData->mExcelText << CLevel (1) << notice << "\n" << ErrorString << "Skipping...\n" << PLevel (); sampleData->mText << notice << "\n" << ErrorString << "Skipping...\n"; return -1; } Progress = 1; if (CoreBioComponent::UseRawData) { if (GetMessageValue (testForColorCorrectionMatrixPreset)) status = SetAllRawDataWithMatrixSM (fileData, sampleData->mTestControlPeak, sampleData->mTestSamplePeak); else status = SetAllRawDataSM (fileData, sampleData->mTestControlPeak, sampleData->mTestSamplePeak); } else status = SetAllDataSM (fileData, sampleData->mTestControlPeak, sampleData->mTestSamplePeak); if (status < 0) { notice << "BIOCOMPONENT COULD NOT SET DATA:"; cout << notice << endl; sampleData->mExcelText << CLevel (1) << notice << "\n" << ErrorString << "Skipping...\n" << PLevel (); sampleData->mText << notice << "\n" << ErrorString << "Skipping...\n"; return -2; } CoreBioComponent::InitializeOffScaleData (fileData); Progress = 2; if (CoreBioComponent::UseRawData) { status = FindAndRemoveFixedOffsets (); if (status < 0) { notice << "BIOCOMPONENT COULD NOT COMPUTE OFFSETS ACCURATELY. Skipping..."; cout << notice << endl; sampleData->mExcelText.Write (1, notice); sampleData->mText << notice << "\n" << ErrorString << " Skipping...\n"; return -5; } } if (GetMessageValue (enableFilteringForNormalization)) ChannelData::SetUseNormalizationFilter (true); else ChannelData::SetUseNormalizationFilter (false); if (GetMessageValue (normalizeRawData) && GetMessageValue (enableFilteringForNormalization)) CreateAndSubstituteFilteredDataSignalForRawDataNonILS (); // status = FitAllCharacteristicsSM (sampleData->mText, sampleData->mExcelText, sampleData->mMsg, FALSE); // ->FALSE status = FitAllSampleCharacteristicsSM (sampleData->mText, sampleData->mExcelText, sampleData->mMsg, FALSE); // ->FALSE if (status < 0) { notice << "BIOCOMPONENT COULD NOT FIT ALL CHARACTERISTICS. Skipping..."; cout << notice << endl; sampleData->mExcelText.Write (1, notice); sampleData->mText << notice << "\n" << ErrorString << "Skipping...\n"; return -3; } Progress = 3; // mLSData->ClearAllPeaksBelowAnalysisThreshold (); if (!GetMessageValue (normalizeRawData)) { //AnalyzeCrossChannelSM (); // Moved below - 07/31/2013 //status = AnalyzeLaneStandardChannelSM (sampleData->mText, sampleData->mExcelText, sampleData->mMsg, sampleData->mPrint); //if (status < 0) { // notice << "BIOCOMPONENT COULD NOT ANALYZE INTERNAL LANE STANDARD. Skipping..."; // cout << notice << endl; // sampleData->mExcelText << CLevel (1) << notice << "\n" << ErrorString << "Skipping...\n" << PLevel (); // sampleData->mText << notice << "\n" << ErrorString << "Skipping...\n"; // SetMessageValue (ilsRequiresReview, true); // return -4; //} status = 0; for (j=1; j<=mNumberOfChannels; j++) { if (mDataChannels [j]->SetAllApproximateIDs (mLSData) < 0) status = -1; } if (status < 0) { notice << "BIOCOMPONENT COULD NOT UTILIZE INTERNAL LANE STANDARD. Skipping..."; cout << notice << endl; SetMessageValue (ilsRequiresReview, true); notice = "Could not create ILS time to base pairs transform"; SetDataForSmartMessage (ilsRequiresReview, notice); return -5; } //AnalyzeCrossChannelSM (); // Moved here 07/31/2013...happy birthday, Mom. You'd be 99 today. AnalyzeCrossChannelWithNegativePeaksSM (); // TestSignalsForLaserOffScaleSM (); // Moved inside AnalyzeCrossChannelWithNegativePeaksSM 09/09/2014 cout << "Analyzed cross channel links with negative peaks" << endl; Progress = 4; return 0; } // // In this branch, we normalize the raw data with respect to the dynamic baseline. First, analyze the lane standard, then find // the baseline and subtract it from the raw data. Finally, refit all non-lane standard channels and continue as before. // /*status = AnalyzeLaneStandardChannelSM (sampleData->mText, sampleData->mExcelText, sampleData->mMsg, sampleData->mPrint); if (status < 0) { notice << "BIOCOMPONENT COULD NOT ANALYZE INTERNAL LANE STANDARD. Skipping..."; cout << notice << endl; sampleData->mExcelText << CLevel (1) << notice << "\n" << ErrorString << "Skipping...\n" << PLevel (); sampleData->mText << notice << "\n" << ErrorString << "Skipping...\n"; SetMessageValue (ilsRequiresReview, true); return -4; }*/ status = 0; for (j=1; j<=mNumberOfChannels; j++) { if (mDataChannels [j]->SetAllApproximateIDs (mLSData) < 0) status = -1; } if (NormalizeBaselineForNonILSChannelsSM () < 0) { notice << "BIOCOMPONENT COULD NOT ANALYZE BASELINE. OMITTING BASELINE ANALYSIS..."; cout << notice << endl; status = -1; } //RestoreRawDataAndDeleteFilteredSignalNonILS (); // 02/02/2014: This is now done at the channel level within normalization function. status = FitNonLaneStandardCharacteristicsSM (sampleData->mText, sampleData->mExcelText, sampleData->mMsg, FALSE); // ->FALSE FitNonLaneStandardNegativeCharacteristicsSM (sampleData->mText, sampleData->mExcelText, sampleData->mMsg, FALSE); if (status < 0) { notice << "BIOCOMPONENT COULD NOT FIT ALL NON ILS CHARACTERISTICS. Skipping..."; cout << notice << endl; sampleData->mExcelText.Write (1, notice); sampleData->mText << notice << "\n" << ErrorString << "Skipping...\n"; return -3; } for (j=1; j<=mNumberOfChannels; j++) { if (mDataChannels [j]->SetAllApproximateIDs (mLSData) < 0) status = -1; } if (status < 0) { notice << "BIOCOMPONENT COULD NOT UTILIZE INTERNAL LANE STANDARD. Skipping..."; cout << notice << endl; SetMessageValue (ilsRequiresReview, true); notice = "Could not create ILS time to base pairs transform"; SetDataForSmartMessage (ilsRequiresReview, notice); return -5; } //AnalyzeCrossChannelSM (); AnalyzeCrossChannelWithNegativePeaksSM (); // TestSignalsForLaserOffScaleSM (); // Moved inside AnalyzeCrossChannelWithNegativePeaksSM 09/09/2014 Progress = 4; return 0; }