const wxArrayString &CVolumes::GetKits() const { if(m_asKits.IsEmpty()) { CPersistKitList *pKits = mainApp::GetKitList(); map<wxString,CVolume *>::const_iterator itr; for(itr = m_mapKitVolume.begin(); itr != m_mapKitVolume.end(); ++itr) { const wxString &sKit(itr->first); if(pKits->GetLsArray(sKit) != NULL) { m_asKits.Add(sKit); } else { wxString sError("Cannot find kit: "); sError.Append(sKit); sError.Append(" in ILSandLadderInfo.xml"); wxASSERT_MSG(0,sError); mainApp::LogMessage(sError); } } } return m_asKits; }
void CPersistKitList::UnitTest() { CPersistKitList kitList; wxString sError; if(!kitList.Load()) { wxString sError("CPersistKitList::Load() failed\n"); wxASSERT_MSG(0,sError); } #undef PP12 }
bool CGridLocusColumns::SetupKit( wxGrid *pGrid, const wxString &sKitName, const vector<wxString> &vs, bool bILS, bool bAllowAmel, bool bSetError, int *pnILScolumn, unsigned int *pnILSchannel) { wxString sProblem; CPersistKitList *pKit = mainApp::GetKitList(); const CLocusNameList *pLocus = pKit->GetLocusNameList(sKitName); if(sKitName.IsEmpty()) { sProblem = "Marker set name is not specified."; } else if(pLocus == NULL) { sProblem = "Marker set, "; sProblem.Append(sKitName); sProblem.Append(", is unknown"); } else if(pLocus->size() < 1) { sProblem = "Marker set, "; sProblem.Append(sKitName); sProblem.Append(", does not have any loci"); } if(!sProblem.IsEmpty()) { if(bSetError) { nwxGrid::SetError(pGrid,sProblem); } } else { vector<unsigned int> vnChannels; vector<int> vnCounts; set<unsigned int> snChannelsUsed; wxFont fnBold = pGrid->GetDefaultCellFont(); int nBeforeLoci = (int)vs.size(); int nCols = (int)(pLocus->size()) + nBeforeLoci + BINT(bILS); int nRemove = 0; int nCol; int nCount = 1; unsigned int nChannel; unsigned int nLastChannel = 0; // invalid channel name for default column unsigned int nILSchannel = 0; const CSingleKitColors *pKitColors; const CLocusNameChannel *plc; pKitColors = mainApp::GetKitColors()->GetKitColors(sKitName); pGrid->SetMargins(0, wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y) + 4); fnBold.SetWeight(wxFONTWEIGHT_BOLD); nwxGrid::SetColCount(pGrid,nCols); for(nCol = 0; nCol < nCols; nCol++) { pGrid->SetCellSize(0,nCol,1,1); //pGrid->SetReadOnly(0,0,true); } vector<wxString>::const_iterator itrs = vs.begin(); for(nCol = 0; nCol < nBeforeLoci; nCol++) { pGrid->SetCellBackgroundColour(0,nCol, pGrid->GetGridLineColour()); pGrid->SetCellValue(0,nCol,wxEmptyString); pGrid->SetColLabelValue(nCol, *itrs); //pGrid->SetReadOnly(0,nCol,true); ++itrs; } // nCol = nBeforeLoci; // redundant // Set up column labels vnCounts.reserve(CHANNEL_MAX); vnChannels.reserve(CHANNEL_MAX); for(CLocusNameList::const_iterator itr = pLocus->begin(); itr != pLocus->end(); ++itr) { plc = *itr; const wxString &sName(plc->GetName()); if(bAllowAmel || !CLabLocus::IsAmel(sName)) { nChannel = plc->GetChannel(); if(nChannel != nLastChannel) { if(nLastChannel > 0) { vnChannels.push_back(nLastChannel); vnCounts.push_back(nCount); } snChannelsUsed.insert(nChannel); nCount = 1; nLastChannel = nChannel; } else { nCount++; } pGrid->SetColLabelValue(nCol,plc->GetName()); nCol++; } else { nRemove++; } } if(nRemove) { nCols -= nRemove; nwxGrid::SetColCount(pGrid,nCols); } vnChannels.push_back(nLastChannel); vnCounts.push_back(nCount); if(bILS) { // figure out which channnel is ILS int nChannelCount = pKit->GetChannelCount(sKitName); for(nChannel = (unsigned int) nChannelCount; nChannel > 0; --nChannel) { if(snChannelsUsed.find(nChannel) == snChannelsUsed.end()) { nILSchannel = nChannel; // unused channel, assume ILS if(pnILSchannel != NULL) { *pnILSchannel = nChannel; } nChannel = 1; // loop exit } } // ILS Column Label pGrid->SetColLabelValue(nCol,"ILS*"); vnChannels.push_back(nILSchannel); vnCounts.push_back(1); if(pnILScolumn != NULL) { *pnILScolumn = nCol; } } // column labels are set pGrid->SetRowLabelValue(0,"Channel"); // now set channel cells in top row // and colors throughout the table size_t nSize = vnChannels.size(); size_t i; nCol = nBeforeLoci; const CChannelColors *pChannelColors; wxString sLabel; bool bColorSet = false; // set cell colors and set channel numbers/names in // first row for(i = 0; i < nSize; i++) { bColorSet = false; nChannel = vnChannels.at(i); nCount = vnCounts.at(i); if(nCount > 1) { pGrid->SetCellSize(0,nCol,1,nCount); } if(nChannel > 0) { pChannelColors = (pKitColors == NULL) ? NULL : pKitColors->GetColorChannel((unsigned int)nChannel); const wxChar *psDyeLabel = NULL; if(pChannelColors != NULL) { // int k; pGrid->SetCellTextColour(0,nCol,*wxWHITE); pGrid->SetCellBackgroundColour( 0,nCol,pChannelColors->GetColorAnalyzed()); psDyeLabel = (const wxChar *)(pChannelColors->GetDyeName()); bColorSet = true; } FORMAT_CHANNEL_DYE(&sLabel,(unsigned int) nChannel, psDyeLabel); pGrid->SetCellFont(0,nCol,fnBold); pGrid->SetCellValue(0,nCol,sLabel); pGrid->SetCellAlignment(0,nCol,wxALIGN_CENTRE, wxALIGN_CENTRE); } else { pGrid->SetCellValue(0,nCol,wxEmptyString); } if(!bColorSet) { pGrid->SetCellTextColour(0,nCol,pGrid->GetDefaultCellTextColour()); pGrid->SetCellBackgroundColour( 0,nCol,pGrid->GetDefaultCellBackgroundColour()); } nCol += nCount; nwxGrid::SetRowReadOnly(pGrid,0,true); } } return sProblem.IsEmpty(); }
bool CPanelLabGeneral::TransferDataToWindow() { bool bRtn = (m_pInfo != NULL) && (m_pMarker != NULL); if(bRtn) { wxString sValue; wxString s; const wxString &sKitName = m_pMarker->GetMarkerSetName(); const wxString &sILS = m_pMarker->GetILSName(); CPersistKitList *pKitList = mainApp::GetKitList(); const wxArrayString *psILS = pKitList->GetLsArray(sKitName); size_t nSize = (psILS == NULL) ? 0 : psILS->GetCount(); m_pChoiceILS->Clear(); if(!nSize) { wxString sError; bRtn = false; sError = "Cannot file ILS for kit, "; sError.Append(sKitName); mainApp::LogMessage(sError); wxASSERT_MSG(0,sError); } else { m_pChoiceILS->Append(*psILS); if(sILS.IsEmpty() || !m_pChoiceILS->SetStringSelection(sILS)) { m_pChoiceILS->Select(0); } m_pLabelVolumeName->SetLabel(m_pInfo->GetVolumeName()); m_pLabelKitName->SetLabel(sKitName); const wxDateTime &dt = m_pInfo->GetLastUpdate(); sValue.Empty(); if(dt.GetTicks() > 100) { const wxString &sUser = m_pInfo->GetUserID(); sValue = dt.Format(); if(!sUser.IsEmpty()) { sValue.Append(" by "); sValue.Append(sUser); } } m_pLabelLastUpdateUser->SetLabel(sValue); m_pCheckUserOverride->SetValue(m_pMarker->GetAllowUserOverrideILS()); m_pTextProtocol->SetValue(m_pInfo->GetProtocol()); m_pTextLot->SetValue(m_pInfo->GetLot()); m_pTextNotes->SetValue(m_pInfo->GetNotes()); bool bDataAnalyzed = m_pMarker->GetAnalyzed(); m_pRadioRaw->SetValue(!bDataAnalyzed); m_pRadioAnalyzed->SetValue(bDataAnalyzed); wxRadioButton *pRadio; wxString sValue = m_pInfo->GetDataFileType(); size_t nLEN = m_vpRadioFileType.size(); bool bFound = false; bool b; if(sValue.Len()) { for(size_t n = 0; n < nLEN; n++) { pRadio = m_vpRadioFileType.at(n); b = (pRadio->GetLabelText() == sValue); if(b) { bFound = true; } pRadio->SetValue(b); } } if(!bFound) { m_vpRadioFileType.at(0)->SetValue(true); } } } return bRtn; }
void CPersistKitList::UnitTest() { CPersistKitList kitList; wxString sError; if(!kitList.Load()) { sError.Append(_T("CPersistKitList::Load() failed\n")); } else { const wxArrayString *psKitArray; const wxArrayString *psArray; psKitArray = &kitList.GetArray(); size_t nCount = psKitArray->GetCount(); #define PP12 _T("PowerPlex 1.2") #define PP18D _T("PowerPlex 18D") #define SGM _T("SGM Plus") #define SEFILER _T("SEfilerPlus") #define NGM _T("NGMSElect") #define PP21 _T("PowerPlex 21") struct { size_t n; // number of loci const wxChar *psName; } LIST[] = { {7, _T("Cofiler")}, {16, _T("Identifiler Less ILS250")}, {16, _T("IdentifilerPlus Less ILS250")}, {16, _T("IdentifilerPlus")}, {16, _T("Identifiler")}, {9, PP12}, {18, PP18D}, {16, _T("PowerPlex 16")}, {11, _T("PowerPlex Y")}, {16, _T("Yfiler")}, {12, SEFILER}, {11, SGM}, {10, _T("ProfilerPlus")}, {17, NGM}, {21,PP21} }; size_t N_LIST = sizeof(LIST) / sizeof(LIST[0]); if(nCount != N_LIST) { sError.Append(wxString::Format( _T("\nNumber of kits is %d, expected %d"), (int)nCount, (int)N_LIST )); } map<wxString,size_t> kitLocusCount; map<wxString,size_t>::iterator itrKL; size_t i; for(i = 0; i < N_LIST; i++) { kitLocusCount.insert( map<wxString,size_t>::value_type( wxString(LIST[i].psName),LIST[i].n)); } for(i = 0; i < nCount; i++) { // verify LS count const wxString &sItem = psKitArray->Item(i); psArray = kitList.GetLsArray(sItem); if(psArray == NULL) { sError.Append(_T("\nCannot find ILS for kit: ")); sError.Append(sItem); } else { size_t nExpected = 4; if(sItem == PP12 || sItem == PP18D || sItem == NGM || sItem == SEFILER || sItem == PP21) { nExpected = 1; } else if(sItem == SGM) { nExpected = 5; } else if( sItem.StartsWith(_T("Identifiler")) && !sItem.Contains(_T("250")) ) { nExpected = 5; } if(psArray->GetCount() != nExpected) { sError.Append( _T("\nLS count for kit: ")); sError.Append(sItem); sError.Append(wxString::Format( _T(", is %d, expected %d"), (int)psArray->GetCount(),(int)nExpected)); } } itrKL = kitLocusCount.find(sItem); const CLocusNameList *pList = kitList.GetLocusNameList(sItem); if(pList == NULL) { sError.Append(_T("\nCannot find loci for kit: ")); sError.Append(sItem); } if(itrKL == kitLocusCount.end()) { sError.Append(_T("\nUnknown kit name: ")); sError.Append(sItem); } else if( (pList != NULL) && (pList->size() != itrKL->second) ) { sError.Append(_T("\nLocus count for kit: ")); sError.Append(sItem); sError.Append(wxString::Format( _T(", is %d, expected %d"), (int)pList->size(),(int)itrKL->second)); } } } wxASSERT_MSG(sError.IsEmpty(),sError); #undef PP12 }