void gt_write_stream(gt_output_file* output, gt_input_file** inputs, uint64_t num_inputs, bool append_extra, bool clean_id, bool interleave, uint64_t threads, bool write_map, bool remove_scores){
  // prepare attributes

  gt_output_fasta_attributes* attributes = 0;
  gt_output_map_attributes* map_attributes = 0;
  if(!write_map){
    attributes = gt_output_fasta_attributes_new();
    gt_output_fasta_attributes_set_print_extra(attributes, append_extra);
    gt_output_fasta_attributes_set_print_casava(attributes, !clean_id);
    // check qualities
    if(!gt_input_file_has_qualities(inputs[0])){
      gt_output_fasta_attributes_set_format(attributes, F_FASTA);
    }
  }else{

    map_attributes = gt_output_map_attributes_new();
    gt_output_map_attributes_set_print_extra(map_attributes, append_extra);
    gt_output_map_attributes_set_print_casava(map_attributes, !clean_id);
    gt_output_map_attributes_set_print_scores(map_attributes, !remove_scores);
  }

  // generic parser attributes
  gt_generic_parser_attributes* parser_attributes = gt_input_generic_parser_attributes_new(false); // do not force pairs
  pthread_mutex_t input_mutex = PTHREAD_MUTEX_INITIALIZER;

  if(interleave){
    // main loop, interleave
    #pragma omp parallel num_threads(threads)
    {
      register uint64_t i = 0;
      register uint64_t c = 0;
      gt_buffered_output_file* buffered_output = gt_buffered_output_file_new(output);
      gt_buffered_input_file** buffered_input = malloc(num_inputs * sizeof(gt_buffered_input_file*));

      for(i=0; i<num_inputs; i++){
        buffered_input[i] = gt_buffered_input_file_new(inputs[i]);
      }
      // attache first input to output
      gt_buffered_input_file_attach_buffered_output(buffered_input[0], buffered_output);

      gt_template* template = gt_template_new();
      gt_status status;
      i=0;
      while( gt_input_generic_parser_synch_blocks_a(&input_mutex, buffered_input, num_inputs, parser_attributes) == GT_STATUS_OK ){
        for(i=0; i<num_inputs; i++){
          if( (status = gt_input_generic_parser_get_template(buffered_input[i], template, parser_attributes)) == GT_STATUS_OK){
            if(write_map){
              gt_output_map_bofprint_template(buffered_output, template, map_attributes);
            }else{
Beispiel #2
0
void gt_stats_fill(gt_input_file* input_file, gt_stats* target_all_stats, gt_stats* target_best_stats, uint64_t num_threads, bool paired_end){
// Stats info
  gt_stats** all_stats = malloc(num_threads*sizeof(gt_stats*));
  all_stats[0] = target_all_stats;
  gt_stats** best_stats = malloc(num_threads*sizeof(gt_stats*));
  best_stats[0] = target_best_stats;

  gt_stats_analysis params_all = GT_STATS_ANALYSIS_DEFAULT();
  params_all.best_map = false;
  gt_stats_analysis params_best = GT_STATS_ANALYSIS_DEFAULT();
  params_best.best_map = true;

  //params_all.indel_profile = true
  // Parallel reading+process
  #pragma omp parallel num_threads(num_threads)
  {
    uint64_t tid = omp_get_thread_num();
    gt_buffered_input_file* buffered_input = gt_buffered_input_file_new(input_file);

    gt_status error_code;
    gt_template *template = gt_template_new();
Beispiel #3
0
/*
 * CORE functions
 */
void gt_stats_parallel_generate_stats() {
  // Stats info
  gt_stats_analysis stats_analysis = GT_STATS_ANALYSIS_DEFAULT();
  gt_stats** stats = malloc(parameters.num_threads*sizeof(gt_stats*));

  // Select analysis
  stats_analysis.best_map = parameters.best_map;
  stats_analysis.maps_profile = parameters.maps_profile|parameters.mismatch_quality|parameters.mismatch_transitions;
  stats_analysis.nucleotide_stats = true;
  stats_analysis.split_map_stats = parameters.splitmaps_profile;
  stats_analysis.indel_profile = parameters.indel_profile;

  // Open file
  gt_input_file* input_file = (parameters.name_input_file==NULL) ?
      gt_input_stream_open(stdin) : gt_input_file_open(parameters.name_input_file,parameters.mmap_input);

  gt_sequence_archive* sequence_archive = NULL;
  if (stats_analysis.indel_profile) {
    sequence_archive = gt_sequence_archive_new();
    register gt_input_file* const reference_file = gt_input_file_open(parameters.name_reference_file,false);
    fprintf(stderr,"Loading reference file ...");
    if (gt_input_multifasta_parser_get_archive(reference_file,sequence_archive)!=GT_IFP_OK) {
      fprintf(stderr,"\n");
      gt_fatal_error_msg("Error parsing reference file '%s'\n",parameters.name_reference_file);
    }
    gt_input_file_close(reference_file);
    fprintf(stderr," done! \n");
  }

  // Parallel reading+process
  #pragma omp parallel num_threads(parameters.num_threads)
  {
    uint64_t tid = omp_get_thread_num();
    gt_buffered_input_file* buffered_input = gt_buffered_input_file_new(input_file);

    gt_status error_code;
    gt_template *template = gt_template_new();