Commit a99e6272 authored by Haowen Zhang's avatar Haowen Zhang
Browse files

Merge branch 'li_dev' into haowen_dev

Conflicts:
	src/chromap.cc
parents 60efd798 34a6ec8d
Loading
Loading
Loading
Loading
+18 −10
Original line number Diff line number Diff line
@@ -1463,8 +1463,11 @@ void Chromap<MappingRecord>::ProcessBestMappingsForPairedEndReadOnOneDirection(D
          split_site1 = split_sites1[i1];
          split_site2 = split_sites2[i2];
        }
        GetRefStartEndPositionForReadFromMapping(first_read_direction, mappings1[i1], effect_read1, read1_length, split_site1, reference, &ref_start_position1, &ref_end_position1, &n_cigar1, &cigar1, &NM1, MD_tag1);
        GetRefStartEndPositionForReadFromMapping(second_read_direction, mappings2[i2], effect_read2, read2_length, split_site2, reference, &ref_start_position2, &ref_end_position2, &n_cigar2, &cigar2, &NM2, MD_tag2);
        GetRefStartEndPositionForReadFromMapping(first_read_direction, mappings1[i1], effect_read1, read1_length, split_site1, 
            reference, &ref_start_position1, &ref_end_position1, &n_cigar1, &cigar1, &NM1, MD_tag1) ;
        GetRefStartEndPositionForReadFromMapping(second_read_direction, mappings2[i2], effect_read2, read2_length, 
            split_site2, reference, &ref_start_position2, &ref_end_position2, 
            &n_cigar2, &cigar2, &NM2, MD_tag2) ;
        /*if (!strcmp(read_batch1.GetSequenceNameAt(pair_index), "XXXX")) {
          printf("%d\n", best_mappings.size());
          printf("%d. %d %d\n", min_sum_errors, i1, i2);
@@ -1513,13 +1516,17 @@ void Chromap<MappingRecord>::ProcessBestMappingsForPairedEndReadOnOneDirection(D
          }

          if (rid1 < rid2 || (rid1 == rid2 && position1 < position2)) {
            EmplaceBackMappingRecord(read_id, read1_name, barcode_key, rid1, rid2, position1, position2, direction, direction2, mapq, is_unique, 1, &((*mappings_on_diff_ref_seqs)[rid1]));
            EmplaceBackMappingRecord(read_id, read1_name, barcode_key, 
                rid1, rid2, position1, position2, direction, direction2, mapq, is_unique, 1,
                &((*mappings_on_diff_ref_seqs)[rid1])) ;
          } else {
            EmplaceBackMappingRecord(read_id, read1_name, barcode_key, rid2, rid1, position2, position1, direction2, direction, mapq, is_unique, 1, &((*mappings_on_diff_ref_seqs)[rid2]));
            EmplaceBackMappingRecord(read_id, read1_name, barcode_key, 
                rid2, rid1, position2, position1, direction2, direction, mapq, is_unique, 1,
                &((*mappings_on_diff_ref_seqs)[rid2])) ;
          }
        } else if (output_mapping_in_PAF_) {
          uint32_t fragment_start_position = ref_start_position1;
          uint16_t fragment_length = ref_end_position2 - ref_start_position1 + 1;
          uint16_t fragment_length = ref_end_position2 - ref_start_position1 + 1;;
          uint16_t positive_alignment_length = ref_end_position1 - ref_start_position1 + 1;
          uint16_t negative_alignment_length = ref_end_position2 - ref_start_position2 + 1;
          if (direction == 0) {
@@ -1542,7 +1549,7 @@ void Chromap<MappingRecord>::ProcessBestMappingsForPairedEndReadOnOneDirection(D
          }
          EmplaceBackMappingRecord(read_id, barcode_key, fragment_start_position, fragment_length, mapq, direction, is_unique, 1, positive_alignment_length, negative_alignment_length, &((*mappings_on_diff_ref_seqs)[rid1]));
        }
      }
        (*num_best_mappings_reported)++;
        if (*num_best_mappings_reported == std::min(max_num_best_mappings_, num_best_mappings)) {
          break;
        }
@@ -1550,6 +1557,7 @@ void Chromap<MappingRecord>::ProcessBestMappingsForPairedEndReadOnOneDirection(D
      (*best_mapping_index)++;
    }
  }
}

template <typename MappingRecord>
void Chromap<MappingRecord>::GenerateBestMappingsForPairedEndRead(uint32_t pair_index, int num_positive_candidates1, int num_negative_candidates1, uint32_t repetitive_seed_length1, int min_num_errors1, int num_best_mappings1, int second_min_num_errors1, int num_second_best_mappings1, const SequenceBatch &read_batch1, const std::vector<std::pair<int, uint64_t> > &positive_mappings1, const std::vector<int> &positive_split_sites1, const std::vector<std::pair<int, uint64_t> > &negative_mappings1, const std::vector<int> &negative_split_sites1, int num_positive_candidates2, int num_negative_candidates2, uint32_t repetitive_seed_length2, int min_num_errors2, int num_best_mappings2, int second_min_num_errors2, int num_second_best_mappings2, const SequenceBatch &read_batch2, const SequenceBatch &reference, const SequenceBatch &barcode_batch, const std::vector<std::pair<int, uint64_t> > &positive_mappings2, const std::vector<int> &positive_split_sites2, const std::vector<std::pair<int, uint64_t> > &negative_mappings2, const std::vector<int> &negative_split_sites2, std::vector<int> *best_mapping_indices, std::mt19937 *generator, std::vector<std::pair<uint32_t, uint32_t> > *F1R2_best_mappings, std::vector<std::pair<uint32_t, uint32_t> > *F2R1_best_mappings, std::vector<std::pair<uint32_t, uint32_t> > *F1F2_best_mappings, std::vector<std::pair<uint32_t, uint32_t> > *R1R2_best_mappings, int *min_sum_errors, int *num_best_mappings, int *second_min_sum_errors, int *num_second_best_mappings, std::vector<std::vector<MappingRecord> > *mappings_on_diff_ref_seqs) {