Skip to content

Commit

Permalink
PD-5064 AMBIGUOUS operon type
Browse files Browse the repository at this point in the history
  • Loading branch information
Vyacheslav Brover committed Jul 29, 2024
1 parent 364cade commit b2d39f6
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 12 deletions.
2 changes: 1 addition & 1 deletion common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4032,7 +4032,7 @@ int Application::run (int argc,
}
catch (const std::exception &e)
{
errorExit ((e. what () + ifS (errno, string ("\n") + strerror (errno))). c_str ());
errorExit ((ifS (errno, strerror (errno) + string ("\n")) + e. what ()). c_str ());
}


Expand Down
8 changes: 8 additions & 0 deletions common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1487,6 +1487,14 @@ inline string colorize (const string &s,
return s;
return Color::code (Color::white, true) + s + Color::code ();
}

inline string colorizeUrl (const string &s,
bool active)
{ const string prefix ("https://");
if (! active)
return prefix + s;
return Color::code (Color::blue, true) + prefix + s + Color::code ();
}


class OColor
Expand Down
52 changes: 42 additions & 10 deletions stxtyper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
* Dependencies: NCBI BLAST, gunzip (optional)
*
* Release changes:
* 1.0.21 07/15/2024 PD-5038 ----nucleotide_output
* 1.0.23 07/29/2024 PD-5064 AMBIGUOUS operon type
* 1.0.22 07/25/2024 First codon L|I|V -> M
* 1.0.21 07/15/2024 PD-5038 --nucleotide_output
* 1.0.20 05/21/2024 PD-5002 {A|B}_reference_subtype
* 1.0.19 03/26/2024 BlastAlignment::targetAlign is removed
* 1.0.18 03/19/2024 PD-4910 Element symbol is <stx type>_operon, Element name contains operon quality attribute"
Expand Down Expand Up @@ -136,7 +138,7 @@ string stxType_reported_operon2elementName (const string &stxType_reported,

struct BlastAlignment
{
size_t length {0}, nident {0} // aa
size_t length {0}, nident {0}, positives {0} // aa
, refStart {0}, refEnd {0}, refLen {0}
, targetStart {0}, targetEnd {0}, targetLen {0};
// Positions are 0-based
Expand Down Expand Up @@ -201,10 +203,27 @@ struct BlastAlignment

length = targetSeq. size ();
nident = 0;
positives = 0;
QC_ASSERT (targetSeq. size () == refSeq. size ());
FFOR (size_t, i, targetSeq. size ())
if (targetSeq [i] == refSeq [i])
{
nident++;
positives++;
}
else
if ( targetSeq [i] == 'X'
|| refSeq [i] == 'X'
)
positives++;
if ( refStart == 0
&& charInSet (targetSeq [0], "LIV")
&& refSeq [0] == 'M'
)
{
nident++;
positives++;
}

stxClass = stxType;
if ( stxType == "2a"
Expand Down Expand Up @@ -241,14 +260,16 @@ struct BlastAlignment
return;
QC_ASSERT (length);
QC_ASSERT (nident);
QC_ASSERT (nident <= length);
QC_ASSERT (nident <= positives);
//QC_ASSERT (nident <= length);
QC_ASSERT (positives <= length);
QC_ASSERT (targetStart < targetEnd);
QC_ASSERT (targetEnd <= targetLen);
QC_ASSERT (refStart < refEnd);
QC_ASSERT (refEnd <= refLen);
if (! frameshift)
{
QC_ASSERT (nident <= refEnd - refStart);
QC_ASSERT (positives <= refEnd - refStart);
QC_ASSERT (refEnd - refStart <= length);
}
QC_ASSERT (! targetName. empty ());
Expand Down Expand Up @@ -359,9 +380,12 @@ struct BlastAlignment
refStart = prev. refStart;
else
refEnd = prev. refEnd;
length += prev. length; // Approximately
nident += prev. nident; // Approximately
// Approximately
length += prev. length;
nident += prev. nident;
positives += prev. positives;
//targetAlign += prev. targetAlign;
//
if (prev. stopCodon)
stopCodon = true;
frameshift = true;
Expand Down Expand Up @@ -402,6 +426,8 @@ struct BlastAlignment
s += string (len - refEnd, '-');
return s;
}
bool ambig () const
{ return nident < positives; }
static bool frameshiftLess (const BlastAlignment* a,
const BlastAlignment* b)
{ ASSERT (a);
Expand Down Expand Up @@ -502,7 +528,7 @@ struct Operon
string stxType (getStxType (verboseP));
const string standard ("COMPLETE");
const bool novel = al1->stxClass != al2->stxClass
|| getIdentity () < stxClass2identity [al1->stxClass] // May be due to X's
|| getIdentity () < stxClass2identity [al1->stxClass]
|| stxType. size () <= 1;
const string operonType = getA () -> frameshift
|| getB () -> frameshift
Expand All @@ -514,12 +540,14 @@ struct Operon
|| getB () -> truncated ()
? "PARTIAL_CONTIG_END"
: partial ()
? "PARTIAL"
? "PARTIAL" // Complete ??
: getA () -> getExtended ()
|| getB () -> getExtended ()
? "EXTENDED"
? "EXTENDED" // Complete ??
: novel
? standard + "_NOVEL"
? ambig ()
? "AMBIGUOUS"
: standard + "_NOVEL"
: standard;
if (! verboseP)
{
Expand Down Expand Up @@ -650,6 +678,10 @@ struct Operon
{ return (getA () -> getRelCoverage () < 1.0 && ! getA () -> getExtended ())
|| (getB () -> getRelCoverage () < 1.0 && ! getB () -> getExtended ());
}
bool ambig () const
{ return getA () -> ambig ()
|| getB () -> ambig ();
}
public:
double getIdentity () const
{ return double (al1->nident + al2->nident) / double (al1->length/*refLen*/ + al2->length/*refLen*/); }
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.21
1.0.23

0 comments on commit b2d39f6

Please sign in to comment.