ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/gclib/gff.h
(Generate patch)
# Line 29 | Line 29
29   extern const uint gfo_flag_CHILDREN_PROMOTED;
30   extern const uint gfo_flag_HAS_ERRORS;
31   extern const uint gfo_flag_IS_GENE;
32 < extern const uint gfo_flag_FROM_GFF3; //parsed from GFF3 formatted record
32 > extern const uint gfo_flag_HAS_GFF_ID; //found a GFF3 formatted main feature with its own ID
33   extern const uint gfo_flag_BY_EXON;  //created by subfeature (exon) directly
34                        //(GTF2 and some chado gff3 dumps with exons given before their mRNA)
35   extern const uint gfo_flag_IS_TRANSCRIPT; //recognized as '*RNA' or '*transcript'
# Line 98 | Line 98
98         num_parents=0;
99         parents=NULL;
100         }
101 <    char* extractAttr(const char* pre, bool caseStrict=true, bool enforce_GTF2=false);
101 >    char* extractAttr(const char* pre, bool caseStrict=false, bool enforce_GTF2=false);
102      GffLine(GffLine* l) { //a copy constructor
103        memcpy((void*)this, (void*)l, sizeof(GffLine));
104        line=NULL;
# Line 472 | Line 472
472        if (v) flags |= gfo_flag_HAS_ERRORS;
473          else flags &= ~gfo_flag_HAS_ERRORS;
474        }
475 <  bool fromGff3() { return ((flags & gfo_flag_FROM_GFF3)!=0); }
476 <  void fromGff3(bool v) {
477 <      if (v) flags |= gfo_flag_FROM_GFF3;
478 <        else flags &= ~gfo_flag_FROM_GFF3;
475 >  bool hasGffID() { return ((flags & gfo_flag_HAS_GFF_ID)!=0); }
476 >  void hasGffID(bool v) {
477 >      if (v) flags |= gfo_flag_HAS_GFF_ID;
478 >        else flags &= ~gfo_flag_HAS_GFF_ID;
479        }
480    bool createdByExon() { return ((flags & gfo_flag_BY_EXON)!=0); }
481    void createdByExon(bool v) {
# Line 674 | Line 674
674       }
675     bool exonOverlap(uint s, uint e) {//check if ANY exon overlaps given segment
676        //ignores strand!
677 <      if (s>e) swap(s,e);
677 >      if (s>e) Gswap(s,e);
678        for (int i=0;i<exons.Count();i++) {
679           if (exons[i]->overlap(s,e)) return true;
680           }
# Line 697 | Line 697
697      int exonOverlapIdx(uint s, uint e, int* ovlen=NULL) {
698        //return the exons' index for the overlapping OR ADJACENT exon
699        //ovlen, if given, will return the overlap length
700 <      if (s>e) swap(s,e);
700 >      if (s>e) Gswap(s,e);
701        s--;e++; //to also catch adjacent exons
702        for (int i=0;i<exons.Count();i++) {
703              if (exons[i]->start>e) break;
# Line 975 | Line 975
975  
976   };
977  
978 < class GfoHolder {
979 < public:
978 > struct GfoHolder {
979     int idx; //position in GffReader::gflst array
980 <   GffObj* gffobj;
980 >   GffObj* gffobj;
981     GfoHolder(GffObj* gfo=NULL, int i=0) {
982       idx=i;
983       gffobj=gfo;
# Line 1018 | Line 1017
1017    bool transcriptsOnly; //keep only transcripts w/ their exon/CDS features
1018    GHash<int> discarded_ids; //for transcriptsOnly mode, keep track
1019                              // of discarded parent IDs
1020 <  GHash<GfoHolder> phash; //transcript_id+contig (Parent~Contig) => [gflst index, GffObj]
1021 <  GHash<int> tids; //transcript_id uniqueness
1020 >  GHash< GVec<GfoHolder> > phash; //transcript_id+contig (Parent~Contig) => [gflst index, GffObj]
1021 >  //GHash<int> tids; //just for transcript_id uniqueness
1022    char* gfoBuildId(const char* id, const char* ctg);
1023 <  void gfoRemove(const char* id, const char* ctg);
1024 <  GfoHolder* gfoAdd(const char* id, const char* ctg, GffObj* gfo, int idx);
1025 <  GfoHolder* gfoFind(const char* id, const char* ctg);
1023 >  //void gfoRemove(const char* id, const char* ctg);
1024 >  GfoHolder* gfoAdd(GffObj* gfo, int idx);
1025 >  GfoHolder* gfoAdd(GVec<GfoHolder>& glst, GffObj* gfo, int idx);
1026 >  GfoHolder* gfoFind(const char* id, const char* ctg=NULL, char strand=0, uint start=0,
1027 >                                                             GVec<GfoHolder>** glst = NULL);
1028    CNonExon* subfPoolCheck(GffLine* gffline, GHash<CNonExon>& pex, char*& subp_name);
1029    void subfPoolAdd(GHash<CNonExon>& pex, GfoHolder* newgfo);
1030    GfoHolder* promoteFeature(CNonExon* subp, char*& subp_name, GHash<CNonExon>& pex,
# Line 1031 | Line 1032
1032   public:
1033    GfList gflst; //accumulate GffObjs being read
1034    GfoHolder* newGffRec(GffLine* gffline, bool keepAttr, bool noExonAttr,
1035 <                               GffObj* parent=NULL, GffExon* pexon=NULL);
1035 >                               GffObj* parent=NULL, GffExon* pexon=NULL, GVec<GfoHolder>* glst=NULL);
1036    GfoHolder* replaceGffRec(GffLine* gffline, bool keepAttr, bool noExonAttr, int replaceidx);
1037    GfoHolder* updateGffRec(GfoHolder* prevgfo, GffLine* gffline,
1038                                           bool keepAttr);
# Line 1039 | Line 1040
1040    bool addExonFeature(GfoHolder* prevgfo, GffLine* gffline, GHash<CNonExon>& pex, bool noExonAttr);
1041    GList<GSeqStat> gseqstats; //list of all genomic sequences seen by this reader, accumulates stats
1042    GffReader(FILE* f=NULL, bool t_only=false, bool sortbyloc=false):discarded_ids(true),
1043 <                       phash(true), tids(true), gflst(sortbyloc), gseqstats(true,true,true) {
1043 >                       phash(true), gflst(sortbyloc), gseqstats(true,true,true) {
1044        gff_warns=gff_show_warnings;
1045        names=NULL;
1046        gffline=NULL;
# Line 1059 | Line 1060
1060        gflst.sortedByLoc(sortbyloc);
1061        }
1062    GffReader(char* fn, bool t_only=false, bool sort=false):discarded_ids(true), phash(true),
1063 <                             tids(true),gflst(sort),gseqstats(true,true,true) {
1063 >                             gflst(sort),gseqstats(true,true,true) {
1064        gff_warns=gff_show_warnings;
1065        names=NULL;
1066        fname=Gstrdup(fn);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines