%{ #include "dyna.h" #define TranscriptLISTLENGTH 32 #define ExonLISTLENGTH 128 %} api object Exon des free_Exon endobject object Transcript des free_Transcript func get_cDNA_from_Transcript endobject endapi struct SupportingFeature int start // in exon coordinates int end // in exon coordinates int hstart int hend int hstrand char* hid struct Exon int start int end boolean used; // used by some prediction programs etc double score SupportingFeature ** sf !list int phase !def="-1" friend Translation friend Gene struct Transcript Exon ** exon !list !len="ex_" Gene * parent; !link Translation ** translation !list cDNA * cDNA // may not be here! %info Transcript represents a single spliced product from a gene. The transcript is considered to be a series of exons and it contains, in addition a series of translations. Most genes will only have one translation. Like gene before it, transcript does not necessarily contain DNA. When some DNA is asked from it, via get_cDNA_from_Transcript (notice the change from Genomic typed sequence in Gene to cDNA typed sequence in Transcript) it first checkes the 'cache'. If it is not there, it asks for its parents genomic DNA, and then assemblies the cDNA using the exon coordinates. The exon coordinates are such that 0 means the start of the gene, not the start of the genomic region. (makes some outputs a pain). Supporting Features are added to exons, and, keeping in the spirit of this module, are relative to the exon start. The strand is inherieted from the exon %% %{ #include "transcript.h" %func Makes a completely new copy of the transcript %% Transcript * copy_Transcript(Transcript * t) { Transcript * out; Exon * temp; int i; out = Transcript_alloc(); for(i=0;iex_len;i++) { temp = Exon_alloc(); temp->start = t->exon[i]->start; temp->end = t->exon[i]->end; add_ex_Transcript(out,temp); } for(i=0;ilen;i++) { add_Transcript(out,copy_Translation(t->translation[i])); } return out; } %func gets the cDNA associated with this transcript, if necessary, building it from the exon information provided. returns a soft-linked object. If you want to ensure that this cDNA object remains in memory use /hard_link_cDNA on the object. %arg trs r transcript to get cDNA from return s cDNA of the transcript %% cDNA * get_cDNA_from_Transcript(Transcript * trs) { Genomic * gn; Sequence * base; int i; char buffer[64]; if( trs->cDNA != NULL) return trs->cDNA; if( trs->parent == NULL ) { warn("Cannot get cDNA, as no parent Gene!"); return NULL; } if ( (gn = get_Genomic_from_Gene(trs->parent)) == NULL ) { warn("Cannot get cDNA, as cannot get Genomic sequence from Gene"); return NULL; } base = Sequence_alloc(); sprintf(buffer,"%s.sp",Genomic_name(gn)); base->name = stringalloc(buffer); base->seq = ckcalloc(length_Transcript(trs)+1,sizeof(char)); base->seq[0]='\0'; for(i=0;iex_len;i++) { strncat(base->seq,gn->baseseq->seq+trs->exon[i]->start,trs->exon[i]->end-trs->exon[i]->start); } make_len_type_Sequence(base); base->type = SEQUENCE_CDNA; trs->cDNA = cDNA_from_Sequence(base); return trs->cDNA; } %func returns the length by looking at the exon lengths %% int length_Transcript(Transcript * tr) { int len = 0; int i; for(i=0;iex_len;i++) { len += tr->exon[i]->end - tr->exon[i]->start; } return len; } %func shows a transcript in vaguely human form %% void show_Transcript(Transcript * tr,FILE * ofp) { int i; int k; SupportingFeature * sf; for(i=0;iex_len;i++) { fprintf(ofp,"Exon %d-%d\n",tr->exon[i]->start,tr->exon[i]->end); /* for(k=0;kexon[i]->len;k++) { sf = tr->exon[i]->sf[k]; fprintf(ofp," SF %d %d %d %d\n",sf->start,sf->end,sf->hstart,sf->hend); } */ } for(i=0;ilen;i++) { show_Translation(tr->translation[i],ofp); } } %}