1 /* @source ensprediction ******************************************************
2 **
3 ** Ensembl Prediction functions
4 **
5 ** @author Copyright (C) 1999 Ensembl Developers
6 ** @author Copyright (C) 2006 Michael K. Schuster
7 ** @version $Revision: 1.58 $
8 ** @modified 2009 by Alan Bleasby for incorporation into EMBOSS core
9 ** @modified $Date: 2013/02/17 13:02:11 $ by $Author: mks $
10 ** @@
11 **
12 ** This library is free software; you can redistribute it and/or
13 ** modify it under the terms of the GNU Lesser General Public
14 ** License as published by the Free Software Foundation; either
15 ** version 2.1 of the License, or (at your option) any later version.
16 **
17 ** This library is distributed in the hope that it will be useful,
18 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ** Lesser General Public License for more details.
21 **
22 ** You should have received a copy of the GNU Lesser General Public
23 ** License along with this library; if not, write to the Free Software
24 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25 ** MA 02110-1301, USA.
26 **
27 ******************************************************************************/
28
29 /* ========================================================================= */
30 /* ============================= include files ============================= */
31 /* ========================================================================= */
32
33 #include "ensprediction.h"
34
35
36
37
38 /* ========================================================================= */
39 /* =============================== constants =============================== */
40 /* ========================================================================= */
41
42
43
44
45 /* ========================================================================= */
46 /* =========================== global variables ============================ */
47 /* ========================================================================= */
48
49
50
51
52 /* ========================================================================= */
53 /* ============================= private data ============================== */
54 /* ========================================================================= */
55
56
57
58
59 /* ========================================================================= */
60 /* =========================== private constants =========================== */
61 /* ========================================================================= */
62
63 /* @conststatic predictionexonadaptorKTablenames ******************************
64 **
65 ** Array of Ensembl Prediction Exon Adaptor SQL table names
66 **
67 ******************************************************************************/
68
69 static const char *const predictionexonadaptorKTablenames[] =
70 {
71 "prediction_exon",
72 (const char *) NULL
73 };
74
75
76
77
78 /* @conststatic predictionexonadaptorKColumnnames *****************************
79 **
80 ** Array of Ensembl Prediction Exon Adaptor SQL column names
81 **
82 ******************************************************************************/
83
84 static const char *const predictionexonadaptorKColumnnames[] =
85 {
86 "prediction_exon.prediction_exon_id",
87 "prediction_exon.seq_region_id",
88 "prediction_exon.seq_region_start",
89 "prediction_exon.seq_region_end",
90 "prediction_exon.seq_region_strand",
91 "prediction_exon.start_phase",
92 "prediction_exon.score",
93 "prediction_exon.p_value",
94 (const char *) NULL
95 };
96
97
98
99
100 /* @conststatic predictionexonadaptorKFinalcondition **************************
101 **
102 ** Ensembl Prediction Exon Adaptor SQL SELECT final condition
103 **
104 ******************************************************************************/
105
106 static const char *predictionexonadaptorKFinalcondition =
107 "ORDER BY "
108 "prediction_exon.prediction_transcript_id, prediction_exon.exon_rank";
109
110
111
112
113 /* @conststatic predictiontranscriptadaptorKTablenames ************************
114 **
115 ** Array of Ensembl Prediction Transcript Adaptor SQL table names
116 **
117 ******************************************************************************/
118
119 static const char *const predictiontranscriptadaptorKTablenames[] =
120 {
121 "prediction_transcript",
122 (const char *) NULL
123 };
124
125
126
127
128 /* @conststatic predictiontranscriptadaptorKColumnnames ***********************
129 **
130 ** Array of Ensembl Prediction Transcript Adaptor SQL column names
131 **
132 ******************************************************************************/
133
134 static const char *const predictiontranscriptadaptorKColumnnames[] =
135 {
136 "prediction_transcript.prediction_transcript_id",
137 "prediction_transcript.seq_region_id",
138 "prediction_transcript.seq_region_start",
139 "prediction_transcript.seq_region_end",
140 "prediction_transcript.seq_region_strand",
141 "prediction_transcript.analysis_id",
142 "prediction_transcript.display_label",
143 (const char *) NULL
144 };
145
146
147
148
149 /* ========================================================================= */
150 /* =========================== private variables =========================== */
151 /* ========================================================================= */
152
153
154
155
156 /* ========================================================================= */
157 /* =========================== private functions =========================== */
158 /* ========================================================================= */
159
160 static int listPredictionexonCompareEndAscending(
161 const void *item1,
162 const void *item2);
163
164 static int listPredictionexonCompareEndDescending(
165 const void *item1,
166 const void *item2);
167
168 static int listPredictionexonCompareIdentifierAscending(
169 const void *item1,
170 const void *item2);
171
172 static int listPredictionexonCompareStartAscending(
173 const void *item1,
174 const void *item2);
175
176 static int listPredictionexonCompareStartDescending(
177 const void *item1,
178 const void *item2);
179
180 static AjBool predictionexonadaptorFetchAllbyStatement(
181 EnsPBaseadaptor ba,
182 const AjPStr statement,
183 EnsPAssemblymapper am,
184 EnsPSlice slice,
185 AjPList pes);
186
187 static EnsPPredictiontranscript predictiontranscriptNewCpyFeatures(
188 EnsPPredictiontranscript pt);
189
190 static int listPredictiontranscriptCompareEndAscending(
191 const void *item1,
192 const void *item2);
193
194 static int listPredictiontranscriptCompareEndDescending(
195 const void *item1,
196 const void *item2);
197
198 static int listPredictiontranscriptCompareIdentifierAscending(
199 const void *item1,
200 const void *item2);
201
202 static int listPredictiontranscriptCompareStartAscending(
203 const void *item1,
204 const void *item2);
205
206 static int listPredictiontranscriptCompareStartDescending(
207 const void *item1,
208 const void *item2);
209
210 static AjBool predictiontranscriptadaptorFetchAllbyStatement(
211 EnsPBaseadaptor ba,
212 const AjPStr statement,
213 EnsPAssemblymapper am,
214 EnsPSlice slice,
215 AjPList pts);
216
217
218
219
220 /* ========================================================================= */
221 /* ======================= All functions by section ======================== */
222 /* ========================================================================= */
223
224
225
226
227 /* @filesection ensprediction *************************************************
228 **
229 ** @nam1rule ens Function belongs to the Ensembl library
230 **
231 ******************************************************************************/
232
233
234
235
236 /* @datasection [EnsPPredictionexon] Ensembl Prediction Exon ******************
237 **
238 ** @nam2rule Predictionexon Functions for manipulating
239 ** Ensembl Prediction Exon objects
240 **
241 ** @cc Bio::EnsEMBL::PredictionExon
242 ** @cc CVS Revision: 1.11
243 ** @cc CVS Tag: branch-ensembl-68
244 **
245 ******************************************************************************/
246
247
248
249
250 /* @section constructors ******************************************************
251 **
252 ** All constructors return a new Ensembl Prediction Exon by pointer.
253 ** It is the responsibility of the user to first destroy any previous
254 ** Prediction Exon. The target pointer does not need to be initialised to
255 ** NULL, but it is good programming practice to do so anyway.
256 **
257 ** @fdata [EnsPPredictionexon]
258 **
259 ** @nam3rule New Constructor
260 ** @nam4rule Cpy Constructor with existing object
261 ** @nam4rule Ini Constructor with initial values
262 ** @nam4rule Ref Constructor by incrementing the reference counter
263 **
264 ** @argrule Cpy pe [const EnsPPredictionexon] Ensembl Prediction Exon
265 ** @argrule Ini pea [EnsPPredictionexonadaptor] Ensembl Prediction Exon Adaptor
266 ** @argrule Ini identifier [ajuint] SQL database-internal identifier
267 ** @argrule Ini feature [EnsPFeature] Ensembl Feature
268 ** @argrule Ini sphase [ajint] Start phase of Translation
269 ** @argrule Ini score [double] Score
270 ** @argrule Ini pvalue [double] P-value
271 ** @argrule Ref pe [EnsPPredictionexon] Ensembl Prediction Exon
272 **
273 ** @valrule * [EnsPPredictionexon] Ensembl Prediction Exon or NULL
274 **
275 ** @fcategory new
276 ******************************************************************************/
277
278
279
280
281 /* @func ensPredictionexonNewCpy **********************************************
282 **
283 ** Object-based constructor function, which returns an independent object.
284 **
285 ** @param [r] pe [const EnsPPredictionexon] Ensembl Prediction Exon
286 **
287 ** @return [EnsPPredictionexon] Ensembl Prediction Exon or NULL
288 **
289 ** @release 6.4.0
290 ** @@
291 ******************************************************************************/
292
ensPredictionexonNewCpy(const EnsPPredictionexon pe)293 EnsPPredictionexon ensPredictionexonNewCpy(const EnsPPredictionexon pe)
294 {
295 EnsPPredictionexon pthis = NULL;
296
297 if (!pe)
298 return NULL;
299
300 AJNEW0(pthis);
301
302 pthis->Use = 1U;
303 pthis->Identifier = pe->Identifier;
304 pthis->Adaptor = pe->Adaptor;
305 pthis->Feature = ensFeatureNewRef(pe->Feature);
306 pthis->PhaseStart = pe->PhaseStart;
307 pthis->Score = pe->Score;
308 pthis->Pvalue = pe->Pvalue;
309
310 if (pe->SequenceCache)
311 pthis->SequenceCache = ajStrNewRef(pe->SequenceCache);
312
313 return pthis;
314 }
315
316
317
318
319 /* @func ensPredictionexonNewIni **********************************************
320 **
321 ** Constructor for an Ensembl Prediction Exon with initial values.
322 **
323 ** @cc Bio::EnsEMBL::Storable::new
324 ** @param [u] pea [EnsPPredictionexonadaptor] Ensembl Prediction Exon Adaptor
325 ** @param [r] identifier [ajuint] SQL database-internal identifier
326 ** @cc Bio::EnsEMBL::Feature::new
327 ** @param [u] feature [EnsPFeature] Ensembl Feature
328 ** @cc Bio::EnsEMBL::PredictionExon::new
329 ** @param [r] sphase [ajint] Start phase of Translation
330 ** @param [r] score [double] Score
331 ** @param [r] pvalue [double] P-value
332 **
333 ** @return [EnsPPredictionexon] Ensembl Prediction Exon or NULL
334 **
335 ** @release 6.4.0
336 ** @@
337 ******************************************************************************/
338
ensPredictionexonNewIni(EnsPPredictionexonadaptor pea,ajuint identifier,EnsPFeature feature,ajint sphase,double score,double pvalue)339 EnsPPredictionexon ensPredictionexonNewIni(EnsPPredictionexonadaptor pea,
340 ajuint identifier,
341 EnsPFeature feature,
342 ajint sphase,
343 double score,
344 double pvalue)
345 {
346 EnsPPredictionexon pe = NULL;
347
348 if (!feature)
349 return NULL;
350
351 AJNEW0(pe);
352
353 pe->Use = 1U;
354 pe->Identifier = identifier;
355 pe->Adaptor = pea;
356 pe->Feature = ensFeatureNewRef(feature);
357 pe->PhaseStart = sphase;
358 pe->Score = score;
359 pe->Pvalue = pvalue;
360
361 return pe;
362 }
363
364
365
366
367 /* @func ensPredictionexonNewRef **********************************************
368 **
369 ** Ensembl Object referencing function, which returns a pointer to the
370 ** Ensembl Object passed in and increases its reference count.
371 **
372 ** @param [u] pe [EnsPPredictionexon] Ensembl Prediction Exon
373 **
374 ** @return [EnsPPredictionexon] Ensembl Prediction Exon or NULL
375 **
376 ** @release 6.2.0
377 ** @@
378 ******************************************************************************/
379
ensPredictionexonNewRef(EnsPPredictionexon pe)380 EnsPPredictionexon ensPredictionexonNewRef(EnsPPredictionexon pe)
381 {
382 if (!pe)
383 return NULL;
384
385 pe->Use++;
386
387 return pe;
388 }
389
390
391
392
393 /* @section destructors *******************************************************
394 **
395 ** Destruction destroys all internal data structures and frees the memory
396 ** allocated for an Ensembl Prediction Exon object.
397 **
398 ** @fdata [EnsPPredictionexon]
399 **
400 ** @nam3rule Del Destroy (free) an Ensembl Prediction Exon
401 **
402 ** @argrule * Ppe [EnsPPredictionexon*] Ensembl Prediction Exon address
403 **
404 ** @valrule * [void]
405 **
406 ** @fcategory delete
407 ******************************************************************************/
408
409
410
411
412 /* @func ensPredictionexonDel *************************************************
413 **
414 ** Default destructor for an Ensembl Prediction Exon.
415 **
416 ** @param [d] Ppe [EnsPPredictionexon*] Ensembl Prediction Exon address
417 **
418 ** @return [void]
419 **
420 ** @release 6.2.0
421 ** @@
422 ******************************************************************************/
423
ensPredictionexonDel(EnsPPredictionexon * Ppe)424 void ensPredictionexonDel(EnsPPredictionexon *Ppe)
425 {
426 EnsPPredictionexon pthis = NULL;
427
428 if (!Ppe)
429 return;
430
431 #if defined(AJ_DEBUG) && AJ_DEBUG >= 1
432 if (ajDebugTest("ensPredictionexonDel"))
433 {
434 ajDebug("ensPredictionexonDel\n"
435 " *Ppe %p\n",
436 *Ppe);
437
438 ensPredictionexonTrace(*Ppe, 1);
439 }
440 #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 1 */
441
442 if (!(pthis = *Ppe) || --pthis->Use)
443 {
444 *Ppe = NULL;
445
446 return;
447 }
448
449 ensFeatureDel(&pthis->Feature);
450
451 ajStrDel(&pthis->SequenceCache);
452
453 ajMemFree((void **) Ppe);
454
455 return;
456 }
457
458
459
460
461 /* @section member retrieval **************************************************
462 **
463 ** Functions for returning members of an Ensembl Prediction Exon object.
464 **
465 ** @fdata [EnsPPredictionexon]
466 **
467 ** @nam3rule Get Return Prediction Exon attribute(s)
468 ** @nam4rule Adaptor Return the Ensembl Prediction Exon Adaptor
469 ** @nam4rule Feature Return the Ensembl Feature
470 ** @nam4rule Identifier Return the SQL database-internal identifier
471 ** @nam4rule Phase Return a phase
472 ** @nam5rule Start Return the phase at start
473 ** @nam4rule Pvalue Return the p-value
474 ** @nam4rule Score Return the score
475 **
476 ** @argrule * pe [const EnsPPredictionexon] Prediction Exon
477 **
478 ** @valrule Adaptor [EnsPPredictionexonadaptor] Ensembl Prediction Exon Adaptor
479 **`or NULL
480 ** @valrule Feature [EnsPFeature] Ensembl Feature or NULL
481 ** @valrule Identifier [ajuint] SQL database-internal identifier or 0U
482 ** @valrule PhaseStart [ajint] Phase at start or 0
483 ** @valrule Pvalue [double] P-value or 0.0
484 ** @valrule Score [double] Score or 0.0
485 **
486 ** @fcategory use
487 ******************************************************************************/
488
489
490
491
492 /* @func ensPredictionexonGetAdaptor ******************************************
493 **
494 ** Get the Ensembl Prediction Exon Adaptor member of an
495 ** Ensembl Prediction Exon.
496 **
497 ** @cc Bio::EnsEMBL::Storable::adaptor
498 ** @param [r] pe [const EnsPPredictionexon] Ensembl Prediction Exon
499 **
500 ** @return [EnsPPredictionexonadaptor] Ensembl Prediction Exon Adaptor or NULL
501 **
502 ** @release 6.2.0
503 ** @@
504 ******************************************************************************/
505
ensPredictionexonGetAdaptor(const EnsPPredictionexon pe)506 EnsPPredictionexonadaptor ensPredictionexonGetAdaptor(
507 const EnsPPredictionexon pe)
508 {
509 return (pe) ? pe->Adaptor : NULL;
510 }
511
512
513
514
515 /* @func ensPredictionexonGetFeature ******************************************
516 **
517 ** Get the Ensembl Feature member of an Ensembl Prediction Exon.
518 **
519 ** @param [r] pe [const EnsPPredictionexon] Ensembl Prediction Exon
520 **
521 ** @return [EnsPFeature] Ensembl Feature or NULL
522 **
523 ** @release 6.2.0
524 ** @@
525 ******************************************************************************/
526
ensPredictionexonGetFeature(const EnsPPredictionexon pe)527 EnsPFeature ensPredictionexonGetFeature(const EnsPPredictionexon pe)
528 {
529 return (pe) ? pe->Feature : NULL;
530 }
531
532
533
534
535 /* @func ensPredictionexonGetIdentifier ***************************************
536 **
537 ** Get the SQL database-internal identifier member of an
538 ** Ensembl Prediction Exon.
539 **
540 ** @cc Bio::EnsEMBL::Storable::dbID
541 ** @param [r] pe [const EnsPPredictionexon] Ensembl Prediction Exon
542 **
543 ** @return [ajuint] SQL database-internal identifier or 0U
544 **
545 ** @release 6.2.0
546 ** @@
547 ******************************************************************************/
548
ensPredictionexonGetIdentifier(const EnsPPredictionexon pe)549 ajuint ensPredictionexonGetIdentifier(const EnsPPredictionexon pe)
550 {
551 return (pe) ? pe->Identifier : 0U;
552 }
553
554
555
556
557 /* @func ensPredictionexonGetPhaseStart ***************************************
558 **
559 ** Get the phase at start member of an Ensembl Prediction Exon.
560 **
561 ** @cc Bio::EnsEMBL::PredictionExon::phase
562 ** @param [r] pe [const EnsPPredictionexon] Ensembl Prediction Exon
563 **
564 ** @return [ajint] Start phase or 0
565 **
566 ** @release 6.4.0
567 ** @@
568 **
569 ** Get or set the phase of the Exon, which tells the translation machinery,
570 ** which makes a peptide from the DNA, where to start.
571 **
572 ** The Ensembl phase convention can be thought of as "the number of bases of
573 ** the first codon which are on the previous exon". It is therefore 0, 1 or 2
574 ** or -1 if the exon is non-coding. In ASCII art, with alternate codons
575 ** represented by '###' and '+++':
576 **
577 ** Previous Exon Intron This Exon
578 ** ...------------- -------------...
579 **
580 ** 5' Phase 3'
581 ** ...#+++###+++### 0 +++###+++###+...
582 ** ...+++###+++###+ 1 ++###+++###++...
583 ** ...++###+++###++ 2 +###+++###+++...
584 **
585 ** Here is another explanation from Ewan:
586 **
587 ** Phase means the place where the intron lands inside the codon - 0 between
588 ** codons, 1 between the 1st and second base, 2 between the second and 3rd
589 ** base. Exons therefore have a start phase and an end phase, but introns have
590 ** just one phase.
591 ******************************************************************************/
592
ensPredictionexonGetPhaseStart(const EnsPPredictionexon pe)593 ajint ensPredictionexonGetPhaseStart(const EnsPPredictionexon pe)
594 {
595 return (pe) ? pe->PhaseStart : 0;
596 }
597
598
599
600
601 /* @func ensPredictionexonGetPvalue *******************************************
602 **
603 ** Get the p-value member of an Ensembl Prediction Exon.
604 **
605 ** @param [r] pe [const EnsPPredictionexon] Ensembl Prediction Exon
606 **
607 ** @return [double] P-value or 0.0
608 **
609 ** @release 6.2.0
610 ** @@
611 ******************************************************************************/
612
ensPredictionexonGetPvalue(const EnsPPredictionexon pe)613 double ensPredictionexonGetPvalue(const EnsPPredictionexon pe)
614 {
615 return (pe) ? pe->Pvalue : 0.0;
616 }
617
618
619
620
621 /* @func ensPredictionexonGetScore ********************************************
622 **
623 ** Get the score member of an Ensembl Prediction Exon.
624 **
625 ** @param [r] pe [const EnsPPredictionexon] Ensembl Prediction Exon
626 **
627 ** @return [double] Score or 0.0
628 **
629 ** @release 6.2.0
630 ** @@
631 ******************************************************************************/
632
ensPredictionexonGetScore(const EnsPPredictionexon pe)633 double ensPredictionexonGetScore(const EnsPPredictionexon pe)
634 {
635 return (pe) ? pe->Score : 0.0;
636 }
637
638
639
640
641 /* @section member assignment *************************************************
642 **
643 ** Functions for assigning members of an Ensembl Prediction Exon object.
644 **
645 ** @fdata [EnsPPredictionexon]
646 **
647 ** @nam3rule Set Set one member of a Prediction Exon
648 ** @nam4rule Adaptor Set the Ensembl Prediction Exon Adaptor
649 ** @nam4rule Feature Set the Ensembl Feature
650 ** @nam4rule Identifier Set the SQL database-internal identifier
651 ** @nam4rule Phase Set a phase
652 ** @nam5rule Start Set the phase at start
653 ** @nam4rule Pvalue Set the p-value
654 ** @nam4rule Score Set the score
655 **
656 ** @argrule * pe [EnsPPredictionexon] Ensembl Prediction Exon object
657 ** @argrule Adaptor pea [EnsPPredictionexonadaptor]
658 ** Ensembl Prediction Exon Adaptor
659 ** @argrule Feature feature [EnsPFeature] Ensembl Feature
660 ** @argrule Identifier identifier [ajuint] SQL database-internal identifier
661 ** @argrule PhaseStart sphase [ajint] Start phase
662 ** @argrule Pvalue pvalue [double] P-value
663 ** @argrule Score score [double] Score
664 **
665 ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise
666 **
667 ** @fcategory modify
668 ******************************************************************************/
669
670
671
672
673 /* @func ensPredictionexonSetAdaptor ******************************************
674 **
675 ** Set the Ensembl Prediction Exon Adaptor member of an
676 ** Ensembl Prediction Exon.
677 **
678 ** @cc Bio::EnsEMBL::Storable::adaptor
679 ** @param [u] pe [EnsPPredictionexon] Ensembl Prediction Exon
680 ** @param [u] pea [EnsPPredictionexonadaptor] Ensembl Prediction Exon Adaptor
681 **
682 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
683 **
684 ** @release 6.3.0
685 ** @@
686 ******************************************************************************/
687
ensPredictionexonSetAdaptor(EnsPPredictionexon pe,EnsPPredictionexonadaptor pea)688 AjBool ensPredictionexonSetAdaptor(EnsPPredictionexon pe,
689 EnsPPredictionexonadaptor pea)
690 {
691 if (!pe)
692 return ajFalse;
693
694 pe->Adaptor = pea;
695
696 return ajTrue;
697 }
698
699
700
701
702 /* @func ensPredictionexonSetFeature ******************************************
703 **
704 ** Set the Ensembl Feature member of an Ensembl Prediction Exon.
705 **
706 ** @param [u] pe [EnsPPredictionexon] Ensembl Prediction Exon
707 ** @param [u] feature [EnsPFeature] Ensembl Feature
708 **
709 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
710 **
711 ** @release 6.2.0
712 ** @@
713 ******************************************************************************/
714
ensPredictionexonSetFeature(EnsPPredictionexon pe,EnsPFeature feature)715 AjBool ensPredictionexonSetFeature(EnsPPredictionexon pe,
716 EnsPFeature feature)
717 {
718 if (ajDebugTest("ensPredictionexonSetFeature"))
719 {
720 ajDebug("ensPredictionexonSetFeature\n"
721 " pe %p\n"
722 " feature %p\n",
723 pe,
724 feature);
725
726 ensPredictionexonTrace(pe, 1);
727
728 ensFeatureTrace(feature, 1);
729 }
730
731 if (!pe)
732 return ajFalse;
733
734 if (!feature)
735 return ajFalse;
736
737 /* Replace the current Feature. */
738
739 ensFeatureDel(&pe->Feature);
740
741 pe->Feature = ensFeatureNewRef(feature);
742
743 /* Clear the sequence cache. */
744
745 ajStrDel(&pe->SequenceCache);
746
747 return ajTrue;
748 }
749
750
751
752
753 /* @func ensPredictionexonSetIdentifier ***************************************
754 **
755 ** Set the SQL database-internal identifier member of an
756 ** Ensembl Prediction Exon.
757 **
758 ** @cc Bio::EnsEMBL::Storable::dbID
759 ** @param [u] pe [EnsPPredictionexon] Ensembl Prediction Exon
760 ** @param [r] identifier [ajuint] SQL database-internal identifier
761 **
762 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
763 **
764 ** @release 6.2.0
765 ** @@
766 ******************************************************************************/
767
ensPredictionexonSetIdentifier(EnsPPredictionexon pe,ajuint identifier)768 AjBool ensPredictionexonSetIdentifier(EnsPPredictionexon pe,
769 ajuint identifier)
770 {
771 if (!pe)
772 return ajFalse;
773
774 pe->Identifier = identifier;
775
776 return ajTrue;
777 }
778
779
780
781
782 /* @func ensPredictionexonSetPhaseStart ***************************************
783 **
784 ** Set the phase at start member of an Ensembl Prediction Exon.
785 **
786 ** @cc Bio::EnsEMBL::PredictionExon::phase
787 ** @param [u] pe [EnsPPredictionexon] Ensembl Prediction Exon
788 ** @param [r] sphase [ajint] Start phase
789 **
790 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
791 **
792 ** @release 6.4.0
793 ** @@
794 ******************************************************************************/
795
ensPredictionexonSetPhaseStart(EnsPPredictionexon pe,ajint sphase)796 AjBool ensPredictionexonSetPhaseStart(EnsPPredictionexon pe,
797 ajint sphase)
798 {
799 if (!pe)
800 return ajFalse;
801
802 pe->PhaseStart = sphase;
803
804 return ajTrue;
805 }
806
807
808
809
810 /* @func ensPredictionexonSetPvalue *******************************************
811 **
812 ** Set the p-value member of an Ensembl Prediction Exon.
813 **
814 ** @cc Bio::EnsEMBL::PredictionExon::p_value
815 ** @param [u] pe [EnsPPredictionexon] Ensembl Prediction Exon
816 ** @param [r] pvalue [double] P-value
817 **
818 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
819 **
820 ** @release 6.2.0
821 ** @@
822 ******************************************************************************/
823
ensPredictionexonSetPvalue(EnsPPredictionexon pe,double pvalue)824 AjBool ensPredictionexonSetPvalue(EnsPPredictionexon pe,
825 double pvalue)
826 {
827 if (!pe)
828 return ajFalse;
829
830 pe->Pvalue = pvalue;
831
832 return ajTrue;
833 }
834
835
836
837
838 /* @func ensPredictionexonSetScore ********************************************
839 **
840 ** Set the score member of an Ensembl Prediction Exon.
841 **
842 ** @cc Bio::EnsEMBL::PredictionExon::score
843 ** @param [u] pe [EnsPPredictionexon] Ensembl Prediction Exon
844 ** @param [r] score [double] Score
845 **
846 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
847 **
848 ** @release 6.2.0
849 ** @@
850 ******************************************************************************/
851
ensPredictionexonSetScore(EnsPPredictionexon pe,double score)852 AjBool ensPredictionexonSetScore(EnsPPredictionexon pe,
853 double score)
854 {
855 if (!pe)
856 return ajFalse;
857
858 pe->Score = score;
859
860 return ajTrue;
861 }
862
863
864
865
866 /* @section debugging *********************************************************
867 **
868 ** Functions for reporting of an Ensembl Prediction Exon object.
869 **
870 ** @fdata [EnsPPredictionexon]
871 **
872 ** @nam3rule Trace Report Ensembl Prediction Exon members to debug file
873 **
874 ** @argrule Trace pe [const EnsPPredictionexon] Ensembl Prediction Exon
875 ** @argrule Trace level [ajuint] Indentation level
876 **
877 ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise
878 **
879 ** @fcategory misc
880 ******************************************************************************/
881
882
883
884
885 /* @func ensPredictionexonTrace ***********************************************
886 **
887 ** Trace an Ensembl Prediction Exon.
888 **
889 ** @param [r] pe [const EnsPPredictionexon] Ensembl Prediction Exon
890 ** @param [r] level [ajuint] Indentation level
891 **
892 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
893 **
894 ** @release 6.2.0
895 ** @@
896 ******************************************************************************/
897
ensPredictionexonTrace(const EnsPPredictionexon pe,ajuint level)898 AjBool ensPredictionexonTrace(const EnsPPredictionexon pe, ajuint level)
899 {
900 AjPStr indent = NULL;
901
902 if (!pe)
903 return ajFalse;
904
905 indent = ajStrNew();
906
907 ajStrAppendCountK(&indent, ' ', level * 2);
908
909 ajDebug("%SensPredictionexonTrace %p\n"
910 "%S Use %u\n"
911 "%S Identifier %u\n"
912 "%S Adaptor %p\n"
913 "%S Feature %p\n"
914 "%S PhaseStart %d\n"
915 "%S Score %f\n"
916 "%S P-value %f\n",
917 indent, pe,
918 indent, pe->Use,
919 indent, pe->Identifier,
920 indent, pe->Adaptor,
921 indent, pe->Feature,
922 indent, pe->PhaseStart,
923 indent, pe->Score,
924 indent, pe->Pvalue);
925
926 ensFeatureTrace(pe->Feature, level + 1);
927
928 ajStrDel(&indent);
929
930 return ajTrue;
931 }
932
933
934
935
936 /* @section calculate *********************************************************
937 **
938 ** Functions for calculating information from an
939 ** Ensembl Prediction Exon object.
940 **
941 ** @fdata [EnsPPredictionexon]
942 **
943 ** @nam3rule Calculate Calculate Ensembl Prediction Exon information
944 ** @nam4rule Memsize Calculate the memory size in bytes
945 **
946 ** @argrule Memsize pe [const EnsPPredictionexon] Ensembl Prediction Exon
947 **
948 ** @valrule Memsize [size_t] Memory size in bytes or 0
949 **
950 ** @fcategory misc
951 ******************************************************************************/
952
953
954
955
956 /* @func ensPredictionexonCalculateMemsize ************************************
957 **
958 ** Calculate the memory size in bytes of an Ensembl Prediction Exon.
959 **
960 ** @param [r] pe [const EnsPPredictionexon] Ensembl Prediction Exon
961 **
962 ** @return [size_t] Memory size in bytes or 0
963 **
964 ** @release 6.4.0
965 ** @@
966 ******************************************************************************/
967
ensPredictionexonCalculateMemsize(const EnsPPredictionexon pe)968 size_t ensPredictionexonCalculateMemsize(const EnsPPredictionexon pe)
969 {
970 size_t size = 0;
971
972 if (!pe)
973 return 0;
974
975 size += sizeof (EnsOPredictionexon);
976
977 size += ensFeatureCalculateMemsize(pe->Feature);
978
979 return size;
980 }
981
982
983
984
985 /* @section convenience functions *********************************************
986 **
987 ** Ensembl Prediction Exon convenience functions
988 **
989 ** @fdata [EnsPPredictionexon]
990 **
991 ** @nam3rule Get Get member(s) of associated objects
992 ** @nam4rule Phase Get the phase
993 ** @nam5rule End Get the end phase
994 **
995 ** @argrule * pe [const EnsPPredictionexon] Ensembl Prediction Exon
996 **
997 ** @valrule PhaseEnd [ajint] End phase or 0
998 **
999 ** @fcategory use
1000 ******************************************************************************/
1001
1002
1003
1004
1005 /* @func ensPredictionexonGetPhaseEnd *****************************************
1006 **
1007 ** Get the end phase member of an Ensembl Prediction Exon.
1008 **
1009 ** @cc Bio::EnsEMBL::PredictionExon::end_phase
1010 ** @param [r] pe [const EnsPPredictionexon] Ensembl Prediction Exon
1011 **
1012 ** @return [ajint] End phase or 0
1013 **
1014 ** @release 6.4.0
1015 ** @@
1016 ******************************************************************************/
1017
ensPredictionexonGetPhaseEnd(const EnsPPredictionexon pe)1018 ajint ensPredictionexonGetPhaseEnd(const EnsPPredictionexon pe)
1019 {
1020 if (!pe)
1021 return 0;
1022
1023 return (pe->PhaseStart + ensFeatureCalculateLength(pe->Feature)) % 3;
1024 }
1025
1026
1027
1028
1029 /* @section map ***************************************************************
1030 **
1031 ** Functions for mapping Ensembl Prediction Exon objects between
1032 ** Ensembl Coordinate System objects.
1033 **
1034 ** @fdata [EnsPPredictionexon]
1035 **
1036 ** @nam3rule Transfer Transfer an Ensembl Prediction Exon
1037 ** @nam3rule Transform Transform an Ensembl Prediction Exon
1038 **
1039 ** @argrule * pe [EnsPPredictionexon] Ensembl Prediction Exon
1040 ** @argrule Transfer slice [EnsPSlice] Ensembl Slice
1041 ** @argrule Transform csname [const AjPStr] Ensembl Coordinate System name
1042 ** @argrule Transform csversion [const AjPStr] Ensembl Coordinate System
1043 ** version
1044 **
1045 ** @valrule * [EnsPPredictionexon] Ensembl Prediction Exon or NULL
1046 **
1047 ** @fcategory misc
1048 ******************************************************************************/
1049
1050
1051
1052
1053 /* @func ensPredictionexonTransfer ********************************************
1054 **
1055 ** Transfer an Ensembl Prediction Exon onto another Ensembl Slice.
1056 **
1057 ** @cc Bio::EnsEMBL::PredictionExon::transfer
1058 ** @param [u] pe [EnsPPredictionexon] Ensembl Prediction Exon
1059 ** @param [u] slice [EnsPSlice] Ensembl Slice
1060 ** @see ensFeatureTransfer
1061 **
1062 ** @return [EnsPPredictionexon] Ensembl Prediction Exon on the defined
1063 ** Ensembl Slice or NULL
1064 **
1065 ** @release 6.2.0
1066 ** @@
1067 ******************************************************************************/
1068
ensPredictionexonTransfer(EnsPPredictionexon pe,EnsPSlice slice)1069 EnsPPredictionexon ensPredictionexonTransfer(EnsPPredictionexon pe,
1070 EnsPSlice slice)
1071 {
1072 EnsPPredictionexon npe = NULL;
1073 EnsPFeature newfeature = NULL;
1074
1075 if (!pe)
1076 return NULL;
1077
1078 if (!slice)
1079 return NULL;
1080
1081 newfeature = ensFeatureTransfer(pe->Feature, slice);
1082
1083 if (!newfeature)
1084 return NULL;
1085
1086 npe = ensPredictionexonNewCpy(pe);
1087
1088 ensPredictionexonSetFeature(npe, newfeature);
1089
1090 ensFeatureDel(&newfeature);
1091
1092 return npe;
1093 }
1094
1095
1096
1097
1098 /* @func ensPredictionexonTransform *******************************************
1099 **
1100 ** Transform an Ensembl Prediction Exon into another Ensembl Coordinate System.
1101 **
1102 ** @cc Bio::EnsEMBL::PredictionExon::transform
1103 ** @param [u] pe [EnsPPredictionexon] Ensembl Prediction Exon
1104 ** @param [r] csname [const AjPStr] Ensembl Coordinate System name
1105 ** @param [r] csversion [const AjPStr] Ensembl Coordinate System version
1106 ** @see ensFeatureTransform
1107 **
1108 ** @return [EnsPPredictionexon] Ensembl Prediction Exon in the defined
1109 ** Ensembl Coordinate System or NULL
1110 **
1111 ** @release 6.2.0
1112 ** @@
1113 ******************************************************************************/
1114
ensPredictionexonTransform(EnsPPredictionexon pe,const AjPStr csname,const AjPStr csversion)1115 EnsPPredictionexon ensPredictionexonTransform(EnsPPredictionexon pe,
1116 const AjPStr csname,
1117 const AjPStr csversion)
1118 {
1119 EnsPPredictionexon npe = NULL;
1120 EnsPFeature nfeature = NULL;
1121
1122 if (!pe)
1123 return NULL;
1124
1125 if (!csname)
1126 return NULL;
1127
1128 if (!csversion)
1129 return NULL;
1130
1131 nfeature = ensFeatureTransform(pe->Feature,
1132 csname,
1133 csversion,
1134 (EnsPSlice) NULL);
1135
1136 if (!nfeature)
1137 return NULL;
1138
1139 npe = ensPredictionexonNewCpy(pe);
1140
1141 ensPredictionexonSetFeature(npe, nfeature);
1142
1143 ensFeatureDel(&nfeature);
1144
1145 return npe;
1146 }
1147
1148
1149
1150
1151 /* @section fetch *************************************************************
1152 **
1153 ** Functions for fetching information from an Ensembl Prediction Exon object.
1154 **
1155 ** @fdata [EnsPPredictionexon]
1156 **
1157 ** @nam3rule Fetch Fetch Ensembl Prediction Exon information
1158 ** @nam4rule Displayidentifier Fetch the display identifier
1159 ** @nam4rule Sequence Fetch the sequence
1160 ** @nam5rule Seq Fetch the sequence as AJAX Sequence object
1161 ** @nam5rule Str Fetch the sequence as AJAX String object
1162 **
1163 ** @argrule Displayidentifier pe [const EnsPPredictionexon] Ensembl Prediction
1164 ** Exon
1165 ** @argrule Displayidentifier Pidentifier [AjPStr*] Display identifier address
1166 ** @argrule SequenceSeq pe [EnsPPredictionexon] Ensembl Prediction Exon
1167 ** @argrule SequenceSeq Psequence [AjPSeq*] AJAX Sequence object address
1168 ** @argrule SequenceStr pe [EnsPPredictionexon] Ensembl Prediction Exon
1169 ** @argrule SequenceStr Psequence [AjPStr*] AJAX String object address
1170 **
1171 ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise
1172 **
1173 ** @fcategory misc
1174 ******************************************************************************/
1175
1176
1177
1178
1179 /* @func ensPredictionexonFetchSequenceSeq ************************************
1180 **
1181 ** Fetch the sequence of an Ensembl Prediction Exon as AJAX Sequence.
1182 ** The caller is responsible for deleting the AJAX Sequence.
1183 **
1184 ** @cc Bio::EnsEMBL::PredictionExon:seq
1185 ** @param [u] pe [EnsPPredictionexon] Ensembl Prediction Exon
1186 ** @param [wP] Psequence [AjPSeq*] Ensembl Prediction Exon sequence address
1187 **
1188 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
1189 **
1190 ** @release 6.3.0
1191 ** @@
1192 ******************************************************************************/
1193
ensPredictionexonFetchSequenceSeq(EnsPPredictionexon pe,AjPSeq * Psequence)1194 AjBool ensPredictionexonFetchSequenceSeq(EnsPPredictionexon pe,
1195 AjPSeq *Psequence)
1196 {
1197 AjPStr name = NULL;
1198 AjPStr sequence = NULL;
1199
1200 if (!pe)
1201 return ajFalse;
1202
1203 if (!Psequence)
1204 return ajFalse;
1205
1206 /*
1207 ** It is sligtly more efficient, if undefined AJAX String objects are
1208 ** directly allocated by the following functions to their final size.
1209 */
1210
1211 name = ajFmtStr("%u", pe->Identifier);
1212
1213 ensPredictionexonFetchSequenceStr(pe, &sequence);
1214
1215 if (*Psequence)
1216 {
1217 ajSeqClear(*Psequence);
1218
1219 ajSeqAssignNameS(*Psequence, name);
1220 ajSeqAssignSeqS(*Psequence, sequence);
1221 }
1222 else
1223 *Psequence = ajSeqNewNameS(sequence, name);
1224
1225 ajSeqSetNuc(*Psequence);
1226
1227 ajStrDel(&name);
1228 ajStrDel(&sequence);
1229
1230 return ajTrue;
1231 }
1232
1233
1234
1235
1236 /* @func ensPredictionexonFetchSequenceStr ************************************
1237 **
1238 ** Fetch the sequence of an Ensembl Prediction Exon as AJAX String.
1239 ** The caller is responsible for deleting the AJAX String.
1240 **
1241 ** @param [u] pe [EnsPPredictionexon] Ensembl Prediction Exon
1242 ** @param [wP] Psequence [AjPStr*] Ensembl Exon sequence address
1243 **
1244 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
1245 **
1246 ** @release 6.3.0
1247 ** @@
1248 ******************************************************************************/
1249
ensPredictionexonFetchSequenceStr(EnsPPredictionexon pe,AjPStr * Psequence)1250 AjBool ensPredictionexonFetchSequenceStr(EnsPPredictionexon pe,
1251 AjPStr *Psequence)
1252 {
1253 EnsPFeature feature = NULL;
1254
1255 EnsPSlice slice = NULL;
1256
1257 if (!pe)
1258 return ajFalse;
1259
1260 if (!Psequence)
1261 return ajFalse;
1262
1263 if (*Psequence)
1264 ajStrAssignClear(Psequence);
1265 else
1266 *Psequence = ajStrNew();
1267
1268 feature = pe->Feature;
1269
1270 if (!feature)
1271 {
1272 ajWarn("ensPredictionexonFetchSequenceStr cannot get sequence without "
1273 "an Ensembl Feature attached to the Ensembl Prediction Exon "
1274 "with idetifier %u.\n",
1275 pe->Identifier);
1276
1277 return ajFalse;
1278 }
1279
1280 slice = ensFeatureGetSlice(feature);
1281
1282 if (!slice)
1283 {
1284 ajWarn("ensPredictionExonFetchSequenceStr cannot get sequence without "
1285 "an Ensembl Slice attached to the Ensembl Feature in the "
1286 "Ensembl Prediction Exon with identifier %u.\n",
1287 pe->Identifier);
1288
1289 return ajFalse;
1290 }
1291
1292 /*
1293 ** It is sligtly more efficient, if undefined AJAX String objects are
1294 ** directly allocated by the following functions to their final size.
1295 */
1296
1297 if ((pe->SequenceCache == NULL) ||
1298 (ajStrGetLen(pe->SequenceCache) == 0))
1299 ensSliceFetchSequenceSubStr(slice,
1300 feature->Start,
1301 feature->End,
1302 feature->Strand,
1303 &pe->SequenceCache);
1304
1305 ajStrAssignS(Psequence, pe->SequenceCache);
1306
1307 return ajTrue;
1308 }
1309
1310
1311
1312
1313 /* @datasection [AjPList] AJAX List *******************************************
1314 **
1315 ** @nam2rule List Functions for manipulating AJAX List objects
1316 **
1317 ******************************************************************************/
1318
1319
1320
1321
1322 /* @funcstatic listPredictionexonCompareEndAscending **************************
1323 **
1324 ** AJAX List of Ensembl Prediction Exon objects comparison function to sort by
1325 ** Ensembl Feature end coordinate in ascending order.
1326 **
1327 ** @param [r] item1 [const void*] Ensembl Prediction Exon address 1
1328 ** @param [r] item2 [const void*] Ensembl Prediction Exon address 2
1329 ** @see ajListSort
1330 **
1331 ** @return [int] The comparison function returns an integer less than,
1332 ** equal to, or greater than zero if the first argument is
1333 ** considered to be respectively less than, equal to, or
1334 ** greater than the second.
1335 **
1336 ** @release 6.4.0
1337 ** @@
1338 ******************************************************************************/
1339
listPredictionexonCompareEndAscending(const void * item1,const void * item2)1340 static int listPredictionexonCompareEndAscending(
1341 const void *item1,
1342 const void *item2)
1343 {
1344 EnsPPredictionexon pe1 = *(EnsOPredictionexon *const *) item1;
1345 EnsPPredictionexon pe2 = *(EnsOPredictionexon *const *) item2;
1346
1347 #if defined(AJ_DEBUG) && AJ_DEBUG >= 2
1348 if (ajDebugTest("listPredictionexonCompareEndAscending"))
1349 ajDebug("listPredictionexonCompareEndAscending\n"
1350 " pe1 %p\n"
1351 " pe2 %p\n",
1352 pe1,
1353 pe2);
1354 #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 2 */
1355
1356 /* Sort empty values towards the end of the AJAX List. */
1357
1358 if (pe1 && (!pe2))
1359 return -1;
1360
1361 if ((!pe1) && (!pe2))
1362 return 0;
1363
1364 if ((!pe1) && pe2)
1365 return +1;
1366
1367 return ensFeatureCompareEndAscending(pe1->Feature, pe2->Feature);
1368 }
1369
1370
1371
1372
1373 /* @funcstatic listPredictionexonCompareEndDescending *************************
1374 **
1375 ** AJAX List of Ensembl Exon objects comparison function to sort by
1376 ** Ensembl Feature start coordinate in descending order.
1377 **
1378 ** @param [r] item1 [const void*] Ensembl Prediction Exon address 1
1379 ** @param [r] item2 [const void*] Ensembl Prediction Exon address 2
1380 ** @see ajListSort
1381 **
1382 ** @return [int] The comparison function returns an integer less than,
1383 ** equal to, or greater than zero if the first argument is
1384 ** considered to be respectively less than, equal to, or
1385 ** greater than the second.
1386 **
1387 ** @release 6.4.0
1388 ** @@
1389 ******************************************************************************/
1390
listPredictionexonCompareEndDescending(const void * item1,const void * item2)1391 static int listPredictionexonCompareEndDescending(
1392 const void *item1,
1393 const void *item2)
1394 {
1395 EnsPPredictionexon pe1 = *(EnsOPredictionexon *const *) item1;
1396 EnsPPredictionexon pe2 = *(EnsOPredictionexon *const *) item2;
1397
1398 #if defined(AJ_DEBUG) && AJ_DEBUG >= 2
1399 if (ajDebugTest("listPredictionexonCompareEndDescending"))
1400 ajDebug("listPredictionexonCompareEndDescending\n"
1401 " pe1 %p\n"
1402 " pe2 %p\n",
1403 pe1,
1404 pe2);
1405 #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 2 */
1406
1407 /* Sort empty values towards the end of the AJAX List. */
1408
1409 if (pe1 && (!pe2))
1410 return -1;
1411
1412 if ((!pe1) && (!pe2))
1413 return 0;
1414
1415 if ((!pe1) && pe2)
1416 return +1;
1417
1418 return ensFeatureCompareEndDescending(pe1->Feature, pe2->Feature);
1419 }
1420
1421
1422
1423
1424 /* @funcstatic listPredictionexonCompareIdentifierAscending *******************
1425 **
1426 ** AJAX List of Ensembl Prediction Exon objects comparison function to sort by
1427 ** identifier member in ascending order.
1428 **
1429 ** @param [r] item1 [const void*] Ensembl Prediction Exon address 1
1430 ** @param [r] item2 [const void*] Ensembl Prediction Exon address 2
1431 ** @see ajListSort
1432 **
1433 ** @return [int] The comparison function returns an integer less than,
1434 ** equal to, or greater than zero if the first argument is
1435 ** considered to be respectively less than, equal to, or
1436 ** greater than the second.
1437 **
1438 ** @release 6.4.0
1439 ** @@
1440 ******************************************************************************/
1441
listPredictionexonCompareIdentifierAscending(const void * item1,const void * item2)1442 static int listPredictionexonCompareIdentifierAscending(
1443 const void *item1,
1444 const void *item2)
1445 {
1446 EnsPPredictionexon pe1 = *(EnsOPredictionexon *const *) item1;
1447 EnsPPredictionexon pe2 = *(EnsOPredictionexon *const *) item2;
1448
1449 #if defined(AJ_DEBUG) && AJ_DEBUG >= 2
1450 if (ajDebugTest("listPredictionexonCompareIdentifierAscending"))
1451 ajDebug("listPredictionexonCompareIdentifierAscending\n"
1452 " pe1 %p\n"
1453 " pe2 %p\n",
1454 pe1,
1455 pe2);
1456 #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 2 */
1457
1458 /* Sort empty values towards the end of the AJAX List. */
1459
1460 if (pe1 && (!pe2))
1461 return -1;
1462
1463 if ((!pe1) && (!pe2))
1464 return 0;
1465
1466 if ((!pe1) && pe2)
1467 return +1;
1468
1469 if (pe1->Identifier < pe2->Identifier)
1470 return -1;
1471
1472 if (pe1->Identifier > pe2->Identifier)
1473 return +1;
1474
1475 return 0;
1476 }
1477
1478
1479
1480
1481 /* @funcstatic listPredictionexonCompareStartAscending ************************
1482 **
1483 ** AJAX List of Ensembl Prediction Exon objects comparison function to sort by
1484 ** Ensembl Feature start coordinate in ascending order.
1485 **
1486 ** @param [r] item1 [const void*] Ensembl Prediction Exon address 1
1487 ** @param [r] item2 [const void*] Ensembl Prediction Exon address 2
1488 ** @see ajListSort
1489 **
1490 ** @return [int] The comparison function returns an integer less than,
1491 ** equal to, or greater than zero if the first argument is
1492 ** considered to be respectively less than, equal to, or
1493 ** greater than the second.
1494 **
1495 ** @release 6.4.0
1496 ** @@
1497 ******************************************************************************/
1498
listPredictionexonCompareStartAscending(const void * item1,const void * item2)1499 static int listPredictionexonCompareStartAscending(
1500 const void *item1,
1501 const void *item2)
1502 {
1503 EnsPPredictionexon pe1 = *(EnsOPredictionexon *const *) item1;
1504 EnsPPredictionexon pe2 = *(EnsOPredictionexon *const *) item2;
1505
1506 #if defined(AJ_DEBUG) && AJ_DEBUG >= 2
1507 if (ajDebugTest("listPredictionexonCompareStartAscending"))
1508 ajDebug("listPredictionexonCompareStartAscending\n"
1509 " pe1 %p\n"
1510 " pe2 %p\n",
1511 pe1,
1512 pe2);
1513 #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 2 */
1514
1515 /* Sort empty values towards the end of the AJAX List. */
1516
1517 if (pe1 && (!pe2))
1518 return -1;
1519
1520 if ((!pe1) && (!pe2))
1521 return 0;
1522
1523 if ((!pe1) && pe2)
1524 return +1;
1525
1526 return ensFeatureCompareStartAscending(pe1->Feature, pe2->Feature);
1527 }
1528
1529
1530
1531
1532 /* @funcstatic listPredictionexonCompareStartDescending ***********************
1533 **
1534 ** AJAX List of Ensembl Exon objects comparison function to sort by
1535 ** Ensembl Feature start coordinate in descending order.
1536 **
1537 ** @param [r] item1 [const void*] Ensembl Prediction Exon address 1
1538 ** @param [r] item2 [const void*] Ensembl Prediction Exon address 2
1539 ** @see ajListSort
1540 **
1541 ** @return [int] The comparison function returns an integer less than,
1542 ** equal to, or greater than zero if the first argument is
1543 ** considered to be respectively less than, equal to, or
1544 ** greater than the second.
1545 **
1546 ** @release 6.4.0
1547 ** @@
1548 ******************************************************************************/
1549
listPredictionexonCompareStartDescending(const void * item1,const void * item2)1550 static int listPredictionexonCompareStartDescending(
1551 const void *item1,
1552 const void *item2)
1553 {
1554 EnsPPredictionexon pe1 = *(EnsOPredictionexon *const *) item1;
1555 EnsPPredictionexon pe2 = *(EnsOPredictionexon *const *) item2;
1556
1557 #if defined(AJ_DEBUG) && AJ_DEBUG >= 2
1558 if (ajDebugTest("listPredictionexonCompareStartDescending"))
1559 ajDebug("listPredictionexonCompareStartDescending\n"
1560 " pe1 %p\n"
1561 " pe2 %p\n",
1562 pe1,
1563 pe2);
1564 #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 2 */
1565
1566 /* Sort empty values towards the end of the AJAX List. */
1567
1568 if (pe1 && (!pe2))
1569 return -1;
1570
1571 if ((!pe1) && (!pe2))
1572 return 0;
1573
1574 if ((!pe1) && pe2)
1575 return +1;
1576
1577 return ensFeatureCompareStartDescending(pe1->Feature, pe2->Feature);
1578 }
1579
1580
1581
1582
1583 /* @section list **************************************************************
1584 **
1585 ** Functions for manipulating AJAX List objects.
1586 **
1587 ** @fdata [AjPList]
1588 **
1589 ** @nam3rule Predictionexon Functions for manipulating AJAX List objects of
1590 ** Ensembl Prediction Exon objects
1591 ** @nam4rule Sort Sort functions
1592 ** @nam5rule End Sort by Ensembl Feature end member
1593 ** @nam5rule Identifier Sort by identifier member
1594 ** @nam5rule Start Sort by Ensembl Feature start member
1595 ** @nam6rule Ascending Sort in ascending order
1596 ** @nam6rule Descending Sort in descending order
1597 **
1598 ** @argrule * pes [AjPList]
1599 ** AJAX List of Ensembl Prediction Exon objects
1600 **
1601 ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise
1602 **
1603 ** @fcategory misc
1604 ******************************************************************************/
1605
1606
1607
1608
1609 /* @func ensListPredictionexonSortEndAscending ********************************
1610 **
1611 ** Sort an AJAX List of Ensembl Prediction Exon objects by their
1612 ** Ensembl Feature end coordinate in ascending order.
1613 **
1614 ** @param [u] pes [AjPList] AJAX List of Ensembl Prediction Exon objects
1615 **
1616 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
1617 **
1618 ** @release 6.4.0
1619 ** @@
1620 ******************************************************************************/
1621
ensListPredictionexonSortEndAscending(AjPList pes)1622 AjBool ensListPredictionexonSortEndAscending(AjPList pes)
1623 {
1624 if (!pes)
1625 return ajFalse;
1626
1627 ajListSortTwoThree(pes,
1628 &listPredictionexonCompareEndAscending,
1629 &listPredictionexonCompareStartAscending,
1630 &listPredictionexonCompareIdentifierAscending);
1631
1632 return ajTrue;
1633 }
1634
1635
1636
1637
1638 /* @func ensListPredictionexonSortEndDescending *******************************
1639 **
1640 ** Sort an AJAX List of Ensembl Prediction Exon objects by their
1641 ** Ensembl Feature end coordinate in descending order.
1642 **
1643 ** @param [u] pes [AjPList] AJAX List of Ensembl Prediction Exon objects
1644 **
1645 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
1646 **
1647 ** @release 6.4.0
1648 ** @@
1649 ******************************************************************************/
1650
ensListPredictionexonSortEndDescending(AjPList pes)1651 AjBool ensListPredictionexonSortEndDescending(AjPList pes)
1652 {
1653 if (!pes)
1654 return ajFalse;
1655
1656 ajListSortTwoThree(pes,
1657 &listPredictionexonCompareEndDescending,
1658 &listPredictionexonCompareStartDescending,
1659 &listPredictionexonCompareIdentifierAscending);
1660
1661 return ajTrue;
1662 }
1663
1664
1665
1666
1667 /* @func ensListPredictionexonSortIdentifierAscending *************************
1668 **
1669 ** Sort an AJAX List of Ensembl Prediction Exon objects by their
1670 ** identifier member in ascending order.
1671 **
1672 ** @param [u] pes [AjPList] AJAX List of Ensembl Prediction Exon objects
1673 **
1674 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
1675 **
1676 ** @release 6.4.0
1677 ** @@
1678 ******************************************************************************/
1679
ensListPredictionexonSortIdentifierAscending(AjPList pes)1680 AjBool ensListPredictionexonSortIdentifierAscending(AjPList pes)
1681 {
1682 if (!pes)
1683 return ajFalse;
1684
1685 ajListSort(pes, &listPredictionexonCompareIdentifierAscending);
1686
1687 return ajTrue;
1688 }
1689
1690
1691
1692
1693 /* @func ensListPredictionexonSortStartAscending ******************************
1694 **
1695 ** Sort an AJAX List of Ensembl Prediction Exon objects by their
1696 ** Ensembl Feature start coordinate in ascending order.
1697 **
1698 ** @param [u] pes [AjPList] AJAX List of Ensembl Prediction Exon objects
1699 **
1700 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
1701 **
1702 ** @release 6.4.0
1703 ** @@
1704 ******************************************************************************/
1705
ensListPredictionexonSortStartAscending(AjPList pes)1706 AjBool ensListPredictionexonSortStartAscending(AjPList pes)
1707 {
1708 if (!pes)
1709 return ajFalse;
1710
1711 ajListSortTwoThree(pes,
1712 &listPredictionexonCompareStartAscending,
1713 &listPredictionexonCompareEndAscending,
1714 &listPredictionexonCompareIdentifierAscending);
1715
1716 return ajTrue;
1717 }
1718
1719
1720
1721
1722 /* @func ensListPredictionexonSortStartDescending *****************************
1723 **
1724 ** Sort an AJAX List of Ensembl Prediction Exon objects by their
1725 ** Ensembl Feature start coordinate in descending order.
1726 **
1727 ** @param [u] pes [AjPList] AJAX List of Ensembl Prediction Exon objects
1728 **
1729 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
1730 **
1731 ** @release 6.4.0
1732 ** @@
1733 ******************************************************************************/
1734
ensListPredictionexonSortStartDescending(AjPList pes)1735 AjBool ensListPredictionexonSortStartDescending(AjPList pes)
1736 {
1737 if (!pes)
1738 return ajFalse;
1739
1740 ajListSortTwoThree(pes,
1741 &listPredictionexonCompareStartDescending,
1742 &listPredictionexonCompareEndDescending,
1743 &listPredictionexonCompareIdentifierAscending);
1744
1745 return ajTrue;
1746 }
1747
1748
1749
1750
1751 /* @datasection [EnsPPredictionexonadaptor] Ensembl Prediction Exon Adaptor ***
1752 **
1753 ** @nam2rule Predictionexonadaptor Functions for manipulating
1754 ** Ensembl Prediction Exon Adaptor objects
1755 **
1756 ** @cc Bio::EnsEMBL::DBSQL::PredictionExonAdaptor
1757 ** @cc CVS Revision: 1.21
1758 ** @cc CVS Tag: branch-ensembl-68
1759 **
1760 ******************************************************************************/
1761
1762
1763
1764
1765 /* @funcstatic predictionexonadaptorFetchAllbyStatement ***********************
1766 **
1767 ** Fetch all Ensembl Prediction Exon objects via an SQL statement.
1768 **
1769 ** @param [u] ba [EnsPBaseadaptor] Ensembl Base Adaptor
1770 ** @param [r] statement [const AjPStr] SQL statement
1771 ** @param [uN] am [EnsPAssemblymapper] Ensembl Assembly Mapper
1772 ** @param [uN] slice [EnsPSlice] Ensembl Slice
1773 ** @param [u] pes [AjPList] AJAX List of Ensembl Prediction Exon objects
1774 **
1775 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
1776 **
1777 ** @release 6.4.0
1778 ** @@
1779 ******************************************************************************/
1780
predictionexonadaptorFetchAllbyStatement(EnsPBaseadaptor ba,const AjPStr statement,EnsPAssemblymapper am,EnsPSlice slice,AjPList pes)1781 static AjBool predictionexonadaptorFetchAllbyStatement(
1782 EnsPBaseadaptor ba,
1783 const AjPStr statement,
1784 EnsPAssemblymapper am,
1785 EnsPSlice slice,
1786 AjPList pes)
1787 {
1788 double score = 0.0;
1789 double pvalue = 0.0;
1790
1791 ajint sphase = 0;
1792
1793 ajuint identifier = 0U;
1794
1795 ajuint srid = 0U;
1796 ajuint srstart = 0U;
1797 ajuint srend = 0U;
1798 ajint srstrand = 0;
1799
1800 AjPSqlstatement sqls = NULL;
1801 AjISqlrow sqli = NULL;
1802 AjPSqlrow sqlr = NULL;
1803
1804 EnsPDatabaseadaptor dba = NULL;
1805
1806 EnsPPredictionexon pe = NULL;
1807 EnsPPredictionexonadaptor pea = NULL;
1808
1809 EnsPFeature feature = NULL;
1810
1811 if (ajDebugTest("predictionexonadaptorFetchAllbyStatement"))
1812 ajDebug("predictionexonadaptorFetchAllbyStatement\n"
1813 " ba %p\n"
1814 " statement %p\n"
1815 " am %p\n"
1816 " slice %p\n"
1817 " pes %p\n",
1818 ba,
1819 statement,
1820 am,
1821 slice,
1822 pes);
1823
1824 if (!ba)
1825 return ajFalse;
1826
1827 if (!statement)
1828 return ajFalse;
1829
1830 if (!pes)
1831 return ajFalse;
1832
1833 dba = ensBaseadaptorGetDatabaseadaptor(ba);
1834
1835 pea = ensRegistryGetPredictionexonadaptor(dba);
1836
1837 sqls = ensDatabaseadaptorSqlstatementNew(dba, statement);
1838
1839 sqli = ajSqlrowiterNew(sqls);
1840
1841 while (!ajSqlrowiterDone(sqli))
1842 {
1843 identifier = 0;
1844 srid = 0;
1845 srstart = 0;
1846 srend = 0;
1847 srstrand = 0;
1848 sphase = 0;
1849 score = 0.0;
1850 pvalue = 0.0;
1851
1852 sqlr = ajSqlrowiterGet(sqli);
1853
1854 ajSqlcolumnToUint(sqlr, &identifier);
1855 ajSqlcolumnToUint(sqlr, &srid);
1856 ajSqlcolumnToUint(sqlr, &srstart);
1857 ajSqlcolumnToUint(sqlr, &srend);
1858 ajSqlcolumnToInt(sqlr, &srstrand);
1859 ajSqlcolumnToInt(sqlr, &sphase);
1860 ajSqlcolumnToDouble(sqlr, &score);
1861 ajSqlcolumnToDouble(sqlr, &pvalue);
1862
1863 ensBaseadaptorRetrieveFeature(ba,
1864 0U,
1865 srid,
1866 srstart,
1867 srend,
1868 srstrand,
1869 am,
1870 slice,
1871 &feature);
1872
1873 if (!feature)
1874 continue;
1875
1876 /* Finally, create a new Ensembl Prediction Exon. */
1877
1878 pe = ensPredictionexonNewIni(pea,
1879 identifier,
1880 feature,
1881 sphase,
1882 score,
1883 pvalue);
1884
1885 ajListPushAppend(pes, (void *) pe);
1886
1887 ensFeatureDel(&feature);
1888 }
1889
1890 ajSqlrowiterDel(&sqli);
1891
1892 ensDatabaseadaptorSqlstatementDel(dba, &sqls);
1893
1894 return ajTrue;
1895 }
1896
1897
1898
1899
1900 /* @section constructors ******************************************************
1901 **
1902 ** All constructors return a new Ensembl Prediction Exon Adaptor by pointer.
1903 ** It is the responsibility of the user to first destroy any previous
1904 ** Prediction Exon Adaptor. The target pointer does not need to be initialised
1905 ** to NULL, but it is good programming practice to do so anyway.
1906 **
1907 ** @fdata [EnsPPredictionexonadaptor]
1908 **
1909 ** @nam3rule New Constructor
1910 **
1911 ** @argrule New dba [EnsPDatabaseadaptor] Ensembl Database Adaptor
1912 **
1913 ** @valrule * [EnsPPredictionexonadaptor]
1914 ** Ensembl Prediction Exon Adaptor or NULL
1915 **
1916 ** @fcategory new
1917 ******************************************************************************/
1918
1919
1920
1921
1922 /* @func ensPredictionexonadaptorNew ******************************************
1923 **
1924 ** Default constructor for an Ensembl Prediction Exon Adaptor.
1925 **
1926 ** Ensembl Object Adaptors are singleton objects in the sense that a single
1927 ** instance of an Ensembl Object Adaptor connected to a particular database is
1928 ** sufficient to instantiate any number of Ensembl Objects from the database.
1929 ** Each Ensembl Object will have a weak reference to the Object Adaptor that
1930 ** instantiated it. Therefore, Ensembl Object Adaptors should not be
1931 ** instantiated directly, but rather obtained from the Ensembl Registry,
1932 ** which will in turn call this function if neccessary.
1933 **
1934 ** @see ensRegistryGetDatabaseadaptor
1935 ** @see ensRegistryGetPredictionexonadaptor
1936 **
1937 ** @param [u] dba [EnsPDatabaseadaptor] Ensembl Database Adaptor
1938 **
1939 ** @return [EnsPPredictionexonadaptor] Ensembl Prediction Exon Adaptor or NULL
1940 **
1941 ** @release 6.2.0
1942 ** @@
1943 ******************************************************************************/
1944
ensPredictionexonadaptorNew(EnsPDatabaseadaptor dba)1945 EnsPPredictionexonadaptor ensPredictionexonadaptorNew(
1946 EnsPDatabaseadaptor dba)
1947 {
1948 return ensFeatureadaptorNew(
1949 dba,
1950 predictionexonadaptorKTablenames,
1951 predictionexonadaptorKColumnnames,
1952 (const EnsPBaseadaptorLeftjoin) NULL,
1953 (const char *) NULL,
1954 predictionexonadaptorKFinalcondition,
1955 &predictionexonadaptorFetchAllbyStatement,
1956 (void *(*)(const void *)) NULL,
1957 (void *(*)(void *)) &ensPredictionexonNewRef,
1958 (AjBool (*)(const void *)) NULL,
1959 (void (*)(void **)) &ensPredictionexonDel,
1960 (size_t (*)(const void *)) &ensPredictionexonCalculateMemsize,
1961 (EnsPFeature (*)(const void *)) &ensPredictionexonGetFeature,
1962 "Predictionexon");
1963 }
1964
1965
1966
1967
1968 /* @section destructors *******************************************************
1969 **
1970 ** Destruction destroys all internal data structures and frees the memory
1971 ** allocated for an Ensembl Prediction Exon Adaptor object.
1972 **
1973 ** @fdata [EnsPPredictionexonadaptor]
1974 **
1975 ** @nam3rule Del Destroy (free) an Ensembl Prediction Exon Adaptor
1976 **
1977 ** @argrule * Ppea [EnsPPredictionexonadaptor*]
1978 ** Ensembl Prediction Exon Adaptor address
1979 **
1980 ** @valrule * [void]
1981 **
1982 ** @fcategory delete
1983 ******************************************************************************/
1984
1985
1986
1987
1988 /* @func ensPredictionexonadaptorDel ******************************************
1989 **
1990 ** Default destructor for an Ensembl Prediction Exon Adaptor.
1991 **
1992 ** Ensembl Object Adaptors are singleton objects that are registered in the
1993 ** Ensembl Registry and weakly referenced by Ensembl Objects that have been
1994 ** instantiated by it. Therefore, Ensembl Object Adaptors should never be
1995 ** destroyed directly. Upon exit, the Ensembl Registry will call this function
1996 ** if required.
1997 **
1998 ** @param [d] Ppea [EnsPPredictionexonadaptor*]
1999 ** Ensembl Prediction Exon Adaptor address
2000 **
2001 ** @return [void]
2002 **
2003 ** @release 6.2.0
2004 ** @@
2005 ******************************************************************************/
2006
ensPredictionexonadaptorDel(EnsPPredictionexonadaptor * Ppea)2007 void ensPredictionexonadaptorDel(EnsPPredictionexonadaptor *Ppea)
2008 {
2009 ensFeatureadaptorDel(Ppea);
2010
2011 return;
2012 }
2013
2014
2015
2016
2017 /* @section member retrieval **************************************************
2018 **
2019 ** Functions for returning members of an
2020 ** Ensembl Prediction Exon Adaptor object.
2021 **
2022 ** @fdata [EnsPPredictionexonadaptor]
2023 **
2024 ** @nam3rule Get Return Ensembl Prediction Exon Adaptor attribute(s)
2025 ** @nam4rule Baseadaptor Return the Ensembl Base Adaptor
2026 ** @nam4rule Databaseadaptor Return the Ensembl Database Adaptor
2027 ** @nam4rule Featureadaptor Return the Ensembl Feature Adaptor
2028 **
2029 ** @argrule * pea [EnsPPredictionexonadaptor] Ensembl Prediction Exon Adaptor
2030 **
2031 ** @valrule Baseadaptor [EnsPBaseadaptor]
2032 ** Ensembl Base Adaptor or NULL
2033 ** @valrule Databaseadaptor [EnsPDatabaseadaptor]
2034 ** Ensembl Database Adaptor or NULL
2035 ** @valrule Featureadaptor [EnsPFeatureadaptor]
2036 ** Ensembl Feature Adaptor or NULL
2037 **
2038 ** @fcategory use
2039 ******************************************************************************/
2040
2041
2042
2043
2044 /* @func ensPredictionexonadaptorGetBaseadaptor *******************************
2045 **
2046 ** Get the Ensembl Base Adaptor member of the
2047 ** Ensembl Feature Adaptor member of an Ensembl Prediction Exon Adaptor.
2048 **
2049 ** @param [u] pea [EnsPPredictionexonadaptor] Ensembl Prediction Exon Adaptor
2050 **
2051 ** @return [EnsPBaseadaptor] Ensembl Base Adaptor or NULL
2052 **
2053 ** @release 6.4.0
2054 ** @@
2055 ******************************************************************************/
2056
ensPredictionexonadaptorGetBaseadaptor(EnsPPredictionexonadaptor pea)2057 EnsPBaseadaptor ensPredictionexonadaptorGetBaseadaptor(
2058 EnsPPredictionexonadaptor pea)
2059 {
2060 return ensFeatureadaptorGetBaseadaptor(
2061 ensPredictionexonadaptorGetFeatureadaptor(pea));
2062 }
2063
2064
2065
2066
2067 /* @func ensPredictionexonadaptorGetDatabaseadaptor ***************************
2068 **
2069 ** Get the Ensembl Database Adaptor member of the
2070 ** Ensembl Feature Adaptor member of an Ensembl Prediction Exon Adaptor.
2071 **
2072 ** @param [u] pea [EnsPPredictionexonadaptor] Ensembl Prediction Exon Adaptor
2073 **
2074 ** @return [EnsPDatabaseadaptor] Ensembl Database Adaptor or NULL
2075 **
2076 ** @release 6.4.0
2077 ** @@
2078 ******************************************************************************/
2079
ensPredictionexonadaptorGetDatabaseadaptor(EnsPPredictionexonadaptor pea)2080 EnsPDatabaseadaptor ensPredictionexonadaptorGetDatabaseadaptor(
2081 EnsPPredictionexonadaptor pea)
2082 {
2083 return ensFeatureadaptorGetDatabaseadaptor(
2084 ensPredictionexonadaptorGetFeatureadaptor(pea));
2085 }
2086
2087
2088
2089
2090 /* @func ensPredictionexonadaptorGetFeatureadaptor ****************************
2091 **
2092 ** Get the Ensembl Feature Adaptor member of an
2093 ** Ensembl Prediction Exon Adaptor.
2094 **
2095 ** @param [u] pea [EnsPPredictionexonadaptor] Ensembl Prediction Exon Adaptor
2096 **
2097 ** @return [EnsPFeatureadaptor] Ensembl Feature Adaptor or NULL
2098 **
2099 ** @release 6.4.0
2100 ** @@
2101 ******************************************************************************/
2102
ensPredictionexonadaptorGetFeatureadaptor(EnsPPredictionexonadaptor pea)2103 EnsPFeatureadaptor ensPredictionexonadaptorGetFeatureadaptor(
2104 EnsPPredictionexonadaptor pea)
2105 {
2106 return pea;
2107 }
2108
2109
2110
2111
2112 /* @section canonical object retrieval ****************************************
2113 **
2114 ** Functions for fetching Ensembl Prediction Exon objects from an
2115 ** Ensembl SQL database.
2116 **
2117 ** @fdata [EnsPPredictionexonadaptor]
2118 **
2119 ** @nam3rule Fetch Fetch Ensembl Prediction Exon object(s)
2120 ** @nam4rule All Fetch all Ensembl Prediction Exon objects
2121 ** @nam4rule Allby Fetch all Ensembl Prediction Exon objects
2122 ** matching a criterion
2123 ** @nam5rule Predictiontranscript Fetch all by an Ensembl Prediction Transcript
2124 ** @nam5rule Slice Fetch all by an Ensembl Slice
2125 ** @nam4rule By Fetch one Ensembl Exon object matching a criterion
2126 ** @nam5rule Identifier Fetch by SQL database-internal identifier
2127 **
2128 ** @argrule * pea [EnsPPredictionexonadaptor]
2129 ** Ensembl Prediction Exon Adaptor
2130 ** @argrule All pes [AjPList]
2131 ** AJAX List of Ensembl Prediction Exon objects
2132 ** @argrule AllbyPredictiontranscript pt [const EnsPPredictiontranscript]
2133 ** Ensembl Prediction Transcript
2134 ** @argrule AllbySlice slice [EnsPSlice] Ensembl Slice
2135 ** @argrule AllbySlice constraint [const AjPStr] SQL constraint
2136 ** @argrule Allby pes [AjPList]
2137 ** AJAX List of Ensembl Prediction Exon objects
2138 ** @argrule ByIdentifier identifier [ajuint] SQL database-internal identifier
2139 ** @argrule By Ppe [EnsPPredictionexon*]
2140 ** Ensembl Prediction Exon address
2141 **
2142 ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise
2143 **
2144 ** @fcategory use
2145 ******************************************************************************/
2146
2147
2148
2149
2150 /* @func ensPredictionexonadaptorFetchAllbyPredictiontranscript ***************
2151 **
2152 ** Fetch all Ensembl Prediction Exon objects via an
2153 ** Ensembl Prediction Transcript.
2154 **
2155 ** The caller is responsible for deleting the Ensembl Prediction Exon objects
2156 ** before deleting the AJAX List.
2157 **
2158 ** @param [u] pea [EnsPPredictionexonadaptor] Ensembl Prediction Exon Adaptor
2159 ** @param [r] pt [const EnsPPredictiontranscript] Ensembl Prediction Transcript
2160 ** @param [u] pes [AjPList] AJAX List of Ensembl Prediction Exon objects
2161 **
2162 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
2163 **
2164 ** @release 6.4.0
2165 ** @@
2166 ******************************************************************************/
2167
ensPredictionexonadaptorFetchAllbyPredictiontranscript(EnsPPredictionexonadaptor pea,const EnsPPredictiontranscript pt,AjPList pes)2168 AjBool ensPredictionexonadaptorFetchAllbyPredictiontranscript(
2169 EnsPPredictionexonadaptor pea,
2170 const EnsPPredictiontranscript pt,
2171 AjPList pes)
2172 {
2173 AjIList iter = NULL;
2174
2175 AjPStr constraint = NULL;
2176
2177 EnsPDatabaseadaptor dba = NULL;
2178
2179 EnsPPredictionexon pe = NULL;
2180
2181 EnsPFeature efeature = NULL;
2182 EnsPFeature tfeature = NULL;
2183
2184 EnsPSlice eslice = NULL;
2185 EnsPSlice tslice = NULL;
2186
2187 EnsPSliceadaptor sla = NULL;
2188
2189 if (ajDebugTest("ensPredictionexonadaptorFetchAllbyPredictiontranscript"))
2190 {
2191 ajDebug("ensPredictionexonadaptorFetchAllbyPredictiontranscript\n"
2192 " pea %p\n"
2193 " pt %p\n"
2194 " pes %p\n",
2195 pea,
2196 pt,
2197 pes);
2198
2199 ensPredictiontranscriptTrace(pt, 1);
2200 }
2201
2202 if (!pea)
2203 return ajFalse;
2204
2205 if (!pt)
2206 return ajFalse;
2207
2208 if (!pes)
2209 return ajFalse;
2210
2211 tfeature = ensPredictiontranscriptGetFeature(pt);
2212
2213 tslice = ensFeatureGetSlice(tfeature);
2214
2215 if (!tslice)
2216 {
2217 ajDebug("ensPredictionexonadaptorFetchAllbyPredictiontranscript "
2218 "cannot fetch Ensembl Prediction Exon objects for an "
2219 "Ensembl Prediction Transcript without an Ensembl Slice.\n");
2220
2221 return ajFalse;
2222 }
2223
2224 dba = ensPredictionexonadaptorGetDatabaseadaptor(pea);
2225
2226 sla = ensRegistryGetSliceadaptor(dba);
2227
2228 /*
2229 ** Get a Slice that spans just this Prediction Transcript to place
2230 ** Ensembl Prediction Exon objects on.
2231 */
2232
2233 ensSliceadaptorFetchByFeature(sla, tfeature, 0, &eslice);
2234
2235 constraint = ajFmtStr("prediction_exon.prediction_transcript_id = %u",
2236 ensPredictiontranscriptGetIdentifier(pt));
2237
2238 ensFeatureadaptorFetchAllbySlice(pea,
2239 eslice,
2240 constraint,
2241 (const AjPStr) NULL,
2242 pes);
2243
2244 /* Remap Exon coordinates if neccessary. */
2245
2246 if (!ensSliceMatch(eslice, tslice))
2247 {
2248 iter = ajListIterNew(pes);
2249
2250 while (!ajListIterDone(iter))
2251 {
2252 pe = (EnsPPredictionexon) ajListIterGet(iter);
2253
2254 efeature = ensFeatureTransfer(pe->Feature, tslice);
2255
2256 ensPredictionexonSetFeature(pe, efeature);
2257
2258 ensFeatureDel(&efeature);
2259 }
2260
2261 ajListIterDel(&iter);
2262 }
2263
2264 ajStrDel(&constraint);
2265
2266 ensSliceDel(&eslice);
2267
2268 return ajTrue;
2269 }
2270
2271
2272
2273
2274 /* @func ensPredictionexonadaptorFetchByIdentifier ****************************
2275 **
2276 ** Fetch an Ensembl Prediction Exon via its SQL database-internal
2277 ** identifier.
2278 ** The caller is responsible for deleting the Ensembl Prediction Exon.
2279 **
2280 ** @param [u] pea [EnsPPredictionexonadaptor]
2281 ** Ensembl Prediction Exon Adaptor
2282 ** @param [r] identifier [ajuint] SQL database-internal identifier
2283 ** @param [wP] Ppe [EnsPPredictionexon*] Ensembl Prediction Exon address
2284 **
2285 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
2286 **
2287 ** @release 6.2.0
2288 ** @@
2289 ******************************************************************************/
2290
ensPredictionexonadaptorFetchByIdentifier(EnsPPredictionexonadaptor pea,ajuint identifier,EnsPPredictionexon * Ppe)2291 AjBool ensPredictionexonadaptorFetchByIdentifier(
2292 EnsPPredictionexonadaptor pea,
2293 ajuint identifier,
2294 EnsPPredictionexon *Ppe)
2295 {
2296 return ensBaseadaptorFetchByIdentifier(
2297 ensPredictionexonadaptorGetBaseadaptor(pea),
2298 identifier,
2299 (void **) Ppe);
2300 }
2301
2302
2303
2304
2305 /* @datasection [EnsPPredictiontranscript] Ensembl Prediction Transcript ******
2306 **
2307 ** @nam2rule Predictiontranscript Functions for manipulating
2308 ** Ensembl Prediction Transcript objects
2309 **
2310 ** @cc Bio::EnsEMBL::PredictionTranscript
2311 ** @cc CVS Revision: 1.51
2312 ** @cc CVS Tag: branch-ensembl-68
2313 **
2314 ******************************************************************************/
2315
2316
2317
2318
2319 /* @section constructors ******************************************************
2320 **
2321 ** All constructors return a new Ensembl Prediction Transcript by pointer.
2322 ** It is the responsibility of the user to first destroy any previous
2323 ** Prediction Transcript. The target pointer does not need to be initialised to
2324 ** NULL, but it is good programming practice to do so anyway.
2325 **
2326 ** @fdata [EnsPPredictiontranscript]
2327 **
2328 ** @nam3rule New Constructor
2329 ** @nam4rule Cpy Constructor with existing object
2330 ** @nam4rule Ini Constructor with initial values
2331 ** @nam4rule Ref Constructor by incrementing the reference counter
2332 **
2333 ** @argrule Cpy pt [const EnsPPredictiontranscript]
2334 ** Ensembl Prediction Transcript
2335 ** @argrule Ini pta [EnsPPredictiontranscriptadaptor]
2336 ** Ensembl Prediction Transcript Adaptor
2337 ** @argrule Ini identifier [ajuint] SQL database-internal identifier
2338 ** @argrule Ini feature [EnsPFeature] Ensembl Feature
2339 ** @argrule Ini label [AjPStr] Display label
2340 ** @argrule Ref pt [EnsPPredictiontranscript] Ensembl Prediction Transcript
2341 **
2342 ** @valrule * [EnsPPredictiontranscript] Ensembl Prediction Transcript or NULL
2343 **
2344 ** @fcategory new
2345 ******************************************************************************/
2346
2347
2348
2349
2350 /* @func ensPredictiontranscriptNewCpy ****************************************
2351 **
2352 ** Object-based constructor function, which returns an independent object.
2353 **
2354 ** @param [r] pt [const EnsPPredictiontranscript] Ensembl Prediction Transcript
2355 **
2356 ** @return [EnsPPredictiontranscript] Ensembl Prediction Transcript or NULL
2357 **
2358 ** @release 6.4.0
2359 ** @@
2360 ******************************************************************************/
2361
ensPredictiontranscriptNewCpy(const EnsPPredictiontranscript pt)2362 EnsPPredictiontranscript ensPredictiontranscriptNewCpy(
2363 const EnsPPredictiontranscript pt)
2364 {
2365 AjIList iter = NULL;
2366
2367 EnsPPredictionexon pe = NULL;
2368
2369 EnsPPredictiontranscript pthis = NULL;
2370
2371 if (!pt)
2372 return NULL;
2373
2374 AJNEW0(pthis);
2375
2376 pthis->Use = 1U;
2377 pthis->Identifier = pt->Identifier;
2378 pthis->Adaptor = pt->Adaptor;
2379 pthis->Feature = ensFeatureNewRef(pt->Feature);
2380
2381 if (pt->Displaylabel)
2382 pthis->Displaylabel = ajStrNewRef(pt->Displaylabel);
2383
2384 /* Copy the AJAX List of Ensembl Prediction Exon objects. */
2385
2386 if (pt->Predictionexons && ajListGetLength(pt->Predictionexons))
2387 {
2388 pthis->Predictionexons = ajListNew();
2389
2390 iter = ajListIterNew(pt->Predictionexons);
2391
2392 while (!ajListIterDone(iter))
2393 {
2394 pe = (EnsPPredictionexon) ajListIterGet(iter);
2395
2396 ajListPushAppend(pthis->Predictionexons,
2397 (void *) ensPredictionexonNewRef(pe));
2398 }
2399
2400 ajListIterDel(&iter);
2401 }
2402 else
2403 pthis->Predictionexons = NULL;
2404
2405 return pthis;
2406 }
2407
2408
2409
2410
2411 /* @func ensPredictiontranscriptNewIni ****************************************
2412 **
2413 ** Constructor for an Ensembl Prediction Transcript with initial values.
2414 **
2415 ** @cc Bio::EnsEMBL::Storable::new
2416 ** @param [u] pta [EnsPPredictiontranscriptadaptor]
2417 ** Ensembl Prediction Transcript Adaptor
2418 ** @param [r] identifier [ajuint] SQL database-internal identifier
2419 ** @cc Bio::EnsEMBL::Feature::new
2420 ** @param [u] feature [EnsPFeature] Ensembl Feature
2421 ** @cc Bio::EnsEMBL::PredictionTranscript::new
2422 ** @param [u] label [AjPStr] Display label
2423 **
2424 ** @return [EnsPPredictiontranscript] Ensembl Prediction Transcript or NULL
2425 **
2426 ** @release 6.4.0
2427 ** @@
2428 ******************************************************************************/
2429
ensPredictiontranscriptNewIni(EnsPPredictiontranscriptadaptor pta,ajuint identifier,EnsPFeature feature,AjPStr label)2430 EnsPPredictiontranscript ensPredictiontranscriptNewIni(
2431 EnsPPredictiontranscriptadaptor pta,
2432 ajuint identifier,
2433 EnsPFeature feature,
2434 AjPStr label)
2435 {
2436 EnsPPredictiontranscript pt = NULL;
2437
2438 if (!feature)
2439 return NULL;
2440
2441 AJNEW0(pt);
2442
2443 pt->Use = 1U;
2444 pt->Identifier = identifier;
2445 pt->Adaptor = pta;
2446 pt->Feature = ensFeatureNewRef(feature);
2447
2448 if (label)
2449 pt->Displaylabel = ajStrNewRef(label);
2450
2451 return pt;
2452 }
2453
2454
2455
2456
2457 /* @func ensPredictiontranscriptNewRef ****************************************
2458 **
2459 ** Ensembl Object referencing function, which returns a pointer to the
2460 ** Ensembl Object passed in and increases its reference count.
2461 **
2462 ** @param [u] pt [EnsPPredictiontranscript] Ensembl Prediction Transcript
2463 **
2464 ** @return [EnsPPredictiontranscript] Ensembl Prediction Transcript or NULL
2465 **
2466 ** @release 6.2.0
2467 ** @@
2468 ******************************************************************************/
2469
ensPredictiontranscriptNewRef(EnsPPredictiontranscript pt)2470 EnsPPredictiontranscript ensPredictiontranscriptNewRef(
2471 EnsPPredictiontranscript pt)
2472 {
2473 if (!pt)
2474 return NULL;
2475
2476 pt->Use++;
2477
2478 return pt;
2479 }
2480
2481
2482
2483
2484 /* @funcstatic predictiontranscriptNewCpyFeatures *****************************
2485 **
2486 ** Returns a new copy of an Ensembl Prediction Transcript, but in addition to
2487 ** the shallow copy provided by ensPredictiontranscriptNewCpy, also copies all
2488 ** Ensembl Prediction Transcript-internal Ensembl Objects based on the
2489 ** Ensembl Feature class. This is useful in preparation of
2490 ** ensPredictiontranscriptTransform and ensPredictiontranscriptTransfer, which
2491 ** return an independent Ensembl Prediction Transcript object and therefore,
2492 ** require independent mapping of all internal Feature objects to the new
2493 ** Ensembl Coordinate System or Ensembl Slice.
2494 **
2495 ** @param [u] pt [EnsPPredictiontranscript] Ensembl Prediction Transcript
2496 **
2497 ** @return [EnsPPredictiontranscript] Ensembl Prediction Transcript or NULL
2498 **
2499 ** @release 6.4.0
2500 ** @@
2501 ******************************************************************************/
2502
predictiontranscriptNewCpyFeatures(EnsPPredictiontranscript pt)2503 static EnsPPredictiontranscript predictiontranscriptNewCpyFeatures(
2504 EnsPPredictiontranscript pt)
2505 {
2506 AjIList iter = NULL;
2507
2508 EnsPPredictionexon newpe = NULL;
2509 EnsPPredictionexon oldpe = NULL;
2510
2511 EnsPPredictiontranscript newpt = NULL;
2512
2513 if (!pt)
2514 return NULL;
2515
2516 newpt = ensPredictiontranscriptNewCpy(pt);
2517
2518 if (!newpt)
2519 return NULL;
2520
2521 /* Copy the AJAX List of Ensembl Prediction Exon objects. */
2522
2523 if (newpt->Predictionexons)
2524 {
2525 iter = ajListIterNew(newpt->Predictionexons);
2526
2527 while (!ajListIterDone(iter))
2528 {
2529 oldpe = (EnsPPredictionexon) ajListIterGet(iter);
2530
2531 ajListIterRemove(iter);
2532
2533 newpe = ensPredictionexonNewCpy(oldpe);
2534
2535 ajListIterInsert(iter, (void *) newpe);
2536
2537 /* Advance the AJAX List Iterator after the insert. */
2538
2539 (void) ajListIterGet(iter);
2540
2541 ensPredictionexonDel(&oldpe);
2542 }
2543
2544 ajListIterDel(&iter);
2545 }
2546
2547 return newpt;
2548 }
2549
2550
2551
2552
2553 /* @section destructors *******************************************************
2554 **
2555 ** Destruction destroys all internal data structures and frees the memory
2556 ** allocated for an Ensembl Prediction Transcript object.
2557 **
2558 ** @fdata [EnsPPredictiontranscript]
2559 **
2560 ** @nam3rule Del Destroy (free) an Ensembl Prediction Transcript
2561 **
2562 ** @argrule * Ppt [EnsPPredictiontranscript*]
2563 ** Ensembl Prediction Transcript address
2564 **
2565 ** @valrule * [void]
2566 **
2567 ** @fcategory delete
2568 ******************************************************************************/
2569
2570
2571
2572
2573 /* @func ensPredictiontranscriptDel *******************************************
2574 **
2575 ** Default destructor for an Ensembl Prediction Transcript.
2576 **
2577 ** @param [d] Ppt [EnsPPredictiontranscript*]
2578 ** Ensembl Prediction Transcript address
2579 **
2580 ** @return [void]
2581 **
2582 ** @release 6.2.0
2583 ** @@
2584 ******************************************************************************/
2585
ensPredictiontranscriptDel(EnsPPredictiontranscript * Ppt)2586 void ensPredictiontranscriptDel(
2587 EnsPPredictiontranscript *Ppt)
2588 {
2589 EnsPPredictionexon pe = NULL;
2590
2591 EnsPPredictiontranscript pthis = NULL;
2592
2593 if (!Ppt)
2594 return;
2595
2596 #if defined(AJ_DEBUG) && AJ_DEBUG >= 1
2597 if (ajDebugTest("ensPredictiontranscriptDel"))
2598 {
2599 ajDebug("ensPredictiontranscriptDel\n"
2600 " *Ppt %p\n",
2601 *Ppt);
2602
2603 ensPredictiontranscriptTrace(*Ppt, 1);
2604 }
2605 #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 1 */
2606
2607 if (!(pthis = *Ppt) || --pthis->Use)
2608 {
2609 *Ppt = NULL;
2610
2611 return;
2612 }
2613
2614 ensFeatureDel(&pthis->Feature);
2615
2616 ajStrDel(&pthis->Displaylabel);
2617
2618 /* Clear and delete the AJAX List of Ensembl Prediction Exon objects. */
2619
2620 while (ajListPop(pthis->Predictionexons, (void **) &pe))
2621 ensPredictionexonDel(&pe);
2622
2623 ajListFree(&pthis->Predictionexons);
2624
2625 ajMemFree((void **) Ppt);
2626
2627 return;
2628 }
2629
2630
2631
2632
2633 /* @section member retrieval **************************************************
2634 **
2635 ** Functions for returning members of an Ensembl Prediction Transcript object.
2636 **
2637 ** @fdata [EnsPPredictiontranscript]
2638 **
2639 ** @nam3rule Get Return Prediction Transcript attribute(s)
2640 ** @nam4rule Adaptor Return the Ensembl Prediction Transcript Adaptor
2641 ** @nam4rule Displaylabel Return the display label
2642 ** @nam4rule Feature Return the Ensembl Feature
2643 ** @nam4rule Identifier Return the SQL database-internal identifier
2644 **
2645 ** @argrule * pt [const EnsPPredictiontranscript] Prediction Transcript
2646 **
2647 ** @valrule Adaptor [EnsPPredictiontranscriptadaptor]
2648 ** Ensembl Prediction Transcript Adaptor or NULL
2649 ** @valrule Displaylabel [AjPStr] Display label or NULL
2650 ** @valrule Feature [EnsPFeature] Ensembl Feature or NULL
2651 ** @valrule Identifier [ajuint] SQL database-internal identifier or 0U
2652 **
2653 ** @fcategory use
2654 ******************************************************************************/
2655
2656
2657
2658
2659 /* @func ensPredictiontranscriptGetAdaptor ************************************
2660 **
2661 ** Get the Ensembl Prediction Transcript Adaptor member of an
2662 ** Ensembl Prediction Transcript.
2663 **
2664 ** @cc Bio::EnsEMBL::Storable::adaptor
2665 ** @param [r] pt [const EnsPPredictiontranscript] Ensembl Prediction Transcript
2666 **
2667 ** @return [EnsPPredictiontranscriptadaptor]
2668 ** Ensembl Prediction Transcript Adaptor or NULL
2669 **
2670 ** @release 6.2.0
2671 ** @@
2672 ******************************************************************************/
2673
ensPredictiontranscriptGetAdaptor(const EnsPPredictiontranscript pt)2674 EnsPPredictiontranscriptadaptor ensPredictiontranscriptGetAdaptor(
2675 const EnsPPredictiontranscript pt)
2676 {
2677 return (pt) ? pt->Adaptor : NULL;
2678 }
2679
2680
2681
2682
2683 /* @func ensPredictiontranscriptGetDisplaylabel *******************************
2684 **
2685 ** Get the display label member of an Ensembl Prediction Transcript.
2686 **
2687 ** @cc Bio::EnsEMBL::PredictionTranscript::display_label
2688 ** @param [r] pt [const EnsPPredictiontranscript] Ensembl Prediction Transcript
2689 **
2690 ** @return [AjPStr] Display label or NULL
2691 **
2692 ** @release 6.4.0
2693 ** @@
2694 ******************************************************************************/
2695
ensPredictiontranscriptGetDisplaylabel(const EnsPPredictiontranscript pt)2696 AjPStr ensPredictiontranscriptGetDisplaylabel(
2697 const EnsPPredictiontranscript pt)
2698 {
2699 return (pt) ? pt->Displaylabel : NULL;
2700 }
2701
2702
2703
2704
2705 /* @func ensPredictiontranscriptGetFeature ************************************
2706 **
2707 ** Get the Ensembl Feature member of an Ensembl Prediction Transcript.
2708 **
2709 ** @param [r] pt [const EnsPPredictiontranscript] Ensembl Prediction Transcript
2710 **
2711 ** @return [EnsPFeature] Ensembl Feature or NULL
2712 **
2713 ** @release 6.2.0
2714 ** @@
2715 ******************************************************************************/
2716
ensPredictiontranscriptGetFeature(const EnsPPredictiontranscript pt)2717 EnsPFeature ensPredictiontranscriptGetFeature(
2718 const EnsPPredictiontranscript pt)
2719 {
2720 return (pt) ? pt->Feature : NULL;
2721 }
2722
2723
2724
2725
2726 /* @func ensPredictiontranscriptGetIdentifier *********************************
2727 **
2728 ** Get the SQL database-internal identifier member of an
2729 ** Ensembl Prediction Transcript.
2730 **
2731 ** @cc Bio::EnsEMBL::Storable::dbID
2732 ** @param [r] pt [const EnsPPredictiontranscript] Ensembl Prediction Transcript
2733 **
2734 ** @return [ajuint] SQL database-internal identifier or 0U
2735 **
2736 ** @release 6.2.0
2737 ** @@
2738 ******************************************************************************/
2739
ensPredictiontranscriptGetIdentifier(const EnsPPredictiontranscript pt)2740 ajuint ensPredictiontranscriptGetIdentifier(
2741 const EnsPPredictiontranscript pt)
2742 {
2743 return (pt) ? pt->Identifier : 0U;
2744 }
2745
2746
2747
2748
2749 /* @section load on demand ****************************************************
2750 **
2751 ** Functions for returning members of an Ensembl Prediction Transcript object,
2752 ** which may need loading from an Ensembl SQL database on demand.
2753 **
2754 ** @fdata [EnsPPredictiontranscript]
2755 **
2756 ** @nam3rule Load Return Ensembl Prediction Transcript attribute(s)
2757 ** loaded on demand
2758 ** @nam4rule Predictionexons Return all Ensembl Prediction Exon objects
2759 **
2760 ** @argrule * pt [EnsPPredictiontranscript] Ensembl Prediction Transcript
2761 **
2762 ** @valrule Predictionexons [const AjPList] AJAX List of
2763 ** Ensembl Prediction Exon objects or NULL
2764 **
2765 ** @fcategory use
2766 ******************************************************************************/
2767
2768
2769
2770
2771 /* @func ensPredictiontranscriptLoadPredictionexons ***************************
2772 **
2773 ** Load all Ensembl Prediction Exon objects of an
2774 ** Ensembl Prediction Transcript.
2775 **
2776 ** This is not a simple accessor function, since it will attempt fetching the
2777 ** Prediction Exon objects from the Ensembl Core database associated with the
2778 ** Prediction Transcript Adaptor.
2779 **
2780 ** @cc Bio::EnsEMBL::PredictionTranscript::get_all_Exons
2781 ** @param [u] pt [EnsPPredictiontranscript] Ensembl Prediction Transcript
2782 **
2783 ** @return [const AjPList] AJAX List of Ensembl Prediction Exon objects
2784 **
2785 ** @release 6.4.0
2786 ** @@
2787 ******************************************************************************/
2788
ensPredictiontranscriptLoadPredictionexons(EnsPPredictiontranscript pt)2789 const AjPList ensPredictiontranscriptLoadPredictionexons(
2790 EnsPPredictiontranscript pt)
2791 {
2792 EnsPDatabaseadaptor dba = NULL;
2793
2794 EnsPPredictionexonadaptor pea = NULL;
2795
2796 if (!pt)
2797 return NULL;
2798
2799 if (pt->Predictionexons)
2800 return pt->Predictionexons;
2801
2802 if (!pt->Adaptor)
2803 {
2804 ajDebug("ensPredictiontranscriptGetPredictionexons cannot fetch "
2805 "Ensembl Prediction Exon objects for an "
2806 "Ensembl Prediction Transcript without an "
2807 "Ensembl Prediction Transcript Adaptor.\n");
2808
2809 return NULL;
2810 }
2811
2812 dba = ensPredictiontranscriptadaptorGetDatabaseadaptor(pt->Adaptor);
2813
2814 pea = ensRegistryGetPredictionexonadaptor(dba);
2815
2816 pt->Predictionexons = ajListNew();
2817
2818 ensPredictionexonadaptorFetchAllbyPredictiontranscript(
2819 pea,
2820 pt,
2821 pt->Predictionexons);
2822
2823 return pt->Predictionexons;
2824 }
2825
2826
2827
2828
2829 /* @section member assignment *************************************************
2830 **
2831 ** Functions for assigning members of an Ensembl Prediction Transcript object.
2832 **
2833 ** @fdata [EnsPPredictiontranscript]
2834 **
2835 ** @nam3rule Set Set one member of a Prediction Transcript
2836 ** @nam4rule Adaptor Set the Ensembl Prediction Transcript Adaptor
2837 ** @nam4rule Displaylabel Set the display label
2838 ** @nam4rule Feature Set the Ensembl Feature
2839 ** @nam4rule Identifier Set the SQL database-internal identifier
2840 **
2841 ** @argrule * pt [EnsPPredictiontranscript] Ensembl Prediction Transcript
2842 ** @argrule Adaptor pta [EnsPPredictiontranscriptadaptor]
2843 ** Ensembl Prediction Transcript Adaptor
2844 ** @argrule Displaylabel label [AjPStr] Display label
2845 ** @argrule Feature feature [EnsPFeature] Ensembl Feature
2846 ** @argrule Identifier identifier [ajuint] SQL database-internal identifier
2847 **
2848 ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise
2849 **
2850 ** @fcategory modify
2851 ******************************************************************************/
2852
2853
2854
2855
2856 /* @func ensPredictiontranscriptSetAdaptor ************************************
2857 **
2858 ** Set the Ensembl Prediction Transcript Adaptor member of an
2859 ** Ensembl Prediction Transcript.
2860 **
2861 ** @cc Bio::EnsEMBL::Storable::adaptor
2862 ** @param [u] pt [EnsPPredictiontranscript] Ensembl Prediction Transcript
2863 ** @param [u] pta [EnsPPredictiontranscriptadaptor]
2864 ** Ensembl Prediction Transcript Adaptor
2865 **
2866 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
2867 **
2868 ** @release 6.2.0
2869 ** @@
2870 ******************************************************************************/
2871
ensPredictiontranscriptSetAdaptor(EnsPPredictiontranscript pt,EnsPPredictiontranscriptadaptor pta)2872 AjBool ensPredictiontranscriptSetAdaptor(
2873 EnsPPredictiontranscript pt,
2874 EnsPPredictiontranscriptadaptor pta)
2875 {
2876 if (!pt)
2877 return ajFalse;
2878
2879 pt->Adaptor = pta;
2880
2881 return ajTrue;
2882 }
2883
2884
2885
2886
2887 /* @func ensPredictiontranscriptSetDisplaylabel *******************************
2888 **
2889 ** Set the display label member of an Ensembl Prediction Transcript.
2890 **
2891 ** @cc Bio::EnsEMBL::PredictionTranscript::display_label
2892 ** @param [u] pt [EnsPPredictiontranscript] Ensembl Prediction Transcript
2893 ** @param [u] label [AjPStr] Display label
2894 **
2895 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
2896 **
2897 ** @release 6.4.0
2898 ** @@
2899 ******************************************************************************/
2900
ensPredictiontranscriptSetDisplaylabel(EnsPPredictiontranscript pt,AjPStr label)2901 AjBool ensPredictiontranscriptSetDisplaylabel(
2902 EnsPPredictiontranscript pt,
2903 AjPStr label)
2904 {
2905 if (!pt)
2906 return ajFalse;
2907
2908 ajStrDel(&pt->Displaylabel);
2909
2910 pt->Displaylabel = ajStrNewRef(label);
2911
2912 return ajTrue;
2913 }
2914
2915
2916
2917
2918 /* @func ensPredictiontranscriptSetFeature ************************************
2919 **
2920 ** Set the Ensembl Feature member of an Ensembl Prediction Transcript.
2921 **
2922 ** @param [u] pt [EnsPPredictiontranscript] Ensembl Prediction Transcript
2923 ** @param [u] feature [EnsPFeature] Ensembl Feature
2924 **
2925 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
2926 **
2927 ** @release 6.2.0
2928 ** @@
2929 ******************************************************************************/
2930
ensPredictiontranscriptSetFeature(EnsPPredictiontranscript pt,EnsPFeature feature)2931 AjBool ensPredictiontranscriptSetFeature(
2932 EnsPPredictiontranscript pt,
2933 EnsPFeature feature)
2934 {
2935 AjIList iter = NULL;
2936
2937 EnsPPredictionexon oldpe = NULL;
2938 EnsPPredictionexon newpe = NULL;
2939
2940 EnsPSlice slice = NULL;
2941
2942 if (!pt)
2943 return ajFalse;
2944
2945 ensFeatureDel(&pt->Feature);
2946
2947 pt->Feature = ensFeatureNewRef(feature);
2948
2949 slice = ensFeatureGetSlice(pt->Feature);
2950
2951 /*
2952 ** Transfer Ensembl Prediction Exon objects onto the new Ensembl Feature
2953 ** Slice.
2954 */
2955
2956 if (pt->Predictionexons)
2957 {
2958 iter = ajListIterNew(pt->Predictionexons);
2959
2960 while (!ajListIterDone(iter))
2961 {
2962 oldpe = (EnsPPredictionexon) ajListIterGet(iter);
2963
2964 ajListIterRemove(iter);
2965
2966 newpe = ensPredictionexonTransfer(oldpe, slice);
2967
2968 if (!newpe)
2969 {
2970 ajDebug("ensPredictiontranscriptSetFeature could not transfer "
2971 "Prediction Exon onto new Ensembl Feature Slice.");
2972
2973 ensPredictionexonTrace(oldpe, 1);
2974 }
2975
2976 ajListIterInsert(iter, (void *) newpe);
2977
2978 /* Advance the AJAX List Iterator after the insert. */
2979
2980 (void) ajListIterGet(iter);
2981
2982 ensPredictionexonDel(&oldpe);
2983 }
2984
2985 ajListIterDel(&iter);
2986 }
2987
2988 return ajTrue;
2989 }
2990
2991
2992
2993
2994 /* @func ensPredictiontranscriptSetIdentifier *********************************
2995 **
2996 ** Set the SQL database-internal identifier member of an
2997 ** Ensembl Prediction Transcript.
2998 **
2999 ** @cc Bio::EnsEMBL::Storable::dbID
3000 ** @param [u] pt [EnsPPredictiontranscript] Ensembl Prediction Transcript
3001 ** @param [r] identifier [ajuint] SQL database-internal identifier
3002 **
3003 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
3004 **
3005 ** @release 6.2.0
3006 ** @@
3007 ******************************************************************************/
3008
ensPredictiontranscriptSetIdentifier(EnsPPredictiontranscript pt,ajuint identifier)3009 AjBool ensPredictiontranscriptSetIdentifier(
3010 EnsPPredictiontranscript pt,
3011 ajuint identifier)
3012 {
3013 if (!pt)
3014 return ajFalse;
3015
3016 pt->Identifier = identifier;
3017
3018 return ajTrue;
3019 }
3020
3021
3022
3023
3024 /* @section debugging *********************************************************
3025 **
3026 ** Functions for reporting of an Ensembl Prediction Transcript object.
3027 **
3028 ** @fdata [EnsPPredictiontranscript]
3029 **
3030 ** @nam3rule Trace Report Ensembl Prediction Transcript members to debug file
3031 **
3032 ** @argrule Trace pt [const EnsPPredictiontranscript] Ensembl Prediction
3033 ** Transcript
3034 ** @argrule Trace level [ajuint] Indentation level
3035 **
3036 ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise
3037 **
3038 ** @fcategory misc
3039 ******************************************************************************/
3040
3041
3042
3043
3044 /* @func ensPredictiontranscriptTrace *****************************************
3045 **
3046 ** Trace an Ensembl Prediction Transcript.
3047 **
3048 ** @param [r] pt [const EnsPPredictiontranscript] Ensembl Prediction Transcript
3049 ** @param [r] level [ajuint] Indentation level
3050 **
3051 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
3052 **
3053 ** @release 6.2.0
3054 ** @@
3055 ******************************************************************************/
3056
ensPredictiontranscriptTrace(const EnsPPredictiontranscript pt,ajuint level)3057 AjBool ensPredictiontranscriptTrace(
3058 const EnsPPredictiontranscript pt,
3059 ajuint level)
3060 {
3061 AjIList iter = NULL;
3062
3063 AjPStr indent = NULL;
3064
3065 EnsPPredictionexon pe = NULL;
3066
3067 if (!pt)
3068 return ajFalse;
3069
3070 indent = ajStrNew();
3071
3072 ajStrAppendCountK(&indent, ' ', level * 2);
3073
3074 ajDebug("%SensPredictiontranscriptTrace %p\n"
3075 "%S Use %u\n"
3076 "%S Identifier %u\n"
3077 "%S Adaptor %p\n"
3078 "%S Feature %p\n"
3079 "%S Displaylabel '%S'\n"
3080 "%S Predictionexons %p\n",
3081 indent, pt,
3082 indent, pt->Use,
3083 indent, pt->Identifier,
3084 indent, pt->Adaptor,
3085 indent, pt->Feature,
3086 indent, pt->Displaylabel,
3087 indent, pt->Predictionexons);
3088
3089 ensFeatureTrace(pt->Feature, level + 1);
3090
3091 /* Trace the AJAX List of Ensembl Prediction Exon objects. */
3092
3093 if (pt->Predictionexons)
3094 {
3095 ajDebug("%S AJAX List %p of Ensembl Prediction Exon objects\n",
3096 indent, pt->Predictionexons);
3097
3098 iter = ajListIterNewread(pt->Predictionexons);
3099
3100 while (!ajListIterDone(iter))
3101 {
3102 pe = (EnsPPredictionexon) ajListIterGet(iter);
3103
3104 ensPredictionexonTrace(pe, level + 2);
3105 }
3106
3107 ajListIterDel(&iter);
3108 }
3109
3110 ajStrDel(&indent);
3111
3112 return ajTrue;
3113 }
3114
3115
3116
3117
3118 /* @section calculate *********************************************************
3119 **
3120 ** Functions for calculating information from an
3121 ** Ensembl Prediction Transcript object.
3122 **
3123 ** @fdata [EnsPPredictiontranscript]
3124 **
3125 ** @nam3rule Calculate Calculate Ensembl Prediction Transcript information
3126 ** @nam4rule Length Calculate the length
3127 ** @nam4rule Memsize Calculate the memory size in bytes
3128 ** @nam4rule Slice Calculate Ensembl Transcript coordinates relative to
3129 ** an Ensembl Slice
3130 ** @nam5rule Coding Calculate Ensembl Transcript coding coordinates
3131 ** @nam6rule End Calculate the Ensembl Transcript coding end coordinate
3132 ** @nam6rule Start Calculate the Ensembl Transcript coding start coordinate
3133 ** @nam4rule Transcript Calculate Ensembl Transcript coordinates relative to
3134 ** an Ensembl Transcript
3135 ** @nam5rule Coding Calculate Ensembl Transcript coding coordinates
3136 ** @nam6rule End Calculate the Ensembl Transcript coding end coordinate
3137 ** @nam6rule Start Calculate the Ensembl Transcript coding start coordinate
3138 ** @nam5rule End Calculate the Ensembl Transcript end coordinate
3139 ** @nam5rule Start Calculate the Ensembl Transcript start coordinate
3140 **
3141 ** @argrule Memsize pt [const EnsPPredictiontranscript]
3142 ** Ensembl Prediction Transcript
3143 ** @argrule Slice pt [const EnsPPredictiontranscript]
3144 ** Ensembl Prediction Transcript
3145 ** @argrule TranscriptCodingEnd pt [EnsPPredictiontranscript]
3146 ** Ensembl Prediction Transcript
3147 ** @argrule TranscriptCodingStart pt [const EnsPPredictiontranscript]
3148 ** Ensembl Prediction Transcript
3149 **
3150 ** @valrule Length [ajuint] Transcript (cDNA) length or 0U
3151 ** @valrule Memsize [size_t] Memory size in bytes or 0
3152 ** @valrule SliceCodingEnd [ajint] End coordinate or 0
3153 ** @valrule SliceCodingStart [ajint] Start coordinate or 0
3154 ** @valrule TranscriptCodingEnd [ajuint] End coordinate or 0U
3155 ** @valrule TranscriptCodingStart [ajuint] Start coordinate or 0U
3156 ** @valrule TranscriptEnd [ajuint] End coordinate or 0U
3157 ** @valrule TranscriptStart [ajuint] Start coordinate or 0U
3158 **
3159 ** @fcategory misc
3160 ******************************************************************************/
3161
3162
3163
3164
3165 /* @func ensPredictiontranscriptCalculateMemsize ******************************
3166 **
3167 ** Calculate the memory size in bytes of an Ensembl Prediction Transcript.
3168 **
3169 ** @param [r] pt [const EnsPPredictiontranscript] Ensembl Prediction Transcript
3170 **
3171 ** @return [size_t] Memory size in bytes or 0
3172 **
3173 ** @release 6.4.0
3174 ** @@
3175 ******************************************************************************/
3176
ensPredictiontranscriptCalculateMemsize(const EnsPPredictiontranscript pt)3177 size_t ensPredictiontranscriptCalculateMemsize(
3178 const EnsPPredictiontranscript pt)
3179 {
3180 size_t size = 0;
3181
3182 AjIList iter = NULL;
3183
3184 EnsPPredictionexon pe = NULL;
3185
3186 if (!pt)
3187 return 0;
3188
3189 size += sizeof (EnsOPredictiontranscript);
3190
3191 size += ensFeatureCalculateMemsize(pt->Feature);
3192
3193 if (pt->Displaylabel)
3194 {
3195 size += sizeof (AjOStr);
3196
3197 size += ajStrGetRes(pt->Displaylabel);
3198 }
3199
3200 /* Summarise the AJAX List of Ensembl Prediction Exon objects. */
3201
3202 if (pt->Predictionexons)
3203 {
3204 size += sizeof (AjOList);
3205
3206 iter = ajListIterNewread(pt->Predictionexons);
3207
3208 while (!ajListIterDone(iter))
3209 {
3210 pe = (EnsPPredictionexon) ajListIterGet(iter);
3211
3212 size += ensPredictionexonCalculateMemsize(pe);
3213 }
3214
3215 ajListIterDel(&iter);
3216 }
3217
3218 return size;
3219 }
3220
3221
3222
3223
3224 /* @func ensPredictiontranscriptCalculateSliceCodingEnd ***********************
3225 **
3226 ** Calculate the end position of the coding region in Slice coordinates.
3227 **
3228 ** Calculates the end of the coding region of this Prediction Transcript in
3229 ** Slice coordinates. For Prediction Transcript objects this is always the same
3230 ** as the end since no UTRs are stored. By convention, the coding region end,
3231 ** returned by ensPredictiontranscriptCalculateSliceCodingEnd is always higher
3232 ** than the value returned by the
3233 ** ensPredictiontranscriptCalculateSliceCodingStart function. The value
3234 ** returned by this function is NOT the biological coding end, since on the
3235 ** reverse strand the biological coding end would be the lower genomic value.
3236 **
3237 ** @cc Bio::EnsEMBL::PredictionTranscript::coding_region_end
3238 ** @param [r] pt [const EnsPPredictiontranscript] Ensembl Prediction Transcript
3239 **
3240 ** @return [ajint] Coding region end in Slice coordinates
3241 **
3242 ** @release 6.4.0
3243 ** @@
3244 ******************************************************************************/
3245
ensPredictiontranscriptCalculateSliceCodingEnd(const EnsPPredictiontranscript pt)3246 ajint ensPredictiontranscriptCalculateSliceCodingEnd(
3247 const EnsPPredictiontranscript pt)
3248 {
3249 if (!pt)
3250 return 0;
3251
3252 return ensFeatureGetEnd(pt->Feature);
3253 }
3254
3255
3256
3257
3258 /* @func ensPredictiontranscriptCalculateSliceCodingStart *********************
3259 **
3260 ** Calculate the start position of the coding region in Slice coordinates.
3261 **
3262 ** Calculates the start of the coding region of this Prediction Transcript in
3263 ** Slice coordinates. For Prediction Transcript objects this is always the
3264 ** start of the transcript (i.e. there is no UTR). By convention, the coding
3265 ** region start returned by ensPredictiontranscriptCalculateSliceCodingStart
3266 ** is always lower than the value returned by the
3267 ** ensPredictiontranscriptCalculateSliceCodingEnd function.
3268 ** The value returned by this function is NOT the biological coding start,
3269 ** since on the reverse strand the biological coding start would be the higher
3270 ** genomic value.
3271 **
3272 ** @cc Bio::EnsEMBL::PredictionTranscript::coding_region_start
3273 ** @param [r] pt [const EnsPPredictiontranscript] Ensembl Prediction Transcript
3274 **
3275 ** @return [ajint] Coding region start in Slice coordinates
3276 **
3277 ** @release 6.4.0
3278 ** @@
3279 ******************************************************************************/
3280
ensPredictiontranscriptCalculateSliceCodingStart(const EnsPPredictiontranscript pt)3281 ajint ensPredictiontranscriptCalculateSliceCodingStart(
3282 const EnsPPredictiontranscript pt)
3283 {
3284 if (!pt)
3285 return 0;
3286
3287 return ensFeatureGetStart(pt->Feature);
3288 }
3289
3290
3291
3292
3293 /* @func ensPredictiontranscriptCalculateTranscriptCodingEnd ******************
3294 **
3295 ** Calculate the end position of the coding region in Prediction Transcript
3296 ** coordinates.
3297 **
3298 ** @cc Bio::EnsEMBL::PredictionTranscript::cdna_coding_end
3299 ** @param [u] pt [EnsPPredictiontranscript] Ensembl Prediction Transcript
3300 **
3301 ** @return [ajuint] Coding region end in Transcript coordinates or 0U
3302 **
3303 ** @release 6.4.0
3304 ** @@
3305 ******************************************************************************/
3306
ensPredictiontranscriptCalculateTranscriptCodingEnd(EnsPPredictiontranscript pt)3307 ajuint ensPredictiontranscriptCalculateTranscriptCodingEnd(
3308 EnsPPredictiontranscript pt)
3309 {
3310 ajuint end = 0U;
3311
3312 AjIList iter = NULL;
3313
3314 const AjPList pes = NULL;
3315
3316 EnsPPredictionexon pe = NULL;
3317
3318 EnsPFeature feature = NULL;
3319
3320 if (!pt)
3321 return 0U;
3322
3323 pes = ensPredictiontranscriptLoadPredictionexons(pt);
3324
3325 iter = ajListIterNewread(pes);
3326
3327 while (!ajListIterDone(iter))
3328 {
3329 pe = (EnsPPredictionexon) ajListIterGet(iter);
3330
3331 /* Add the entire length of this Prediction Exon. */
3332
3333 feature = ensPredictionexonGetFeature(pe);
3334
3335 end += ensFeatureCalculateLength(feature);
3336 }
3337
3338 ajListIterDel(&iter);
3339
3340 return end;
3341 }
3342
3343
3344
3345
3346 /* @func ensPredictiontranscriptCalculateTranscriptCodingStart ****************
3347 **
3348 ** Calculate the start position of the coding region in Prediction Transcript
3349 ** coordinates.
3350 **
3351 ** @cc Bio::EnsEMBL::PredictionTranscript::cdna_coding_start
3352 ** @param [r] pt [const EnsPPredictiontranscript] Ensembl Prediction Transcript
3353 **
3354 ** @return [ajuint] Coding region start in Transcript coordinates or 0U
3355 **
3356 ** @release 6.4.0
3357 ** @@
3358 ******************************************************************************/
3359
ensPredictiontranscriptCalculateTranscriptCodingStart(const EnsPPredictiontranscript pt)3360 ajuint ensPredictiontranscriptCalculateTranscriptCodingStart(
3361 const EnsPPredictiontranscript pt)
3362 {
3363 if (!pt)
3364 return 0U;
3365
3366 return 1U;
3367 }
3368
3369
3370
3371
3372 /* @section fetch *************************************************************
3373 **
3374 ** Functions for fetching information from an
3375 ** Ensembl Prediction Transcript object.
3376 **
3377 ** @fdata [EnsPPredictiontranscript]
3378 **
3379 ** @nam3rule Fetch Fetch Ensembl Prediction Transcript information
3380 ** @nam4rule All Fetch all objects
3381 ** @nam4rule Sequence Fetch the sequence
3382 ** @nam5rule Coding Fetch the coding sequence
3383 ** @nam5rule Transcript Fetch the Ensembl Transcript (cDNA) sequence
3384 ** @nam6rule Seq Fetch as AJAX Sequence object
3385 ** @nam6rule Str Fetch as AJAX String object
3386 ** @nam5rule Translation Fetch the Ensembl Translation sequence
3387 ** @nam6rule Seq Fetch as AJAX Sequence object
3388 ** @nam6rule Str Fetch as AJAX String object
3389 **
3390 ** @argrule * pt [EnsPPredictiontranscript] Ensembl Prediction Transcript
3391 ** @argrule Seq Psequence [AjPSeq*] AJAX Sequence address
3392 ** @argrule Str Psequence [AjPStr*] AJAX String address
3393 **
3394 ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise
3395 **
3396 ** @fcategory misc
3397 ******************************************************************************/
3398
3399
3400
3401
3402 /* @func ensPredictiontranscriptFetchSequenceTranscriptSeq ********************
3403 **
3404 ** Fetch the sequence of an Ensembl Prediction Transcript as AJAX Sequence.
3405 ** The caller is responsible for deleting the AJAX Sequence.
3406 **
3407 ** @cc Bio::EnsEMBL::PredictionTranscript:spliced_seq
3408 ** @param [u] pt [EnsPPredictiontranscript] Ensembl Prediction Transcript
3409 ** @param [wP] Psequence [AjPSeq*] AJAX Sequence address
3410 **
3411 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
3412 **
3413 ** @release 6.4.0
3414 ** @@
3415 ******************************************************************************/
3416
ensPredictiontranscriptFetchSequenceTranscriptSeq(EnsPPredictiontranscript pt,AjPSeq * Psequence)3417 AjBool ensPredictiontranscriptFetchSequenceTranscriptSeq(
3418 EnsPPredictiontranscript pt,
3419 AjPSeq *Psequence)
3420 {
3421 AjPStr sequence = NULL;
3422
3423 if (!pt)
3424 return ajFalse;
3425
3426 if (!Psequence)
3427 return ajFalse;
3428
3429 /*
3430 ** It is sligtly more efficient, if undefined AJAX String objects are
3431 ** directly allocated by the following functions to their final size.
3432 */
3433
3434 ensPredictiontranscriptFetchSequenceTranscriptStr(pt, &sequence);
3435
3436 if (*Psequence)
3437 {
3438 ajSeqClear(*Psequence);
3439
3440 ajSeqAssignNameS(*Psequence, pt->Displaylabel);
3441 ajSeqAssignSeqS(*Psequence, sequence);
3442 }
3443 else
3444 *Psequence = ajSeqNewNameS(sequence, pt->Displaylabel);
3445
3446 ajSeqSetNuc(*Psequence);
3447
3448 ajStrDel(&sequence);
3449
3450 return ajTrue;
3451 }
3452
3453
3454
3455
3456 /* @func ensPredictiontranscriptFetchSequenceTranscriptStr ********************
3457 **
3458 ** Fetch the spliced sequence of an Ensembl Prediction Transcript as
3459 ** AJAX String.
3460 **
3461 ** The sequence of all Ensembl Prediction Exon objects is concatenated.
3462 **
3463 ** The caller is responsible for deleting the AJAX String.
3464 **
3465 ** @cc Bio::EnsEMBL::PredictionTranscript::spliced_seq
3466 ** @param [u] pt [EnsPPredictiontranscript] Ensembl Prediction Transcript
3467 ** @param [wP] Psequence [AjPStr*] AJAX String address
3468 **
3469 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
3470 **
3471 ** @release 6.4.0
3472 ** @@
3473 ******************************************************************************/
3474
ensPredictiontranscriptFetchSequenceTranscriptStr(EnsPPredictiontranscript pt,AjPStr * Psequence)3475 AjBool ensPredictiontranscriptFetchSequenceTranscriptStr(
3476 EnsPPredictiontranscript pt,
3477 AjPStr *Psequence)
3478 {
3479 AjIList iter = NULL;
3480 const AjPList pes = NULL;
3481
3482 AjPStr sequence = NULL;
3483
3484 EnsPPredictionexon pe = NULL;
3485
3486 EnsPFeature feature = NULL;
3487
3488 if (!pt)
3489 return ajFalse;
3490
3491 if (!Psequence)
3492 return ajFalse;
3493
3494 if (*Psequence)
3495 ajStrAssignClear(Psequence);
3496 else
3497 *Psequence = ajStrNew();
3498
3499 sequence = ajStrNew();
3500
3501 pes = ensPredictiontranscriptLoadPredictionexons(pt);
3502
3503 iter = ajListIterNewread(pes);
3504
3505 while (!ajListIterDone(iter))
3506 {
3507 pe = (EnsPPredictionexon) ajListIterGet(iter);
3508
3509 ensPredictionexonFetchSequenceStr(pe, &sequence);
3510
3511 if (sequence && ajStrGetLen(sequence))
3512 ajStrAppendS(Psequence, sequence);
3513 else
3514 {
3515 ajDebug("ensPredictiontranscriptFetchSequenceTranscriptStr could "
3516 "not get sequence for Prediction Exon. The "
3517 "Prediction Transcript sequence may not be correct.\n");
3518
3519 feature = ensPredictionexonGetFeature(pe);
3520
3521 ajStrAppendCountK(Psequence,
3522 'N',
3523 ensFeatureCalculateLength(feature));
3524 }
3525 }
3526
3527 ajListIterDel(&iter);
3528
3529 ajStrDel(&sequence);
3530
3531 return ajTrue;
3532 }
3533
3534
3535
3536
3537 /* @func ensPredictiontranscriptFetchSequenceTranslationSeq *******************
3538 **
3539 ** Fetch the sequence of the Ensembl Prediction Translation of an
3540 ** Ensembl Prediction Transcript as AJAX Sequence.
3541 **
3542 ** The sequence is based on ensPredictiontranscriptFetchSequenceTranslationStr.
3543 **
3544 ** The caller is responsible for deleting the AJAX Sequence.
3545 **
3546 ** @cc Bio::EnsEMBL::PredictionTranscript::translate
3547 ** @param [u] pt [EnsPPredictiontranscript] Ensembl Prediction Transcript
3548 ** @param [wP] Psequence [AjPSeq*] AJAX Sequence address
3549 **
3550 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
3551 **
3552 ** @release 6.4.0
3553 ** @@
3554 ******************************************************************************/
3555
ensPredictiontranscriptFetchSequenceTranslationSeq(EnsPPredictiontranscript pt,AjPSeq * Psequence)3556 AjBool ensPredictiontranscriptFetchSequenceTranslationSeq(
3557 EnsPPredictiontranscript pt,
3558 AjPSeq *Psequence)
3559 {
3560 AjPStr sequence = NULL;
3561
3562 if (!pt)
3563 return ajFalse;
3564
3565 if (!Psequence)
3566 return ajFalse;
3567
3568 /*
3569 ** It is sligtly more efficient, if undefined AJAX String objects are
3570 ** directly allocated by the following functions to their final size.
3571 */
3572
3573 ensPredictiontranscriptFetchSequenceTranslationStr(pt, &sequence);
3574
3575 if (*Psequence)
3576 {
3577 ajSeqClear(*Psequence);
3578
3579 ajSeqAssignNameS(*Psequence, pt->Displaylabel);
3580 ajSeqAssignSeqS(*Psequence, sequence);
3581 }
3582 else
3583 *Psequence = ajSeqNewNameS(sequence, pt->Displaylabel);
3584
3585 ajSeqSetProt(*Psequence);
3586
3587 ajStrDel(&sequence);
3588
3589 return ajTrue;
3590 }
3591
3592
3593
3594
3595 /* @func ensPredictiontranscriptFetchSequenceTranslationStr *******************
3596 **
3597 ** Fetch the sequence of the Ensembl Prediction Translation of an
3598 ** Ensembl Prediction Transcript as AJAX String.
3599 **
3600 ** The sequence is based on ensPredictiontranscriptFetchSequenceTranscriptStr.
3601 **
3602 ** The caller is responsible for deleting the AJAX String.
3603 **
3604 ** @cc Bio::EnsEMBL::PredictionTranscript::translate
3605 ** @param [u] pt [EnsPPredictiontranscript] Ensembl Prediction Transcript
3606 ** @param [wP] Psequence [AjPStr*] AJAX String address
3607 **
3608 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
3609 **
3610 ** @release 6.4.0
3611 ** @@
3612 ******************************************************************************/
3613
ensPredictiontranscriptFetchSequenceTranslationStr(EnsPPredictiontranscript pt,AjPStr * Psequence)3614 AjBool ensPredictiontranscriptFetchSequenceTranslationStr(
3615 EnsPPredictiontranscript pt,
3616 AjPStr *Psequence)
3617 {
3618 AjPStr sequence = NULL;
3619
3620 const AjPTrn atranslation = NULL;
3621
3622 EnsPSlice slice = NULL;
3623
3624 if (ajDebugTest("ensPredictiontranscriptFetchSequenceTranslationStr"))
3625 ajDebug("ensPredictiontranscriptFetchSequenceTranslationStr\n"
3626 " pt %p\n"
3627 " Psequence %p\n",
3628 pt,
3629 Psequence);
3630
3631 if (!pt)
3632 return ajFalse;
3633
3634 if (!Psequence)
3635 return ajFalse;
3636
3637 if (*Psequence)
3638 ajStrAssignClear(Psequence);
3639 else
3640 *Psequence = ajStrNew();
3641
3642 /*
3643 ** Ensembl Prediction Transcript objects have no untranslated regions
3644 ** (UTRs), so that it is sufficient to fetch the Prediction Transcript
3645 ** sequence, rather than the translatable sequence, as in the case of an
3646 ** Ensembl Transcript.
3647 **
3648 ** It is sligtly more efficient, if undefined AJAX String objects are
3649 ** directly allocated by the following functions to their final size.
3650 */
3651
3652 ensPredictiontranscriptFetchSequenceTranscriptStr(pt, &sequence);
3653
3654 if (ajStrGetLen(sequence) < 1)
3655 return ajTrue;
3656
3657 slice = ensFeatureGetSlice(pt->Feature);
3658
3659 atranslation = ensSliceGetTranslation(slice);
3660
3661 ajTrnSeqS(atranslation, sequence, Psequence);
3662
3663 ajStrDel(&sequence);
3664
3665 /*
3666 ** Remove the final stop codon from the mRNA if it is present, so that the
3667 ** resulting peptides do not end with a '*'. If a terminal stop codon is
3668 ** desired, call ensTranscriptFetchSequenceCodingStr and translate it
3669 ** directly.
3670 ** NOTE: This test is simpler and hopefully more efficient than the one
3671 ** in the Perl API, which tests for a termination codon in a
3672 ** codon table-specifc manner and removes the last triplet from the cDNA.
3673 */
3674
3675 if (ajStrGetCharLast(*Psequence) == '*')
3676 ajStrCutEnd(Psequence, 1);
3677
3678 return ajTrue;
3679 }
3680
3681
3682
3683
3684 /* @section map ***************************************************************
3685 **
3686 ** Functions for mapping Ensembl Prediction Transcript objects between
3687 ** Ensembl Coordinate System objects.
3688 **
3689 ** @fdata [EnsPPredictiontranscript]
3690 **
3691 ** @nam3rule Transfer Transfer an Ensembl Prediction Transcript
3692 ** @nam3rule Transform Transform an Ensembl Prediction Transcript
3693 **
3694 ** @argrule * pt [EnsPPredictiontranscript] Ensembl Prediction Transcript
3695 ** @argrule Transfer slice [EnsPSlice] Ensembl Slice
3696 ** @argrule Transform csname [const AjPStr] Ensembl Coordinate System name
3697 ** @argrule Transform csversion [const AjPStr] Ensembl Coordinate System
3698 ** version
3699 **
3700 ** @valrule * [EnsPPredictiontranscript] Ensembl Prediction Transcript or NULL
3701 **
3702 ** @fcategory misc
3703 ******************************************************************************/
3704
3705
3706
3707
3708 /* @func ensPredictiontranscriptTransfer **************************************
3709 **
3710 ** Transfer an Ensembl Prediction Transcript onto another Ensembl Slice.
3711 **
3712 ** @cc Bio::EnsEMBL::PredictionTranscript::transfer
3713 ** @param [u] pt [EnsPPredictiontranscript] Ensembl Prediction Transcript
3714 ** @param [u] slice [EnsPSlice] Ensembl Slice
3715 ** @see ensFeatureTransfer
3716 **
3717 ** @return [EnsPPredictiontranscript] Ensembl Prediction Transcript or NULL
3718 **
3719 ** @release 6.4.0
3720 ** @@
3721 ******************************************************************************/
3722
ensPredictiontranscriptTransfer(EnsPPredictiontranscript pt,EnsPSlice slice)3723 EnsPPredictiontranscript ensPredictiontranscriptTransfer(
3724 EnsPPredictiontranscript pt,
3725 EnsPSlice slice)
3726 {
3727 EnsPFeature newptf = NULL;
3728
3729 EnsPPredictiontranscript newpt = NULL;
3730
3731 if (ajDebugTest("ensPredictiontranscriptTransfer"))
3732 ajDebug("ensPredictiontranscriptTransfer\n"
3733 " pt %p\n"
3734 " slice %p\n",
3735 pt,
3736 slice);
3737
3738 if (!pt)
3739 return NULL;
3740
3741 if (!slice)
3742 return NULL;
3743
3744 if (!pt->Feature)
3745 ajFatal("ensPredictiontranscriptTransfer cannot transfer an "
3746 "Ensembl Prediction Transcript "
3747 "without an Ensembl Feature.\n");
3748
3749 newptf = ensFeatureTransfer(pt->Feature, slice);
3750
3751 if (!newptf)
3752 return NULL;
3753
3754 newpt = predictiontranscriptNewCpyFeatures(pt);
3755
3756 ensPredictiontranscriptSetFeature(newpt, newptf);
3757
3758 ensFeatureDel(&newptf);
3759
3760 return newpt;
3761 }
3762
3763
3764
3765
3766 /* @func ensPredictiontranscriptTransform *************************************
3767 **
3768 ** Transform an Ensembl Prediction Transcript into another
3769 ** Ensembl Coordinate System.
3770 **
3771 ** @cc Bio::EnsEMBL::PredictionTranscript::transform
3772 ** @param [u] pt [EnsPPredictiontranscript] Ensembl Prediction Transcript
3773 ** @param [r] csname [const AjPStr] Ensembl Coordinate System name
3774 ** @param [rN] csversion [const AjPStr] Ensembl Coordinate System version
3775 ** @see ensFeatureTransform
3776 **
3777 ** @return [EnsPPredictiontranscript] Ensembl Prediction Transcript or NULL
3778 **
3779 ** @release 6.4.0
3780 ** @@
3781 ******************************************************************************/
3782
ensPredictiontranscriptTransform(EnsPPredictiontranscript pt,const AjPStr csname,const AjPStr csversion)3783 EnsPPredictiontranscript ensPredictiontranscriptTransform(
3784 EnsPPredictiontranscript pt,
3785 const AjPStr csname,
3786 const AjPStr csversion)
3787 {
3788 EnsPFeature newptf = NULL;
3789
3790 EnsPPredictiontranscript newpt = NULL;
3791
3792 if (ajDebugTest("ensPredictiontranscriptTransform"))
3793 ajDebug("ensPredictiontranscriptTransform\n"
3794 " pt %p\n"
3795 " csname '%S'\n"
3796 " csversion '%S'\n",
3797 pt,
3798 csname,
3799 csversion);
3800
3801 if (!pt)
3802 return NULL;
3803
3804 if (!csname)
3805 return NULL;
3806
3807 if (!pt->Feature)
3808 ajFatal("ensPredictiontranscriptTransfer cannot transfer an "
3809 "Ensembl Prediction Transcript "
3810 "without an Ensembl Feature.\n");
3811
3812 newptf = ensFeatureTransform(pt->Feature,
3813 csname,
3814 csversion,
3815 (EnsPSlice) NULL);
3816
3817 if (!newptf)
3818 return NULL;
3819
3820 newpt = predictiontranscriptNewCpyFeatures(pt);
3821
3822 ensPredictiontranscriptSetFeature(newpt, newptf);
3823
3824 ensFeatureDel(&newptf);
3825
3826 return newpt;
3827 }
3828
3829
3830
3831
3832 /* @datasection [AjPList] AJAX List *******************************************
3833 **
3834 ** @nam2rule List Functions for manipulating AJAX List objects
3835 **
3836 ******************************************************************************/
3837
3838
3839
3840
3841 /* @funcstatic listPredictiontranscriptCompareEndAscending ********************
3842 **
3843 ** AJAX List of Ensembl Prediction Transcript objects comparison function to
3844 ** sort by Ensembl Feature end member in ascending order.
3845 **
3846 ** @param [r] item1 [const void*] Ensembl Prediction Transcript address 1
3847 ** @param [r] item2 [const void*] Ensembl Prediction Transcript address 2
3848 ** @see ajListSort
3849 **
3850 ** @return [int] The comparison function returns an integer less than,
3851 ** equal to, or greater than zero if the first argument is
3852 ** considered to be respectively less than, equal to, or
3853 ** greater than the second.
3854 **
3855 ** @release 6.4.0
3856 ** @@
3857 ******************************************************************************/
3858
listPredictiontranscriptCompareEndAscending(const void * item1,const void * item2)3859 static int listPredictiontranscriptCompareEndAscending(
3860 const void *item1,
3861 const void *item2)
3862 {
3863 EnsPPredictiontranscript pt1 = *(EnsOPredictiontranscript *const *) item1;
3864 EnsPPredictiontranscript pt2 = *(EnsOPredictiontranscript *const *) item2;
3865
3866 #if defined(AJ_DEBUG) && AJ_DEBUG >= 2
3867 if (ajDebugTest("listPredictiontranscriptCompareEndAscending"))
3868 ajDebug("listPredictiontranscriptCompareEndAscending\n"
3869 " pt1 %p\n"
3870 " pt2 %p\n",
3871 pt1,
3872 pt2);
3873 #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 2 */
3874
3875 /* Sort empty values towards the end of the AJAX List. */
3876
3877 if (pt1 && (!pt2))
3878 return -1;
3879
3880 if ((!pt1) && (!pt2))
3881 return 0;
3882
3883 if ((!pt1) && pt2)
3884 return +1;
3885
3886 return ensFeatureCompareEndAscending(pt1->Feature, pt2->Feature);
3887 }
3888
3889
3890
3891
3892 /* @funcstatic listPredictiontranscriptCompareEndDescending *******************
3893 **
3894 ** AJAX List of Ensembl Prediction Transcript objects comparison function to
3895 ** sort by Ensembl Feature end member in descending order.
3896 **
3897 ** @param [r] item1 [const void*] Ensembl Prediction Transcript address 1
3898 ** @param [r] item2 [const void*] Ensembl Prediction Transcript address 2
3899 ** @see ajListSort
3900 **
3901 ** @return [int] The comparison function returns an integer less than,
3902 ** equal to, or greater than zero if the first argument is
3903 ** considered to be respectively less than, equal to, or
3904 ** greater than the second.
3905 **
3906 ** @release 6.4.0
3907 ** @@
3908 ******************************************************************************/
3909
listPredictiontranscriptCompareEndDescending(const void * item1,const void * item2)3910 static int listPredictiontranscriptCompareEndDescending(
3911 const void *item1,
3912 const void *item2)
3913 {
3914 EnsPPredictiontranscript pt1 = *(EnsOPredictiontranscript *const *) item1;
3915 EnsPPredictiontranscript pt2 = *(EnsOPredictiontranscript *const *) item2;
3916
3917 #if defined(AJ_DEBUG) && AJ_DEBUG >= 2
3918 if (ajDebugTest("listPredictiontranscriptCompareEndDescending"))
3919 ajDebug("listPredictiontranscriptCompareEndDescending\n"
3920 " pt1 %p\n"
3921 " pt2 %p\n",
3922 pt1,
3923 pt2);
3924 #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 2 */
3925
3926 /* Sort empty values towards the end of the AJAX List. */
3927
3928 if (pt1 && (!pt2))
3929 return -1;
3930
3931 if ((!pt1) && (!pt2))
3932 return 0;
3933
3934 if ((!pt1) && pt2)
3935 return +1;
3936
3937 return ensFeatureCompareEndDescending(pt1->Feature, pt2->Feature);
3938 }
3939
3940
3941
3942
3943 /* @funcstatic listPredictiontranscriptCompareIdentifierAscending *************
3944 **
3945 ** AJAX List of Ensembl Prediction Transcript objects comparison function to
3946 ** sort by identifier member in ascending order.
3947 **
3948 ** @param [r] item1 [const void*] Ensembl Prediction Transcript address 1
3949 ** @param [r] item2 [const void*] Ensembl Prediction Transcript address 2
3950 ** @see ajListSort
3951 **
3952 ** @return [int] The comparison function returns an integer less than,
3953 ** equal to, or greater than zero if the first argument is
3954 ** considered to be respectively less than, equal to, or
3955 ** greater than the second.
3956 **
3957 ** @release 6.4.0
3958 ** @@
3959 ******************************************************************************/
3960
listPredictiontranscriptCompareIdentifierAscending(const void * item1,const void * item2)3961 static int listPredictiontranscriptCompareIdentifierAscending(
3962 const void *item1,
3963 const void *item2)
3964 {
3965 EnsPPredictiontranscript pt1 = *(EnsOPredictiontranscript *const *) item1;
3966 EnsPPredictiontranscript pt2 = *(EnsOPredictiontranscript *const *) item2;
3967
3968 #if defined(AJ_DEBUG) && AJ_DEBUG >= 2
3969 if (ajDebugTest("listPredictiontranscriptCompareIdentifierAscending"))
3970 ajDebug("listPredictiontranscriptCompareIdentifierAscending\n"
3971 " pt1 %p\n"
3972 " pt2 %p\n",
3973 pt1,
3974 pt2);
3975 #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 2 */
3976
3977 /* Sort empty values towards the end of the AJAX List. */
3978
3979 if (pt1 && (!pt2))
3980 return -1;
3981
3982 if ((!pt1) && (!pt2))
3983 return 0;
3984
3985 if ((!pt1) && pt2)
3986 return +1;
3987
3988 if (pt1->Identifier < pt2->Identifier)
3989 return -1;
3990
3991 if (pt1->Identifier > pt2->Identifier)
3992 return +1;
3993
3994 return 0;
3995 }
3996
3997
3998
3999
4000 /* @funcstatic listPredictiontranscriptCompareStartAscending ******************
4001 **
4002 ** AJAX List of Ensembl Prediction Transcript objects comparison function to
4003 ** sort by Ensembl Feature start member in ascending order.
4004 **
4005 ** @param [r] item1 [const void*] Ensembl Prediction Transcript address 1
4006 ** @param [r] item2 [const void*] Ensembl Prediction Transcript address 2
4007 ** @see ajListSort
4008 **
4009 ** @return [int] The comparison function returns an integer less than,
4010 ** equal to, or greater than zero if the first argument is
4011 ** considered to be respectively less than, equal to, or
4012 ** greater than the second.
4013 **
4014 ** @release 6.4.0
4015 ** @@
4016 ******************************************************************************/
4017
listPredictiontranscriptCompareStartAscending(const void * item1,const void * item2)4018 static int listPredictiontranscriptCompareStartAscending(
4019 const void *item1,
4020 const void *item2)
4021 {
4022 EnsPPredictiontranscript pt1 = *(EnsOPredictiontranscript *const *) item1;
4023 EnsPPredictiontranscript pt2 = *(EnsOPredictiontranscript *const *) item2;
4024
4025 #if defined(AJ_DEBUG) && AJ_DEBUG >= 2
4026 if (ajDebugTest("listPredictiontranscriptCompareStartAscending"))
4027 ajDebug("listPredictiontranscriptCompareStartAscending\n"
4028 " pt1 %p\n"
4029 " pt2 %p\n",
4030 pt1,
4031 pt2);
4032 #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 2 */
4033
4034 /* Sort empty values towards the end of the AJAX List. */
4035
4036 if (pt1 && (!pt2))
4037 return -1;
4038
4039 if ((!pt1) && (!pt2))
4040 return 0;
4041
4042 if ((!pt1) && pt2)
4043 return +1;
4044
4045 return ensFeatureCompareStartAscending(pt1->Feature, pt2->Feature);
4046 }
4047
4048
4049
4050
4051 /* @funcstatic listPredictiontranscriptCompareStartDescending *****************
4052 **
4053 ** AJAX List of Ensembl Prediction Transcript objects comparison function to
4054 ** sort by Ensembl Feature start member in descending order.
4055 **
4056 ** @param [r] item1 [const void*] Ensembl Prediction Transcript address 1
4057 ** @param [r] item2 [const void*] Ensembl Prediction Transcript address 2
4058 ** @see ajListSort
4059 **
4060 ** @return [int] The comparison function returns an integer less than,
4061 ** equal to, or greater than zero if the first argument is
4062 ** considered to be respectively less than, equal to, or
4063 ** greater than the second.
4064 **
4065 ** @release 6.4.0
4066 ** @@
4067 ******************************************************************************/
4068
listPredictiontranscriptCompareStartDescending(const void * item1,const void * item2)4069 static int listPredictiontranscriptCompareStartDescending(
4070 const void *item1,
4071 const void *item2)
4072 {
4073 EnsPPredictiontranscript pt1 = *(EnsOPredictiontranscript *const *) item1;
4074 EnsPPredictiontranscript pt2 = *(EnsOPredictiontranscript *const *) item2;
4075
4076 #if defined(AJ_DEBUG) && AJ_DEBUG >= 2
4077 if (ajDebugTest("listPredictiontranscriptCompareStartDescending"))
4078 ajDebug("listPredictiontranscriptCompareStartDescending\n"
4079 " pt1 %p\n"
4080 " pt2 %p\n",
4081 pt1,
4082 pt2);
4083 #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 2 */
4084
4085 /* Sort empty values towards the end of the AJAX List. */
4086
4087 if (pt1 && (!pt2))
4088 return -1;
4089
4090 if ((!pt1) && (!pt2))
4091 return 0;
4092
4093 if ((!pt1) && pt2)
4094 return +1;
4095
4096 return ensFeatureCompareStartDescending(pt1->Feature, pt2->Feature);
4097 }
4098
4099
4100
4101
4102 /* @section list **************************************************************
4103 **
4104 ** Functions for manipulating AJAX List objects.
4105 **
4106 ** @fdata [AjPList]
4107 **
4108 ** @nam3rule Predictiontranscript Functions for manipulating AJAX List objects
4109 ** of Ensembl Prediction Transcript objects
4110 ** @nam4rule Sort Sort functions
4111 ** @nam5rule End Sort by Ensembl feature end member
4112 ** @nam5rule Identifier Sort by identifier member
4113 ** @nam5rule Start Sort by Ensembl Feature start member
4114 ** @nam6rule Ascending Sort in ascending order
4115 ** @nam6rule Descending Sort in descending order
4116 **
4117 ** @argrule * pts [AjPList]
4118 ** AJAX List of Ensembl Prediction Transcript objects
4119 **
4120 ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise
4121 **
4122 ** @fcategory misc
4123 ******************************************************************************/
4124
4125
4126
4127
4128 /* @func ensListPredictiontranscriptSortEndAscending **************************
4129 **
4130 ** Sort Ensembl Prediction Transcript objects by their
4131 ** Ensembl Feature end coordinate in ascending order.
4132 **
4133 ** @param [u] pts [AjPList] AJAX List of Ensembl Prediction Transcript objects
4134 **
4135 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
4136 **
4137 ** @release 6.4.0
4138 ** @@
4139 ******************************************************************************/
4140
ensListPredictiontranscriptSortEndAscending(AjPList pts)4141 AjBool ensListPredictiontranscriptSortEndAscending(AjPList pts)
4142 {
4143 if (!pts)
4144 return ajFalse;
4145
4146 ajListSortTwoThree(pts,
4147 &listPredictiontranscriptCompareEndAscending,
4148 &listPredictiontranscriptCompareStartAscending,
4149 &listPredictiontranscriptCompareIdentifierAscending);
4150
4151 return ajTrue;
4152 }
4153
4154
4155
4156
4157 /* @func ensListPredictiontranscriptSortEndDescending *************************
4158 **
4159 ** Sort Ensembl Prediction Transcript objects by their
4160 ** Ensembl Feature end coordinate in descending order.
4161 **
4162 ** @param [u] pts [AjPList] AJAX List of Ensembl Prediction Transcript objects
4163 **
4164 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
4165 **
4166 ** @release 6.4.0
4167 ** @@
4168 ******************************************************************************/
4169
ensListPredictiontranscriptSortEndDescending(AjPList pts)4170 AjBool ensListPredictiontranscriptSortEndDescending(AjPList pts)
4171 {
4172 if (!pts)
4173 return ajFalse;
4174
4175 ajListSortTwoThree(pts,
4176 &listPredictiontranscriptCompareEndDescending,
4177 &listPredictiontranscriptCompareStartDescending,
4178 &listPredictiontranscriptCompareIdentifierAscending);
4179
4180 return ajTrue;
4181 }
4182
4183
4184
4185
4186 /* @func ensListPredictiontranscriptSortIdentifierAscending *******************
4187 **
4188 ** Sort Ensembl Prediction Transcript objects by their
4189 ** identifier member in ascending order.
4190 **
4191 ** @param [u] pts [AjPList] AJAX List of Ensembl Prediction Transcript objects
4192 **
4193 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
4194 **
4195 ** @release 6.4.0
4196 ** @@
4197 ******************************************************************************/
4198
ensListPredictiontranscriptSortIdentifierAscending(AjPList pts)4199 AjBool ensListPredictiontranscriptSortIdentifierAscending(AjPList pts)
4200 {
4201 if (!pts)
4202 return ajFalse;
4203
4204 ajListSort(pts, &listPredictiontranscriptCompareIdentifierAscending);
4205
4206 return ajTrue;
4207 }
4208
4209
4210
4211
4212 /* @func ensListPredictiontranscriptSortStartAscending ************************
4213 **
4214 ** Sort Ensembl Prediction Transcript objects by their
4215 ** Ensembl Feature start coordinate in ascending order.
4216 **
4217 ** @param [u] pts [AjPList] AJAX List of Ensembl Prediction Transcript objects
4218 **
4219 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
4220 **
4221 ** @release 6.4.0
4222 ** @@
4223 ******************************************************************************/
4224
ensListPredictiontranscriptSortStartAscending(AjPList pts)4225 AjBool ensListPredictiontranscriptSortStartAscending(AjPList pts)
4226 {
4227 if (!pts)
4228 return ajFalse;
4229
4230 ajListSortTwoThree(pts,
4231 &listPredictiontranscriptCompareStartAscending,
4232 &listPredictiontranscriptCompareEndAscending,
4233 &listPredictiontranscriptCompareIdentifierAscending);
4234
4235 return ajTrue;
4236 }
4237
4238
4239
4240
4241 /* @func ensListPredictiontranscriptSortStartDescending ***********************
4242 **
4243 ** Sort Ensembl Prediction Transcript objects by their
4244 ** Ensembl Feature start coordinate in descending order.
4245 **
4246 ** @param [u] pts [AjPList] AJAX List of Ensembl Prediction Transcript objects
4247 **
4248 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
4249 **
4250 ** @release 6.4.0
4251 ** @@
4252 ******************************************************************************/
4253
ensListPredictiontranscriptSortStartDescending(AjPList pts)4254 AjBool ensListPredictiontranscriptSortStartDescending(AjPList pts)
4255 {
4256 if (!pts)
4257 return ajFalse;
4258
4259 ajListSortTwoThree(pts,
4260 &listPredictiontranscriptCompareStartDescending,
4261 &listPredictiontranscriptCompareEndDescending,
4262 &listPredictiontranscriptCompareIdentifierAscending);
4263
4264 return ajTrue;
4265 }
4266
4267
4268
4269
4270 /* @datasection [EnsPPredictiontranscriptadaptor] Ensembl Prediction Transcript
4271 ** Adaptor
4272 **
4273 ** @nam2rule Predictiontranscriptadaptor Functions for manipulating
4274 ** Ensembl Prediction Transcript Adaptor objects
4275 **
4276 ** @cc Bio::EnsEMBL::DBSQL::PredictionTranscriptAdaptor
4277 ** @cc CVS Revision: 1.53
4278 ** @cc CVS Tag: branch-ensembl-68
4279 **
4280 ******************************************************************************/
4281
4282
4283
4284
4285 /* @funcstatic predictiontranscriptadaptorFetchAllbyStatement *****************
4286 **
4287 ** Fetch all Ensembl Prediction Transcript objects via an SQL statement.
4288 **
4289 ** @param [u] ba [EnsPBaseadaptor] Ensembl Base Adaptor
4290 ** @param [r] statement [const AjPStr] SQL statement
4291 ** @param [uN] am [EnsPAssemblymapper] Ensembl Assembly Mapper
4292 ** @param [uN] slice [EnsPSlice] Ensembl Slice
4293 ** @param [u] pts [AjPList] AJAX List of Ensembl Prediction Transcript objects
4294 **
4295 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
4296 **
4297 ** @release 6.4.0
4298 ** @@
4299 ******************************************************************************/
4300
predictiontranscriptadaptorFetchAllbyStatement(EnsPBaseadaptor ba,const AjPStr statement,EnsPAssemblymapper am,EnsPSlice slice,AjPList pts)4301 static AjBool predictiontranscriptadaptorFetchAllbyStatement(
4302 EnsPBaseadaptor ba,
4303 const AjPStr statement,
4304 EnsPAssemblymapper am,
4305 EnsPSlice slice,
4306 AjPList pts)
4307 {
4308 ajuint identifier = 0U;
4309 ajuint analysisid = 0U;
4310
4311 ajuint srid = 0U;
4312 ajuint srstart = 0U;
4313 ajuint srend = 0U;
4314 ajint srstrand = 0;
4315
4316 AjPSqlstatement sqls = NULL;
4317 AjISqlrow sqli = NULL;
4318 AjPSqlrow sqlr = NULL;
4319
4320 AjPStr label = NULL;
4321
4322 EnsPDatabaseadaptor dba = NULL;
4323
4324 EnsPFeature feature = NULL;
4325
4326 EnsPPredictiontranscript pt = NULL;
4327 EnsPPredictiontranscriptadaptor pta = NULL;
4328
4329 if (ajDebugTest("predictiontranscriptadaptorFetchAllbyStatement"))
4330 ajDebug("predictiontranscriptadaptorFetchAllbyStatement\n"
4331 " ba %p\n"
4332 " statement %p\n"
4333 " am %p\n"
4334 " slice %p\n"
4335 " pts %p\n",
4336 ba,
4337 statement,
4338 am,
4339 slice,
4340 pts);
4341
4342 if (!ba)
4343 return ajFalse;
4344
4345 if (!statement)
4346 return ajFalse;
4347
4348 if (!pts)
4349 return ajFalse;
4350
4351 dba = ensBaseadaptorGetDatabaseadaptor(ba);
4352
4353 pta = ensRegistryGetPredictiontranscriptadaptor(dba);
4354
4355 sqls = ensDatabaseadaptorSqlstatementNew(dba, statement);
4356
4357 sqli = ajSqlrowiterNew(sqls);
4358
4359 while (!ajSqlrowiterDone(sqli))
4360 {
4361 identifier = 0;
4362 srid = 0;
4363 srstart = 0;
4364 srend = 0;
4365 srstrand = 0;
4366 analysisid = 0;
4367 label = ajStrNew();
4368
4369 sqlr = ajSqlrowiterGet(sqli);
4370
4371 ajSqlcolumnToUint(sqlr, &identifier);
4372 ajSqlcolumnToUint(sqlr, &srid);
4373 ajSqlcolumnToUint(sqlr, &srstart);
4374 ajSqlcolumnToUint(sqlr, &srend);
4375 ajSqlcolumnToInt(sqlr, &srstrand);
4376 ajSqlcolumnToUint(sqlr, &analysisid);
4377 ajSqlcolumnToStr(sqlr, &label);
4378
4379 ensBaseadaptorRetrieveFeature(ba,
4380 analysisid,
4381 srid,
4382 srstart,
4383 srend,
4384 srstrand,
4385 am,
4386 slice,
4387 &feature);
4388
4389 if (!feature)
4390 {
4391 ajStrDel(&label);
4392
4393 continue;
4394 }
4395
4396 /* Finally, create a new Ensembl Prediction Transcript. */
4397
4398 pt = ensPredictiontranscriptNewIni(pta,
4399 identifier,
4400 feature,
4401 label);
4402
4403 ajListPushAppend(pts, (void *) pt);
4404
4405 ensFeatureDel(&feature);
4406
4407 ajStrDel(&label);
4408 }
4409
4410 ajSqlrowiterDel(&sqli);
4411
4412 ensDatabaseadaptorSqlstatementDel(dba, &sqls);
4413
4414 return ajTrue;
4415 }
4416
4417
4418
4419
4420 /* @section constructors ******************************************************
4421 **
4422 ** All constructors return a new Ensembl Prediction Transcript Adaptor by
4423 ** pointer.
4424 ** It is the responsibility of the user to first destroy any previous
4425 ** Prediction Transcript Adaptor. The target pointer does not need to be
4426 ** initialised to NULL, but it is good programming practice to do so anyway.
4427 **
4428 ** @fdata [EnsPPredictiontranscriptadaptor]
4429 **
4430 ** @nam3rule New Constructor
4431 **
4432 ** @argrule New dba [EnsPDatabaseadaptor] Ensembl Database Adaptor
4433 **
4434 ** @valrule * [EnsPPredictiontranscriptadaptor]
4435 ** Ensembl Prediction Transcript Adaptor or NULL
4436 **
4437 ** @fcategory new
4438 ******************************************************************************/
4439
4440
4441
4442
4443 /* @func ensPredictiontranscriptadaptorNew ************************************
4444 **
4445 ** Default constructor for an Ensembl Prediction Transcript Adaptor.
4446 **
4447 ** Ensembl Object Adaptors are singleton objects in the sense that a single
4448 ** instance of an Ensembl Object Adaptor connected to a particular database is
4449 ** sufficient to instantiate any number of Ensembl Objects from the database.
4450 ** Each Ensembl Object will have a weak reference to the Object Adaptor that
4451 ** instantiated it. Therefore, Ensembl Object Adaptors should not be
4452 ** instantiated directly, but rather obtained from the Ensembl Registry,
4453 ** which will in turn call this function if neccessary.
4454 **
4455 ** @see ensRegistryGetDatabaseadaptor
4456 ** @see ensRegistryGetPredictiontranscriptadaptor
4457 **
4458 ** @param [u] dba [EnsPDatabaseadaptor] Ensembl Database Adaptor
4459 **
4460 ** @return [EnsPPredictiontranscriptadaptor]
4461 ** Ensembl Prediction Transcript Adaptor or NULL
4462 **
4463 ** @release 6.2.0
4464 ** @@
4465 ******************************************************************************/
4466
ensPredictiontranscriptadaptorNew(EnsPDatabaseadaptor dba)4467 EnsPPredictiontranscriptadaptor ensPredictiontranscriptadaptorNew(
4468 EnsPDatabaseadaptor dba)
4469 {
4470 return ensFeatureadaptorNew(
4471 dba,
4472 predictiontranscriptadaptorKTablenames,
4473 predictiontranscriptadaptorKColumnnames,
4474 (const EnsPBaseadaptorLeftjoin) NULL,
4475 (const char *) NULL,
4476 (const char *) NULL,
4477 &predictiontranscriptadaptorFetchAllbyStatement,
4478 (void *(*)(const void *)) NULL,
4479 (void *(*)(void *)) &ensPredictiontranscriptNewRef,
4480 (AjBool (*)(const void *)) NULL,
4481 (void (*)(void **)) &ensPredictiontranscriptDel,
4482 (size_t (*)(const void *)) &ensPredictiontranscriptCalculateMemsize,
4483 (EnsPFeature (*)(const void *)) &ensPredictiontranscriptGetFeature,
4484 "Predictiontranscript");
4485 }
4486
4487
4488
4489
4490 /* @section destructors *******************************************************
4491 **
4492 ** Destruction destroys all internal data structures and frees the memory
4493 ** allocated for an Ensembl Prediction Transcript Adaptor object.
4494 **
4495 ** @fdata [EnsPPredictiontranscriptadaptor]
4496 **
4497 ** @nam3rule Del Destroy (free) an
4498 ** Ensembl Prediction Transcript Adaptor
4499 **
4500 ** @argrule * Ppta [EnsPPredictiontranscriptadaptor*]
4501 ** Ensembl Prediction Transcript Adaptor address
4502 **
4503 ** @valrule * [void]
4504 **
4505 ** @fcategory delete
4506 ******************************************************************************/
4507
4508
4509
4510
4511 /* @func ensPredictiontranscriptadaptorDel ************************************
4512 **
4513 ** Default destructor for an Ensembl Prediction Transcript Adaptor.
4514 **
4515 ** Ensembl Object Adaptors are singleton objects that are registered in the
4516 ** Ensembl Registry and weakly referenced by Ensembl Objects that have been
4517 ** instantiated by it. Therefore, Ensembl Object Adaptors should never be
4518 ** destroyed directly. Upon exit, the Ensembl Registry will call this function
4519 ** if required.
4520 **
4521 ** @param [d] Ppta [EnsPPredictiontranscriptadaptor*]
4522 ** Ensembl Prediction Transcript Adaptor address
4523 **
4524 ** @return [void]
4525 **
4526 ** @release 6.2.0
4527 ** @@
4528 ******************************************************************************/
4529
ensPredictiontranscriptadaptorDel(EnsPPredictiontranscriptadaptor * Ppta)4530 void ensPredictiontranscriptadaptorDel(
4531 EnsPPredictiontranscriptadaptor *Ppta)
4532 {
4533 ensFeatureadaptorDel(Ppta);
4534
4535 return;
4536 }
4537
4538
4539
4540
4541 /* @section member retrieval **************************************************
4542 **
4543 ** Functions for returning members of an
4544 ** Ensembl Prediction Transcript Adaptor object.
4545 **
4546 ** @fdata [EnsPPredictiontranscriptadaptor]
4547 **
4548 ** @nam3rule Get Return Ensembl Prediction Transcript Adaptor attribute(s)
4549 ** @nam4rule Baseadaptor Return the Ensembl Base Adaptor
4550 ** @nam4rule Databaseadaptor Return the Ensembl Database Adaptor
4551 ** @nam4rule Featureadaptor Return the Ensembl Feature Adaptor
4552 **
4553 ** @argrule * pta [EnsPPredictiontranscriptadaptor]
4554 ** Ensembl Prediction Transcript Adaptor
4555 **
4556 ** @valrule Baseadaptor [EnsPBaseadaptor]
4557 ** Ensembl Base Adaptor or NULL
4558 ** @valrule Databaseadaptor [EnsPDatabaseadaptor]
4559 ** Ensembl Database Adaptor or NULL
4560 ** @valrule Featureadaptor [EnsPFeatureadaptor]
4561 ** Ensembl Feature Adaptor or NULL
4562 **
4563 ** @fcategory use
4564 ******************************************************************************/
4565
4566
4567
4568
4569 /* @func ensPredictiontranscriptadaptorGetBaseadaptor *************************
4570 **
4571 ** Get the Ensembl Base Adaptor member of an
4572 ** Ensembl Prediction Transcript Adaptor.
4573 **
4574 ** @param [u] pta [EnsPPredictiontranscriptadaptor]
4575 ** Ensembl Prediction Transcript Adaptor
4576 **
4577 ** @return [EnsPBaseadaptor] Ensembl Base Adaptor or NULL
4578 **
4579 ** @release 6.4.0
4580 ** @@
4581 ******************************************************************************/
4582
ensPredictiontranscriptadaptorGetBaseadaptor(EnsPPredictiontranscriptadaptor pta)4583 EnsPBaseadaptor ensPredictiontranscriptadaptorGetBaseadaptor(
4584 EnsPPredictiontranscriptadaptor pta)
4585 {
4586 return ensFeatureadaptorGetBaseadaptor(
4587 ensPredictiontranscriptadaptorGetFeatureadaptor(pta));
4588 }
4589
4590
4591
4592
4593 /* @func ensPredictiontranscriptadaptorGetDatabaseadaptor *********************
4594 **
4595 ** Get the Ensembl Database Adaptor member of an
4596 ** Ensembl Prediction Transcript Adaptor.
4597 **
4598 ** @param [u] pta [EnsPPredictiontranscriptadaptor]
4599 ** Ensembl Prediction Transcript Adaptor
4600 **
4601 ** @return [EnsPDatabaseadaptor] Ensembl Database Adaptor or NULL
4602 **
4603 ** @release 6.4.0
4604 ** @@
4605 ******************************************************************************/
4606
ensPredictiontranscriptadaptorGetDatabaseadaptor(EnsPPredictiontranscriptadaptor pta)4607 EnsPDatabaseadaptor ensPredictiontranscriptadaptorGetDatabaseadaptor(
4608 EnsPPredictiontranscriptadaptor pta)
4609 {
4610 return ensFeatureadaptorGetDatabaseadaptor(
4611 ensPredictiontranscriptadaptorGetFeatureadaptor(pta));
4612 }
4613
4614
4615
4616
4617 /* @func ensPredictiontranscriptadaptorGetFeatureadaptor **********************
4618 **
4619 ** Get the Ensembl Feature Adaptor member of an
4620 ** Ensembl Prediction Transcript Adaptor.
4621 **
4622 ** @param [u] pta [EnsPPredictiontranscriptadaptor]
4623 ** Ensembl Prediction Transcript Adaptor
4624 **
4625 ** @return [EnsPFeatureadaptor] Ensembl Feature Adaptor or NULL
4626 **
4627 ** @release 6.4.0
4628 ** @@
4629 ******************************************************************************/
4630
ensPredictiontranscriptadaptorGetFeatureadaptor(EnsPPredictiontranscriptadaptor pta)4631 EnsPFeatureadaptor ensPredictiontranscriptadaptorGetFeatureadaptor(
4632 EnsPPredictiontranscriptadaptor pta)
4633 {
4634 return pta;
4635 }
4636
4637
4638
4639
4640 /* @section canonical object retrieval ****************************************
4641 **
4642 ** Functions for fetching Ensembl Prediction Transcript objects from an
4643 ** Ensembl SQL database.
4644 **
4645 ** @fdata [EnsPPredictiontranscriptadaptor]
4646 **
4647 ** @nam3rule Fetch Fetch Ensembl Prediction Transcript object(s)
4648 ** @nam4rule All Fetch all Ensembl Prediction Transcript objects
4649 ** @nam4rule Allby Fetch all Ensembl Prediction Transcript objects
4650 ** matching a criterion
4651 ** @nam5rule Slice Fetch all by an Ensembl Slice
4652 ** @nam5rule Stableidentifier Fetch all by a stable identifier
4653 ** @nam4rule By Fetch one Ensembl Prediction Transcript object
4654 ** matching a criterion
4655 ** @nam5rule Displaylabel Fetch by display label
4656 ** @nam5rule Identifier Fetch by SQL database-internal identifier
4657 ** @nam5rule Stableidentifier Fetch by a stable identifier
4658 **
4659 ** @argrule * pta [EnsPPredictiontranscriptadaptor]
4660 ** Ensembl Prediction Transcript Adaptor
4661 ** @argrule All pts [AjPList]
4662 ** AJAX List of Ensembl Prediction Transcript objects
4663 ** @argrule AllbySlice slice [EnsPSlice] Ensembl Slice
4664 ** @argrule AllbySlice anname [const AjPStr] Ensembl Analysis name
4665 ** @argrule AllbySlice constraint [const AjPStr] SQL constraint
4666 ** @argrule AllbySlice loadexons [AjBool] Load Ensembl Prediction Exon objects
4667 ** @argrule AllbyStableidentifier stableid [const AjPStr] Stable identifier
4668 ** @argrule Allby pts [AjPList]
4669 ** AJAX List of Ensembl Prediction Transcript objects
4670 ** @argrule ByDisplaylabel label [const AjPStr] Display label
4671 ** @argrule ByExonidentifier identifier [ajuint]
4672 ** Ensembl Prediction Exon identifier
4673 ** @argrule ByIdentifier identifier [ajuint] SQL database-internal identifier
4674 ** @argrule ByStableidentifier stableid [const AjPStr] Stable identifier
4675 ** @argrule By Ppt [EnsPPredictiontranscript*]
4676 ** Ensembl Prediction Transcript address
4677 **
4678 ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise
4679 **
4680 ** @fcategory use
4681 ******************************************************************************/
4682
4683
4684
4685
4686 /* @func ensPredictiontranscriptadaptorFetchByIdentifier **********************
4687 **
4688 ** Fetch an Ensembl Prediction Transcript via its SQL database-internal
4689 ** identifier.
4690 ** The caller is responsible for deleting the Ensembl Prediction Transcript.
4691 **
4692 ** @param [u] pta [EnsPPredictiontranscriptadaptor]
4693 ** Ensembl Prediction Transcript Adaptor
4694 ** @param [r] identifier [ajuint] SQL database-internal identifier
4695 ** @param [wP] Ppt [EnsPPredictiontranscript*]
4696 ** Ensembl Prediction Transcript address
4697 **
4698 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
4699 **
4700 ** @release 6.2.0
4701 ** @@
4702 ******************************************************************************/
4703
ensPredictiontranscriptadaptorFetchByIdentifier(EnsPPredictiontranscriptadaptor pta,ajuint identifier,EnsPPredictiontranscript * Ppt)4704 AjBool ensPredictiontranscriptadaptorFetchByIdentifier(
4705 EnsPPredictiontranscriptadaptor pta,
4706 ajuint identifier,
4707 EnsPPredictiontranscript *Ppt)
4708 {
4709 return ensBaseadaptorFetchByIdentifier(
4710 ensPredictiontranscriptadaptorGetBaseadaptor(pta),
4711 identifier,
4712 (void **) Ppt);
4713 }
4714
4715
4716
4717
4718 /* @func ensPredictiontranscriptadaptorFetchByStableidentifier ****************
4719 **
4720 ** Fetch an Ensembl Prediction Transcript via its stable identifier and
4721 ** version. This method is called FetchByStableidentifier for polymorphism with
4722 ** the Ensembl Transcript Adaptor. Prediction Transcript display
4723 ** labels are not necessarily stable in that the same identifier may be reused
4724 ** for a completely different Ensembl Prediction Transcript in a subsequent
4725 ** database release.
4726 **
4727 ** The caller is responsible for deleting the Ensembl Prediction Transcript.
4728 **
4729 ** @param [u] pta [EnsPPredictiontranscriptadaptor]
4730 ** Ensembl Prediction Transcript Adaptor
4731 ** @param [r] stableid [const AjPStr] Stable identifier
4732 ** @param [wP] Ppt [EnsPPredictiontranscript*]
4733 ** Ensembl Prediction Transcript address
4734 **
4735 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
4736 **
4737 ** @release 6.4.0
4738 ** @@
4739 ******************************************************************************/
4740
ensPredictiontranscriptadaptorFetchByStableidentifier(EnsPPredictiontranscriptadaptor pta,const AjPStr stableid,EnsPPredictiontranscript * Ppt)4741 AjBool ensPredictiontranscriptadaptorFetchByStableidentifier(
4742 EnsPPredictiontranscriptadaptor pta,
4743 const AjPStr stableid,
4744 EnsPPredictiontranscript *Ppt)
4745 {
4746 char *txtstableid = NULL;
4747
4748 AjBool result = AJFALSE;
4749
4750 AjPList pts = NULL;
4751
4752 AjPStr constraint = NULL;
4753
4754 EnsPBaseadaptor ba = NULL;
4755
4756 EnsPPredictiontranscript pt = NULL;
4757
4758 if (!pta)
4759 return ajFalse;
4760
4761 if (!stableid)
4762 return ajFalse;
4763
4764 if (!Ppt)
4765 return ajFalse;
4766
4767 ba = ensPredictiontranscriptadaptorGetBaseadaptor(pta);
4768
4769 ensBaseadaptorEscapeC(ba, &txtstableid, stableid);
4770
4771 constraint =
4772 ajFmtStr("prediction_transcript.display_label = '%s'", txtstableid);
4773
4774 ajCharDel(&txtstableid);
4775
4776 pts = ajListNew();
4777
4778 result = ensBaseadaptorFetchAllbyConstraint(
4779 ba,
4780 constraint,
4781 (EnsPAssemblymapper) NULL,
4782 (EnsPSlice) NULL,
4783 pts);
4784
4785 if (ajListGetLength(pts) > 1)
4786 ajDebug("ensPredictiontranscriptadaptorFetchByStableidentifier got "
4787 "more than one Ensembl Prediction Transcript for "
4788 "stable identifier '%S'.\n",
4789 stableid);
4790
4791 ajListPop(pts, (void **) Ppt);
4792
4793 while (ajListPop(pts, (void **) &pt))
4794 ensPredictiontranscriptDel(&pt);
4795
4796 ajListFree(&pts);
4797
4798 ajStrDel(&constraint);
4799
4800 return result;
4801 }
4802