Example #1
0
bool InterchannelLinkage :: RecalculatePrimarySignalSM (SmartNotice&  primaryTarget, SmartNotice&  primaryReplace) {

	// Add notice objects for test and replacement on removal

	if (mSecondarySignals.Entries () <= 1)
		return false;

	if (mPrimarySignal != NULL)
		return true;
	
	DataSignal* nextSignal;
	RGDListIterator it (mSecondarySignals);
	DataSignal* maxSignal = NULL;
	double maxPeak = 0.0;
	double thisPeak;

	while (nextSignal = (DataSignal*) it ()) {

		thisPeak = nextSignal->Peak ();

		if (thisPeak > maxPeak) {

			maxPeak = thisPeak;
			maxSignal = nextSignal;
		}
	}

	if (maxSignal == NULL)
		return false;

	mPrimarySignal = maxSignal;
	mPrimarySignal->SetMessageValue (primaryTarget, false);
	mPrimarySignal->SetMessageValue (primaryReplace, true);

	it.Reset ();
	mPrimarySignal->RemoveAllCrossChannelSignalLinks ();

	while (nextSignal = (DataSignal*) it ()) {

		if (nextSignal != mPrimarySignal) {

			nextSignal->SetPrimaryCrossChannelSignalLink (mPrimarySignal);
			mPrimarySignal->AddCrossChannelSignalLink (nextSignal);
		}
	}

	return true;
}
Example #2
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 << "&#10;";

			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 ();
}
Example #3
0
bool InterchannelLinkage :: RecalculatePrimarySignalBasedOnValiditySM () {

	// Add notice objects for test and replacement on removal

	//
	//  This is sample stage 1 and 3
	//

	smPrimaryInterchannelLink primaryLink;
	smNotInterchannelLink notInterchannelLink;

	if ((mPrimarySignal != NULL) && mPrimarySignal->cannotBePrimary ()) {

	//	mSecondarySignals.InsertWithNoReferenceDuplication (mPrimarySignal);
		mPrimarySignal->SetMessageValue (primaryLink, false);
		//mPrimarySignal->RemoveCrossChannelSignalLinkSM ();
		//mPrimarySignal->SetMessageValue (notInterchannelLink, true);
		mPrimarySignal = NULL;
	}

	if (mSecondarySignals.Entries () <= 1) {

		RemoveAllBasedOnValiditySM ();
		return true;
	}

	if (mPrimarySignal != NULL)
		return false;
	
	DataSignal* nextSignal;
	RGDListIterator it (mSecondarySignals);
	DataSignal* maxSignal = NULL;
	double maxPeak = 0.0;
	double thisPeak;

	while (nextSignal = (DataSignal*) it ()) {

		if (nextSignal->cannotBePrimary ())
			continue;

		thisPeak = nextSignal->Peak ();

		if (thisPeak > maxPeak) {

			maxPeak = thisPeak;
			maxSignal = nextSignal;
		}
	}

	if (maxSignal == NULL) {

		RemoveAllBasedOnValiditySM ();
		return true;
	}

	mPrimarySignal = maxSignal;
	mPrimarySignal->SetMessageValue (primaryLink, true);

	it.Reset ();
	mPrimarySignal->RemoveAllCrossChannelSignalLinksSM ();	//???????????????????????????????????????

	while (nextSignal = (DataSignal*) it ()) {

		if (nextSignal != mPrimarySignal) {

			nextSignal->SetPrimaryCrossChannelSignalLink (mPrimarySignal);
			nextSignal->AddCrossChannelSignalLink (nextSignal);
			nextSignal->SetMessageValue (primaryLink, false);
		}
	}

	return true;
}
Example #4
0
bool InterchannelLinkage :: RecalculatePrimarySignalSM () {

	// Add notice objects for test and replacement on removal

	//
	//  This is sample stage 1 and 3
	//

	smPrimaryInterchannelLink primaryLink;
	smPullUp pullup;

	if (mSecondarySignals.Entries () <= 1)
		return false;

	if (mPrimarySignal != NULL)
		return true;
	
	DataSignal* nextSignal;
	RGDListIterator it (mSecondarySignals);
	DataSignal* maxSignal = NULL;
	double maxPeak = 0.0;
	double thisPeak;

	while (nextSignal = (DataSignal*) it ()) {

		thisPeak = nextSignal->Peak ();

		if (thisPeak > maxPeak) {

			maxPeak = thisPeak;
			maxSignal = nextSignal;
		}
	}

	if (maxSignal == NULL)
		return false;

	mPrimarySignal = maxSignal;
	mPrimarySignal->SetMessageValue (primaryLink, true);
	mPrimarySignal->SetMessageValue (pullup, false);

	it.Reset ();
	mPrimarySignal->RemoveAllCrossChannelSignalLinksSM ();	//???????????????????????????????????????
	list<int> pChannels;
	double ratio;
	int nextChannel = mPrimarySignal->GetChannel ();

	while (nextSignal = (DataSignal*) it ()) {

		if (nextSignal != mPrimarySignal) {

			nextSignal->SetPrimaryCrossChannelSignalLink (mPrimarySignal);
			mPrimarySignal->AddCrossChannelSignalLink (nextSignal);
			nextSignal->SetMessageValue (primaryLink, false);
			nextSignal->SetMessageValue (pullup, true);
			ratio = 0.01 * floor (10000.0 * (nextSignal->Peak () / mPrimarySignal->Peak ()) + 0.5);
			nextSignal->AppendDataForSmartMessage (pullup, nextChannel);
			nextSignal->AppendDataForSmartMessage (pullup, ratio);
			pChannels.push_back (nextSignal->GetChannel ());
			//mPrimarySignal->AppendDataForSmartMessage (primaryLink, nextSignal->GetChannel ());
		}
	}

	pChannels.sort ();

	while (!pChannels.empty ()) {

		nextChannel = pChannels.front ();
		mPrimarySignal->AppendDataForSmartMessage (primaryLink, nextChannel);
		pChannels.pop_front ();
	}

	return true;
}
Example #5
0
Boolean STRBaseLocus :: ExtractGridSignals (RGDList& channelSignalList, const LaneStandard* ls, RGDList& locusDataSignalList, ChannelData* lsData, Locus* locus) {

    int lsSize = ls->GetNumberOfCharacteristics ();
    int i1;
    int i2;
    double c1;
    double c2;
    Notice* newNotice;

    if (lsSize < 0) {

        Msg << "Number of characteristics not available for Locus named " << LocusName << "\n";
        newNotice = new SetupErrorNumberPeaksUnavailableForLocus;
        locus->AddNoticeToList (newNotice);
        return FALSE;
    }

    if (LowerBoundGridLSBasePair < 0.0) {

        i1 = (int) floor (LowerBoundGridLSIndex);

        if (i1 < 0) {

            Msg << "Internal Lane Standard lower bound index for Grid is out of bounds for Locus named " << LocusName << "\n";
            return FALSE;
        }

        i2 = i1 + 1;
        c2 = LowerBoundGridLSIndex - i1;
        c1 = 1.0 - c2;
        MinimumGridTime = c1 * ls->GetLaneStandardTimeForCharacteristicNumber (i1) +
                          c2 * ls->GetLaneStandardTimeForCharacteristicNumber (i2);
//		cout << "Not using base pairs for minimum of locus " << LocusName << endl;
    }

    else
        MinimumGridTime = lsData->GetTimeForSpecifiedID (LowerBoundGridLSBasePair);

    if (UpperBoundGridLSBasePair < 0.0) {

        i1 = (int) floor (UpperBoundGridLSIndex);

        if (i1 < 0) {

            Msg << "Internal Lane Standard upper bound index for Grid is out of bounds for Locus named " << LocusName << "\n";
            return FALSE;
        }

        i2 = i1 + 1;
        c2 = UpperBoundGridLSIndex - i1;
        c1 = 1.0 - c2;
        MaximumGridTime = c1 * ls->GetLaneStandardTimeForCharacteristicNumber (i1) +
                          c2 * ls->GetLaneStandardTimeForCharacteristicNumber (i2);
//		cout << "Not using base pairs for maximum of locus " << LocusName << endl;
    }

    else
        MaximumGridTime = lsData->GetTimeForSpecifiedID (UpperBoundGridLSBasePair);

    RGDListIterator it (channelSignalList);
    DataSignal* nextSignal;
    double nextMean;
    locusDataSignalList.Clear ();

    // Assume channelSignalList is in increasing order by signal means

    while (nextSignal = (DataSignal*) it ()) {

        nextMean = nextSignal->GetMean ();

        if (nextMean >= MinimumGridTime) {

            if (nextMean <= MaximumGridTime) {

                it.RemoveCurrentItem ();
                locusDataSignalList.Append (nextSignal);
            }

            else
                break;
        }
    }

    if (locusDataSignalList.Entries () < mLocusSize) {

        Msg << "Locus named " << LocusName << " could not find the required number of unanalyzed peaks in range\n";
        newNotice = new LocusHasTooFewPeaks;
        locus->AddNoticeToList (newNotice);
        return FALSE;
    }

    return TRUE;
}
bool CoreBioComponent :: ReportXMLSmartNoticeObjects (RGTextOutput& text, RGTextOutput& tempText, const RGString& delim) {

	if (NumberOfSmartNoticeObjects () > 0) {

		int msgLevel = GetHighestMessageLevelWithRestrictionSM ();
		RGDListIterator it (*mSmartMessageReporters);
		SmartMessageReporter* nextNotice;
		text.SetOutputLevel (msgLevel);
		tempText.SetOutputLevel (1);
		int msgNum;
		int triggerLevel = Notice::GetMessageTrigger ();
		bool includesExportInfo = false;
		bool viable;

		while (nextNotice = (SmartMessageReporter*) it ()) {

			if (nextNotice->HasViableExportInfo ()) {

				includesExportInfo = true;
				break;
			}
		}

		if (!text.TestCurrentLevel () && !includesExportInfo) {

			text.ResetOutputLevel ();
			tempText.ResetOutputLevel ();
			return FALSE;
		}

		text.ResetOutputLevel ();
		text << CLevel (1) << "\t\t\t<SampleAlerts>\n" << PLevel ();
		it.Reset ();
		text.SetOutputLevel (1);

		while (nextNotice = (SmartMessageReporter*) it ()) {

			viable = nextNotice->HasViableExportInfo ();
			msgLevel = nextNotice->GetMessagePriority ();

			if (((msgLevel > 0) && (msgLevel <= triggerLevel)) || viable) {

				msgNum = Notice::GetNextMessageNumber ();
				nextNotice->SetMessageCount (msgNum);
				text << "\t\t\t\t<MessageNumber>" << msgNum << "</MessageNumber>\n";
				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 (viable) {

					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";
			}
		}

		text.ResetOutputLevel ();
		text << CLevel (1) << "\t\t\t</SampleAlerts>\n" << PLevel ();
		tempText.ResetOutputLevel ();
	}

	else
		return false;

	return true;
}
void RGHashTable :: ResizeTable (int size) {

	RGPersistent* next;
	unsigned hash;
	unsigned index;
	int i;
	if (NumberOfLists < size) {

		RGDList** NewArray = new RGDList* [size];

		for (i=0; i<size; i++) {

			if (i < NumberOfLists)
				NewArray [i] = ListArray [i];

			else
				NewArray [i] = new RGDList;
		}

		delete[] ListArray;
		ListArray = NewArray;

		for (i=0; i<NumberOfLists; i++) {

			if (ListArray [i]->Entries() > 0) {

				RGDListIterator* it = new RGDListIterator (*ListArray [i]);

				while (next = (*it)()) {

					hash = next->HashNumber (size);
					index = hash%size;

					if (index != i) {

						it->RemoveCurrentItem ();
						ListArray [index]->Insert (next);
					}
				}

				delete it;
			}
		}

		NumberOfLists = size;
	}

	else if ((NumberOfLists > size) && (size > 0)) {

		RGDList** NewArray = new RGDList* [size];

		for (int i=0; i<NumberOfLists; i++) {

			if (i < size)
				NewArray [i] = ListArray [i];

			if (ListArray [i]->Entries() > 0) {

				RGDListIterator* it = new RGDListIterator (*ListArray [i]);

				while (next = (*it)()) {

					hash = next->HashNumber (size);
					index = hash%size;

					if (index != i) {

						it->RemoveCurrentItem ();
						ListArray [index]->Insert (next);
					}
				}

				delete it;
			}

			if (i >= size)
				delete ListArray [i];
		}

		delete[] ListArray;
		ListArray = NewArray;
		NumberOfLists = size;
	}
}