9d707c71d687a0a0caafd123d6ced70fe0519200 kate Fri Nov 14 16:49:11 2014 -0800 Add custom item name to show peptide sequence. refs #14054 diff --git src/hg/hgTracks/peptideAtlasTrack.c src/hg/hgTracks/peptideAtlasTrack.c new file mode 100644 index 0000000..92924a2 --- /dev/null +++ src/hg/hgTracks/peptideAtlasTrack.c @@ -0,0 +1,85 @@ +/* peptideAtlasTracks - Peptide identifications from tandem MS mapped to the genome, + * from PeptideAtlas (peptideatlas.org) */ + +/* Copyright (C) 2014 The Regents of the University of California + * See README in this or parent directory for licensing information. */ + +#include "common.h" +#include "hgTracks.h" + +struct dnaBuf +/* Hold DNA sequence for translating to peptide */ +{ + DNA *dna; + int chromStart; + int chromEnd; +}; + +static DNA *dnaForLinkedFeature(struct linkedFeatures *lf, struct dnaBuf *dnaBuf) +/* Return DNA string for all simple features in a linked feature using buffer of + * genomic sequence in the browser window */ +{ +struct dyString *dna = dyStringNew(0); +struct simpleFeature *sf; + +// NOTE: odd this is needed +slReverse(&lf->components); +for (sf = lf->components; sf != NULL; sf = sf->next) + { + dyStringAppendN(dna, dnaBuf->dna + sf->start - dnaBuf->chromStart, sf->end - sf->start); + } +if (lf->orientation == -1) + { + reverseComplement(dna->string, strlen(dna->string)); + } +return dyStringCannibalize(&dna); +} + +void linkedFeaturesRange(struct track *tg, int *minStart, int *maxEnd) +/* Return minimum chromStart and maximum chromEnd for linked features in the track */ +{ +if (minStart == NULL || maxEnd == NULL) + errAbort("Internal error: peptideAtlas feature comparison (hide this track)"); +*minStart = hChromSize(database, chromName); +*maxEnd = 0; +struct linkedFeatures *lf; +for (lf = (struct linkedFeatures *)tg->items; lf != NULL; lf = lf->next) + { + *minStart = min(*minStart, lf->start); + *maxEnd = max(*maxEnd, lf->end); + } +} + +static char *peptideAtlasItemName(struct track *tg, void *item) +/* Display peptide sequence translated from genome as item name. + * This suffices since all PeptideAtlas peptide mappings (in Aug 2014 human build) + * are perfect matches to genome */ +{ +if (tg->customPt == NULL) + { + int minStart, maxEnd; + linkedFeaturesRange(tg, &minStart, &maxEnd); + struct dnaBuf *dnaBuf; + AllocVar(dnaBuf); + struct dnaSeq *dnaSeq = hDnaFromSeq(database, chromName, minStart, maxEnd, dnaLower); + dnaBuf->dna = dnaSeq->dna; + dnaBuf->chromStart = minStart; + dnaBuf->chromEnd = maxEnd; + tg->customPt = dnaBuf; + } +struct linkedFeatures *lf = (struct linkedFeatures *)item; +DNA *dna = dnaForLinkedFeature(lf, (struct dnaBuf *)tg->customPt); +int size = strlen(dna)/3 + 1; +AA *peptide = needMem(size); +dnaTranslateSome(dna, peptide, size); +return peptide; +} + +void peptideAtlasMethods(struct track *tg) +/* Item label is peptide sequence translated from genome */ +{ +tg->itemName = peptideAtlasItemName; +} + + +