Skip to content

Commit ccf119c

Browse files
author
Vyacheslav Brover
committed
PD-4722 bug: calling fusion2geneSymbols() for a mutation protein; color codes are printed only when output is to screen
1 parent 76f1c26 commit ccf119c

File tree

5 files changed

+2193
-2060
lines changed

5 files changed

+2193
-2060
lines changed

amr_report.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ struct BlastAlignment : Alignment
808808
}
809809
public:
810810
string fusion2geneSymbols () const
811-
{ ASSERT (! isMutationProt ());
811+
{ ASSERT (! isMutationProt ());
812812
if (fusions. empty ())
813813
return getGeneSymbol ();
814814
string s;
@@ -1011,6 +1011,7 @@ struct BlastAlignment : Alignment
10111011
)
10121012
return false;
10131013
// PD-4698
1014+
// Most probably a repeat protein
10141015
const size_t pseudoOverlap = mismatchTailTarget () * 2; // PAR
10151016
return (targetStart < other. targetStart && targetEnd >= other. targetStart + pseudoOverlap)
10161017
|| (targetEnd > other. targetEnd && targetStart + pseudoOverlap <= other. targetEnd);
@@ -1100,7 +1101,9 @@ struct BlastAlignment : Alignment
11001101
&& ! insideEq (other)
11011102
)
11021103
if ( ! targetProt
1103-
|| fusion2geneSymbols () != other. fusion2geneSymbols ()
1104+
|| ( ! isMutationProt () // PD-4722
1105+
&& fusion2geneSymbols () != other. fusion2geneSymbols ()
1106+
)
11041107
) // PD-4687
11051108
return false;
11061109
if ( ! isMutationProt ()

amrfinder.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
* gunzip (optional)
3434
*
3535
* Release changes:
36+
* 3.11.20 09/06/2023 PD-4722 bug: calling fusion2geneSymbols() for a mutation protein
37+
* TERM codes are printed only when output is to screen
3638
* 3.11.19 08/09/2023 PD-4698 if a pseudogene is overlapped by a different gene on the length >= 20 aa with the same gene symbol then the pseudogene is not reported
3739
* 08/04/2023 PD-4706 protein match overrides a nucleotide match for point mutations
3840
* 3.11.18 07/25/2023 parameter order in instruction; "can be gzipped" is added to help

common.cpp

Lines changed: 84 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,17 @@
4343
#include <csignal>
4444

4545
#ifndef _MSC_VER
46-
#include <execinfo.h>
47-
#include <sys/types.h>
48-
#include <sys/stat.h>
49-
#include <unistd.h>
50-
#include <dirent.h>
51-
#ifdef __APPLE__
52-
#include <sys/sysctl.h>
53-
#endif
46+
extern "C"
47+
{
48+
#include <execinfo.h>
49+
#include <sys/types.h>
50+
#include <sys/stat.h>
51+
#include <unistd.h>
52+
#include <dirent.h>
53+
#ifdef __APPLE__
54+
#include <sys/sysctl.h>
55+
#endif
56+
}
5457
#endif
5558

5659

@@ -107,6 +110,7 @@ bool sigpipe = false;
107110

108111

109112

113+
110114
// COutErr
111115

112116
#ifndef _MSC_VER
@@ -223,6 +227,8 @@ namespace
223227
bool segmFault)
224228
// alloc() may not work
225229
{
230+
beep ();
231+
226232
ostream* os = logPtr ? logPtr : & cerr;
227233

228234
// time ??
@@ -315,6 +321,37 @@ string getStack ()
315321

316322

317323

324+
//
325+
326+
bool isRedirected (const ostream &os)
327+
{
328+
#ifdef _MSC_VER
329+
return false;
330+
#else
331+
if (& os == & cout)
332+
return ! isatty (fileno (stdout));
333+
if (& os == & cerr)
334+
return ! isatty (fileno (stderr));
335+
if (& os == & clog)
336+
return ! isatty (fileno (stderr));
337+
return false;
338+
#endif
339+
}
340+
341+
342+
343+
void beep ()
344+
{
345+
constexpr char c = '\x07';
346+
if (! isRedirected (cerr))
347+
cerr << c;
348+
else if (! isRedirected (cout))
349+
cout << c;
350+
}
351+
352+
353+
354+
318355
// Chronometer
319356

320357
bool Chronometer::enabled = false;
@@ -383,8 +420,9 @@ Chronometer_OnePass::~Chronometer_OnePass ()
383420
const OColor oc (os, Color::magenta, false, true /*& os == & cerr*/);
384421
os << "CHRON: " << name << ": ";
385422
const ONumber on (os, 0, false);
386-
os << difftime (stop, start) << " sec." << endl;
423+
os << difftime (stop, start) << " sec.";
387424
}
425+
os << endl;
388426

389427
if (addNewLine)
390428
os << endl;
@@ -393,12 +431,12 @@ Chronometer_OnePass::~Chronometer_OnePass ()
393431

394432

395433

396-
// Byte
434+
// uchar
397435

398-
size_t byte2first (Byte b)
436+
size_t byte2first (uchar b)
399437
{
400438
if (! b)
401-
return sizeof (Byte);
439+
return sizeof (uchar);
402440
const uint u = b;
403441
size_t i = 0;
404442
uint mask = 1;
@@ -414,7 +452,7 @@ size_t byte2first (Byte b)
414452

415453
size_t utf8_len (char first)
416454
{
417-
const uint u = numeric_limits<uint>::max () - (Byte) first;
455+
const uint u = numeric_limits<uint>::max () - (uchar) first;
418456
size_t len = 0;
419457
uint mask = 0x80;
420458
while (! contains (u, mask))
@@ -883,6 +921,21 @@ void collapseSpace (string &s)
883921

884922

885923

924+
void visualizeTrailingSpaces (string &s)
925+
{
926+
size_t spaces = 0;
927+
while ( ! s. empty ()
928+
&& s. back () == ' '
929+
)
930+
{
931+
s. erase (s. size () - 1);
932+
spaces++;
933+
}
934+
FFOR (size_t, i, spaces)
935+
s += nonPrintable2str (' ');
936+
}
937+
938+
886939

887940
string str2streamWord (const string &s,
888941
size_t wordNum)
@@ -1622,6 +1675,22 @@ Threads::~Threads ()
16221675

16231676
// Xml::TextFile
16241677

1678+
void Xml::TextFile::printRawText (const string &s)
1679+
{
1680+
string res; res. reserve (s. size ());
1681+
for (const char c : s)
1682+
switch (c)
1683+
{
1684+
case '<': res += "&lt;"; break;
1685+
case '>': res += "&gt;"; break;
1686+
case '&': res += "&amp;"; break;
1687+
default: res += c;
1688+
}
1689+
printRaw (res);
1690+
}
1691+
1692+
1693+
16251694
void Xml::TextFile::tagStart (const string &tag)
16261695
{
16271696
ASSERT (! isText);
@@ -1675,11 +1744,11 @@ void Xml::BinFile::tagStart (const string &tag)
16751744
QC_ASSERT (! contains (tag, '\n'));
16761745
size_t i = names. add (tag);
16771746
//ASSERT (i);
1678-
const Byte b = i % 256;
1747+
const uchar b = i % 256;
16791748
i /= 256;
16801749
if (i > 256)
16811750
throw runtime_error (FUNC "Too many different tag names");
1682-
os << (Byte) i << b;
1751+
os << (uchar) i << b;
16831752
}
16841753

16851754

0 commit comments

Comments
 (0)