You are on page 1of 18

Trans-Proteomic

Pipeline (TPP)
:
: 21.08.2012
, , TPP. ,
. ,
. , . ,
PVS-Studio. .
, Trans-Proteomic Pipeline (TPP) 4.5.2.
:

;
Wikipedia: TPP;
Seattle Proteome Center: TPP Wiki.

. - .
, . , ,
, - . TPP
. ,
. TPP . .
, TPP,
XML. , ,
XML.
TPP. ,
. . .

,
, . ,
, a-,
() -C(O)NH-. , TPP ,
Peptide, . :
bool Peptide::operator==(Peptide& p) {
...
for (i = 0, j = 0;
i < this->stripped.length(), j < p.stripped.length();
i++, j++) {
...

}
PVS-Studio: V521 Such expressions using the ',' operator are dangerous. Make sure the expression is
correct. tpplib peptide.cpp 191
, ','.
, . ,
: "j < p.stripped.length()".
:
for (i = 0, j = 0;
i < this->stripped.length() && j < p.stripped.length();
i++, j++) {
Peptide::strippedEquals(). :).


, ,
\ /. :
bool TandemResultsParser::writePepXML(....)
{
...
char c = pathSummary.at(pathSummary.length() - 1);
if (c != '\\' || c != '/')
{
if (pathSummary.find('\\') != string::npos)
pathSummary.append("\\");
else
pathSummary.append("/");
}
...
}
PVS-Studio: V547 Expression 'c != '\\' || c != '/'' is always true. Probably the '&&' operator should be
used here. Tandem2XML tandemresultsparser.cxx 787
"if (c != '\\' || c != '/')", .
. 'c' '\\' '/'. ,
. , , .

:
if (c != '\\' && c != '/')


, " PI ":
class basic_string
{
...
size_type find(const _Elem *_Ptr, size_type _Off = 0) const
...
}

void PipelineAnalysis::prepareFields(void) {
...
if (peptideProphetOpts_.find(" PI ", 0)>=0) {
fields_.push_back(Field("PpI_zscore"));
}
...
}
PVS-Studio: V547 Expression 'peptideProphetOpts_.find(" PI ", 0) >= 0' is always true. Unsigned type
value is always >= 0. pepXMLViewer pipelineanalysis.cxx 1590
std::string::find(). , find()
string::npos. , .
, , find()
. . "peptideProphetOpts_.find(" PI ", 0)>=0"
, >= 0.
, 'peptideProphetOpts',
"PpI_zscore". ,
( 1593). .
:
if (peptideProphetOpts_.find(" PI ", 0) != string::npos)


,
, . :
int main(int argc, char **argv) {
...
char salt[3];
...
salt[0] = (argc>2)?(argv[1][0]):rndChar[rand() % 64];
salt[1] = (argc>2)?(argv[1][1]):rndChar[rand() % 64];
salt[3] = 0;
...
}
PVS-Studio: V557 Array overrun is possible. The '3' index is pointing beyond array bound. crypt crypt.cxx
567
.
. ,
. , ,
. .
:
salt[2] = 0;


void DIGEST_PROTEIN(char *szSeq, int iLenSeq)
{
...
if (pOptions.bMarkNXST
&& szPeptide[i] == 'N'
&& szPeptide[i + 1] != 'P'
&& (szPeptide[i + 2] == 'S' ||
szPeptide[i + 2] == 'T')
&& szPeptide[i + 1] != 'P')
...

}
PVS-Studio: V501 There are identical sub-expressions 'szPeptide[i + 1] != 'P'' to the left and to the right
of the '&&' operator. Comet_fastadb comet-fastadb1.cxx 1906
'szPeptide[i + 1]' 'P'.
. ,
:
if (pOptions.bMarkNXST
&& szPeptide[i] == 'N'
&& szPeptide[i + 1] != 'P'
&& (szPeptide[i + 2] == 'S' ||
szPeptide[i + 2] == 'T')
&& szPeptide[i + 3] != 'P')


, - .
. .
void MascotConverter::init(....) {
...
if(line_len > 8 && .... && line[7] == '=')
if(database_ == NULL)
database_ = strCopy(line+8);
else if(line_len > 5 && .... && line[4] == '=') {
header_ = strCopy(line+5);
...
}
'else if'. ? else ,
'if'. , :
if(line_len > 8 && .... && line[7] == '=')
if(database_ == NULL)
database_ = strCopy(line+8);
else if(line_len > 5 && .... && line[4] == '=') {
header_ = strCopy(line+5);

...
? . ,
. , :
if(line_len > 8 && .... && line[7] == '=')
{
if(database_ == NULL)
database_ = strCopy(line+8);
}
else if(line_len > 5 && .... && line[4] == '=') {
header_ = strCopy(line+5);
...
: .


,
. , . :
class ExperimentCycleRecord {
public:
ExperimentCycleRecord()
{ ExperimentCycleRecord(0,0,0,True,False); }
...
}
PVS-Studio: V603 The object was created but it is not being used. If you wish to call constructor, 'this>ExperimentCycleRecord::ExperimentCycleRecord(....)' should be used. Mascot2XML
mascotconverter.cxx 101
"ExperimentCycleRecord(0,0,0,True,False);"
. .
: , . .
, .
:

V603 The object was created but it is not being used. If you wish to call constructor, 'this>ASAPRatioPeptideCGIDisplayParser::ASAPRatioPeptideCGIDisplayParser(....)' should be used.
tpplib asapratiopeptidecgidisplayparser.cxx 36

V603 The object was created but it is not being used. If you wish to call constructor, 'this>ASAPRatioPeptideParser::ASAPRatioPeptideParser(....)' should be used. tpplib
asapratiopeptideparser.cxx 57
V603 The object was created but it is not being used. If you wish to call constructor, 'this>CruxDiscrimFunction::CruxDiscrimFunction(....)' should be used. tpplib cruxdiscrimfunction.cxx
36
V603 The object was created but it is not being used. If you wish to call constructor, 'this>MascotDiscrimFunction::MascotDiscrimFunction(....)' should be used. tpplib
mascotdiscrimfunction.cxx 47
V603 The object was created but it is not being used. If you wish to call constructor, 'this>MascotScoreParser::MascotScoreParser(....)' should be used. tpplib mascotscoreparser.cxx 37
V603 The object was created but it is not being used. If you wish to call constructor, 'this>TandemKscoreDF::TandemKscoreDF(....)' should be used. tpplib tandemkscoredf.cxx 37
V603 The object was created but it is not being used. If you wish to call constructor, 'this>TandemDiscrimFunction::TandemDiscrimFunction(....)' should be used. tpplib
tandemdiscrimfunction.cxx 35
V603 The object was created but it is not being used. If you wish to call constructor, 'this>TandemNativeDF::TandemNativeDF(....)' should be used. tpplib tandemnativedf.cxx 37


void TRANSLATE(int iFrame, char *szNewSeq,
char *szSeq, int

*iLenSeq)

{
...
*iLenSeq;
}
PVS-Studio: V607 Ownerless expression '* iLenSeq'. Comet_fastadb comet-fastadb1.cxx 2241
'TRANSLATE' "*iLenSeq;".
. , . , - .
, ...


. :
void MixtureModel::assessPeptideProperties(char* filename, Boolean
icat, Boolean glyc)
{
...
double fval;

...
// fval
...
if(! icat && strstr(pep, "C") != NULL && fval >= min_fval) {
...
}
PVS-Studio: V614 Uninitialized variable 'fval' used. tpplib mixturemodel.cxx 834
- . 'fval' .

, :
double mscore_c::dot_hr(unsigned long *_v)
{
...
int iSeqSize;
//perform a single pass through each array.
//check every point in m_pfSeq,
//but don't revisit positions in m_vmiType
for (int a = 0; a < iSeqSize; a++) {
...
}
PVS-Studio: V614 Uninitialized variable 'iSeqSize' used. xtandem mscore_c.cpp 552
'iSeqSize' .
.
:

V614 Uninitialized variable 'separator' used. pwiz sampledatum.hpp 95


V614 Uninitialized variable 'close' used. pwiz sampledatum.hpp 96
V614 Uninitialized variable 'threshold' used. pwiz spectrumlistfactory.cpp 497
V614 Uninitialized variable 'r' used. xtandem serialize.cpp 306
V614 Uninitialized variable 'fval' used. tpplib mixturemodel.cxx 840
V614 Uninitialized variable 'val' used. tpplib rtcalculator.cxx 735

. .
, :).


. -
, .
int main(int argc, char **argv)
{
...
ii=0;
for (i=0; pEnvironment.szPeptide[i]!=0; i++)
ii =+ pEnvironment.szPeptide[i];
...
}
PVS-Studio: V588 The expression of the 'A =+ B' kind is utilized. Consider reviewing it, as it is possible
that 'A += B' was meant. plot_msms plot-msms1.cxx 478
. .
, . ,
. : " .
".
:
for (i=0; pEnvironment.szPeptide[i]!=0; i++)
ii += pEnvironment.szPeptide[i];


.
CharIndexedVectorIterator& operator++()
{ // preincrement
++m_itr;
return (*this);
}

CharIndexedVectorIterator& operator--()
{

// predecrement
++m_itr;

return (*this);
}
PVS-Studio: V524 It is odd that the body of '--' function is fully equivalent to the body of '++' function
(charindexedvector.hpp, line 68). pwiz charindexedvector.hpp 81
'++' . '--' Copy-Paste.
, , '++'. , '--'
. , .

" "
, .
const char* ResidueMass::getStdModResidues(....) {
...
for (rmap::const_iterator i = p.first; i != p.second; ++i) {
const cResidue &r = (*i).second;
if (r.m_masses[0].m_nterm) {
n_term_aa_mod = true;
} else if (r.m_masses[0].m_cterm) {
c_term_aa_mod = true;
}
return r.m_residue.c_str();
}
...
}
PVS-Studio: V612 An unconditional 'return' within a loop. tpplib residuemass.cxx 1442
'return'. ,
'continue' . , .
, . 'return'
'else'.


void ASAPCGIParser::writeProteinRatio(....)
{
...

pvalue = (double)norm_->normalize(adj_inv_ratio);

double tmp[2];
tmp[0] = adj_inv_ratio[0];
tmp[1] = adj_inv_ratio[1];
adj_inv_ratio[0] = 1/ tmp[0];
adj_inv_ratio[1] = tmp[1]/(tmp[0]*tmp[0]);

pvalue = (double)norm_->normalize(adjratio);
...
}
PVS-Studio: V519 The 'pvalue' variable is assigned values twice successively. Perhaps this is a mistake.
Check lines: 205, 214. tpplib asapcgiparser.cxx 214 (...)
'pvalue' .
. , - .

0
, .
, , \, /.
int Dta2mzXML::extractScanNum(const string& dtaFileName)
{
...
std::string::size_type pos = dtaFileName.rfind("/");

if (pos < 0)

pos = dtaFileName.rfind("\\");
}
...
}
PVS-Studio: V547 Expression 'pos < 0' is always false. Unsigned type value is never < 0. dta2mzXML
dta2mzxml.cpp 622

'pos' 0. .
:
V547 Expression 'pos < 0' is always false. Unsigned type value is never < 0. dta2mzXML
dta2mzxml.cpp 626
V547 Expression 'pos < 0' is always false. Unsigned type value is never < 0. dta2mzXML
dta2mzxml.cpp 653
V547 Expression 'pos < 0' is always false. Unsigned type value is never < 0. dta2mzXML
dta2mzxml.cpp 657

. . :
void SpectraSTReplicates::aggregateStats(....)
{
...
unsigned int numAssignedPeaks =
(*r)->entry->getPeakList()->getNumAssignedPeaks();
if (numAssignedPeaks >= 0) {
sumFracAssigned += (double)numAssignedPeaks/(double)numPeaks;
numAnnotated++;
}
...
}
PVS-Studio: V547 Expression 'numAssignedPeaks >= 0' is always true. Unsigned type value is always >=
0. tpplib spectrastreplicates.cpp 642
, . :
V547 Expression 'pl->getNumAssignedPeaks() >= 0' is always true. Unsigned type value is always >= 0.
tpplib spectrastreplicates.cpp 724


, -
. , Copy-Paste.
bool KernelDensityRTMixtureDistr::recalc_RTstats(....)
{
...

if (catalog) {
tmp = (*run_RT_calc_)[i]->recalc_RTstats(
(*probs)[i], min_prob, (*ntts)[i], min_ntt, 2700);
}
else {
tmp = (*run_RT_calc_)[i]->recalc_RTstats(
(*probs)[i], min_prob, (*ntts)[i], min_ntt, 2700);
}
...
}
PVS-Studio: V523 The 'then' statement is equivalent to the 'else' statement. tpplib
kerneldensityrtmixturedistr.cxx 104


,
. , , ,
.
RAMPREAL *readPeaks(RAMPFILE *pFI,
ramp_fileoffset_t lScanIndex)
{
...
else
{
const char* pEndAttrValue;
pEndAttrValue = strchr( pBeginData +
strlen( "contentType=\"") + 1 , '\"' );
pEndAttrValue

= '\0';

fprintf(stderr, "%s Unsupported content type\n" , pBeginData);


return NULL;
}
...
}

PVS-Studio: V527 It is odd that the '\0' value is assigned to 'char' type pointer. Probably meant:
*pEndAttrValue = '\0'. tpplib ramp.cpp 1856
.
, pEndAttrValue .
, pEndAttrValue. ,
.
:
*pEndAttrValue

= '\0';

V527 It is odd that the '\0' value is assigned to 'char' type pointer. Probably meant:
*pEndAttrValue = '\0'. tpplib ramp.cpp 1875
V527 It is odd that the '\0' value is assigned to 'char' type pointer. Probably meant:
*pEndAttrValue = '\0'. spectrast spectrast_ramp.cpp 1844
V527 It is odd that the '\0' value is assigned to 'char' type pointer. Probably meant:
*pEndAttrValue = '\0'. spectrast spectrast_ramp.cpp 1863


XML 10 .
'1', .
strncpy(). strncpy:
char *strncpy (char *dst, const char *src, size_t len);
dst Destination string.
src Source string.
len Number of characters to be copied.
The strncpy function copies the initial count characters of strSource to strDest and returns strDest. If
count is less than or equal to the length of strSource, a null character is not appended automatically to
the copied string. If count is greater than the length of strSource, the destination string is padded with
null characters up to length count.
XML :
void Out2XML::writeOutData() {
...
// assume a string of less than
// 9 characters will represent the charge state
char *chg=(char*)malloc(10 * sizeof(char));
//zero-fill the rest of the array

strncpy(chg, "1", sizeof(chg));


...
}
PVS-Studio: V579 The strncpy function receives the pointer and its size as arguments. It is possibly a
mistake. Inspect the third argument. CombineOut out2xml.cxx 210
, sizeof() ,
. . :
strncpy(chg, "1", 10); // zero-fill the rest of the array
:
V579 The strncpy function receives the pointer and its size as arguments. It is possibly a mistake. Inspect
the third argument. CombineOut out2xml.cxx 214


, , . : str[0] ==
'\0'. , , , .
:
void SAXSpectraHandler::pushPeaks(....)
{
...
while(*pValue != '\0' && a < m_peaksCount) {
while(*pValue != '\0' && isspace(*pValue))
pValue++;
if(pValue == '\0')
break;
m_vfM.push_back((float)atof(pValue));
...
}
PVS-Studio: V528 It is odd that pointer to 'char' type is compared with the '\0' value. Probably meant:
*pValue == '\0'. xtandem saxhandler.cpp 323
while() , . ,
- . 'pValue'
.
:

if(*pValue == '\0')

, :

V528 It is odd that pointer to 'char' type is compared with the '\0' value. Probably meant:
*pValue == '\0'. xtandem saxhandler.cpp 335
V528 It is odd that pointer to 'char' type is compared with the '\0' value. Probably meant:
*pValue != '\0'. xtandem loadmspectrum.cpp 727
V528 It is odd that pointer to 'char' type is compared with the '\0' value. Probably meant:
*pValue != '\0'. xtandem loadmspectrum.cpp 918


XML . ,
- TPP, , .
(, ..) , .
,
. . . ,
, : - ?
, - .
memset(). . ,
. :
V597.
:
void CSHA1::Final()
{
UINT_8 finalcount[8];
...
memset(finalcount, 0, 8);
Transform(m_state, m_buffer);
}
PVS-Studio: V597 The compiler could delete the 'memset' function call, which is used to flush
'finalcount' buffer. The RtlSecureZeroMemory() function should be used to erase the private data. pwiz
sha1.cpp 205
memset(), 'finalcount'
.
:

RtlSecureZeroMemory(finalcount, 8);
:

V597 The compiler could delete the 'memset' function call, which is used to flush 'finalcount'
buffer. The RtlSecureZeroMemory() function should be used to erase the private data.
dta2mzXML sha1.cpp 252
V597 The compiler could delete the 'memset' function call, which is used to flush 'finalcount'
buffer. The RtlSecureZeroMemory() function should be used to erase the private data.
indexmzXML indexmzxmlsha1.cpp 225

DiscriminantFunction ,
.
V599 The virtual destructor is not present, although the 'DiscriminantFunction' class contains virtual
functions. tpplib discrimvalmixturedistr.cxx 201
V595. ,
, . ,
. , .
0 .
, ,
, . :). , ,
, PVS-Studio. ,
, .
.

, ,
. ,
. , . ,
. . ,
. ,
.
.
, . .
, .
,
. .
. :

( ) ;
;
, ;

;
,
.