38b9ede07fb3bfb98c74f611c62146b820747e4a braney Sat Dec 11 08:32:34 2021 -0800 check in custom hgc code for support of TOGA gene annotation from Michael Hiller's group diff --git src/hg/hgc/togaClick.c src/hg/hgc/togaClick.c new file mode 100644 index 0000000..86b49db --- /dev/null +++ src/hg/hgc/togaClick.c @@ -0,0 +1,371 @@ +/* togaClick - click handling for TOGA tracks */ +#include "common.h" +#include "hgc.h" +#include "togaClick.h" +#include "string.h" +#include "htmshell.h" + + +struct togaData *togaDataLoad(char **row) +/* Load a togaData from row fetched with select * from togaData + * from database. Dispose of this with togaDataFree(). */ +{ + struct togaData *ret; + AllocVar(ret); + ret->projection = cloneString(row[0]); + ret->ref_trans_id = cloneString(row[1]); + ret->ref_region = cloneString(row[2]); + ret->query_region = cloneString(row[3]); + ret->chain_score = cloneString(row[4]); + + ret->chain_synteny = cloneString(row[5]); + ret->chain_flank = cloneString(row[6]); + ret->chain_gl_cds_fract = cloneString(row[7]); + ret->chain_loc_cds_fract = cloneString(row[8]); + ret->chain_exon_cov = cloneString(row[9]); + + ret->chain_intron_cov = cloneString(row[10]); + ret->status = cloneString(row[11]); + ret->perc_intact_ign_M = cloneString(row[12]); + ret->perc_intact_int_M = cloneString(row[13]); + ret->intact_codon_prop = cloneString(row[14]); + + ret->ouf_prop = cloneString(row[15]); + ret->mid_intact = cloneString(row[16]); + ret->mid_pres = cloneString(row[17]); + ret->prot_alignment = cloneString(row[18]); + ret->svg_line = cloneString(row[19]); + return ret; +} + + +void togaDataFree(struct togaData **pEl) +/* Free a single dynamically allocated togaDatasuch as created + * with togaDataLoad(). */ +{ + struct togaData *el; + + if ((el = *pEl) == NULL) return; + freeMem(el->projection); + freeMem(el->ref_trans_id); + freeMem(el->ref_region); + freeMem(el->query_region); + freeMem(el->chain_score); + + freeMem(el->chain_synteny); + freeMem(el->chain_flank); + freeMem(el->chain_gl_cds_fract); + freeMem(el->chain_loc_cds_fract); + freeMem(el->chain_exon_cov); + + freeMem(el->chain_intron_cov); + freeMem(el->status); + freeMem(el->perc_intact_ign_M); + freeMem(el->perc_intact_int_M); + freeMem(el->intact_codon_prop); + + freeMem(el->ouf_prop); + freeMem(el->mid_intact); + freeMem(el->mid_pres); + freeMem(el->prot_alignment); + freeMem(el->svg_line); + freez(pEl); +} + +struct togaNucl *togaNuclLoad(char **row) +/* Load a togaNucl from row fetched with select * from togaNucl + * from database. Dispose of this with togaNuclFree(). */ +{ + struct togaNucl *ret; + AllocVar(ret); + ret->transcript = cloneString(row[0]); + ret->exon_num = cloneString(row[1]); + ret->exon_region = cloneString(row[2]); + ret->pid = cloneString(row[3]); + ret->blosum = cloneString(row[4]); + + ret->gaps = cloneString(row[5]); + ret->ali_class = cloneString(row[6]); + ret->exp_region = cloneString(row[7]); + ret->in_exp_region = cloneString(row[8]); + ret->alignment = cloneString(row[9]); + return ret; +} + + +void togaNuclFree(struct togaNucl **pEl) +/* Free a single dynamically allocated togaNucl such as created + * with togaNuclLoad(). */ +{ + struct togaNucl *el; + + if ((el = *pEl) == NULL) return; + freeMem(el->transcript); + freeMem(el->exon_num); + freeMem(el->exon_region); + freeMem(el->pid); + freeMem(el->blosum); + + freeMem(el->gaps); + freeMem(el->ali_class); + freeMem(el->exp_region); + freeMem(el->in_exp_region); + freeMem(el->alignment); + freez(pEl); +} + + +struct togaInactMut *togaInactMutLoad(char **row) +/* Load a togaInactMut from row fetched with select * from togaInactMut + * from database. Dispose of this with togaInactMutFree(). */ +{ + struct togaInactMut *ret; + AllocVar(ret); + ret->transcript = cloneString(row[0]); + ret->exon_num = cloneString(row[1]); + ret->position = cloneString(row[2]); + ret->mut_class = cloneString(row[3]); + ret->mutation = cloneString(row[4]); + + ret->is_inact = cloneString(row[5]); + ret->mut_id = cloneString(row[6]); + return ret; +} + + +void togaInactMutFree(struct togaInactMut **pEl) +/* Free a single dynamically allocated togaInactMut such as created + * with togaInactMutLoad(). */ +{ + struct togaInactMut *el; + if ((el = *pEl) == NULL) return; + freeMem(el->transcript); + freeMem(el->exon_num); + freeMem(el->position); + freeMem(el->mut_class); + freeMem(el->mutation); + + freeMem(el->is_inact); + freeMem(el->mut_id); + freez(pEl); +} + + +void extractHLTOGAsuffix(char *suffix) +/* Extract suffix from TOGA table name. +Prefix must be HLTOGAannot */ +{ + int suff_len = strlen(suffix); + if (suff_len <= HLTOGA_BED_PREFIX_LEN) + // we cannot chop first PREFIX_LEN characters + { + // TODO: NOT SURE IF IT WORKS; but this must not happen + char empty[5] = { '\0' }; + strcpy(suffix, empty); + } else { + // just start the string 11 characters upstream + memmove(suffix, suffix + HLTOGA_BED_PREFIX_LEN, suff_len - HLTOGA_BED_PREFIX_LEN + 1); + } +} + + +void doHillerLabTOGAGene(struct trackDb *tdb, char *item, char *table_name) +/* Put up TOGA Gene track info. */ +{ + //int start = cartInt(cart, "o"); + char headerTitle[512]; + char suffix[512]; + strcpy(suffix, table_name); + extractHLTOGAsuffix(suffix); + safef(headerTitle, sizeof(headerTitle), "%s", item); + genericHeader(tdb, headerTitle); + printf("
exon | pos | m_class | mut | is_inact | mut_id | \n"); + printf("|
---|---|---|---|---|---|---|
%s | \n", info->exon_num); + printf("%s | \n", info->position); + printf("%s | \n", info->mut_class); + printf("%s | \n", info->mutation); + if (sameWord(info->is_inact, ONE_)){ + printf("%s | \n", YES_); + } else { + printf("%s | \n", NO_); + } + printf("%s | \n", info->mut_id); + printf("