Skip to content

Commit

Permalink
revert some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hasindu2008 committed Sep 9, 2024
1 parent ae18190 commit 207a5e7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 41 deletions.
80 changes: 40 additions & 40 deletions src/eventalign.c
Original file line number Diff line number Diff line change
Expand Up @@ -1263,32 +1263,32 @@ struct EventAlignmentParameters
};


static inline int32_t *get_ref_to_read_map(AlignedSegment& aligned_pairs, int32_t *ref_seg_len_ptr){

int32_t ref_start = aligned_pairs.front().ref_pos;
int32_t ref_end = aligned_pairs.back().ref_pos;
int32_t ref_seg_len = ref_end - ref_start + 1;
*ref_seg_len_ptr = ref_seg_len;
assert(ref_start < ref_end);
assert(ref_seg_len > 0);

int32_t *ref_to_read_map = (int32_t*)malloc(sizeof(int32_t)*ref_seg_len);
MALLOC_CHK(ref_to_read_map);
for(int32_t i=0; i<ref_seg_len; i++){
ref_to_read_map[i] = -1;
}
for(size_t i = 0; i < aligned_pairs.size(); i++){
int32_t ref_pos = aligned_pairs[i].ref_pos - ref_start;
int32_t read_pos = aligned_pairs[i].read_pos;
ref_to_read_map[ref_pos] = read_pos;
}
// static inline int32_t *get_ref_to_read_map(AlignedSegment& aligned_pairs, int32_t *ref_seg_len_ptr){

// int32_t ref_start = aligned_pairs.front().ref_pos;
// int32_t ref_end = aligned_pairs.back().ref_pos;
// int32_t ref_seg_len = ref_end - ref_start + 1;
// *ref_seg_len_ptr = ref_seg_len;
// assert(ref_start < ref_end);
// assert(ref_seg_len > 0);

// int32_t *ref_to_read_map = (int32_t*)malloc(sizeof(int32_t)*ref_seg_len);
// MALLOC_CHK(ref_to_read_map);
// for(int32_t i=0; i<ref_seg_len; i++){
// ref_to_read_map[i] = -1;
// }
// for(size_t i = 0; i < aligned_pairs.size(); i++){
// int32_t ref_pos = aligned_pairs[i].ref_pos - ref_start;
// int32_t read_pos = aligned_pairs[i].read_pos;
// ref_to_read_map[ref_pos] = read_pos;
// }

// for(int32_t i=0; i<ref_seg_len; i++){
// fprintf(stderr, "ref_to_read_map[%d] = %d\n",i+ref_start,ref_to_read_map[i]);
// }
// // for(int32_t i=0; i<ref_seg_len; i++){
// // fprintf(stderr, "ref_to_read_map[%d] = %d\n",i+ref_start,ref_to_read_map[i]);
// // }

return ref_to_read_map;
}
// return ref_to_read_map;
// }

std::vector<event_alignment_t> align_read_to_ref(const EventAlignmentParameters& params, char *ref)
{
Expand Down Expand Up @@ -1346,8 +1346,8 @@ static inline int32_t *get_ref_to_read_map(AlignedSegment& aligned_pairs, int32_

AlignedSegment& aligned_pairs = aligned_segments[segment_idx];

int32_t ref_seg_len = 0;
int32_t *ref_to_read_map = get_ref_to_read_map(aligned_pairs, &ref_seg_len);
//int32_t ref_seg_len = 0;
//int32_t *ref_to_read_map = get_ref_to_read_map(aligned_pairs, &ref_seg_len);

if(params.region_start != -1 && params.region_end != -1) {
//fprintf(stderr, "params.region_start = %d params.region_end = %d\n",params.region_start,params.region_end);
Expand Down Expand Up @@ -1498,8 +1498,8 @@ static inline int32_t *get_ref_to_read_map(AlignedSegment& aligned_pairs, int32_
ea.ref_position = curr_start_ref + as.kmer_idx;
std::string ref__kmer = ref_seq.substr(ea.ref_position - ref_offset, k);
kmer_cpy(ea.ref_kmer, ref__kmer.c_str(),k);
assert(as.kmer_idx < ref_seg_len - params.kmer_size + 1);
ea.read_position = ref_to_read_map[as.kmer_idx];
//assert(as.kmer_idx < ref_seg_len - params.kmer_size + 1);
//ea.read_position = ref_to_read_map[as.kmer_idx];

// event
ea.read_idx = params.read_idx;
Expand Down Expand Up @@ -1560,7 +1560,7 @@ static inline int32_t *get_ref_to_read_map(AlignedSegment& aligned_pairs, int32_
tester_i++;
} // for realignmentsegment
// fprintf(stderr, "tester_i = %d\n",tester_i);
free(ref_to_read_map);
//free(ref_to_read_map);
} // for bam aligned segment
// fprintf(stderr, "alignment_output len = %d\n",alignment_output.size());
// assert(alignment_output.size() == 4451);
Expand Down Expand Up @@ -2098,18 +2098,18 @@ std::vector<float> get_scaled_samples_for_event(const event_table* events,scalin
// }


static inline void sprintf_read_kmer(kstring_t *sp, int32_t read_pos, char *read, int32_t read_len, uint32_t kmer_size){
// static inline void sprintf_read_kmer(kstring_t *sp, int32_t read_pos, char *read, int32_t read_len, uint32_t kmer_size){

if(read_pos == -1){
sprintf_append(sp, "\t.\t.");
return;
} else {
char kmer[kmer_size+1];
kmer_cpy(kmer, read+read_pos, kmer_size);
sprintf_append(sp, "\t%d\t%s", read_pos, kmer);
}
// if(read_pos == -1){
// sprintf_append(sp, "\t.\t.");
// return;
// } else {
// char kmer[kmer_size+1];
// kmer_cpy(kmer, read+read_pos, kmer_size);
// sprintf_append(sp, "\t%d\t%s", read_pos, kmer);
// }

}
// }

char *emit_event_alignment_tsv(uint32_t strand_idx,
const event_table* et, model_t* model, uint32_t kmer_size, scalings_t scalings,
Expand Down Expand Up @@ -2245,7 +2245,7 @@ char *emit_event_alignment_tsv(uint32_t strand_idx,
sample_str.resize(sample_str.size() - 1);
sprintf_append(sp, "\t%s", sample_str.c_str());
}
sprintf_read_kmer(sp, ea.read_position, read, read_len, kmer_size);
//sprintf_read_kmer(sp, ea.read_position, read, read_len, kmer_size);
sprintf_append(sp, "\n");
}

Expand Down
2 changes: 1 addition & 1 deletion src/f5c.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ typedef struct {
//int32_t strand_idx;
int32_t event_idx;
bool rc;
int32_t read_position;
//int32_t read_position;

// hmm data
char model_kmer[MAX_KMER_SIZE + 1];
Expand Down

0 comments on commit 207a5e7

Please sign in to comment.