PWIZ_API_DECL size_t ProteinList::find(const string& id) const { for (size_t index = 0, end = size(); index < end; ++index) if (protein(index, false)->id == id) return index; return size(); }
PWIZ_API_DECL IndexList ProteinList::findKeyword(const string& keyword, bool caseSensitive /*= true*/) const { IndexList indexList; if (caseSensitive) { for (size_t index = 0, end = size(); index < end; ++index) if (protein(index, false)->description.find(keyword) != string::npos) indexList.push_back(index); } else { string lcKeyword = keyword; for (size_t index = 0, end = size(); index < end; ++index) { string lcDescription = protein(index, false)->description; bal::to_lower(lcDescription); if (lcDescription.find(lcKeyword) != string::npos) indexList.push_back(index); } } return indexList; }
// printStartQuery - prints the hit void SpectraSTTxtSearchOutput::printHit(string query, unsigned int hitRank, SpectraSTLibEntry* entry, SpectraSTSimScores& simScores) { if (!entry) { (*m_fout).width(4); (*m_fout) << "0"; (*m_fout).width(MAX_NAME_LEN); (*m_fout) << left << "NO_MATCH"; (*m_fout) << endl; return; } if (hitRank > 1) { (*m_fout).width(MAX_NAME_LEN); (*m_fout) << left << "--"; } (*m_fout).width(4); (*m_fout) << left << hitRank; stringstream peptidess; peptidess << entry->getName(); (*m_fout).width(MAX_NAME_LEN); (*m_fout) << left << peptidess.str(); simScores.printFixedWidth((*m_fout)); (*m_fout).width(10); (*m_fout) << left << entry->getStatus(); (*m_fout).width(10); string inst(""); if (entry->getOneComment("Inst", inst)) { (*m_fout) << left << inst; } else { (*m_fout) << left << "Unk"; } (*m_fout).width(6); string spectrumType(""); if (entry->getOneComment("Spec", spectrumType)) { (*m_fout) << left << spectrumType.substr(0, spectrumType.length() < 3 ? spectrumType.length() : 3); } else { (*m_fout) << left << "Unk"; } (*m_fout).width(20); (*m_fout) << left << entry->getLibFileOffset(); string protein(""); stringstream proteinss; string sample(""); string::size_type pos = 0; if (entry->getOneComment("Protein", protein)) { if (protein.find('/') != string::npos) { int proteinCount = atoi(nextToken(protein, 0, pos, "/\t\r\n").c_str()); proteinss << proteinCount << ':'; bool isFirstProtein = true; while (pos < protein.length()) { if (!isFirstProtein) proteinss << ';'; proteinss << nextToken(protein, pos, pos, "/\t\r\n", "/"); isFirstProtein = false; } } else { proteinss << '1' << ':' << protein; } } else if (entry->getOneComment("Sample", sample)) { // if no protein field is given, use the sample field. (this is useful for unidentified spectra) if (sample.find('/') != string::npos) { int sampleCount = atoi(nextToken(sample, 0, pos, "/\t\r\n").c_str()); proteinss << sampleCount << ':'; bool isFirstSample = true; while (pos < sample.length()) { if (!isFirstSample) proteinss << ';'; proteinss << nextToken(sample, pos, pos, "/\t\r\n", "/"); isFirstSample = false; } } } else { proteinss << '0'; } (*m_fout) << proteinss.str(); (*m_fout) << endl; }