Commit 8f6e6b3a authored by Haowen Zhang's avatar Haowen Zhang
Browse files

More refactors.

1. use reference instead of pointers when necessary.
2. more new lines to separate code blocks.
3. rename GetRidRank()
4. use const when possible.
parent 6e81245c
Loading
Loading
Loading
Loading
+85 −158

File changed.

Preview size limit exceeded, changes collapsed.

+8 −7
Original line number Diff line number Diff line
@@ -353,7 +353,7 @@ class Chromap {
      std::vector<MappingRecord> *mappings_on_diff_ref_seqs);
  void ApplyTn5ShiftOnPairedEndMapping(
      uint32_t num_reference_sequences,
      std::vector<std::vector<MappingRecord> > *mappings);
      std::vector<std::vector<MappingRecord> > &mappings);

  // For single-end read mapping
  void MapSingleEndReads();
@@ -502,7 +502,7 @@ class Chromap {
      int num_second_best_mappings2, int read1_length, int read2_length,
      int force_mapq, uint8_t &mapq1, uint8_t &mapq2);
  void SortOutputMappings(uint32_t num_reference_sequences,
                          std::vector<std::vector<MappingRecord> > *mappings);
                          std::vector<std::vector<MappingRecord> > &mappings);
  void BuildAugmentedTree(uint32_t ref_id);
  uint32_t GetNumOverlappedMappings(uint32_t ref_id,
                                    const MappingRecord &mapping);
@@ -510,9 +510,9 @@ class Chromap {
  void ComputeBarcodeAbundance(uint64_t max_num_sample_barcodes);
  void UpdateBarcodeAbundance(uint32_t num_loaded_barcodes,
                              const SequenceBatch &barcode_batch);
  bool CorrectBarcodeAt(uint32_t barcode_index, SequenceBatch *barcode_batch,
                        uint64_t *num_barcode_in_whitelist,
                        uint64_t *num_corrected_barcode);
  bool CorrectBarcodeAt(uint32_t barcode_index, SequenceBatch &barcode_batch,
                        uint64_t &num_barcode_in_whitelist,
                        uint64_t &num_corrected_barcode);
  uint32_t CallPeaks(uint16_t coverage_threshold,
                     uint32_t num_reference_sequences,
                     const SequenceBatch &reference);
@@ -543,8 +543,9 @@ class Chromap {
      const SequenceBatch &reference, uint32_t *ref_start_position,
      uint32_t *ref_end_position, int *n_cigar, uint32_t **cigar, int *NM,
      std::string &MD_TAG);
  void GetRidRank(const std::string rid_order_path,
                  const SequenceBatch &reference, std::vector<int> &rid_rank);
  void GenerateCustomizedRidRank(const std::string rid_order_path,
                                 const SequenceBatch &reference,
                                 std::vector<int> &rid_rank);
  void RerankCandidatesRid(std::vector<Candidate> &candidates);
  void ParseReadFormat(const std::string &read_format);

+6 −0
Original line number Diff line number Diff line
@@ -8,26 +8,32 @@ namespace chromap {
struct MappingBuffer {
  std::vector<std::pair<uint64_t, uint64_t>> minimizers1;
  std::vector<std::pair<uint64_t, uint64_t>> minimizers2;

  std::vector<uint64_t> positive_hits1;
  std::vector<uint64_t> positive_hits2;
  std::vector<uint64_t> negative_hits1;
  std::vector<uint64_t> negative_hits2;

  std::vector<Candidate> positive_candidates1;
  std::vector<Candidate> positive_candidates2;
  std::vector<Candidate> negative_candidates1;
  std::vector<Candidate> negative_candidates2;

  std::vector<Candidate> positive_candidates1_buffer;
  std::vector<Candidate> positive_candidates2_buffer;
  std::vector<Candidate> negative_candidates1_buffer;
  std::vector<Candidate> negative_candidates2_buffer;

  std::vector<std::pair<int, uint64_t>> positive_mappings1;
  std::vector<std::pair<int, uint64_t>> positive_mappings2;
  std::vector<std::pair<int, uint64_t>> negative_mappings1;
  std::vector<std::pair<int, uint64_t>> negative_mappings2;

  std::vector<int> positive_split_sites1;
  std::vector<int> negative_split_sites1;
  std::vector<int> positive_split_sites2;
  std::vector<int> negative_split_sites2;

  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;