Skip to content

Commit

Permalink
PD-4687 distinct overlapping hits are not reported separately for pro…
Browse files Browse the repository at this point in the history
…tein targets for the same alleles or gene symbols
  • Loading branch information
Vyacheslav Brover committed Jul 19, 2023
1 parent 80beec7 commit d61f728
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 113 deletions.
14 changes: 7 additions & 7 deletions amr_report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,7 @@ struct BlastAlignment : Alignment
? mut->wildtype ()
: mut->geneMutation
: gene + "_" + seqChange. getMutationStr ()
/*: print_node
? famId */
: fusion2geneSymbols ()
: fusion2geneSymbols ()
)
<< (isMutationProt ()
? mut
Expand Down Expand Up @@ -1072,10 +1070,12 @@ struct BlastAlignment : Alignment
if (targetName != other. targetName)
return false;
// PD-807, PD-4277
if (! targetProt) // PD-4687
if ( ! other. insideEq (*this)
&& ! insideEq (other)
)
if ( ! other. insideEq (*this)
&& ! insideEq (other)
)
if ( ! targetProt
|| fusion2geneSymbols () != other. fusion2geneSymbols ()
) // PD-4687
return false;
if ( ! isMutationProt ()
&& ! refAccession. empty ()
Expand Down
3 changes: 2 additions & 1 deletion amrfinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
* gunzip (optional)
*
* Release changes:
* 3.11.16 07/18/2023 PD-4687 distinct overlapping hits are not reported separately for protein targets (because the start/stop is not reported)
* 3.11.17 07/19/2023 PD-4687 distinct overlapping hits are not reported separately for protein targets for the same alleles or gene symbols
* 3.11.16 07/18/2023 PD-4687 distinct overlapping hits are not reported separately for protein targets (because the start/stop are not reported)
* 3.11.15 05/23/2023 PD-4629 "amrfinder_update -d DIR" will create DIR if DIR is missing
* 3.11.14 05/06/2023 PD-4598 error messages in curl_easy.cpp
* 3.11.13 05/04/2023 PD-4596 Prohibit ASCII characters only between 0x00 and 0x1F in GFF files
Expand Down
122 changes: 85 additions & 37 deletions common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ size_t get_threads_max_max ()
#ifdef __APPLE__
//stderr << "Compiled for MacOS" << "\n";
int count = 0;
size_t count_len = sizeof(count);
sysctlbyname ("hw.logicalcpu", &count, &count_len, NULL, 0);
/*const*/ size_t count_len = sizeof(count);
sysctlbyname ("hw.logicalcpu", &count, &count_len, nullptr, 0);
//fprintf(stderr,"you have %i cpu cores", count);
ASSERT (count >= 0);
return (size_t) count;
Expand Down Expand Up @@ -308,10 +308,7 @@ string getStack ()
[[noreturn]] void throwf (const string &s)
{
if (cxml)
{
const Xml::Tag xml (*cxml, "ERROR");
*cxml << s;
}
cxml->print (string (error_caption) + ": " + s);
throw logic_error (s + "\nStack:\n" + getStack ());
}

Expand Down Expand Up @@ -1552,6 +1549,81 @@ Threads::~Threads ()



// Xml

// Xml::TextFile

void Xml::TextFile::tagStart (const string &tag)
{
ASSERT (! isText);

string tag_ (tag);
replace (tag_, ':', '_');
if (! isIdentifier (tag_, true))
throw runtime_error (FUNC "Bad tag name: " + strQuote (tag));

printRaw ("<" + tag + ">");
}



void Xml::TextFile::tagEnd (const string &tag)
{
printRaw ("</" + tag + ">\n");
}




// Xml::BinFile

Xml::BinFile::~BinFile ()
{
rootTag. reset ();
for (const string& name : names. num2elem)
os << name << '\n';
}



void Xml::BinFile::printRaw (const string &s)
{
QC_ASSERT (! contains (s, '\0'));
if (! isText)
os << '\0' << '\0'; // Tags closing
os << s;
}



void Xml::BinFile::tagStart (const string &tag)
{
ASSERT (! isText);

if (tag. empty ())
throw runtime_error (FUNC "Empty tag");
QC_ASSERT (! contains (tag, '\0'));
QC_ASSERT (! contains (tag, '\n'));
size_t i = names. add (tag);
//ASSERT (i);
const Byte b = i % 256;
i /= 256;
if (i > 256)
throw runtime_error (FUNC "Too many different tag names");
os << (Byte) i << b;
}



void Xml::BinFile::tagEnd (const string &/*tag*/)
{
if (! isText)
os << '\0' << '\0'; // Tags closing
os << '\0'; // Text closing
}




// Xml::Tag

Expand All @@ -1564,44 +1636,19 @@ Xml::Tag::Tag (Xml::File &f_arg,
{
if (name. empty ())
throw runtime_error (FUNC "Empty XML tag name");
if (contains (name, ' '))
throwf ("tag name contains a space: " + strQuote (name_arg));
if (f. printOffset)
{
f. print ("\n");
f. offset++;
FOR (size_t, i, f. offset * File::offset_spaces)
f. print (" ");
}
//if (! name. empty ())
if (f. isText)
throw runtime_error (FUNC "Cannot put tag " + strQuote (name) + " after a text");
if (active)
f. print ("<" + name + ">");
f. tagStart (name);
}



Xml::Tag::~Tag ()
{
if (f. printOffset)
{
if (f. printBrief)
{
f. offset--;
return;
}
else
{
f. print ("\n");
FOR (size_t, i, f. offset * File::offset_spaces)
f . print (" ");
f. offset--;
}
}
//if (! name. empty ())
if (active)
f. print ("</" + name + ">");
if (! f. printOffset)
f. print ("\n");
f. tagEnd (name);
f. isText = false;
}


Expand All @@ -1611,6 +1658,7 @@ unique_ptr<Xml::File> cxml;




// Root

void Root::saveFile (const string &fName) const
Expand Down Expand Up @@ -1742,7 +1790,7 @@ void StringVector::to_xml (Xml::File &f,
for (const string& s : *this)
{
const Xml::Tag xml_item (f, "item");
f << s;
f. print (s);
}

clear ();
Expand Down
Loading

0 comments on commit d61f728

Please sign in to comment.