// New Vector *Translation_getAllSeqEdits(Translation *translation) { char *edits[] = { "initial_met", "_selenocysteine", "amino_acid_sub", NULL }; Vector *seqEds = Vector_new(); char **editP = edits; while (*editP) { char *edit = *editP; Vector *attribs = Translation_getAllAttributes(translation, edit); // convert attributes to SeqEdit objects int i; for (i=0; i<Vector_getNumElement(attribs); i++) { Attribute *attrib = Vector_getElementAt(attribs, i); SeqEdit *seqEd = SeqEdit_newFromAttribute(attrib); Vector_addElement(seqEds, seqEd); } Vector_free(attribs); editP++; } return seqEds; }
int dumpGenes(Vector *genes, int withSupport) { FILE *fp = stderr; int i; int failed = 0; for (i=0;i<Vector_getNumElement(genes) && !failed;i++) { Gene *g = Vector_getElementAt(genes,i); fprintf(fp,"Gene %s (%s) coords: %ld %ld %d\n",Gene_getStableId(g),(Gene_getDisplayXref(g) ? DBEntry_getDisplayId(Gene_getDisplayXref(g)) : ""),Gene_getStart(g),Gene_getEnd(g),Gene_getStrand(g)); int j; for (j=0;j<Gene_getTranscriptCount(g);j++) { Transcript *t = Gene_getTranscriptAt(g,j); int k; fprintf(fp," Trans %s coords: %ld %ld %d biotype: %s\n",Transcript_getStableId(t), Transcript_getStart(t),Transcript_getEnd(t),Transcript_getStrand(t),Transcript_getBiotype(t)); if (withSupport) { Vector *support = Transcript_getAllSupportingFeatures(t); for (k=0; k<Vector_getNumElement(support); k++) { BaseAlignFeature *baf = Vector_getElementAt(support, k); fprintf(fp," support %s coords: %ld %ld %d\n", BaseAlignFeature_getHitSeqName(baf), BaseAlignFeature_getStart(baf), BaseAlignFeature_getEnd(baf), BaseAlignFeature_getStrand(baf)); } Vector *intronSupport = Transcript_getAllIntronSupportingEvidence(t); for (k=0; k<Vector_getNumElement(intronSupport); k++) { IntronSupportingEvidence *ise = Vector_getElementAt(intronSupport, k); fprintf(fp," intron support %s coords: %ld %ld %d\n", IntronSupportingEvidence_getHitName(ise), IntronSupportingEvidence_getStart(ise), IntronSupportingEvidence_getEnd(ise), IntronSupportingEvidence_getStrand(ise)); } } for (k=0;k<Transcript_getExonCount(t);k++) { Exon *e = Transcript_getExonAt(t,k); fprintf(fp," exon %s (%p) coords: %ld %ld %d\n",Exon_getStableId(e), e, Exon_getStart(e), Exon_getEnd(e), Exon_getStrand(e)); if (withSupport) { Vector *support = Exon_getAllSupportingFeatures(e); int m; for (m=0; m<Vector_getNumElement(support); m++) { BaseAlignFeature *baf = Vector_getElementAt(support, m); fprintf(fp," support %s coords: %ld %ld %d\n", BaseAlignFeature_getHitSeqName(baf), BaseAlignFeature_getStart(baf), BaseAlignFeature_getEnd(baf), BaseAlignFeature_getStrand(baf)); } } } Translation *tln = Transcript_getTranslation(t); if (tln) { fprintf(fp," translation id: %s %s %d %s %d\n",Translation_getStableId(tln), Exon_getStableId(Translation_getStartExon(tln)), Translation_getStart(tln), Exon_getStableId(Translation_getEndExon(tln)), Translation_getEnd(tln)); char *tSeq = Transcript_translate(t); fprintf(fp," translation: %s\n",tSeq); free(tSeq); Vector *tlnAttribs = Translation_getAllAttributes(tln, NULL); if (Vector_getNumElement(tlnAttribs)) { fprintf(fp, " translation attributes:\n"); int n; for (n=0; n<Vector_getNumElement(tlnAttribs); n++) { Attribute *attrib = Vector_getElementAt(tlnAttribs, n); fprintf(fp, " code %s name %s desc %s value %s\n", Attribute_getCode(attrib), Attribute_getName(attrib), Attribute_getDescription(attrib), Attribute_getValue(attrib)); } } } } } return failed; }