diff --git a/python/obitools3/commands/clean.pyx b/python/obitools3/commands/clean.pyx index b4848fd..72aa918 100755 --- a/python/obitools3/commands/clean.pyx +++ b/python/obitools3/commands/clean.pyx @@ -36,8 +36,7 @@ def addOptions(parser): dest="clean:sample-tag-name", metavar="", type=str, - default="merged_sample", - help="Name of the tag where sample counts are kept.") + help="Name of the tag where merged sample count informations are kept (typically generated by obi uniq, usually MERGED_sample, default: None).") group.add_argument('--ratio', '-r', action="store", dest="clean:ratio", @@ -107,6 +106,9 @@ def run(config): command_line = " ".join(sys.argv[1:]) comments = View.print_config(config, "clean", command_line, input_dms_name=[i_dms_name], input_view_name=[i_view_name]) + if 'sample-tag-name' not in config['clean']: + config['clean']['sample-tag-name'] = "" + if obi_clean(i_dms.name_with_full_path, tobytes(i_view_name), tobytes(config['clean']['sample-tag-name']), tobytes(o_view_name), comments, \ config['clean']['distance'], config['clean']['ratio'], config['clean']['heads-only'], config['clean']['thread-count']) < 0: raise Exception("Error running obiclean") diff --git a/python/obitools3/version.py b/python/obitools3/version.py index 9e360af..ecb2262 100755 --- a/python/obitools3/version.py +++ b/python/obitools3/version.py @@ -1,5 +1,5 @@ major = 3 minor = 0 -serial= '0b26' +serial= '0b26a' version ="%d.%d.%s" % (major,minor,serial) diff --git a/src/obi_clean.c b/src/obi_clean.c index 2534c95..5b69412 100755 --- a/src/obi_clean.c +++ b/src/obi_clean.c @@ -246,7 +246,16 @@ int obi_clean(const char* dms_name, // Open the sample column if there is one if ((strcmp(sample_column_name, "") == 0) || (sample_column_name == NULL)) - sample_column = NULL; + { + fprintf(stderr, "Info: No sample information provided, assuming one sample.\n"); + sample_column = obi_view_get_column(i_view, COUNT_COLUMN); + if (sample_column == NULL) + { + obidebug(1, "\nError getting the COUNT column"); + return -1; + } + sample_count = 1; + } else { sample_column = obi_view_get_column(i_view, sample_column_name); @@ -255,6 +264,13 @@ int obi_clean(const char* dms_name, obidebug(1, "\nError getting the sample column"); return -1; } + sample_count = (sample_column->header)->nb_elements_per_line; + // Check that the sample column is a merged column with all sample informations + if (sample_count == 1) + { + obidebug(1, "\n\nError: If a sample column is provided, it must contain 'merged' sample counts as built by obi uniq with the -m option\n"); + return -1; + } } // Create the output view, or a temporary one if heads only @@ -279,8 +295,6 @@ int obi_clean(const char* dms_name, return -1; } - sample_count = (sample_column->header)->nb_elements_per_line; - // Create the output columns if (create_output_columns(o_view, sample_column, sample_count) < 0) { @@ -549,7 +563,7 @@ int obi_clean(const char* dms_name, if (heads_only) { - line_selection = malloc((o_view->infos)->line_count * sizeof(index_t)); + line_selection = malloc((((o_view->infos)->line_count) + 1) * sizeof(index_t)); if (line_selection == NULL) { obi_set_errno(OBI_MALLOC_ERROR); diff --git a/src/obi_clean.h b/src/obi_clean.h index 35011c8..c4293ac 100755 --- a/src/obi_clean.h +++ b/src/obi_clean.h @@ -52,7 +52,8 @@ * * @param dms A pointer on an OBIDMS. * @param i_view_name The name of the input view. - * @param sample_column_name The name of the OBI_STR column in the input view where the sample information is kept. + * @param sample_column_name The name of the column in the input view where the sample information is kept. + * Must be merged informations as built by the obi uniq tool (checked by the function). * NULL or "" (empty string) if there is no sample information. * @param o_view_name The name of the output view where the results should be written (should not already exist). * @param o_view_comments The comments that should be associated with the output view.