LocusData :: LocusData (const RGString& locusName, const RGString& alleleString) : mLocusName (locusName) { RGStringArray alleles; RGStringArray delimiters; if (alleleString.Length () == 0) return; RGString alleleStr = alleleString; RGStringTokenizer alleleJoin (alleleStr); alleleJoin.AddDelimiter (","); alleleJoin.Split (alleles, delimiters); int n = alleles.Length (); if (n == 0) return; int i; RGString* newAllele; cout << "Locus Name = " << (char*)mLocusName.GetData () << " with allele(s) "; for (i=0; i<n; i++) { newAllele = new RGString (alleles [i]); cout << (char*)newAllele->GetData () << " "; mAlleleList.append (newAllele); } cout << endl; }
void Ladder :: OutputTo (RGTextOutput& xmlFile, LadderInputFile& inputFile) { RGString link ("http://www.w3.org/2001/XMLSchema-instance"); xmlFile << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; xmlFile << "<KitData xmlns:xsi=\"" << link.GetData () << "\" xsi:noNamespaceSchemaLocation=\"MarkerSet.xsd\">\n"; xmlFile << "\t<Version>2.0</Version>\n"; xmlFile << "\t<Kits>\n"; xmlFile << "\t\t<Set>\n"; xmlFile << "\t\t\t<Name>" << mMarkerSetName.GetData () << "</Name>\n"; xmlFile << "\t\t\t<NChannels>" << mNumberOfChannels << "</NChannels>\n"; xmlFile << "\t\t\t<LS>\n"; OutputILSListTo (xmlFile); xmlFile << "\t\t\t\t<ChannelNo>" << mChannelForILS << "</ChannelNo>\n"; xmlFile << "\t\t\t</LS>\n"; xmlFile << "\t\t\t<FileNameSuffix>" << mSuffix << "</FileNameSuffix>\n"; xmlFile << "\t\t\t<GenotypeSuffix>" << mSuffix << "</GenotypeSuffix>\n"; xmlFile << "\t\t\t<DirectorySearchString>" << mSuffix << "</DirectorySearchString>\n"; OutputChannelMapTo (xmlFile, inputFile); list <Locus*>::const_iterator locusIterator; Locus* nextLocus; for (locusIterator = mLocusList.begin(); locusIterator != mLocusList.end(); locusIterator++) { nextLocus = *locusIterator; nextLocus->OutputTo (xmlFile); } xmlFile << "\t\t</Set>\n"; xmlFile << "\t</Kits>\n"; xmlFile << "</KitData>"; }
void Ladder :: OutputILSListTo (RGTextOutput& xmlFile) { RGDListIterator it (mILSList); RGString* nextName; while (nextName = (RGString*) it ()) xmlFile << "\t\t\t\t<LSName>" << nextName->GetData () << "</LSName>\n"; }
STRAlleleName :: STRAlleleName (const RGString& name) { size_t position; RGString repeats; RGString variant; size_t len; if (name.FindNextSubstring (0, ".", position)) { repeats = name.ExtractSubstring (0, position - 1); mRepeats = repeats.ConvertToInteger (); len = name.Length () - 1; if (position <= len) { variant = name.ExtractSubstring (position + 1, len); mMicroVariant = variant.ConvertToInteger (); } else mMicroVariant = 0; } else { mRepeats = name.ConvertToInteger (); mMicroVariant = 0; } }
void IndividualGenotype :: WriteXML (RGTextOutput& text, const RGString& indent, const RGString& tag) { Endl endLine; RGString indent2 = indent + "\t"; RGString indent3 = indent2 + "\t"; text << indent.GetData () << "<" << tag << ">" << endLine; text << indent2 << "<Name>" << mName << "</Name>" << endLine; text << indent2 << "<Loci>" << endLine; mLoci->WriteXML (text, indent3); text << indent2 << "</Loci>" << endLine; text << indent.GetData () << "</" << tag << ">" << endLine; }
bool STRBaseLocus :: GetLadderSearchRegion (size_t& startIndex, RGString& input, const RGString& familyName) { RGBracketStringSearch searchRegionsSearch ("<SearchRegions>", "</SearchRegions>", input); RGString searchRegion; RGString searchDetails; RGBracketStringSearch individualRegionsSearch ("<Region>", "</Region>", searchRegion); RGBracketStringSearch familyNameSearch ("<ILSName>", "</ILSName>", searchDetails); RGBracketStringSearch minILSGridSearch ("<MinGrid>", "</MinGrid>", searchDetails); RGBracketStringSearch maxILSGridSearch ("<MaxGrid>", "</MaxGrid>", searchDetails); size_t start = startIndex; size_t end; size_t individualEnd; bool foundData = false; RGString searchName; RGString number; if (!searchRegionsSearch.FindNextBracketedString (start, end, searchRegion)) return false; startIndex = end; individualRegionsSearch.ResetSearch (); start = 0; while (individualRegionsSearch.FindNextBracketedString (start, end, searchDetails)) { familyNameSearch.ResetSearch (); if (!familyNameSearch.FindNextBracketedString (0, individualEnd, searchName)) return false; if (searchName == familyName) { minILSGridSearch.ResetSearch (); maxILSGridSearch.ResetSearch (); if (!minILSGridSearch.FindNextBracketedString (0, individualEnd, number)) return false; LowerBoundGridLSBasePair = number.ConvertToDouble (); if (!maxILSGridSearch.FindNextBracketedString (0, individualEnd, number)) return false; UpperBoundGridLSBasePair = number.ConvertToDouble (); return true; } start = end; } return false; }
RGString PackedTime :: GetStringTime () const { RGString temp; RGString Ans; temp.Convert (hour, 10); Ans = temp + ":"; temp.Convert (minute, 10); Ans += temp + ":"; temp.Convert (second, 10); Ans += temp + ":"; temp.Convert (hsecond, 10); Ans += temp; return Ans; }
bool DirectoryManager :: TestForExtension (const RGString& fileName) { RGString Extension; int length = fileName.Length (); // size_t position; // RGString localFileName (fileName); // localFileName.ToLower (); if (length > 4) Extension = fileName.ExtractSubstring (length-4, length-1); if ((length > 4) && (Extension == DirectoryManager::DataFileTypeWithDot)) return true; return false; }
Boolean DirectoryManager :: TestForPositiveControl (const RGString& fileName) { int length = (int)fileName.Length (); RGString Extension; Boolean FoundPosControl; Boolean FoundLadder; if (length > 4) Extension = fileName.ExtractSubstring (length-4, length-1); FoundPosControl = mPServer->PosControlDoesTargetStringContainASynonymCaseIndep (fileName); FoundLadder = mPServer->LadderDoesTargetStringContainASynonymCaseIndep (fileName); if ((length > 4) && (Extension == DirectoryManager::DataFileTypeWithDot) && FoundPosControl && !FoundLadder) //old = if ((length > 4) && (Extension == ".fsa") && FoundPosControl && !FoundLadder) return TRUE; return FALSE; }
STRBaseAllele :: STRBaseAllele (const RGString& xmlInput) : BaseAllele (xmlInput) { RGString Input (xmlInput); RGBracketStringSearch BPToken ("<BP>", "</BP>", Input); RGString bpString; size_t EndPosition; if (!BPToken.FindNextBracketedString (0, EndPosition, bpString)) { BP = -1; Valid = FALSE; Msg << "Allele invalid...could not find BP string for allele named " << AlleleName << "\n"; // cout << "Allele invalid...could not find BP string...name: " << AlleleName << endl; } else BP = bpString.ConvertToInteger (); }
Boolean RGDirectory :: FileIsDirectory (const RGString& Name) { unsigned long Attributes = GetFileAttributes (Name.GetData ()); if (Attributes & FILE_ATTRIBUTE_DIRECTORY) return TRUE; return FALSE; }
Boolean RGDirectory :: FileIsDirectory (const RGString& Name) { struct stat statbuf; lstat(Name.GetData (), &statbuf); if (S_ISDIR (statbuf.st_mode) == 0) return FALSE; return TRUE; }
bool SynonymList :: DoesTargetStringEqualASynonymCaseIndep (const RGString& target) { RGString lcTarget (target); lcTarget.ToLower (); mIt.Reset (); RGString test; RGString* nextString; while (nextString = (RGString*) mIt ()) { test = *nextString; test.ToLower (); if (lcTarget.IsEqualTo (&test)) return true; } return false; }
Boolean DirectoryManager :: TestForNonLadder (const RGString& fileName) { int length = (int)fileName.Length (); RGString Extension; Boolean FoundControl; // size_t position; // RGString localFileName (fileName); // localFileName.ToLower (); if (length > 4) Extension = fileName.ExtractSubstring (length-4, length-1); // FoundControl = localFileName.FindSubstring ("ladder", position); FoundControl = mPServer->LadderDoesTargetStringContainASynonymCaseIndep (fileName); if ((length > 4) && (Extension == DirectoryManager::DataFileTypeWithDot) && !FoundControl) //old = if ((length > 4) && (Extension == ".fsa") && !FoundControl) return TRUE; return FALSE; }
Boolean RGDirectory :: MoveDirectory (const RGString& oldName, const RGString& suffix, int MaxLevels) { int i = 0; RGString newName = oldName + suffix; while (i < MaxLevels) { if (!FileOrDirectoryExists (newName)) { // FinalName = newName; cout << "Attempting to move " << oldName.GetData () << " to " << newName.GetData () << endl; return MoveFile (oldName.GetData (), newName.GetData ()); } i++; newName += suffix; } return FALSE; }
RGString STRBaseLocus :: ReconstructAlleleName (int id, Allele* nearAllele) { int difference = id - nearAllele->GetBioID (); RGString nearName = nearAllele->GetAlleleName (); if (difference == 0) return nearName; int KK = CoreRepeatNumber; double nearDouble; int nearInt; int temp; RGString intString; RGString fractString; RGString returnValue; nearDouble = nearName.ConvertToDouble (); nearInt = nearName.ConvertToInteger (); temp = (int) floor (10 * (nearDouble - nearInt) + 0.5); // temp is fractional part...should be integer mod 4 if (difference > 0) { nearInt += (difference / KK); temp += difference%KK; nearInt += (temp / KK); temp = temp%KK; } else { difference = - difference; nearInt -= (difference / KK); temp -= difference%KK; if (temp < 0) { temp += KK; nearInt--; } } if (nearInt < 1) { returnValue = "$"; return returnValue; } intString.Convert (nearInt, 10); if (temp == 0) return intString; fractString.Convert (temp, 10); returnValue = intString + "." + fractString; return returnValue; }
LocusWithAlleles :: LocusWithAlleles (const RGString& inputLine) : RGPersistent (), mLineNumber (0), mMaxRFU (0) { RGStringArray tokens; RGStringArray delimiters; RGString locusString (inputLine); locusString.FindAndReplaceAllSubstrings ("\t\t", "\t"); RGStringTokenizer tokenizer (locusString); tokenizer.AddDelimiter ("\t"); tokenizer.Split (tokens, delimiters); int size = tokens.Length (); int rfu; double fit; double residual; LocusAllele* newAllele; int i; if (size >= 8) { for (i=0; i<8; i++) { if ((tokens [i].Length () == 0) || (tokens [i] == "\t")) return; } mLineNumber = tokens [0].ConvertToInteger (); mLocusName = tokens [1]; rfu = tokens [2].ConvertToInteger (); residual = tokens [3].ConvertToDouble (); fit = tokens [4].ConvertToDouble (); newAllele = new LocusAllele (rfu, residual, fit); InsertAllele (newAllele); rfu = tokens [5].ConvertToInteger (); residual = tokens [6].ConvertToDouble (); fit = tokens [7].ConvertToDouble (); newAllele = new LocusAllele (rfu, residual, fit); InsertAllele (newAllele); } }
bool SynonymList :: DoesTargetStringEqualASynonym (const RGString& target) { RGString* nextString; mIt.Reset (); while (nextString = (RGString*) mIt()) { if (target.IsEqualTo (nextString)) return true; } return false; }
RGString LocusData :: FormXMLString () { RGString Result; if (AlleleStringIsEmpty ()) return Result; RGTPtrDList<RGString> temp; RGString sixTabs = "\t\t\t\t\t\t"; RGString sevenTabs = "\t\t\t\t\t\t\t"; RGString eightTabs = "\t\t\t\t\t\t\t\t"; Result << sixTabs << "<Locus>\n"; Result << sevenTabs << "<Name>" << (char*)mLocusName.GetData () << "</Name>\n"; RGString* nextAllele; while (mAlleleList.entries () > 0) { nextAllele = mAlleleList.RemoveFirst (); nextAllele->FindAndReplaceAllSubstrings ("\"", ""); temp.append (nextAllele); Result << sevenTabs << "<Allele>\n"; Result << eightTabs << "<Name>" << (char*)nextAllele->GetData () << "</Name>\n"; Result << eightTabs << "<BioID>0</BioID>\n"; Result << sevenTabs << "</Allele>\n"; } Result << sixTabs << "</Locus>\n"; //cout << (char*) Result.GetData (); while (temp.entries () > 0) { nextAllele = temp.RemoveFirst (); mAlleleList.append (nextAllele); } return Result; }
int SmartNoticeWarehouse :: AddType (SmartNotice* NewType) { RGPersistent* test = ClassTypes->Append (NewType); int val; if (SmartNoticeWarehouse::DebugFlag) { RGString name (NewType->GetName ()); cout << "Adding class to notice list, Name = " << name.GetData () << endl; } if (test != NULL) { val = ClassTypes->Entries (); } else { val = 0; } return val; }
bool SynonymList :: DoesTargetStringContainASynonymCaseIndep (const RGString& target) { mIt.Reset (); RGString* nextString; size_t pos = 0; while (nextString = (RGString*) mIt ()) { if (target.FindSubstringCaseIndependent (*nextString, pos)) return true; } return false; }
RGDirectory :: RGDirectory (const RGString& fullName) : direct (NULL) { DWORD dwAttr; #ifdef FILENAME_MAX if (fullName.Length () > FILENAME_MAX) { cout << "Full path name too long: name = " << fullName.GetData () << endl; return; } #endif // Must be a valid name if( (fullName.Length () == 0) || (dwAttr = GetFileAttributes(fullName.GetData ())) == INVALID_FILE_ATTRIBUTES) { errno = ENOENT; } // Must be a directory else if (!(dwAttr & FILE_ATTRIBUTE_DIRECTORY)) { errno = ENOTDIR; } else { direct = new DIR; //(DIR*)malloc(sizeof(DIR)); if (direct == NULL) { errno = ENOMEM; } else { direct->hFind = findfile_directory (fullName.GetData (), &direct->find_data); if (direct->hFind == INVALID_HANDLE_VALUE) { //free(directory); delete direct; direct = NULL; } else { // Save the directory, in case of rewind. lstrcpyA(direct->directory, fullName.GetData ()); lstrcpyA(direct->dirent.d_name, direct->find_data.cFileName); } } } }
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; }
Boolean RGDirectory :: MakeDirectory (const RGString& fullName) { if (fullName.Length () == 0) return FALSE; // Must not already exist if (FileOrDirectoryExists (fullName)) { cout << "File or directory " << fullName << " already exists" << endl; return FALSE; } return CreateDirectory (fullName, NULL); }
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 (); }
void DataSignal :: WriteSmartArtifactInfoToXML (RGTextOutput& text, const RGString& indent, const RGString& bracketTag, const RGString& locationTag) { int peak; Endl endLine; RGString suffix; RGString label; SmartMessageReporter* notice; int i; RGString virtualAllele; int reportedMessageLevel; reportedMessageLevel = GetHighestMessageLevelWithRestrictionSM (); bool thisIsFirstNotice = true; if ((!DontLook ()) && (NumberOfSmartNoticeObjects () != 0)) { peak = (int) floor (Peak () + 0.5); if (mOffGrid) suffix = " OL"; virtualAllele = GetVirtualAlleleName (); RGDListIterator it (*mSmartMessageReporters); i = 0; while (notice = (SmartMessageReporter*) it ()) { if (!notice->GetDisplayOsirisInfo ()) continue; if (thisIsFirstNotice) { text << indent << "<" << bracketTag << ">" << endLine; text << indent << "\t<level>" << reportedMessageLevel << "</level>" << endLine; text << indent << "\t<mean>" << GetMean () << "</mean>" << endLine; text << indent << "\t<height>" << peak << "</height>" << endLine; // text << indent << "\t<" << locationTag << ">" << (int) floor (GetApproximateBioID () + 0.5) << "</" << locationTag << ">" << endLine; text << indent << "\t<" << locationTag << ">" << GetApproximateBioID () << "</" << locationTag << ">" << endLine; text << indent << "\t<PeakArea>" << TheoreticalArea () << "</PeakArea>" << endLine; if (virtualAllele.Length () > 0) text << indent << "\t<equivAllele>" << virtualAllele << suffix << "</equivAllele>" << endLine; text << indent << "\t<width>" << 4.0 * GetStandardDeviation () << "</width>" << endLine; text << indent << "\t<fit>" << GetCurveFit () << "</fit>" << endLine; label = indent + "\t<label>"; thisIsFirstNotice = false; } if (i > 0) label << " "; label += notice->GetMessage (); label += notice->GetMessageData (); i++; } RGString temp = GetVirtualAlleleName () + suffix; if (temp.Length () > 0) { if (i > 0) label << " "; label += "Allele " + temp; } if (i > 0) { label << "</label>"; text << label << endLine; text << indent << "</" + bracketTag << ">" << endLine; } /*if ((signalLink != NULL) && (!signalLink->xmlArtifactInfoWritten)) { signalLink->xmlArtifactInfoWritten = true; peak = signalLink->height; text << indent << "<" << bracketTag << ">" << endLine; text << indent << "\t<mean>" << signalLink->mean << "</mean>" << endLine; text << indent << "\t<height>" << peak << "</height>" << endLine; text << indent << "\t<" << locationTag << ">" << signalLink->bioID << "</" << locationTag << ">" << endLine; text << indent << "\t<fit>" << GetCurveFit () << "</fit>" << endLine; label = indent + "\t<label>"; mNoticeObjectIterator.Reset (); i = 0; while (notice = (Notice*) mNoticeObjectIterator ()) { if (i > 0) label << " "; label += notice->GetLabel (); i++; } if (temp.Length () > 0) { if (i > 0) label << " "; label += "Allele " + temp; } label << "</label>"; text << label << endLine; text << indent << "</" + bracketTag << ">" << endLine; }*/ } }
void CoreBioComponent :: ReportXMLSmartSampleTableRowWithLinks (RGTextOutput& text, RGTextOutput& tempText) { RGString type; if (mIsNegativeControl) type = "-Control"; else if (mIsPositiveControl) type = "+Control"; else type = "Sample"; RGString pResult; RGString SimpleFileName (mName); size_t startPos = 0; size_t endPos; size_t length = SimpleFileName.Length (); if (SimpleFileName.FindLastSubstringCaseIndependent (DirectoryManager::GetDataFileType (), startPos, endPos)) { if (endPos == length - 1) SimpleFileName.ExtractAndRemoveLastCharacters (4); } SimpleFileName.FindAndReplaceAllSubstrings ("\\", "/"); startPos = endPos = 0; if (SimpleFileName.FindLastSubstring ("/", startPos, endPos)) { SimpleFileName.ExtractAndRemoveSubstring (0, startPos); } text << CLevel (1) << "\t\t<Sample>\n"; text << "\t\t\t<Name>" << xmlwriter::EscAscii (SimpleFileName, &pResult) << "</Name>\n"; text << "\t\t\t<SampleName>" << xmlwriter::EscAscii (mSampleName, &pResult) << "</SampleName>\n"; text << "\t\t\t<RunStart>" << mRunStart.GetData () << "</RunStart>\n"; text << "\t\t\t<Type>" << type.GetData () << "</Type>\n" << PLevel (); int trigger = Notice::GetMessageTrigger (); // int channelHighestLevel; // bool channelAlerts = false; int cbcHighestMsgLevel = GetHighestMessageLevelWithRestrictionSM (); RGDListIterator it (*mSmartMessageReporters); SmartMessageReporter* nextNotice; bool includesExportInfo = false; while (nextNotice = (SmartMessageReporter*) it ()) { if (nextNotice->HasViableExportInfo ()) { includesExportInfo = true; break; } } if (((cbcHighestMsgLevel > 0) && (cbcHighestMsgLevel <= trigger)) || includesExportInfo) { // text << CLevel (1) << "\t\t\t<SampleAlerts>\n" << PLevel (); // get message numbers and report ReportXMLSmartNoticeObjects (text, tempText, " "); // text << CLevel (1) << "\t\t\t</SampleAlerts>\n" << PLevel (); } mDataChannels [mLaneStandardChannel]->ReportXMLILSSmartNoticeObjects (text, tempText, " "); int i; //for (i=1; i<=mNumberOfChannels; i++) { // //if (i == mLaneStandardChannel) // // continue; // channelHighestLevel = mDataChannels [i]->GetHighestMessageLevelWithRestrictionSM (); // if ((channelHighestLevel > 0) && (channelHighestLevel <= trigger)) { // channelAlerts = true; // break; // } //} // if (channelAlerts) { text << CLevel (1) << "\t\t\t<ChannelAlerts>\n" << PLevel (); for (i=1; i<=mNumberOfChannels; i++) { if (i == mLaneStandardChannel) continue; mDataChannels [i]->ReportXMLSmartNoticeObjects (text, tempText, " "); } text << CLevel (1) << "\t\t\t</ChannelAlerts>\n" << PLevel (); // } mMarkerSet->ResetLocusList (); Locus* nextLocus; while (nextLocus = mMarkerSet->GetNextLocus ()) { nextLocus->ReportXMLSmartSampleTableRowWithLinks (text, tempText, " "); } if (mIsPositiveControl) text << CLevel (1) << "\t\t\t<PositiveControl>" << mPositiveControlName << "</PositiveControl>\n"; text << CLevel (1) << "\t\t</Sample>\n" << PLevel (); }
STRBaseLaneStandard :: STRBaseLaneStandard (const RGString& xmlString) : BaseLaneStandard (xmlString), mCharacteristicArray (NULL), mDifferenceArray (NULL), mUnnormalizedDifferenceArray(0), mNormsLeft (NULL), mNormsRight (NULL), mRelativeSizes (NULL), mSize (0), mDifferenceSize (0), mOmissionSize (0), mOmissionArray (NULL), mNumberOfLargePeaks (0), mLargeCharacteristicArray (NULL), mLargeDifferenceArray (NULL), mNumberOfLargeDifferences (0), mFirstIntervalFraction (-1.0), mSmallestIntervalFraction (-1.0), mMaxRelativeHeight (-1), mCorrelationAcceptanceThreshold (0.993), mCorrelationAutoAcceptanceThreshold (0.9975) // //, mLastHalfSize (0), mLastHalfCharacteristicArray (NULL), mLastHalfUnnormalizedDifferenceArray (NULL), //mLastHalfRelativeSizes (NULL), mLastHalfDifferenceSize (0), mLastHalfNormsLeft (NULL), mLastHalfNormsRight (NULL) { RGString TextInput (xmlString); RGBracketStringSearch CharacteristicsToken ("<Characteristics>", "</Characteristics>", TextInput); RGString CharacteristicsString; RGString HeightString; RGBracketStringSearch HeightToken ("<RelativeHeights>", "</RelativeHeights>", TextInput); RGBracketStringSearch OmissionSearch ("<Omissions>", "</Omissions>", TextInput); RGBracketStringSearch AcceptanceThresholdSearch ("<CorrelationAcceptanceThreshold>", "</CorrelationAcceptanceThreshold>", TextInput); RGBracketStringSearch AutoAcceptanceThresholdSearch ("<CorrelationAutoAcceptanceThreshold>", "</CorrelationAutoAcceptanceThreshold>", TextInput); RGString OmissionString; size_t endPosition; RGString token; RGString delim; RGString numberString; double minChar; double maxChar; RGDList tokens; double value; RGPDouble* valuePtr; double previous; double next; double cumulative; int i = 0; double temp; int k; int j; if (!CharacteristicsToken.FindNextBracketedString (0, endPosition, CharacteristicsString)) { Msg << "Internal Lane Standard named " << Name << " could not find Characteristics token from string\n"; Msg << TextInput << "\n"; Valid = FALSE; } else { RGStringTokenizer data (CharacteristicsString); data.AddDelimiter (' '); data.AddDelimiter (" "); data.AddDelimiter (" "); data.AddDelimiter (" "); data.AddDelimiter (" "); data.AddRemoveItem (','); data.AddDelimiter ('\t'); data.AddDelimiter ('\n'); while (data.NextToken (token, delim)) { if (token.Length () > 0) { value = token.ConvertToDouble (); valuePtr = new RGPDouble (value); if (tokens.Entries () == 0) { minChar = maxChar = value; tokens.Append (valuePtr); } else if (value < minChar) { minChar = value; tokens.Prepend (valuePtr); } else if (value > maxChar) { maxChar = value; tokens.Append (valuePtr); } else tokens.Insert (valuePtr); } } mSize = (int)tokens.Entries (); NCharacteristics = mSize; mCharacteristicArray = new double [mSize]; mDifferenceSize = mSize - 1; mDifferenceArray = new double [mDifferenceSize]; mUnnormalizedDifferenceArray = new double [mDifferenceSize]; mNormsLeft = new double [mDifferenceSize]; mNormsRight = new double [mDifferenceSize]; //mLastHalfSize = mSize / 2; //if (2 * mLastHalfSize < mSize) // mLastHalfSize += 1; //mLastHalfDifferenceSize = mLastHalfSize - 1; //mLastHalfCharacteristicArray = new double [mLastHalfSize]; //mLastHalfUnnormalizedDifferenceArray = new double [mLastHalfDifferenceSize]; //mLastHalfNormsLeft = new double [mLastHalfDifferenceSize]; //mLastHalfNormsRight = new double [mLastHalfDifferenceSize]; while (valuePtr = (RGPDouble*)tokens.GetFirst ()) { mCharacteristicArray [i] = valuePtr->GetDouble (); delete valuePtr; i++; } //int displacement = mSize - mLastHalfSize; // +0, +1, -1????? //for (i=0; i<mLastHalfSize; i++) // mLastHalfCharacteristicArray [i] = mCharacteristicArray [i + displacement]; previous = mCharacteristicArray [0]; for (i=0; i<mDifferenceSize; i++) { next = mCharacteristicArray [i+1]; mUnnormalizedDifferenceArray [i] = mDifferenceArray [i] = next - previous; previous = next; } //for (i=0; i<mLastHalfSize; i++) // mLastHalfUnnormalizedDifferenceArray [i] = mUnnormalizedDifferenceArray [i + displacement]; double norm = 0.0; for (i=0; i<mDifferenceSize; i++) norm += mDifferenceArray [i] * mDifferenceArray [i]; norm = sqrt (norm); if (norm > 0.0) { for (i=0; i<mDifferenceSize; i++) mDifferenceArray [i] /= norm; } cumulative = 0.0; for (i=0; i<mDifferenceSize; i++) { temp = mUnnormalizedDifferenceArray [i]; cumulative += temp * temp; mNormsLeft [i] = cumulative; } cumulative = 0.0; for (i=mDifferenceSize-1; i>=0; i--) { temp = mUnnormalizedDifferenceArray [i]; cumulative += temp * temp; mNormsRight [i] = cumulative; } //cumulative = 0.0; //for (i=0; i<mLastHalfDifferenceSize; i++) { // temp = mLastHalfUnnormalizedDifferenceArray [i]; // cumulative += temp * temp; // mLastHalfNormsLeft [i] = cumulative; //} //cumulative = 0.0; //for (i=mLastHalfDifferenceSize-1; i>=0; i--) { // temp = mLastHalfUnnormalizedDifferenceArray [i]; // cumulative += temp * temp; // mLastHalfNormsRight [i] = cumulative; //} MaxCharacteristic = maxChar; MinCharacteristic = minChar; double width = mCharacteristicArray [mSize - 1] - mCharacteristicArray [0]; if (width > 0.0) mFirstIntervalFraction = mUnnormalizedDifferenceArray [0] / width; else mFirstIntervalFraction = 1.0; double temp = mUnnormalizedDifferenceArray [0]; double value; for (i=0; i<mDifferenceSize; i++) { value = mUnnormalizedDifferenceArray [i]; if (value < temp) temp = value; } if (width > 0.0) mSmallestIntervalFraction = temp / width; else mSmallestIntervalFraction = 1.0; if (!HeightToken.FindNextBracketedString (0, endPosition, HeightString)) { mRelativeSizes = NULL; // mLastHalfRelativeSizes = NULL; } else { RGStringTokenizer data2 (HeightString); data2.AddDelimiter (' '); data2.AddDelimiter (" "); data2.AddDelimiter (" "); data2.AddDelimiter (" "); data2.AddDelimiter (" "); data2.AddRemoveItem (','); data2.AddDelimiter ('\t'); data2.AddDelimiter ('\n'); mRelativeSizes = new int [mSize]; for (k=0; k<mSize; k++) mRelativeSizes [k] = -1; k = 0; while (data2.NextToken (token, delim)) { if (token.Length () > 0) { token.ToUpper (); char first = token.GetFirstCharacter (); switch (first) { case 'H': mRelativeSizes [k] = 5; break; case 'L': mRelativeSizes [k] = 1; break; case 'M': if (token.Length () == 1) mRelativeSizes [k] = 3; else if (token.GetLastCharacter () == 'H') mRelativeSizes [k] = 4; else mRelativeSizes [k] = 2; break; default: mRelativeSizes [k] = -1; } } k++; if (k >= mSize) break; } //mLastHalfRelativeSizes = new int [mLastHalfSize]; //for (i=0; i<mLastHalfSize; i++) // mLastHalfRelativeSizes [i] = mRelativeSizes [i + displacement]; int maxRelativeSize = 0; int relativeSize; for (j=0; j<mSize; j++) { relativeSize = mRelativeSizes [j]; if (relativeSize > maxRelativeSize) maxRelativeSize = relativeSize; } int numberOfHighsInILS = 0; mMaxRelativeHeight = maxRelativeSize; for (j=0; j<mSize; j++) { if (mRelativeSizes [j] == maxRelativeSize) numberOfHighsInILS++; } mNumberOfLargePeaks = numberOfHighsInILS; mNumberOfLargeDifferences = numberOfHighsInILS - 1; mLargeCharacteristicArray = new double [numberOfHighsInILS]; if (mNumberOfLargeDifferences > 0) mLargeDifferenceArray = new double [mNumberOfLargeDifferences]; k = 0; for (j=0; j<mSize; j++) { if (mRelativeSizes [j] == maxRelativeSize) { mLargeCharacteristicArray [k] = mCharacteristicArray [j]; k++; } } if (mLargeDifferenceArray != NULL) { for (j=0; j<mNumberOfLargeDifferences; j++) mLargeDifferenceArray [j] = mLargeCharacteristicArray [j + 1] - mLargeCharacteristicArray [j]; } } if (OmissionSearch.FindNextBracketedString (0, endPosition, OmissionString)) { RGStringTokenizer omissionData (OmissionString); omissionData.AddDelimiter (' '); omissionData.AddDelimiter (" "); omissionData.AddDelimiter (" "); omissionData.AddDelimiter (" "); omissionData.AddDelimiter (" "); omissionData.AddRemoveItem (','); omissionData.AddDelimiter ('\t'); omissionData.AddDelimiter ('\n'); while (omissionData.NextToken (token, delim)) { if (token.Length () > 0) { value = token.ConvertToDouble (); valuePtr = new RGPDouble (value); if (tokens.Entries () == 0) { minChar = maxChar = value; tokens.Append (valuePtr); } else if (value < minChar) { minChar = value; tokens.Prepend (valuePtr); } else if (value > maxChar) { maxChar = value; tokens.Append (valuePtr); } else tokens.Insert (valuePtr); } } mOmissionSize = (int)tokens.Entries (); if (mOmissionSize == 0) return; mOmissionArray = new double [mOmissionSize]; i = 0; while (valuePtr = (RGPDouble*)tokens.GetFirst ()) { mOmissionArray [i] = valuePtr->GetDouble (); delete valuePtr; i++; } } } cout << "ILS Name = " << Name.GetData () << endl; if (!AcceptanceThresholdSearch.FindNextBracketedString (0, endPosition, numberString)) cout << "\tCould not find ILS acceptance threshold...using " << mCorrelationAcceptanceThreshold << endl; else { mCorrelationAcceptanceThreshold = numberString.ConvertToDouble (); cout << "\tFrom ILS settings...ILS acceptance threshold = " << mCorrelationAcceptanceThreshold << endl; } if (!AutoAcceptanceThresholdSearch.FindNextBracketedString (0, endPosition, numberString)) cout << "\tCould not find ILS auto acceptance threshold...using default value = " << mCorrelationAutoAcceptanceThreshold << endl << endl; else { mCorrelationAutoAcceptanceThreshold = numberString.ConvertToDouble (); cout << "\tFrom ILS settings...ILS auto acceptance threshold = " << mCorrelationAutoAcceptanceThreshold << endl << endl; } }
int CoreBioComponent :: InitializeSM (SampleData& fileData, PopulationCollection* collection, const RGString& markerSetName, Boolean isGrid) { // // This is ladder and sample stage 1 // mTime = fileData.GetCollectionStartTime (); mDate = fileData.GetCollectionStartDate (); mName = fileData.GetName (); mRunStart = mDate.GetOARString () + mTime.GetOARString (); mMarkerSet = collection->GetNamedPopulationMarkerSet (markerSetName); Progress = 0; smMarkerSetNameUnknown noNamedMarkerSet; smNamedILSUnknown noNamedILS; smChannelIsILS channelIsILS; if (mMarkerSet == NULL) { ErrorString = "*******COULD NOT FIND MARKER SET NAMED "; ErrorString << markerSetName << " IN POPULATION COLLECTION********\n"; SetMessageValue (noNamedMarkerSet, true); AppendDataForSmartMessage (noNamedMarkerSet, markerSetName); return -1; } mLaneStandard = mMarkerSet->GetLaneStandard (); mNumberOfChannels = mMarkerSet->GetNumberOfChannels (); if ((mLaneStandard == NULL) || !mLaneStandard->IsValid ()) { ErrorString = "Could not find named internal lane standard associated with marker set named "; ErrorString << markerSetName << "\n"; cout << "Could not find named internal lane standard associated with marker set named " << (char*)markerSetName.GetData () << endl; SetMessageValue (noNamedILS, true); AppendDataForSmartMessage (noNamedILS, markerSetName); return -1; } mDataChannels = new ChannelData* [mNumberOfChannels + 1]; int i; const int* fsaChannelMap = mMarkerSet->GetChannelMap (); for (i=0; i<=mNumberOfChannels; i++) mDataChannels [i] = NULL; mLaneStandardChannel = mMarkerSet->GetLaneStandardChannel (); for (i=1; i<=mNumberOfChannels; i++) { if (i == mLaneStandardChannel) mDataChannels [i] = GetNewLaneStandardChannel (i, mLaneStandard); else { if (isGrid) mDataChannels [i] = GetNewGridDataChannel (i, mLaneStandard); else mDataChannels [i] = GetNewDataChannel (i, mLaneStandard); } mDataChannels [i]->SetFsaChannel (fsaChannelMap [i]); } mLSData = mDataChannels [mLaneStandardChannel]; mLSData->SetMessageValue (channelIsILS, true); mMarkerSet->ResetLocusList (); Locus* nextLocus; while (nextLocus = mMarkerSet->GetNextLocus ()) mDataChannels [nextLocus->GetLocusChannel ()]->AddLocus (nextLocus); Progress = 1; return 0; }
STRBaseLocus :: STRBaseLocus (const RGString& xmlInput) : BaseLocus (xmlInput), LowerBoundGridLSIndex (-1.0), UpperBoundGridLSIndex (-1.0), MinimumGridTime (-1.0), MaximumGridTime (-1.0), LowerBoundGridLSBasePair (-1.0), UpperBoundGridLSBasePair (-1.0), mNoExtension (false) { mSampleLocusSpecificStutterThreshold = Locus::GetSampleStutterThreshold (); mSampleLocusSpecificPlusStutterThreshold = Locus::GetSamplePlusStutterThreshold (); mSampleLocusSpecificAdenylationThreshold = Locus::GetSampleAdenylationThreshold (); mSampleLocusSpecificFractionalFilter = Locus::GetSampleFractionalFilter (); mSampleLocusSpecificPullupFractionalFilter = Locus::GetSamplePullupFractionalFilter (); mSampleLocusSpecificHeterozygousImbalanceThreshold = Locus::GetHeterozygousImbalanceLimit (); mSampleLocusSpecificMinBoundForHomozygote = Locus::GetMinBoundForHomozygote (); mLadderLocusSpecificStutterThreshold = Locus::GetGridStutterThreshold (); mLadderLocusSpecificAdenylationThreshold = Locus::GetGridAdenylationThreshold (); mLadderLocusSpecificFractionalFilter = Locus::GetGridFractionalFilter (); mLadderLocusSpecificPullupFractionalFilter = Locus::GetGridPullupFractionalFilter (); RGString Input (xmlInput); RGBracketStringSearch MinToken ("<MinBP>", "</MinBP>", Input); RGBracketStringSearch MaxToken ("<MaxBP>", "</MaxBP>", Input); RGBracketStringSearch LowerGridIndex ("<MinGridLSIndex>", "</MinGridLSIndex>", Input); RGBracketStringSearch UpperGridIndex ("<MaxGridLSIndex>", "</MaxGridLSIndex>", Input); RGBracketStringSearch CoreRepeatSearch ("<CoreRepeatNumber>", "</CoreRepeatNumber>", Input); RGBracketStringSearch LowerGridBasePair ("<MinGridLSBasePair>", "</MinGridLSBasePair>", Input); RGBracketStringSearch UpperGridBasePair ("<MaxGridLSBasePair>", "</MaxGridLSBasePair>", Input); RGBracketStringSearch NoExtensionSearch ("<NoExtension>", "</NoExtension>", Input); RGXMLTagSearch yLinkedSearch ("YLinked", Input); RGXMLTagSearch maxExpectedAllelesSearch ("MaxExpectedAlleles", Input); RGXMLTagSearch minExpectedAllelesSearch ("MinExpectedAlleles", Input); size_t EndPosition; RGString BPString; RGString extString; bool lowerBoundFound = false; bool upperBoundFound = false; RGString trueString ("true"); RGString familyName = BaseLocus::GetILSFamilyName (); // cout << "Current Family Name = " << familyName.GetData () << endl; // This was a test to make sure the family name is known at this point. Test succeeded 12/31/2015. bool useILSFamilies = PopulationCollection::UseILSFamiliesInLadderFile (); // if true, use families; otherwise, use the old way. bool isValid = true; size_t StartPosition = 0; if (NoExtensionSearch.FindNextBracketedString (0, EndPosition, extString)) { if (extString.FindNextSubstringCaseIndependent (0, trueString, EndPosition)) mNoExtension = true; else mNoExtension = false; } if (!MinToken.FindNextBracketedString (0, EndPosition, BPString)) { Valid = FALSE; Msg << "Locus named " << LocusName << " could not find Minimum Base Pair token\n"; MinimumBP = -1; } else MinimumBP = BPString.ConvertToInteger (); if (!MaxToken.FindNextBracketedString (0, EndPosition, BPString)) { Valid = FALSE; Msg << "Locus named " << LocusName << " could not find Maximum Base Pair token\n"; MaximumBP = -1; } else MaximumBP = BPString.ConvertToInteger (); if (LowerGridIndex.FindNextBracketedString (0, EndPosition, BPString)) { LowerBoundGridLSIndex = BPString.ConvertToDouble (); lowerBoundFound = true; } if (UpperGridIndex.FindNextBracketedString (0, EndPosition, BPString)) { UpperBoundGridLSIndex = BPString.ConvertToDouble (); upperBoundFound = true; } // test for ladder with ILS Family names here and, if found, use family name instead of the following four if's ******* if (useILSFamilies) { isValid = GetLadderSearchRegion (StartPosition, Input, familyName); if (!isValid) { Valid = FALSE; Msg << "Locus named " << LocusName << " could not find family-based search region\n"; } } else { if (LowerGridBasePair.FindNextBracketedString (0, EndPosition, BPString)) { LowerBoundGridLSBasePair = BPString.ConvertToDouble (); lowerBoundFound = true; } if (UpperGridBasePair.FindNextBracketedString (0, EndPosition, BPString)) { UpperBoundGridLSBasePair = BPString.ConvertToDouble (); upperBoundFound = true; } if (!lowerBoundFound) { Valid = FALSE; Msg << "Locus named " << LocusName << " could not find Minimum Grid Internal Lane Standard token, either index or base pair\n"; } if (!upperBoundFound) { Valid = FALSE; Msg << "Locus named " << LocusName << " could not find Maximum Grid Internal Lane Standard token, either index or base pair\n"; } } if (!CoreRepeatSearch.FindNextBracketedString (0, EndPosition, BPString)) CoreRepeatNumber = 4; else CoreRepeatNumber = BPString.ConvertToInteger (); if (!yLinkedSearch.FindNextTag (0, EndPosition, BPString)) mIsYLinked = false; else { if (BPString == "false") mIsYLinked = false; else mIsYLinked = true; } if (!maxExpectedAllelesSearch.FindNextTag (0, EndPosition, BPString)) mMaxExpectedAlleles = 2; else mMaxExpectedAlleles = BPString.ConvertToInteger (); if (!minExpectedAllelesSearch.FindNextTag (0, EndPosition, BPString)) mMinExpectedAlleles = 1; else mMinExpectedAlleles = BPString.ConvertToInteger (); if (!Valid) { Msg << "XML Input:\n" << Input << "\n"; } }