[Debichem-commits] [SCM] massXpert mass spectrometry suite: debian packaging branch, debian, updated. upstream/3.2.0-1-g5564507
Filippo Rusconi (Debian Maintainer)
rusconi-debian at laposte.net
Thu Nov 24 21:27:33 UTC 2011
The following commit has been merged in the debian branch:
commit 0c7b5222cf19ddd6059e6e4576420859d5d3275c
Author: Filippo Rusconi (Debian Maintainer) <rusconi-debian at laposte.net>
Date: Thu Nov 26 20:51:08 2009 +0100
Fixed a bug causing a crash in corner polymer cleavage cases.
diff --git a/lib/cleaver.cpp b/lib/cleaver.cpp
index 915726e..59cd1a9 100644
--- a/lib/cleaver.cpp
+++ b/lib/cleaver.cpp
@@ -196,7 +196,7 @@ namespace massXpert
int index = -1;
- while(1)
+ while (1)
{
index = findCleaveMotif(*cleaveMotif, index + 1);
@@ -301,7 +301,7 @@ namespace massXpert
int
Cleaver::findCleaveMotif(CleaveMotif &cleaveMotif, int index)
{
- bool noGood;
+ bool noGood = false;
int firstIndex = 0;
@@ -334,70 +334,83 @@ namespace massXpert
if (codeList.size() == 0)
return -1;
- Q_ASSERT(index < mp_polymer->size());
- Q_ASSERT(index >= 0);
-
-
+ if (index < 0)
+ return -1;
+
+ if (index >= mp_polymer->size())
+ return -1;
+
// Seed the routine by setting 'first' to the first motif in the
- // codeList(in our example this is "Lys").
+ // codeList (in our example this is "Lys").
QString firstCode = codeList.first();
- // And now iterate(starting from 'index') in the polymer sequence's
- // list of monomers in search for a monomer having the proper code
- //("Lys").
+ // And now iterate (starting from 'index') in the polymer
+ // sequence's list of monomers in search for a monomer having the
+ // proper code ("Lys").
int iterIndex = index;
- while(iterIndex < monomerList.size())
+ while (iterIndex < monomerList.size())
{
const Monomer *monomer = monomerList.at(iterIndex);
-
- if(monomer->code() == firstCode)
+
+ if (monomer->code() != firstCode)
{
- firstIndex = iterIndex;
- noGood = false;
-
- for (int iter = 1; iter < codeList.size(); ++iter)
+ // The currently iterated code is not the one we
+ // search. So go one code further in the sequence.
+
+ ++iterIndex;
+ continue;
+ }
+
+ // If we are here, then that means that we actually found on
+ // monomer code in the sequence that matches the one we are
+ // looking for.
+
+ firstIndex = iterIndex;
+ noGood = false;
+
+ // Now that we have anchored our search at firstIndex in the
+ // polymer sequence, continue with next monomer and check if
+ // it matches the next monomer in the motif we are looking
+ // for.
+
+ for (int iter = 1; iter < codeList.size(); ++iter)
+ {
+ if (iterIndex + iter >= mp_polymer->size())
{
- if(iterIndex + iter >= mp_polymer->size())
- {
- noGood = true;
- break;
- }
+ noGood = true;
+ break;
+ }
- QString nextCode = codeList.at(iter);
+ QString nextCode = codeList.at(iter);
- monomer = monomerList.at(iterIndex + iter);
-
- if(monomer->code() == nextCode)
- continue;
- else
- {
- noGood = true;
- break;
- }
- }
- // End of
- // for (int iter = 1; iter < codeList.size(); ++iter)
+ monomer = monomerList.at(iterIndex + iter);
- if (noGood)
- {
- ++iterIndex;
- continue;
- }
+ if (monomer->code() == nextCode)
+ continue;
else
{
- return firstIndex;
+ noGood = true;
+ break;
}
}
// End of
- // if (monomer->code() == firstCode)
+ // for (int iter = 1; iter < codeList.size(); ++iter)
- ++iterIndex;
+ if (noGood)
+ {
+ ++iterIndex;
+ continue;
+ }
+ else
+ {
+ return firstIndex;
+ }
}
// End of
- // while(iterIndex < monomerList.size())
+ // while (iterIndex < monomerList.size())
return -1;
}
--
massXpert mass spectrometry suite: debian packaging
More information about the Debichem-commits
mailing list