Skip to content

Commit

Permalink
PD-5014 duplicate susceptible proteins are not reported
Browse files Browse the repository at this point in the history
  • Loading branch information
Vyacheslav Brover committed Jun 3, 2024
1 parent 73963ac commit a10f791
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 13 deletions.
4 changes: 3 additions & 1 deletion amr_report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ struct BlastRule : Root
// 0 <=> undefined
// 0 .. 1
double ident {0.0};
// Of alignment
double target_coverage {0.0}; // Not used
double ref_coverage {0.0};

Expand Down Expand Up @@ -436,6 +437,7 @@ struct BlastAlignment : Alignment
{
// PD-4856
ASSERT (! brFam);
// brFam
EXEC_ASSERT (brFam = getFam ());
while (brFam)
{
Expand Down Expand Up @@ -1223,7 +1225,7 @@ struct BlastAlignment : Alignment
// Requires: all SCCs of betterEq() are complete subgraphs ??
{ return betterEq (other)
&& ( ! other. betterEq (*this)
|| (inFam () && ! equidistant && refAccession < other. refAccession) // Tie resolution: PD-1245
|| (! isMutationProt () /*inFam () --PD-5014*/ && ! equidistant && refAccession < other. refAccession) // Tie resolution: PD-1245
);
}
bool better (const HmmAlignment& other) const
Expand Down
1 change: 1 addition & 0 deletions amrfinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
* Dependencies: NCBI BLAST, HMMer, libcurl, gunzip (optional)
*
* Release changes:
* 3.12.21 05/31/2024 PD-5014 duplicate susceptible proteins are not reported
* 3.12.20 05/22/2024 PD-4078 a regular reference protein can have point mutations
* 3.12.19 05/21/2024 PD-5002 StxTyper 1.0.20
* 05/06/2024 BlastAlignment: isMutation() => !seqChanges.empty()
Expand Down
35 changes: 26 additions & 9 deletions tsv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,31 +51,48 @@ namespace Common_sp
Date Date::parse (const string &s,
Format fmt)
{
Date d;
istringstream iss (s);
short year = 0;
short month = 0;
short day = 0;
char c1 = '\0';
char c2 = '\0';
string tmp;
iss >> year >> tmp;
switch (fmt)
{
case fmt_Year:
if (! tmp. empty ())
return d;
if (! isYear (year))
return d;
return Date (year);
iss >> year >> tmp;
if ( tmp. empty ()
&& isYear (year)
)
return Date (year);
break;
case fmt_YMD:
iss >> year >> c1 >> month >> c2 >> day >> tmp;
month--;
day--;
if ( tmp. empty ()
&& isYear (year)
&& isMonth (month)
&& isDay (day)
&& c1 == c2
)
return Date (year, (char) month, (char) day);
break;
default: throw runtime_error (FUNC "Unknown date format");
}
return Date ();
}



bool Date::operator<= (const Date &other) const
bool Date::less (const Date &other,
bool equal) const
{
LESS_PART (*this, other, year);
LESS_PART (*this, other, month);
LESS_PART (*this, other, day);
return true;
return equal;
}


Expand Down
14 changes: 12 additions & 2 deletions tsv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace Common_sp

struct Date : Root
{
enum Format {fmt_Year, fmt_None}; // not complete list ??
enum Format {fmt_Year, fmt_YMD, fmt_None}; // not complete list ??
short year {0};
char month {0};
// 0 .. 12 - 1
Expand All @@ -66,6 +66,10 @@ struct Date : Root
{}
static bool isYear (short n)
{ return n > 1000 && n < 2500; } // PAR
static bool isMonth (short n)
{ return between<short> (n, 0, 12); }
static bool isDay (short n)
{ return between<short> (n, 0, 31); } // Must depend on month ??
static Date parse (const string &s,
Format fmt);
// Return: !empty() <=> success
Expand Down Expand Up @@ -94,7 +98,12 @@ struct Date : Root
&& month == other. month
&& day == other. day;
}
bool operator<= (const Date &other) const;
bool less (const Date &other,
bool equal) const;
bool operator<= (const Date &other) const
{ return less (other, true); }
bool operator< (const Date &other) const
{ return less (other, false); }
Date operator- (const Date &other) const;
// Requires: other <= *this
};
Expand All @@ -120,6 +129,7 @@ struct TextTable : Named
static constexpr size_t choices_max {7}; // PAR
Set<string> choices;
// size() <= choices_max + 1
Header () = default;
explicit Header (const string &name_arg)
: Named (name_arg)
{}
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.12.20
3.12.21

0 comments on commit a10f791

Please sign in to comment.