Exemplo n.º 1
0
static void close_output_files(Store_in_subset_file_data
                               *store_in_subset_file_data)
{
  unsigned long i;
  GtStr *buf;

  buf = gt_str_new();
  for (i = 0; i < store_in_subset_file_data->num_of_subset_files; i++) {
    if (store_in_subset_file_data->subset_files[i]) {
      if (store_in_subset_file_data->gthsplitinfo->showverbose) {
        gt_str_reset(buf);
        gt_str_append_cstr(buf, "split file created: ");
        gt_str_append_str(buf, store_in_subset_file_data->subset_filenames[i]);
        gt_str_append_cstr(buf, " (size=");
        gt_str_append_ulong(buf,
                          store_in_subset_file_data->subset_file_sa_counter[i]);
        gt_str_append_cstr(buf, ")");
        store_in_subset_file_data->gthsplitinfo->showverbose(gt_str_get(buf));
      }
      gt_assert(store_in_subset_file_data->subset_filenames[i]);
      /* put XML trailer in file before closing it */
      gth_xml_show_trailer(true, store_in_subset_file_data->subset_files[i]);
      gt_file_delete(store_in_subset_file_data->subset_files[i]);
      gt_str_delete(store_in_subset_file_data->subset_filenames[i]);
      store_in_subset_file_data->subset_files[i]           = NULL;
      store_in_subset_file_data->subset_file_sa_counter[i] = 0;
    }
  }
  gt_str_delete(buf);
}
int gth_similarity_filter(GthCallInfo *call_info, GthInput *input,
                          GthStat *stat, unsigned int indentlevel,
                          const GthPlugins *plugins, GT_UNUSED GtError *err)
{
  GthSACollection *sa_collection; /* stores the calculated spliced alignments */

  gt_error_check(err);

  /* initialization */
  sa_collection = gth_sa_collection_new(call_info->duplicate_check);

  /* compute the spliced alignments */
  if (compute_sa_collection(sa_collection, call_info, input, stat, plugins)) {
    gth_sa_collection_delete(sa_collection);
    return -1;
  }

  /* process the alignments */
  gth_proc_sa_collection(sa_collection, call_info, input, stat, indentlevel);

  /* show XML trailer */
  if (call_info->out->xmlout) {
    gth_xml_show_trailer(call_info->intermediate, call_info->out->outfp);
  }

  /* output statistics */
  if (!call_info->out->gff3out)
    gth_stat_show(stat, true, call_info->out->xmlout, call_info->out->outfp);

#ifndef NDEBUG
  if (call_info->intermediate && call_info->out->outputfile) {
    /* intermediate output equals tree of alignments */
    gt_assert(gth_intermediate_output_is_correct(call_info->out->outputfile,
                                                 sa_collection, input,
                                                 &call_info->out->outfp, err));
  }
#endif

  /* free spliced alignment collection */
  gth_sa_collection_delete(sa_collection);

  return 0;
}