Ejemplo n.º 1
0
void GenotypesForAMarkerSet :: WriteXML (RGTextOutput& text, const RGString& indent, const RGString& offLadderTag, const RGString& triallelesTag, const RGString& posTriTag) {

	RGDListIterator it (mGenotypes);
	IndividualGenotype* nextGenotype;

	Endl endLine;
	RGString indent2 = indent + "\t";
	text << indent << "<MarkerSetName>" << mMarkerSetName << "</MarkerSetName>" << endLine;
	text << indent << "<PositiveControls>" << endLine;

	while (nextGenotype = (IndividualGenotype*) it ())
		nextGenotype->WriteXML (text, indent2, "PositiveControl");

	text << indent << "</PositiveControls>" << endLine;

	text << indent << "<" << offLadderTag << ">" << endLine;
	mOffLadderAlleles->WriteXML (text, indent2);
	text << indent << "</" << offLadderTag << ">" << endLine;

	text << indent << "<" << triallelesTag << ">" << endLine;
	mSampleTriAlleles->WriteXML (text, indent2);
	text << indent << "</" << triallelesTag << ">" << endLine;

	text << indent << "<" << posTriTag << ">" << endLine;
	mControlTriAlleles->WriteXML (text, indent2);
	text << indent << "</" << posTriTag << ">" << endLine;
}
Ejemplo n.º 2
0
int CoreBioComponent :: TestPositiveControlSM (GenotypesForAMarkerSet* genotypes) {

	//
	//  This is sample stage 5
	//

	IndividualGenotype* genotype;
	smNamedPosCtrlNotFound posCtrlNotFound;
	int returnValue = 0;

	if (!mIsPositiveControl)
		return 0;

	genotype = genotypes->FindGenotypeForFileName (mControlIdName);

	if (genotype == NULL) {

		ParameterServer* pServer = new ParameterServer;
		mPositiveControlName = pServer->GetStandardPositiveControlName ();
		genotype = genotypes->FindGenotypeForFileName (mPositiveControlName);
		delete pServer;

		if (genotype == NULL) {
		
			SetMessageValue (posCtrlNotFound, true);

			if (mPositiveControlName.Length () > 0)
				AppendDataForSmartMessage (posCtrlNotFound, mPositiveControlName);

			return -1;
		}
	}

	else
		mPositiveControlName = genotype->GetName ();

	for (int i=1; i<=mNumberOfChannels; i++) {

		if (i != mLaneStandardChannel) {

			if (mDataChannels [i]->TestPositiveControlSM (genotype) < 0)
				returnValue = -1;
		}			
	}

	return returnValue;
}
Ejemplo n.º 3
0
IndividualGenotype* GenotypesForAMarkerSet :: FindGenotypeThatMatchesFileName (const RGString& fileName) {

	RGDListIterator it (mGenotypes);
	IndividualGenotype* genotype;
	RGString name;
	size_t position = 0;

	while (genotype = (IndividualGenotype*) it ()) {

		name = genotype->GetName ();

		if (fileName == name)
			return genotype;
	}

	return NULL;
}
Ejemplo n.º 4
0
IndividualGenotype* GenotypesForAMarkerSet :: FindGenotypeForFileName (const RGString& fileName) {

	RGDListIterator it (mGenotypes);
	IndividualGenotype* genotype;
	RGString name;
	size_t position = 0;

	while (genotype = (IndividualGenotype*) it ()) {

//		name = genotype->GetName ();
		name = genotype->GetFileNameSearchCriterion ();

		if (fileName.FindSubstringCaseIndependent (name, position))
			return genotype;
	}

	return NULL;
}
Ejemplo n.º 5
0
bool GenotypesForAMarkerSet :: AddCollectionToTables (const RGString& xmlString, const RGString& offLadderTag, const RGString& triallelesTag, const RGString& posTriTag) {

	RGString XMLString (xmlString);
	RGString positiveControlString;
	RGString pControlsString;
	RGString fullPathControlFileName = GenotypesForAMarkerSet::PathToStandardControlFile + "/LadderSpecifications/StandardPositiveControls.xml";

	RGFile* allPositiveControls = new RGFile (fullPathControlFileName, "rt");

	if (!allPositiveControls->isValid ()) {

		cout << "Could not find positive controls file:  " << (char*)fullPathControlFileName.GetData () << endl;
		return false;
	}

	RGString posXMLString;
	posXMLString.ReadTextFile (*allPositiveControls);
	delete allPositiveControls;

	RGXMLTagSearch nameSearch ("MarkerSetName", XMLString);
	RGXMLTagSearch positiveControlsSearch ("PositiveControls", posXMLString);
	RGXMLTagSearch oldPositiveControlsSearch ("PositiveControls", XMLString);
	RGXMLTagSearch posCtrlSearch ("PositiveControl", pControlsString);
	RGXMLTagSearch offLadderSearch (offLadderTag, XMLString);
	RGXMLTagSearch trialleleSearch (triallelesTag, XMLString);
	RGXMLTagSearch posTriSearch (posTriTag, XMLString);

	size_t startOffset = 0;
	size_t endOffset = 0;
	RGString collectionString;
	
	RGString offLadderString;
	RGString triString;
	RGString posTriString;
	size_t startPControls = 0;
	size_t endPControls = 0;
	bool returnValue = true;
	RGString markerSetName;
	IndividualGenotype* nextGenotype;

	if (!nameSearch.FindNextTag (startOffset, endOffset, markerSetName))
		return false;

	if (mMarkerSetName.Length () == 0)
		mMarkerSetName = markerSetName;

	else if (mMarkerSetName != markerSetName)
		return false;

	startOffset = endOffset;
	size_t startOffsetPos = 0;
	size_t endOffsetPos = 0;
	RGString temp;

	if (oldPositiveControlsSearch.FindNextTag (startOffset, endOffset, temp))
		startOffset = endOffset;

	if (positiveControlsSearch.FindNextTag (startOffsetPos, endOffsetPos, pControlsString)) {

		posCtrlSearch.ResetSearch ();
//		cout << "Found positive controls in file" << endl;

		while (posCtrlSearch.FindNextTag (startPControls, endPControls, positiveControlString)) {

//			cout << "Found positive control..." << endl;
			startPControls = endPControls;
			nextGenotype = new IndividualGenotype (positiveControlString);

			if (!nextGenotype->isValid ()) {

				returnValue = false;
				delete nextGenotype;
			}

			else {

				if (!mGenotypes.Contains (nextGenotype)) {
					mGenotypes.Insert (nextGenotype);
//					cout << "Inserted genotype in list..." << endl;
				}

				else {

					returnValue = false;
					delete nextGenotype;
				}
			}
		}
	}

	startOffset = endOffset;

	if (offLadderSearch.FindNextTag (startOffset, endOffset, offLadderString)) {

		if (mOffLadderAlleles == NULL) {

			mOffLadderAlleles = new LocusCollection (offLadderString);

			if (!mOffLadderAlleles->isValid ())
				returnValue = false;
		}

		else {

			if (!mOffLadderAlleles->AddLoci (offLadderString))
				returnValue = false;
		}
	}

	startOffset = endOffset;

	if (trialleleSearch.FindNextTag (startOffset, endOffset, triString)) {

		if (mSampleTriAlleles == NULL) {

			mSampleTriAlleles = new LocusCollection (triString);

			if (!mSampleTriAlleles->isValid ())
				returnValue = false;
		}

		else {

			if (!mSampleTriAlleles->AddLoci (triString))
				returnValue = false;
		}
	}

	startOffset = endOffset;

	if (posTriSearch.FindNextTag (startOffset, endOffset, posTriString)) {

		if (mControlTriAlleles == NULL) {

			mControlTriAlleles = new LocusCollection (posTriString);

			if (!mControlTriAlleles->isValid ())
				returnValue = false;
		}

		else {

			if (!mControlTriAlleles->AddLoci (posTriString))
				returnValue = false;
		}
	}

	return returnValue;
}
Ejemplo n.º 6
0
bool GenotypesForAMarkerSet :: AddCollectionToTablesFromLabSettings (const RGString& xmlString, const RGString& offLadderTag, const RGString& triallelesTag, const RGString& posTriTag) {

	RGString XMLString (xmlString);
	RGString positiveControlString;
	RGString pControlsString;

	RGXMLTagSearch nameSearch ("MarkerSetName", XMLString);
	RGXMLTagSearch positiveControlsSearch ("PositiveControls", XMLString);
	RGXMLTagSearch posCtrlSearch ("PositiveControl", pControlsString);
	RGXMLTagSearch offLadderSearch (offLadderTag, XMLString);
	RGXMLTagSearch trialleleSearch (triallelesTag, XMLString);
	RGXMLTagSearch posTriSearch (posTriTag, XMLString);

	size_t startOffset = 0;
	size_t endOffset = 0;
	RGString collectionString;
	
	RGString offLadderString;
	RGString triString;
	RGString posTriString;
	size_t startPControls = 0;
	size_t endPControls = 0;
	bool returnValue = true;
	RGString markerSetName;
	IndividualGenotype* nextGenotype;

	if (!nameSearch.FindNextTag (startOffset, endOffset, markerSetName))
		return false;

	if (mMarkerSetName.Length () == 0)
		mMarkerSetName = markerSetName;

	else if (mMarkerSetName != markerSetName)
		return false;

	startOffset = endOffset;

	if (positiveControlsSearch.FindNextTag (startOffset, endOffset, pControlsString)) {

		posCtrlSearch.ResetSearch ();
		startOffset = endOffset;
		cout << "Found positive controls in lab settings file" << endl;

		while (posCtrlSearch.FindNextTag (startPControls, endPControls, positiveControlString)) {

			cout << "Found positive control..." << endl;
			startPControls = endPControls;
			nextGenotype = new IndividualGenotype (positiveControlString);

			if (!nextGenotype->isValid ()) {

				returnValue = false;
				delete nextGenotype;
			}

			else {

				if (!mGenotypes.Contains (nextGenotype)) {
					mGenotypes.Insert (nextGenotype);
					cout << "Inserted genotype in list..." << endl;
				}

				else {

					//returnValue = false;
					cout << "\nWARNING***Found duplicate positive control named " << nextGenotype->GetName ().GetData () << ".  Ignoring...\n" << endl;
					delete nextGenotype;
				}
			}
		}
	}

	startOffset = endOffset;

	if (offLadderSearch.FindNextTag (startOffset, endOffset, offLadderString)) {

		if (mOffLadderAlleles == NULL) {

			mOffLadderAlleles = new LocusCollection (offLadderString);

			if (!mOffLadderAlleles->isValid ())
				returnValue = false;
		}

		else {

			if (!mOffLadderAlleles->AddLoci (offLadderString))
				returnValue = false;
		}
	}

	startOffset = endOffset;

	if (trialleleSearch.FindNextTag (startOffset, endOffset, triString)) {

		if (mSampleTriAlleles == NULL) {

			mSampleTriAlleles = new LocusCollection (triString);

			if (!mSampleTriAlleles->isValid ())
				returnValue = false;
		}

		else {

			if (!mSampleTriAlleles->AddLoci (triString))
				returnValue = false;
		}
	}

	startOffset = endOffset;

	if (posTriSearch.FindNextTag (startOffset, endOffset, posTriString)) {

		if (mControlTriAlleles == NULL) {

			mControlTriAlleles = new LocusCollection (posTriString);

			if (!mControlTriAlleles->isValid ())
				returnValue = false;
		}

		else {

			if (!mControlTriAlleles->AddLoci (posTriString))
				returnValue = false;
		}
	}

	return returnValue;
}