Skip to content

Commit

Permalink
adding initial code to turn cigar strings into variants
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaceves committed Nov 3, 2023
1 parent 9f81b61 commit 076827f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
14 changes: 13 additions & 1 deletion src/primer_bed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ std::string primer::get_region() { return region; }

std::vector<std::vector<uint32_t>> cigarotype::get_cigarotypes() { return cigarotypes; }

std::vector<uint32_t> cigarotype::get_count_cigarotypes() { return count_cigarotypes; }

std::vector<uint32_t> cigarotype::get_nlengths() { return nlengths; }

int primer::get_score() { return score; }
Expand Down Expand Up @@ -287,7 +289,17 @@ int populate_pair_indices(std::vector<primer>& primers, std::string path) {
}
return 0;
}
//this must be passed by pointer due to array decay

void primer::transform_mutations() {
/*
* Take all recorded cigarotypes and transform them into positions relative to primer
*/
std::vector<std::vector<uint32_t>> cigarotypes = this->get_cigarotypes();
std::cerr << cigarotypes.size() << std::endl;
std::cerr << "hello world" << std::endl;;
}

//cigar must be passed by pointer due to array decay
void cigarotype::add_cigarotype(uint32_t *cigar , uint32_t start_pos, uint32_t nlength){
bool found = false; //have we seen this before
std::vector<uint32_t> cig;
Expand Down
8 changes: 6 additions & 2 deletions src/primer_bed.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@

class cigarotype{
protected:
std::vector<std::vector<uint32_t>> cigarotypes; //unique cigar value x = cigar, y = operation z, = length
std::vector<std::vector<uint32_t>> cigarotypes; //unique cigar value
std::vector<uint32_t> nlengths; //this is just for printing, record length og cig ops
std::vector<uint32_t> ncigarotypes; //starting pos of these cigars
std::vector<uint32_t> count_cigarotypes; //count of amount found

public:
std::vector<std::vector<uint32_t>> get_cigarotypes();
std::vector<uint32_t> get_count_cigarotypes();
std::vector<uint32_t> get_nlengths();
void add_cigarotype(uint32_t *cigar, uint32_t start_pos, uint32_t nlength);
//void transform_mutations(); //this is will process unique cigar strings into mutations/indels
int test = 12;

};
Expand Down Expand Up @@ -55,6 +56,7 @@ class primer : public cigarotype{
void set_indice(int16_t i);
void set_read_count(uint32_t rc);
void add_read_count(uint32_t rc);
void transform_mutations();
bool operator==(const primer& p) const {
return (indice == p.get_indice()) ? true : false;
}
Expand All @@ -71,5 +73,7 @@ primer get_min_start(std::vector<primer> primers);
primer get_max_end(std::vector<primer> primers);
void add_cigarotype(uint32_t *cigar, uint32_t start_pos, uint32_t nlength);
std::vector<std::vector<uint32_t>> get_cigarotypes();
std::vector<uint32_t> get_count_cigarotypes();
std::vector<uint32_t> get_nlengths();
void transform_mutations();
#endif
18 changes: 10 additions & 8 deletions src/saga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,24 +152,26 @@ int preprocess_reads(std::string bam, std::string bed, std::string bam_out,
}
}

for(uint32_t i=0; i < primers.size(); i++){
//sanity check not intended for final version
/*for(uint32_t i=0; i < primers.size(); i++){
std::cout << "primer " << i << std::endl;
primer tmp = primers[i];
std::vector<std::vector<uint32_t>> otmp = tmp.get_cigarotypes();
std::vector<uint32_t> nlengths = tmp.get_nlengths();
std::vector<uint32_t> counts = tmp.get_count_cigarotypes();
for(uint32_t j=0; j < otmp.size(); j++){
std::cerr << "cigarotype " << j << std::endl;
std::cerr << "cigarotype " << j << " counts " << counts[j] << std::endl;
std::cerr << nlengths[j] << std::endl;
for(uint32_t k = 0; k < nlengths[j]; k++){
std::cerr << "k " << k << std::endl;
std:: cerr << bam_cigar_op(otmp[j][k]) << " " << bam_cigar_oplen(otmp[j][k]) << std::endl;
}
}
if( i > 10) break;
}
}*/

//PRIMER METHOD calculate mutations from unique cigars per primer (ie. count mutations per primer efficiently)
//PRIMER METHOD calculate mutations from unique cigars per primer, outputing variant frequencies
for(uint32_t i=0; i < primers.size(); i++){
primers[i].transform_mutations();
if(i > 10) break;
}
//AMPLICON METHOD translate this into amplicon haplotype obj of mutations per primer (ie. variant freq per amplicon)
//detect fluctuating variants - iterate every position and look for fluctuation between every amplicon objects, flag these
//combine amplicon counts to get total variants
Expand Down

0 comments on commit 076827f

Please sign in to comment.