int Ladder :: MergeLocusIntoLadder (const Locus* locus) { // This combines info and then computes the rest Locus* matchingLocus = FindLocusByName (locus->GetName ()); if (matchingLocus == NULL) { cout << "Could not find locus matching name: " << locus->GetName ().GetData () << endl; return -1; } matchingLocus->SetFirstCoreLocusBP (locus->GetFirstCoreLocusBP ()); matchingLocus->SetFirstExtendedAllele (locus->GetFirstExtendedAllele ()); matchingLocus->SetLastExtendedAllele (locus->GetLastExtendedAllele ()); matchingLocus->ComputeAllBPs (); matchingLocus->SetMinMaxSearchILSBP (locus->GetMinSearchILSBP (), locus->GetMaxSearchILSBP ()); matchingLocus->AdjustSearchRegion (); matchingLocus->SetMerged (); return 0; }
Locus* Bins :: AssembleLocusFromLineStrings () { // uses current values in mLocusLineStrings Locus* newLocus = new Locus (); int nLines = mLocusLineStrings.Length (); SplitLocusLine (mLocusLineStrings [0]); // This should give us the name field RGString name = mLocusLineFieldString [1]; cout << "Locus name = " << name.GetData () << endl; //cout << "Bins locus line 1: "; int i; int len = mLocusLineFieldString.Length (); //for (i=0; i<len; i++) { // cout << mLocusLineFieldString [i].GetData (); // if (i < len - 1) // cout << ", "; //} //cout << endl; RGString firstAlleleName; int firstLocusBP; double firstILSBP; double lastILSBP; RGString firstExtendedAlleleName; RGString lastExtendedAlleleName; int lineForFirstAllele = 0; for (i=1; i<nLines; i++) { SplitLocusLine (mLocusLineStrings [i]); if (mLocusLineFieldString.Length () < 4) { cout << "Could not find first allele for locus " << name.GetData () << endl; delete newLocus; return NULL; } if (mLocusLineFieldString.Length () >= 5) { if (mLocusLineFieldString [4] == "virtual") { if (i == 1) { firstExtendedAlleleName = mLocusLineFieldString [0]; } continue; } } firstAlleleName = mLocusLineFieldString [0]; firstILSBP = mLocusLineFieldString [1].ConvertToDouble (); firstLocusBP = (int) floor (firstILSBP + 0.5); lineForFirstAllele = i; break; } if (firstExtendedAlleleName.Length () == 0) firstExtendedAlleleName = firstAlleleName; bool foundLastExtendedAllele = false; for (i=nLines-1; i>lineForFirstAllele; i--) { SplitLocusLine (mLocusLineStrings [i]); if (mLocusLineFieldString.Length () < 4) continue; if (!foundLastExtendedAllele) { lastExtendedAlleleName = mLocusLineFieldString [0]; foundLastExtendedAllele = true; } if ((mLocusLineFieldString.Length () >= 5) && (mLocusLineFieldString [4] == "virtual")) continue; lastILSBP = mLocusLineFieldString [1].ConvertToDouble (); break; } if (lastExtendedAlleleName.Length () == 0) { cout << "Could not locate last extended allele name for locus: " << name.GetData () << endl; delete newLocus; return NULL; } newLocus->SetFirstCoreAllele (firstAlleleName); newLocus->SetFirstExtendedAllele (firstExtendedAlleleName); newLocus->SetLastExtendedAllele (lastExtendedAlleleName); newLocus->SetMinMaxSearchILSBP (firstILSBP, lastILSBP); // These will have to be adjusted later when core repeat number is known newLocus->SetFirstCoreLocusBP (firstLocusBP); newLocus->SetName (name); // Need to add to Locus ability to compute first and last extended bp return newLocus; }