1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
#include "Fragment.h"
#include "commons.h"
extern char comp['t'+1];
Fragment::Fragment(char *fragment_sequence) : fragment_sequence(strdup(fragment_sequence))
{
Mapped = NULL;
fragment_comment=(char *)"TODO: read and store the fragment comment";
}
Fragment::~Fragment(){
if(Mapped)
hash_delete(Mapped, list_of_generic_free);
free(fragment_sequence);
// free(fragment_comment);
}
bool Fragment::isPalindromic(){
if(strlen(fragment_sequence)%2) return false;
const int size = strlen(fragment_sequence);
for(int i=0;i<size/2;i++){
if(fragment_sequence[i]!=comp[fragment_sequence[size-i-1]]) return false;
}
return true;
}
Fragment_Starting::Fragment_Starting(char *fragment_sequence) :Fragment(fragment_sequence) {}
Fragment_Starting::~Fragment_Starting(){}
void Mapped_Fragment::alloc_coverage_quality(const int nb){
#ifdef CHARQUAL
coverage = (unsigned char **) malloc(sizeof(unsigned char *)*nb); test_alloc(coverage);
for(int i=0;i<nb;i++){
coverage[i]= (unsigned char *) malloc(sizeof(unsigned char)*strlen(fragment_sequence));
test_alloc(coverage[i]);
}
#else
coverage = (int **) malloc(sizeof(int *)*nb); test_alloc(coverage);
for(int i=0;i<nb;i++){
coverage[i]= (int *) malloc(sizeof(int)*strlen(fragment->fragment_sequence));
test_alloc(coverage[i]);
}
#endif
for(int i=0;i<nb;i++) for(int j=0;j<strlen(fragment_sequence);j++) coverage[i][j]=0;
}
Mapped_Fragment::Mapped_Fragment(char * fragment_sequence, const int number_of_read_sets) : Fragment(fragment_sequence) {
read_coherent = (char *) malloc(sizeof(char)*number_of_read_sets); test_alloc(read_coherent);
sum_quality_per_position=NULL;
number_mapped_reads=NULL;
}
Mapped_Fragment::Mapped_Fragment(Mapped_Fragment * clone) : Fragment(clone->fragment_sequence){
read_coherent = NULL;
sum_quality_per_position=NULL;
number_mapped_reads=NULL;
// IF WE ARE HERE, we duplicated a node. Thus we don't know its coverage. No need to create infos related to its quality or coverage.
// the idea is to write back the graph in a file and to re-run the whole mapping.
}
Mapped_Fragment::~Mapped_Fragment(){
if(read_coherent)
free(read_coherent);
if(sum_quality_per_position)
free(sum_quality_per_position); // TODO: free for each read set
if(number_mapped_reads)
free(number_mapped_reads);
}
|