build_ref_db: fixed bug erasing some of the higher LCAs (i.e. lowest
similarities)
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
major = 3
|
major = 3
|
||||||
minor = 0
|
minor = 0
|
||||||
serial= '0-beta14e'
|
serial= '0-beta15'
|
||||||
|
|
||||||
version ="%d.%02d.%s" % (major,minor,serial)
|
version ="%d.%02d.%s" % (major,minor,serial)
|
||||||
|
@ -477,6 +477,8 @@ int build_reference_db(const char* dms_name,
|
|||||||
// Read alignment score
|
// Read alignment score
|
||||||
score = obi_get_float_with_elt_idx_and_col_p_in_view(matrix_with_lca_view, matrix_score_column, i, 0);
|
score = obi_get_float_with_elt_idx_and_col_p_in_view(matrix_with_lca_view, matrix_score_column, i, 0);
|
||||||
|
|
||||||
|
//fprintf(stderr, "\n\ntaxid_lca=%d, score=%f, idx1=%d, idx2=%d", taxid_lca, score, idx1, idx2);
|
||||||
|
|
||||||
///////////////// Compute for first sequence \\\\\\\\\\\\\\\\\\\\\\\ (TODO function)
|
///////////////// Compute for first sequence \\\\\\\\\\\\\\\\\\\\\\\ (TODO function)
|
||||||
|
|
||||||
// Read arrays
|
// Read arrays
|
||||||
@ -493,9 +495,11 @@ int build_reference_db(const char* dms_name,
|
|||||||
// return -1;
|
// return -1;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
//fprintf(stderr, "\n1st sequence");
|
||||||
// If empty, add values
|
// If empty, add values
|
||||||
if (taxid_array_length == 0)
|
if (taxid_array_length == 0)
|
||||||
{
|
{
|
||||||
|
//fprintf(stderr, "\nEmpty, add value");
|
||||||
if (obi_set_array_with_col_p_in_view(o_view, final_lca_taxid_a_column, idx1, &taxid_lca, (uint8_t) (obi_sizeof(OBI_INT) * 8), 1) < 0)
|
if (obi_set_array_with_col_p_in_view(o_view, final_lca_taxid_a_column, idx1, &taxid_lca, (uint8_t) (obi_sizeof(OBI_INT) * 8), 1) < 0)
|
||||||
{
|
{
|
||||||
obidebug(1, "\nError setting a LCA taxid array in a column when building a reference database");
|
obidebug(1, "\nError setting a LCA taxid array in a column when building a reference database");
|
||||||
@ -509,6 +513,8 @@ int build_reference_db(const char* dms_name,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
//fprintf(stderr, "\nNot empty");
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
modified = false;
|
modified = false;
|
||||||
while (j < taxid_array_length)
|
while (j < taxid_array_length)
|
||||||
@ -522,6 +528,9 @@ int build_reference_db(const char* dms_name,
|
|||||||
memcpy(score_array_writable, score_array, score_array_length*sizeof(obifloat_t));
|
memcpy(score_array_writable, score_array, score_array_length*sizeof(obifloat_t));
|
||||||
modified = true;
|
modified = true;
|
||||||
|
|
||||||
|
//fprintf(stderr, "\nSame LCA, replace %d and %f with %d and %f", lca_taxid_array_writable[j],
|
||||||
|
// score_array_writable[j], taxid_lca, score);
|
||||||
|
|
||||||
// Better score for the same LCA, replace this LCA/score pair
|
// Better score for the same LCA, replace this LCA/score pair
|
||||||
lca_taxid_array_writable[j] = taxid_lca;
|
lca_taxid_array_writable[j] = taxid_lca;
|
||||||
score_array_writable[j] = score;
|
score_array_writable[j] = score;
|
||||||
@ -548,6 +557,8 @@ int build_reference_db(const char* dms_name,
|
|||||||
{
|
{
|
||||||
if (score > score_array[j])
|
if (score > score_array[j])
|
||||||
{
|
{
|
||||||
|
//fprintf(stderr, "\nInsert new");
|
||||||
|
|
||||||
memcpy(lca_taxid_array_writable, lca_taxid_array, taxid_array_length*sizeof(obiint_t));
|
memcpy(lca_taxid_array_writable, lca_taxid_array, taxid_array_length*sizeof(obiint_t));
|
||||||
memcpy(score_array_writable, score_array, score_array_length*sizeof(obifloat_t));
|
memcpy(score_array_writable, score_array, score_array_length*sizeof(obifloat_t));
|
||||||
modified = true;
|
modified = true;
|
||||||
@ -592,10 +603,15 @@ int build_reference_db(const char* dms_name,
|
|||||||
memcpy(score_array_writable, score_array, score_array_length*sizeof(obifloat_t));
|
memcpy(score_array_writable, score_array, score_array_length*sizeof(obifloat_t));
|
||||||
modified = true;
|
modified = true;
|
||||||
|
|
||||||
|
//fprintf(stderr, "\nAppend at the end");
|
||||||
|
|
||||||
// Append LCA
|
// Append LCA
|
||||||
lca_taxid_array_writable[taxid_array_writable_length] = taxid_lca;
|
lca_taxid_array_writable[taxid_array_writable_length] = taxid_lca;
|
||||||
score_array_writable[score_array_writable_length] = score;
|
score_array_writable[score_array_writable_length] = score;
|
||||||
|
|
||||||
|
taxid_array_writable_length++;
|
||||||
|
score_array_writable_length++;
|
||||||
|
|
||||||
// Remove the previous (children) LCAs from the array if their score is equal or lower
|
// Remove the previous (children) LCAs from the array if their score is equal or lower
|
||||||
while ((j>0) && (score_array_writable[j-1] <= score))
|
while ((j>0) && (score_array_writable[j-1] <= score))
|
||||||
{
|
{
|
||||||
@ -616,6 +632,13 @@ int build_reference_db(const char* dms_name,
|
|||||||
// Write new arrays
|
// Write new arrays
|
||||||
if (modified)
|
if (modified)
|
||||||
{
|
{
|
||||||
|
// fprintf(stderr, "\n\nnew array:");
|
||||||
|
// for (k=0;k<taxid_array_writable_length;k++)
|
||||||
|
// {
|
||||||
|
// lca = obi_taxo_get_taxon_with_taxid(tax, lca_taxid_array_writable[k]);
|
||||||
|
// fprintf(stderr, "\nLCA=%d, %s, score=%f", lca_taxid_array_writable[k], lca->name, score_array_writable[k]);
|
||||||
|
// }
|
||||||
|
|
||||||
if (obi_set_array_with_col_p_in_view(o_view, final_lca_taxid_a_column, idx1, lca_taxid_array_writable, (uint8_t) (obi_sizeof(OBI_INT) * 8), taxid_array_writable_length) < 0)
|
if (obi_set_array_with_col_p_in_view(o_view, final_lca_taxid_a_column, idx1, lca_taxid_array_writable, (uint8_t) (obi_sizeof(OBI_INT) * 8), taxid_array_writable_length) < 0)
|
||||||
{
|
{
|
||||||
obidebug(1, "\nError setting a LCA taxid array in a column when building a reference database");
|
obidebug(1, "\nError setting a LCA taxid array in a column when building a reference database");
|
||||||
@ -645,9 +668,13 @@ int build_reference_db(const char* dms_name,
|
|||||||
// return -1;
|
// return -1;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
//fprintf(stderr, "\n2nd sequence");
|
||||||
|
|
||||||
// If empty, add values
|
// If empty, add values
|
||||||
if (taxid_array_length == 0)
|
if (taxid_array_length == 0)
|
||||||
{
|
{
|
||||||
|
//fprintf(stderr, "\nEmpty, add value");
|
||||||
|
|
||||||
if (obi_set_array_with_col_p_in_view(o_view, final_lca_taxid_a_column, idx2, &taxid_lca, (uint8_t) (obi_sizeof(OBI_INT) * 8), 1) < 0)
|
if (obi_set_array_with_col_p_in_view(o_view, final_lca_taxid_a_column, idx2, &taxid_lca, (uint8_t) (obi_sizeof(OBI_INT) * 8), 1) < 0)
|
||||||
{
|
{
|
||||||
obidebug(1, "\nError setting a LCA taxid array in a column when building a reference database");
|
obidebug(1, "\nError setting a LCA taxid array in a column when building a reference database");
|
||||||
@ -661,6 +688,8 @@ int build_reference_db(const char* dms_name,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
//fprintf(stderr, "\nNot empty");
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
modified = false;
|
modified = false;
|
||||||
while (j < taxid_array_length)
|
while (j < taxid_array_length)
|
||||||
@ -674,6 +703,9 @@ int build_reference_db(const char* dms_name,
|
|||||||
memcpy(score_array_writable, score_array, score_array_length*sizeof(obifloat_t));
|
memcpy(score_array_writable, score_array, score_array_length*sizeof(obifloat_t));
|
||||||
modified = true;
|
modified = true;
|
||||||
|
|
||||||
|
//fprintf(stderr, "\nSame LCA, replace %d and %f with %d and %f", lca_taxid_array_writable[j],
|
||||||
|
// score_array_writable[j], taxid_lca, score);
|
||||||
|
|
||||||
// Better score for the same LCA, replace this LCA/score pair
|
// Better score for the same LCA, replace this LCA/score pair
|
||||||
lca_taxid_array_writable[j] = taxid_lca;
|
lca_taxid_array_writable[j] = taxid_lca;
|
||||||
score_array_writable[j] = score;
|
score_array_writable[j] = score;
|
||||||
@ -700,6 +732,8 @@ int build_reference_db(const char* dms_name,
|
|||||||
{
|
{
|
||||||
if (score > score_array[j])
|
if (score > score_array[j])
|
||||||
{
|
{
|
||||||
|
//fprintf(stderr, "\nInsert new");
|
||||||
|
|
||||||
memcpy(lca_taxid_array_writable, lca_taxid_array, taxid_array_length*sizeof(obiint_t));
|
memcpy(lca_taxid_array_writable, lca_taxid_array, taxid_array_length*sizeof(obiint_t));
|
||||||
memcpy(score_array_writable, score_array, score_array_length*sizeof(obifloat_t));
|
memcpy(score_array_writable, score_array, score_array_length*sizeof(obifloat_t));
|
||||||
modified = true;
|
modified = true;
|
||||||
@ -740,6 +774,8 @@ int build_reference_db(const char* dms_name,
|
|||||||
|
|
||||||
if (j == taxid_array_length) // same or parent LCA not found, need to be appended at the end
|
if (j == taxid_array_length) // same or parent LCA not found, need to be appended at the end
|
||||||
{
|
{
|
||||||
|
//fprintf(stderr, "\nAppend at the end");
|
||||||
|
|
||||||
memcpy(lca_taxid_array_writable, lca_taxid_array, taxid_array_length*sizeof(obiint_t));
|
memcpy(lca_taxid_array_writable, lca_taxid_array, taxid_array_length*sizeof(obiint_t));
|
||||||
memcpy(score_array_writable, score_array, score_array_length*sizeof(obifloat_t));
|
memcpy(score_array_writable, score_array, score_array_length*sizeof(obifloat_t));
|
||||||
modified = true;
|
modified = true;
|
||||||
@ -748,6 +784,9 @@ int build_reference_db(const char* dms_name,
|
|||||||
lca_taxid_array_writable[taxid_array_writable_length] = taxid_lca;
|
lca_taxid_array_writable[taxid_array_writable_length] = taxid_lca;
|
||||||
score_array_writable[score_array_writable_length] = score;
|
score_array_writable[score_array_writable_length] = score;
|
||||||
|
|
||||||
|
taxid_array_writable_length++;
|
||||||
|
score_array_writable_length++;
|
||||||
|
|
||||||
// Remove the previous (children) LCAs from the array if their score is equal or lower
|
// Remove the previous (children) LCAs from the array if their score is equal or lower
|
||||||
while ((j>0) && (score_array_writable[j-1] <= score))
|
while ((j>0) && (score_array_writable[j-1] <= score))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user