Loading GBase.h +1 −1 Original line number Diff line number Diff line #ifndef G_BASE_DEFINED #define G_BASE_DEFINED #define GCLIB_VERSION "0.11.2" #define GCLIB_VERSION "0.11.3" #ifdef HAVE_CONFIG_H #include "config.h" Loading GVec.hh +4 −4 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ template <class OBJ> class GVec { GVec(int init_count, const OBJ init_val); GVec(int init_count, OBJ* init_val, bool delete_initval=true); //convenience constructor for complex vectors GVec(const GVec<OBJ>& array); //copy constructor const GVec<OBJ>& operator=(GVec<OBJ>& array); //copy operator const GVec<OBJ>& operator=(const GVec<OBJ>& array); //copy operator virtual ~GVec(); void Insert(int idx, OBJ item) { Insert(idx, &item); } void Insert(int idx, OBJ* item); Loading Loading @@ -148,7 +148,7 @@ template <class OBJ> class GPVec { GPVec(bool free_elements); GPVec(GPVec<OBJ>& list); //copy constructor? GPVec(GPVec<OBJ>* list); //kind of a copy constructor const GPVec<OBJ>& operator=(GPVec<OBJ>& list); const GPVec<OBJ>& operator=(const GPVec<OBJ>& list); inline OBJ* Get(int i) { TEST_INDEX(i); return fList[i]; Loading Loading @@ -246,7 +246,7 @@ template <class OBJ> GVec<OBJ>::GVec(const GVec<OBJ>& array) { //copy constructo this->fCount=array.fCount; } template <class OBJ> const GVec<OBJ>& GVec<OBJ>::operator=(GVec<OBJ>& array) { template <class OBJ> const GVec<OBJ>& GVec<OBJ>::operator=(const GVec<OBJ>& array) { if (&array==this) return *this; Clear(); fCapacity=array.fCapacity; Loading Loading @@ -580,7 +580,7 @@ template <class OBJ> GPVec<OBJ>::GPVec(GPVec* plist) { //another copy constructo } } template <class OBJ> const GPVec<OBJ>& GPVec<OBJ>::operator=(GPVec& list) { template <class OBJ> const GPVec<OBJ>& GPVec<OBJ>::operator=(const GPVec& list) { if (&list!=this) { Clear(); fFreeProc=list.fFreeProc; Loading gff.cpp +37 −2 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ void gffnames_unref(GffNames* &n) { if (n->numrefs==0) { delete n; n=NULL; } } const int CLASSCODE_OVL_RANK = 15; int classcode_rank(char c) { switch (c) { case '=': return 0; //intron chain match or full exon chain match if strict matching is enabled Loading @@ -42,6 +43,7 @@ int classcode_rank(char c) { case 'j': return 6; // multi-exon transfrag with at least one junction match case 'e': return 12; // single exon transfrag partially overlapping an intron of reference (possible pre-mRNA fragment) case 'o': return 14; // other generic exon overlap //**** >15 = no-overlaps (not on the same strand) from here on ***** case 's': return 16; //"shadow" - an intron overlaps with a ref intron on the opposite strand (wrong strand mapping?) case 'x': return 18; // generic overlap on opposite strand (usually wrong strand mapping) case 'i': return 20; // intra-intron (transfrag fully contained within a reference intron) Loading Loading @@ -2439,6 +2441,17 @@ void GffObj::printExonList(FILE* fout) { } } void GffObj::printCDSList(FILE* fout) { //print comma delimited list of CDS intervals if (!hasCDS()) return; GVec<GffExon> cds; this->getCDSegs(cds); //also uses/prepares the CDS phase for each CDS segment for (int i=0;i<cds.Count();i++) { if (i>0) fprintf(fout, ","); fprintf(fout, "%d-%d", cds[i].start, cds[i].end); } } void BED_addAttribute(FILE* fout, int& acc, const char* format,... ) { ++acc; if (acc==1) fprintf(fout, "\t"); Loading Loading @@ -2708,6 +2721,26 @@ char* GffObj::getUnspliced(GFaSeqGet* faseq, int* rlen, GMapSegments* seglst) { return unspliced; } void GffObj::addPadding(int padLeft, int padRight) { this->start-=padLeft; this->end+=padRight; if (exons.Count()>0) { exons[0]->start-=padLeft; exons.Last()->end+=padRight; } covlen+=padLeft+padRight; } void GffObj::removePadding(int padLeft, int padRight) { this->start+=padLeft; this->end-=padRight; if (exons.Count()>0) { exons[0]->start+=padLeft; exons.Last()->end-=padRight; } covlen-=padLeft+padRight; } char* GffObj::getSpliced(GFaSeqGet* faseq, bool CDSonly, int* rlen, uint* cds_start, uint* cds_end, GMapSegments* seglst, bool cds_open) { //cds_open only makes sense when CDSonly is true by overriding CDS 3'end such that the end of Loading @@ -2729,7 +2762,8 @@ char* GffObj::getSpliced(GFaSeqGet* faseq, bool CDSonly, int* rlen, uint* cds_st if (gsubseq==NULL) { GError("Error getting subseq for %s (%d..%d)!\n", gffID, start, end); } if (fspan<(int)(end-start+1)) { //special case: stop coordinate was extended past the gseq length, must adjust if (fspan<(int)(end-start+1)) { //special case: stop coordinate was extended past the gseq length, must adjust int endadj=end-start+1-fspan; uint prevend=end; end-=endadj; Loading @@ -2744,7 +2778,7 @@ char* GffObj::getSpliced(GFaSeqGet* faseq, bool CDSonly, int* rlen, uint* cds_st } } char* spliced=NULL; GMALLOC(spliced, covlen+1); //allocate more here GMALLOC(spliced, covlen+1); //IMPORTANT: covlen must be correct here! uint g_start=0, g_end=0; int cdsadj=0; if (CDphase=='1' || CDphase=='2') { Loading Loading @@ -3216,6 +3250,7 @@ void GffObj::getCDSegs(GVec<GffExon>& cds) { cds.Add(cdseg); } //for each exon } // + strand } //-- transcript overlap classification functions Loading gff.h +16 −5 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ extern int gff_fid_exon; extern const uint GFF_MAX_LOCUS; extern const uint GFF_MAX_EXON; extern const uint GFF_MAX_INTRON; extern const int CLASSCODE_OVL_RANK; //extern const uint gfo_flag_LEVEL_MSK; //hierarchical level: 0 = no parent //extern const byte gfo_flagShift_LEVEL; Loading Loading @@ -651,13 +651,18 @@ class GffExon : public GSeg { } //constructor GffExon(const GffExon& ex):GSeg(ex.start, ex.end) { //copy constructor (*this)=ex; //use the default copy operator if (ex.attrs!=NULL) { (*this)=ex; //use the default (shallow!) copy operator if (ex.attrs!=NULL) { //make a deep copy here attrs=new GffAttrs(); attrs->copyAttrs(ex.attrs); } } GffExon& operator=(const GffExon& o) = default; //prevent gcc 9 warnings: //yes, I want a shallow copy here ~GffExon() { //destructor if (attrs!=NULL && !sharedAttrs) delete attrs; } Loading Loading @@ -1015,6 +1020,8 @@ public: printGxf(fout, showCDS ? pgffBoth : pgffExon, tlabel, gfparent, cvtChars); } void printExonList(FILE* fout); //print comma delimited list of exon intervals void printCDSList(FILE* fout); //print comma delimited list of CDS intervals void printBED(FILE* fout, bool cvtChars, char* dbuf, int dbuf_len); //print a BED-12 line + GFF3 attributes in 13th field void printSummary(FILE* fout=NULL); Loading @@ -1023,6 +1030,10 @@ public: uint* cds_start=NULL, uint* cds_end=NULL, GMapSegments* seglst=NULL, bool cds_open=false); char* getUnspliced(GFaSeqGet* faseq, int* rlen, GMapSegments* seglst=NULL); void addPadding(int padLeft, int padRight); //change exons to include this padding on the sides void removePadding(int padLeft, int padRight); //bool validCDS(GFaSeqGet* faseq); //has In-Frame Stop Codon ? bool empty() { return (start==0); } }; Loading Loading
GBase.h +1 −1 Original line number Diff line number Diff line #ifndef G_BASE_DEFINED #define G_BASE_DEFINED #define GCLIB_VERSION "0.11.2" #define GCLIB_VERSION "0.11.3" #ifdef HAVE_CONFIG_H #include "config.h" Loading
GVec.hh +4 −4 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ template <class OBJ> class GVec { GVec(int init_count, const OBJ init_val); GVec(int init_count, OBJ* init_val, bool delete_initval=true); //convenience constructor for complex vectors GVec(const GVec<OBJ>& array); //copy constructor const GVec<OBJ>& operator=(GVec<OBJ>& array); //copy operator const GVec<OBJ>& operator=(const GVec<OBJ>& array); //copy operator virtual ~GVec(); void Insert(int idx, OBJ item) { Insert(idx, &item); } void Insert(int idx, OBJ* item); Loading Loading @@ -148,7 +148,7 @@ template <class OBJ> class GPVec { GPVec(bool free_elements); GPVec(GPVec<OBJ>& list); //copy constructor? GPVec(GPVec<OBJ>* list); //kind of a copy constructor const GPVec<OBJ>& operator=(GPVec<OBJ>& list); const GPVec<OBJ>& operator=(const GPVec<OBJ>& list); inline OBJ* Get(int i) { TEST_INDEX(i); return fList[i]; Loading Loading @@ -246,7 +246,7 @@ template <class OBJ> GVec<OBJ>::GVec(const GVec<OBJ>& array) { //copy constructo this->fCount=array.fCount; } template <class OBJ> const GVec<OBJ>& GVec<OBJ>::operator=(GVec<OBJ>& array) { template <class OBJ> const GVec<OBJ>& GVec<OBJ>::operator=(const GVec<OBJ>& array) { if (&array==this) return *this; Clear(); fCapacity=array.fCapacity; Loading Loading @@ -580,7 +580,7 @@ template <class OBJ> GPVec<OBJ>::GPVec(GPVec* plist) { //another copy constructo } } template <class OBJ> const GPVec<OBJ>& GPVec<OBJ>::operator=(GPVec& list) { template <class OBJ> const GPVec<OBJ>& GPVec<OBJ>::operator=(const GPVec& list) { if (&list!=this) { Clear(); fFreeProc=list.fFreeProc; Loading
gff.cpp +37 −2 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ void gffnames_unref(GffNames* &n) { if (n->numrefs==0) { delete n; n=NULL; } } const int CLASSCODE_OVL_RANK = 15; int classcode_rank(char c) { switch (c) { case '=': return 0; //intron chain match or full exon chain match if strict matching is enabled Loading @@ -42,6 +43,7 @@ int classcode_rank(char c) { case 'j': return 6; // multi-exon transfrag with at least one junction match case 'e': return 12; // single exon transfrag partially overlapping an intron of reference (possible pre-mRNA fragment) case 'o': return 14; // other generic exon overlap //**** >15 = no-overlaps (not on the same strand) from here on ***** case 's': return 16; //"shadow" - an intron overlaps with a ref intron on the opposite strand (wrong strand mapping?) case 'x': return 18; // generic overlap on opposite strand (usually wrong strand mapping) case 'i': return 20; // intra-intron (transfrag fully contained within a reference intron) Loading Loading @@ -2439,6 +2441,17 @@ void GffObj::printExonList(FILE* fout) { } } void GffObj::printCDSList(FILE* fout) { //print comma delimited list of CDS intervals if (!hasCDS()) return; GVec<GffExon> cds; this->getCDSegs(cds); //also uses/prepares the CDS phase for each CDS segment for (int i=0;i<cds.Count();i++) { if (i>0) fprintf(fout, ","); fprintf(fout, "%d-%d", cds[i].start, cds[i].end); } } void BED_addAttribute(FILE* fout, int& acc, const char* format,... ) { ++acc; if (acc==1) fprintf(fout, "\t"); Loading Loading @@ -2708,6 +2721,26 @@ char* GffObj::getUnspliced(GFaSeqGet* faseq, int* rlen, GMapSegments* seglst) { return unspliced; } void GffObj::addPadding(int padLeft, int padRight) { this->start-=padLeft; this->end+=padRight; if (exons.Count()>0) { exons[0]->start-=padLeft; exons.Last()->end+=padRight; } covlen+=padLeft+padRight; } void GffObj::removePadding(int padLeft, int padRight) { this->start+=padLeft; this->end-=padRight; if (exons.Count()>0) { exons[0]->start+=padLeft; exons.Last()->end-=padRight; } covlen-=padLeft+padRight; } char* GffObj::getSpliced(GFaSeqGet* faseq, bool CDSonly, int* rlen, uint* cds_start, uint* cds_end, GMapSegments* seglst, bool cds_open) { //cds_open only makes sense when CDSonly is true by overriding CDS 3'end such that the end of Loading @@ -2729,7 +2762,8 @@ char* GffObj::getSpliced(GFaSeqGet* faseq, bool CDSonly, int* rlen, uint* cds_st if (gsubseq==NULL) { GError("Error getting subseq for %s (%d..%d)!\n", gffID, start, end); } if (fspan<(int)(end-start+1)) { //special case: stop coordinate was extended past the gseq length, must adjust if (fspan<(int)(end-start+1)) { //special case: stop coordinate was extended past the gseq length, must adjust int endadj=end-start+1-fspan; uint prevend=end; end-=endadj; Loading @@ -2744,7 +2778,7 @@ char* GffObj::getSpliced(GFaSeqGet* faseq, bool CDSonly, int* rlen, uint* cds_st } } char* spliced=NULL; GMALLOC(spliced, covlen+1); //allocate more here GMALLOC(spliced, covlen+1); //IMPORTANT: covlen must be correct here! uint g_start=0, g_end=0; int cdsadj=0; if (CDphase=='1' || CDphase=='2') { Loading Loading @@ -3216,6 +3250,7 @@ void GffObj::getCDSegs(GVec<GffExon>& cds) { cds.Add(cdseg); } //for each exon } // + strand } //-- transcript overlap classification functions Loading
gff.h +16 −5 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ extern int gff_fid_exon; extern const uint GFF_MAX_LOCUS; extern const uint GFF_MAX_EXON; extern const uint GFF_MAX_INTRON; extern const int CLASSCODE_OVL_RANK; //extern const uint gfo_flag_LEVEL_MSK; //hierarchical level: 0 = no parent //extern const byte gfo_flagShift_LEVEL; Loading Loading @@ -651,13 +651,18 @@ class GffExon : public GSeg { } //constructor GffExon(const GffExon& ex):GSeg(ex.start, ex.end) { //copy constructor (*this)=ex; //use the default copy operator if (ex.attrs!=NULL) { (*this)=ex; //use the default (shallow!) copy operator if (ex.attrs!=NULL) { //make a deep copy here attrs=new GffAttrs(); attrs->copyAttrs(ex.attrs); } } GffExon& operator=(const GffExon& o) = default; //prevent gcc 9 warnings: //yes, I want a shallow copy here ~GffExon() { //destructor if (attrs!=NULL && !sharedAttrs) delete attrs; } Loading Loading @@ -1015,6 +1020,8 @@ public: printGxf(fout, showCDS ? pgffBoth : pgffExon, tlabel, gfparent, cvtChars); } void printExonList(FILE* fout); //print comma delimited list of exon intervals void printCDSList(FILE* fout); //print comma delimited list of CDS intervals void printBED(FILE* fout, bool cvtChars, char* dbuf, int dbuf_len); //print a BED-12 line + GFF3 attributes in 13th field void printSummary(FILE* fout=NULL); Loading @@ -1023,6 +1030,10 @@ public: uint* cds_start=NULL, uint* cds_end=NULL, GMapSegments* seglst=NULL, bool cds_open=false); char* getUnspliced(GFaSeqGet* faseq, int* rlen, GMapSegments* seglst=NULL); void addPadding(int padLeft, int padRight); //change exons to include this padding on the sides void removePadding(int padLeft, int padRight); //bool validCDS(GFaSeqGet* faseq); //has In-Frame Stop Codon ? bool empty() { return (start==0); } }; Loading