Skip to content

Commit

Permalink
Fix compilation on Clang and MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
althonos committed May 18, 2024
1 parent 1562471 commit d354cd0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 5 additions & 8 deletions pyrodigal/_sequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ static inline char _amino(const uint8_t* digits, const int slen, const int i, co
const char* table = _TT[tt];
uint_fast32_t x0, x1, x2;

inline size_t offset(size_t x0, size_t x1, size_t x2) {
return (x0 << 4) + (x1 << 2) + x2;
}

if (strand == 1) {
x0 = digits[i];
Expand All @@ -91,26 +88,26 @@ static inline char _amino(const uint8_t* digits, const int slen, const int i, co
}

if ((x0 <= T) && (x1 <= T) && (x2 <= T)) {
return _TT[tt][offset(x0, x1, x2)];
return _translate_codon(tt, x0, x1, x2);
}

if (strict) {
return 'X';
}

if ((x0 <= T) && (x1 <= T) && (x2 > T)) {
char aa = _TT[tt][offset(x0, x1, A)];
char aa = _translate_codon(tt, x0, x1, A);
for (x2 = G; x2 <= T; x2++) {
if (_TT[tt][offset(x0, x1, x2)] != aa)
if (_translate_codon(tt, x0, x1, x2) != aa)
return 'X';
}
return aa;
}

if ((x0 <= T) && (x1 > T) && (x2 <= T)) {
char aa = _TT[tt][offset(x0, A, x2)];
char aa = _translate_codon(tt, x0, A, x2);
for (x1 = G; x1 <= T; x2++) {
if (_TT[tt][offset(x0, x1, x2)] != aa)
if (_translate_codon(tt, x0, x1, x2) != aa)
return 'X';
}
return aa;
Expand Down
4 changes: 4 additions & 0 deletions pyrodigal/_translation.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,9 @@ const char* _TT[34] = {
_TT30, _TT31, _TT32, _TT33
};

static inline size_t _translate_codon(size_t tt, size_t x0, size_t x1, size_t x2) {
size_t offset = (x0 << 4) + (x1 << 2) + x2;
return _TT[tt][offset];
}

#endif

0 comments on commit d354cd0

Please sign in to comment.