Ejemplo n.º 1
0
int CopyVolumeFile (const RGString& inputFileName, const RGString& outputFileName) {

	RGFile inputFile (inputFileName, "rt");

	if (!inputFile.isValid ()) {

		cout << "Could not read " << inputFileName.GetData () << " for default volume...exiting" << endl;
		return -1;
	}

	RGString inputFileString;
	inputFileString.ReadTextFile (inputFile);

	RGTextOutput outputFile (outputFileName, FALSE);

	if (!outputFile.FileIsValid ()) {

		cout << "Could not create " << outputFileName.GetData () << "...exiting" << endl;
		return -1;
	}

	outputFile << inputFileString;
	return 0;
}
Ejemplo n.º 2
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.º 3
0
int _tmain(int argc, _TCHAR* argv[])
{
  MEMDIFF(x);
	int nRtn = 1;
// 	char *ps = strdup("ABCDEFG - ignore this");
#ifdef _DEBUG
  if(!fsaFileInput::TESTMEMSTR())
  {
    cerr << "function fsaFileInput::MEMSTR() failed test." << endl;
  }
#endif
	if(argc < 3)
	{
		cerr << "Usage: " << argv[0] << " <infilename> <outfilename>" << endl;
		//Pause();
		return 1;
	}

	fsaFileInput fsa(argv[1],true);
//	fsaFileIO fsa ("E:/Users/goorrob/My Documents/ABI Info/DataFileConverter/20030707BCOF_B02_2002-011420_016.fsa");

	if(fsa.Error())
	{
		cerr << "Cannot open " << argv[1] << endl;
		Pause();
		return 2;
	}

	RGFile file (argv [2], "wt");
//	RGFile file ("E:/Users/goorrob/My Documents/ABI Info/DataFileConverter/Test.xml");

	if (!file.isValid ()) {

		cerr << "Output file name invalid" << endl;
		return 5;
	}
  if(fsa.Warning())
  {
    cerr << "File has problems, continuing" << endl;
  }

	fsa.WriteXML (file);
	file.Flush ();
	file.Close ();

	if (argc > 3) {

		RGFile notify (argv [3], "a+t");

		if (!notify.isValid ()) {

			cerr << "Cannot open " << argv [3] << " to notify about " << argv [2] << endl;
			return 6;
		}

		RGString Notification = "     <xml>Wrote         ";
		Notification += argv [2];
		Notification += "</xml>";
		Notification.WriteTextLine (notify);
		notify.Close ();
	}

	return 0;

}