03d79bf4ff976c1c0f7327d91e8b9d9adc70cefd markd Tue Jan 23 21:55:36 2018 -0800 do a better job converting NCBI [CDJV]_gene_segment GFF3 annotations. This avoids split into genePreds. Another evening wasted with bioinformatics file formats diff --git src/lib/gff3.c src/lib/gff3.c index 614a28a..bbba639 100644 --- src/lib/gff3.c +++ src/lib/gff3.c @@ -46,30 +46,33 @@ /* commonly used features names */ char *gff3FeatGene = "gene"; char *gff3FeatPseudogene = "pseudogene"; char *gff3FeatNCRna ="ncRNA"; char *gff3FeatRRna = "rRNA"; char *gff3FeatTRna = "tRNA"; char *gff3FeatMRna = "mRNA"; char *gff3FeatExon = "exon"; char *gff3FeatCDS = "CDS"; char *gff3FeatThreePrimeUTR = "three_prime_UTR"; char *gff3FeatFivePrimeUTR = "five_prime_UTR"; char *gff3FeatStartCodon = "start_codon"; char *gff3FeatStopCodon = "stop_codon"; char *gff3FeatTranscript = "transcript"; char *gff3FeatPrimaryTranscript = "primary_transcript"; +char *gff3FeatCGeneSegment = "C_gene_segment"; +char *gff3FeatDGeneSegment = "D_gene_segment"; +char *gff3FeatJGeneSegment = "J_gene_segment"; char *gff3FeatVGeneSegment = "V_gene_segment"; static bool gff3FileStopDueToErrors(struct gff3File *g3f) /* determine if we should stop due to the number of errors */ { return g3f->errCnt > g3f->maxErr; } static void gff3FileErr(struct gff3File *g3f, char *format, ...) #if defined(__GNUC__) __attribute__((format(printf, 2, 3))) #endif ; static void gff3AnnErr(struct gff3Ann *g3a, char *format, ...) @@ -1102,15 +1105,42 @@ { // allow for various types of strand fields. above tests handles both null if (a->strand == NULL) diff = 1; else if (b->strand == NULL) diff = -1; else diff = strcmp(a->strand, b->strand); } if (diff == 0) diff = a->start - b->start; if (diff == 0) diff = a->end - b->end; return diff; } + +void gff3UnlinkChild(struct gff3Ann *g3a, + struct gff3Ann *child) +/* unlink the child from it's parent (do not free) */ +{ +struct gff3AnnRef *childRef; +for (childRef = g3a->children; childRef != NULL; childRef = childRef->next) + if (childRef->ann == child) + break; +if (childRef == NULL) + errAbort("gff3UnlinkChild: not a child of specified parent"); +slRemoveEl(&g3a->children, childRef); +child->parentIds = NULL; +child->parents = NULL; +} + +void gff3LinkChild(struct gff3Ann *g3a, + struct gff3Ann *child) +/* Add a child to new parent */ +{ +struct gff3AnnRef *childRef = gff3AnnRefAlloc(child); +slSafeAddHead(&g3a->children, childRef); +slSort(&g3a->children, gff3AnnRefLocCmp); +slAddHead(&child->parentIds, gff3FileSlNameNew(g3a->file, g3a->id)); +slAddHead(&child->parents, gff3AnnRefAlloc(g3a)); +} +