Skip to content

Commit

Permalink
missed a zero for xcorr rounding in standard (non FI) Comet in prevou…
Browse files Browse the repository at this point in the history
…s commit; other useless cleanup that do nothing
  • Loading branch information
jke000 committed Sep 10, 2024
1 parent 50aab09 commit 03bc95c
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 33 deletions.
49 changes: 25 additions & 24 deletions CometSearch/CometFragmentIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ void CometFragmentIndex::GenerateFragmentIndex(ThreadPool *tp)

// sort list of peptides at each fragment bin by peptide mass
for (int iWhichThread = 0; iWhichThread < iNumIndexingThreads; ++iWhichThread)
pFragmentIndexPool->doJob(std::bind(SortFragmentThreadProc, iWhichThread, iNumIndexingThreads, pFragmentIndexPool));
pFragmentIndexPool->doJob(std::bind(SortFragmentThreadProc, iWhichThread, pFragmentIndexPool));

pFragmentIndexPool->wait_on_threads();

Expand Down Expand Up @@ -372,7 +372,6 @@ void CometFragmentIndex::AddFragmentsThreadProc(int iWhichThread,


void CometFragmentIndex::SortFragmentThreadProc(int iWhichThread,
int iNumIndexingThreads,
ThreadPool *tp)
{
for (int iPrecursorBin = 0; iPrecursorBin < FRAGINDEX_PRECURSORBINS; ++iPrecursorBin)
Expand Down Expand Up @@ -1019,26 +1018,26 @@ bool CometFragmentIndex::ReadPlainPeptideIndex(void)
comet_fileoffset_t clPermutationsFilePos; // file position of permutations variables

comet_fseek(fp, -clSizeCometFileOffset*3, SEEK_END);
fread(&clPeptidesFilePos, clSizeCometFileOffset, 1, fp);
fread(&clProteinsFilePos, clSizeCometFileOffset, 1, fp);
fread(&clPermutationsFilePos, clSizeCometFileOffset, 1, fp);
tTmp = fread(&clPeptidesFilePos, clSizeCometFileOffset, 1, fp);
tTmp = fread(&clProteinsFilePos, clSizeCometFileOffset, 1, fp);
tTmp = fread(&clPermutationsFilePos, clSizeCometFileOffset, 1, fp);

comet_fseek(fp, clPeptidesFilePos, SEEK_SET);

size_t tNumPeptides;
fread(&tNumPeptides, sizeof(size_t), 1, fp); // read # of peptides
tTmp = fread(&tNumPeptides, sizeof(size_t), 1, fp); // read # of peptides

struct PlainPeptideIndex sTmp;
int iLen;
char szPeptide[MAX_PEPTIDE_LEN];
for (size_t it = 0; it < tNumPeptides; ++it)
{
fread(&iLen, sizeof(int), 1, fp);
fread(szPeptide, sizeof(char), iLen, fp);
tTmp = fread(&iLen, sizeof(int), 1, fp);
tTmp = fread(szPeptide, sizeof(char), iLen, fp);
szPeptide[iLen] = '\0';
sTmp.sPeptide = szPeptide;
fread(&(sTmp.dPepMass), sizeof(double), 1, fp);
fread(&(sTmp.lIndexProteinFilePosition), clSizeCometFileOffset, 1, fp);
tTmp = fread(&(sTmp.dPepMass), sizeof(double), 1, fp);
tTmp = fread(&(sTmp.lIndexProteinFilePosition), clSizeCometFileOffset, 1, fp);

g_vRawPeptides.push_back(sTmp);
}
Expand All @@ -1047,20 +1046,21 @@ bool CometFragmentIndex::ReadPlainPeptideIndex(void)

// now read in: vector<vector<comet_fileoffset_t>> g_pvProteinsList
size_t tSize;
fread(&tSize, clSizeCometFileOffset, 1, fp);
tTmp = fread(&tSize, clSizeCometFileOffset, 1, fp);
vector<comet_fileoffset_t> vTmp;

g_pvProteinsList.clear();
g_pvProteinsList.reserve(tSize);

for (size_t it = 0; it < tSize; ++it)
{
fread(&tTmp, clSizeCometFileOffset, 1, fp);
size_t tNumProteinOffsets;
tTmp = fread(&tNumProteinOffsets, clSizeCometFileOffset, 1, fp);

vTmp.clear();
for (size_t it2 = 0; it2 < tTmp; ++it2)
for (size_t it2 = 0; it2 < tNumProteinOffsets; ++it2)
{
fread(&clTmp, clSizeCometFileOffset, 1, fp);
tTmp = fread(&clTmp, clSizeCometFileOffset, 1, fp);
vTmp.push_back(clTmp);
}
g_pvProteinsList.push_back(vTmp);
Expand All @@ -1072,31 +1072,32 @@ bool CometFragmentIndex::ReadPlainPeptideIndex(void)
unsigned long ulSizevRawPeptides; // size of g_vRawPeptides
unsigned long ulModNumSize; // size of MOD_NUMBERS

fread(&ulSizeModSeqs, sizeof(unsigned long), 1, fp);
fread(&ulSizevRawPeptides, sizeof(unsigned long), 1, fp);
fread(&ulModNumSize, sizeof(unsigned long), 1, fp);
tTmp = fread(&ulSizeModSeqs, sizeof(unsigned long), 1, fp);
tTmp = fread(&ulSizevRawPeptides, sizeof(unsigned long), 1, fp);
tTmp = fread(&ulModNumSize, sizeof(unsigned long), 1, fp);

MOD_SEQ_MOD_NUM_START = new int[ulSizeModSeqs];
MOD_SEQ_MOD_NUM_CNT = new int[ulSizeModSeqs];
PEPTIDE_MOD_SEQ_IDXS = new int[ulSizevRawPeptides];

fread(MOD_SEQ_MOD_NUM_START, sizeof(int), ulSizeModSeqs, fp);
fread(MOD_SEQ_MOD_NUM_CNT, sizeof(int), ulSizeModSeqs, fp);
fread(PEPTIDE_MOD_SEQ_IDXS, sizeof(int), ulSizevRawPeptides, fp); //FIX
tTmp = fread(MOD_SEQ_MOD_NUM_START, sizeof(int), ulSizeModSeqs, fp);
tTmp = fread(MOD_SEQ_MOD_NUM_CNT, sizeof(int), ulSizeModSeqs, fp);
tTmp = fread(PEPTIDE_MOD_SEQ_IDXS, sizeof(int), ulSizevRawPeptides, fp); //FIX

int iTmp;
char szTmp[MAX_PEPTIDE_LEN];
for (unsigned long i = 0; i < ulSizeModSeqs; ++i)
{
fread(&iTmp, sizeof(int), 1, fp); // read length
fread(szTmp, 1, iTmp, fp);
tTmp = fread(&iTmp, sizeof(int), 1, fp); // read length
tTmp = fread(szTmp, 1, iTmp, fp);
szTmp[iTmp]='\0';
MOD_SEQS.push_back(szTmp);
}
for (unsigned long i = 0; i < ulModNumSize; ++i)
{
ModificationNumber sTmp;
fread(&iTmp, sizeof(int), 1, fp); // read length
fread(szTmp, 1, iTmp, fp);
tTmp = fread(&iTmp, sizeof(int), 1, fp); // read length
tTmp = fread(szTmp, 1, iTmp, fp);
szTmp[iTmp]='\0';
sTmp.modStringLen = iTmp;
sTmp.modifications = new char[iTmp];
Expand Down
1 change: 0 additions & 1 deletion CometSearch/CometFragmentIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class CometFragmentIndex
static bool SortFragmentsByPepMass(unsigned int x,
unsigned int y);
static void SortFragmentThreadProc(int iWhichThread,
int iNumIndexingThreads,
ThreadPool* tp);
static bool CompareByPeptide(const DBIndex &lhs,
const DBIndex &rhs);
Expand Down
8 changes: 5 additions & 3 deletions CometSearch/CometMassSpecUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,25 +133,27 @@ void CometMassSpecUtils::GetProteinName(FILE *fpdb,
comet_fileoffset_t lFilePosition,
char *szProteinName)
{
size_t tTmp;

comet_fseek(fpdb, lFilePosition, SEEK_SET);

if (g_staticParams.bIndexDb) //index database
{
long lSize;

fread(&lSize, sizeof(long), 1, fpdb);
tTmp = fread(&lSize, sizeof(long), 1, fpdb);
vector<comet_fileoffset_t> vOffsets;
for (long x = 0; x < lSize; ++x) // read file offsets
{
comet_fileoffset_t tmpoffset;
fread(&tmpoffset, sizeof(comet_fileoffset_t), 1, fpdb);
tTmp = fread(&tmpoffset, sizeof(comet_fileoffset_t), 1, fpdb);
vOffsets.push_back(tmpoffset);
}
for (long x = 0; x < lSize; ++x) // read name from fasta
{
char szTmp[WIDTH_REFERENCE];
comet_fseek(fpdb, vOffsets.at(x), SEEK_SET);
fread(szTmp, sizeof(char)*WIDTH_REFERENCE, 1, fpdb);
tTmp = fread(szTmp, sizeof(char)*WIDTH_REFERENCE, 1, fpdb);
sscanf(szTmp, "%511s", szProteinName); // WIDTH_REFERENCE-1
break; //break here to only get first protein reference (out of lSize)
}
Expand Down
2 changes: 1 addition & 1 deletion CometSearch/CometPostAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ void CometPostAnalysis::CalculateSP(Results *pOutput,

int _iSizepiVarModSites = sizeof(int)*MAX_PEPTIDE_LEN_P2;

for (i=0; i<iSize; ++i)
for (i = 0; i < iSize; ++i)
{
if (!g_staticParams.bIndexDb)
{
Expand Down
2 changes: 1 addition & 1 deletion CometSearch/CometSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3179,7 +3179,7 @@ void CometSearch::XcorrScore(char *szProteinSeq,

dXcorr *= 0.005; // Scale intensities to 50 and divide score by 1E4.

dXcorr= std::round(dXcorr* 10000.0) / 1000.0; // round to 4 decimal points
dXcorr= std::round(dXcorr* 10000.0) / 10000.0; // round to 4 decimal points

Threading::LockMutex(pQuery->accessMutex);

Expand Down
3 changes: 2 additions & 1 deletion CometSearch/CometSearchManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3487,13 +3487,14 @@ bool CometSearchManager::DoSingleSpectrumSearchMultiResults(const int topN,
if (!bSucceeded)
goto cleanup_results;

g_massRange.dMinMass = g_pvQuery.at(0)->_pepMassInfo.dPeptideMassToleranceMinus;
g_massRange.dMinMass = g_pvQuery.at(0)->_pepMassInfo.dPeptideMassToleranceMinus;
g_massRange.dMaxMass = g_pvQuery.at(g_pvQuery.size() - 1)->_pepMassInfo.dPeptideMassTolerancePlus;

if (g_massRange.dMaxMass - g_massRange.dMinMass > g_massRange.dMinMass)
g_massRange.bNarrowMassRange = true; // unused in this context but setting here anyways
else
g_massRange.bNarrowMassRange = false;

g_sCometVersion = comet_version;

// Now that spectra are loaded to memory and sorted, do search.
Expand Down
3 changes: 1 addition & 2 deletions CometSearch/CometWritePepXML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ bool CometWritePepXML::WritePepXMLHeader(FILE *fpout,
strcpy(szResolvedInputBaseName, g_staticParams.inputFile.szFileName);

// now remove extension from szRunSummaryResolvedPath to leave just the base name
int iLen = (int)strlen(szResolvedInputBaseName);
if ( (pStr = strrchr(szResolvedInputBaseName, '.')))
if ((pStr = strrchr(szResolvedInputBaseName, '.')))
*pStr = '\0';

if (g_staticParams.options.bResolveFullPaths)
Expand Down

0 comments on commit 03bc95c

Please sign in to comment.