1 /* @source ensassemblyexception ***********************************************
2 **
3 ** Ensembl Assembly Exception functions
4 **
5 ** @author Copyright (C) 1999 Ensembl Developers
6 ** @author Copyright (C) 2006 Michael K. Schuster
7 ** @version $Revision: 1.52 $
8 ** @modified 2009 by Alan Bleasby for incorporation into EMBOSS core
9 ** @modified $Date: 2013/02/17 13:02:40 $ 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 "ensassemblyexception.h"
34 #include "enstable.h"
35 
36 
37 
38 
39 /* ========================================================================= */
40 /* =============================== constants =============================== */
41 /* ========================================================================= */
42 
43 
44 
45 
46 /* ========================================================================= */
47 /* =========================== global variables ============================ */
48 /* ========================================================================= */
49 
50 
51 
52 
53 /* ========================================================================= */
54 /* ============================= private data ============================== */
55 /* ========================================================================= */
56 
57 
58 
59 
60 /* ========================================================================= */
61 /* =========================== private constants =========================== */
62 /* ========================================================================= */
63 
64 /* @conststatic assemblyexceptionKType ****************************************
65 **
66 ** The Ensembl Assembly Exception type is enumerated in both, the SQL table
67 ** definition and the data structure. The following strings are used for
68 ** conversion in database operations and correspond to
69 ** EnsEAssemblyexceptionType.
70 **
71 ** HAP:         Haplotype
72 ** PAR:         Pseudo-autosomal Region
73 ** PATCH_FIX:   Genome sequence patch with updated sequence
74 ** PATCH_NOVEL: Genome sequence patch with new sequence
75 **
76 ******************************************************************************/
77 
78 static const char *assemblyexceptionKType[] =
79 {
80     "",
81     "HAP",
82     "PAR",
83     "PATCH_FIX",
84     "PATCH_NOVEL",
85     "HAP REF",
86     "PATCH_FIX REF",
87     "PATCH_NOVEL REF",
88     (const char *) NULL
89 };
90 
91 
92 
93 
94 /* ========================================================================= */
95 /* =========================== private variables =========================== */
96 /* ========================================================================= */
97 
98 
99 
100 
101 /* ========================================================================= */
102 /* =========================== private functions =========================== */
103 /* ========================================================================= */
104 
105 static int listAssemblyexceptionCompareReferenceEndAscending(
106     const void *item1,
107     const void *item2);
108 
109 static int listAssemblyexceptionCompareReferenceEndDescending(
110     const void *item1,
111     const void *item2);
112 
113 static AjBool assemblyexceptionadaptorFetchAllbyStatement(
114     EnsPAssemblyexceptionadaptor aea,
115     const AjPStr statement,
116     AjPList aes);
117 
118 static AjBool assemblyexceptionadaptorCacheInit(
119     EnsPAssemblyexceptionadaptor aea);
120 
121 static void assemblyexceptionadaptorListAssemblyexceptionValdel(void **Pvalue);
122 
123 static void assemblyexceptionadaptorFetchAll(const void *key,
124                                              void **Pvalue,
125                                              void *cl);
126 
127 
128 
129 
130 /* ========================================================================= */
131 /* ======================= All functions by section ======================== */
132 /* ========================================================================= */
133 
134 
135 
136 
137 /* @filesection ensassemblyexception ******************************************
138 **
139 ** @nam1rule ens Function belongs to the Ensembl library
140 **
141 ******************************************************************************/
142 
143 
144 
145 
146 /* @datasection [EnsPAssemblyexception] Ensembl Assembly Exception ************
147 **
148 ** @nam2rule Assemblyexception Functions for manipulating
149 ** Ensembl Assembly Exception objects
150 **
151 ** The Ensembl Assembly Exception class has no counterpart in the Perl API,
152 ** it has been split out of the Bio::EnsEMBL::DBSQL::SliceAdaptor class.
153 **
154 ** @cc Bio::EnsEMBL::Slice
155 ** @cc CVS Revision: 1.301
156 ** @cc CVS Tag: branch-ensembl-68
157 **
158 ** @cc Bio::EnsEMBL::DBSQL::SliceAdaptor
159 ** @cc CVS Revision: 1.134
160 ** @cc CVS Tag: branch-ensembl-68
161 **
162 ******************************************************************************/
163 
164 
165 
166 
167 /* @section constructors ******************************************************
168 **
169 ** All constructors return a new Ensembl Assembly Exception by pointer.
170 ** It is the responsibility of the user to first destroy any previous
171 ** Assembly Exception. The target pointer does not need to be initialised to
172 ** NULL, but it is good programming practice to do so anyway.
173 **
174 ** @fdata [EnsPAssemblyexception]
175 **
176 ** @nam3rule New Constructor
177 ** @nam4rule Cpy Constructor with existing object
178 ** @nam4rule Ini Constructor with initial values
179 ** @nam4rule NewRef Constructor by incrementing the reference counter
180 **
181 ** @argrule Cpy ae [const EnsPAssemblyexception] Ensembl Assembly Exception
182 ** @argrule Ini aea [EnsPAssemblyexceptionadaptor] Ensembl Assembly
183 ** @argrule Ini identifier [ajuint] SQL database-internal identifier
184 ** @argrule Ini srid [ajuint] Reference Ensembl Sequence Region identifier
185 ** @argrule Ini srstart [ajuint] Reference Ensembl Sequence Region start
186 ** @argrule Ini srend [ajuint] Reference Ensembl Sequence Region end
187 ** @argrule Ini erid [ajuint] Exception Ensembl Sequence Region identifier
188 ** @argrule Ini erstart [ajuint] Exception Ensembl Sequence Region start
189 ** @argrule Ini erend [ajuint] Exception Ensembl Sequence Region end
190 ** @argrule Ini ori [ajint] Orientation
191 ** @argrule Ini aet [EnsEAssemblyexceptionType]
192 ** Ensembl Assembly Exception Type enumeration
193 ** @argrule Ref ae [EnsPAssemblyexception] Ensembl Assembly Exception
194 **
195 ** @valrule * [EnsPAssemblyexception] Ensembl Assembly Exception or NULL
196 **
197 ** @fcategory new
198 ******************************************************************************/
199 
200 
201 
202 
203 /* @func ensAssemblyexceptionNewCpy *******************************************
204 **
205 ** Object-based constructor function, which returns an independent object.
206 **
207 ** @param [r] ae [const EnsPAssemblyexception] Ensembl Assembly Exception
208 **
209 ** @return [EnsPAssemblyexception] Ensembl Assembly Exception or NULL
210 **
211 ** @release 6.4.0
212 ** @@
213 ******************************************************************************/
214 
ensAssemblyexceptionNewCpy(const EnsPAssemblyexception ae)215 EnsPAssemblyexception ensAssemblyexceptionNewCpy(
216     const EnsPAssemblyexception ae)
217 {
218     EnsPAssemblyexception pthis = NULL;
219 
220     if (!ae)
221         return NULL;
222 
223     AJNEW0(pthis);
224 
225     pthis->Use = 1U;
226 
227     pthis->Identifier         = ae->Identifier;
228     pthis->Adaptor            = ae->Adaptor;
229     pthis->ReferenceSeqregion = ae->ReferenceSeqregion;
230     pthis->ReferenceStart     = ae->ReferenceStart;
231     pthis->ReferenceEnd       = ae->ReferenceEnd;
232     pthis->ExceptionSeqregion = ae->ExceptionSeqregion;
233     pthis->ExceptionStart     = ae->ExceptionStart;
234     pthis->ExceptionEnd       = ae->ExceptionEnd;
235     pthis->Orientation        = ae->Orientation;
236     pthis->Type               = ae->Type;
237 
238     return pthis;
239 }
240 
241 
242 
243 
244 /* @func ensAssemblyexceptionNewIni *******************************************
245 **
246 ** Constructor for an Ensembl Assembly Exception with initial values.
247 **
248 ** @param [u] aea [EnsPAssemblyexceptionadaptor]
249 ** Ensembl Assembly Exception Adaptor
250 ** @param [r] identifier [ajuint] SQL database-internal identifier
251 ** @param [r] srid [ajuint] Reference Ensembl Sequence Region identifier
252 ** @param [r] srstart [ajuint] Reference Ensembl Sequence Region start
253 ** @param [r] srend [ajuint] Reference Ensembl Sequence Region end
254 ** @param [r] erid [ajuint] Exception Ensembl Sequence Region identifier
255 ** @param [r] erstart [ajuint] Exception Ensembl Sequence Region start
256 ** @param [r] erend [ajuint] Exception Ensembl Sequence Region end
257 ** @param [r] ori [ajint] Orientation
258 ** @param [u] aet [EnsEAssemblyexceptionType]
259 ** Ensembl Assembly Exception Type enumeration
260 **
261 ** @return [EnsPAssemblyexception] Ensembl Assembl Exception or NULL
262 **
263 ** @release 6.4.0
264 ** @@
265 ******************************************************************************/
266 
ensAssemblyexceptionNewIni(EnsPAssemblyexceptionadaptor aea,ajuint identifier,ajuint srid,ajuint srstart,ajuint srend,ajuint erid,ajuint erstart,ajuint erend,ajint ori,EnsEAssemblyexceptionType aet)267 EnsPAssemblyexception ensAssemblyexceptionNewIni(
268     EnsPAssemblyexceptionadaptor aea,
269     ajuint identifier,
270     ajuint srid,
271     ajuint srstart,
272     ajuint srend,
273     ajuint erid,
274     ajuint erstart,
275     ajuint erend,
276     ajint ori,
277     EnsEAssemblyexceptionType aet)
278 {
279     EnsPAssemblyexception ae = NULL;
280 
281     if (!srid)
282         return NULL;
283 
284     if (!erid)
285         return NULL;
286 
287     AJNEW0(ae);
288 
289     ae->Use = 1U;
290 
291     ae->Identifier         = identifier;
292     ae->Adaptor            = aea;
293     ae->ReferenceSeqregion = srid;
294     ae->ReferenceStart     = srstart;
295     ae->ReferenceEnd       = srend;
296     ae->ExceptionSeqregion = erid;
297     ae->ExceptionStart     = erstart;
298     ae->ExceptionEnd       = erend;
299     ae->Orientation        = ori;
300     ae->Type               = aet;
301 
302     return ae;
303 }
304 
305 
306 
307 
308 /* @func ensAssemblyexceptionNewRef *******************************************
309 **
310 ** Ensembl Object referencing function, which returns a pointer to the
311 ** Ensembl Object passed in and increases its reference count.
312 **
313 ** @param [u] ae [EnsPAssemblyexception] Ensembl Assembly Exception
314 **
315 ** @return [EnsPAssemblyexception] Ensembl Assembly Exception or NULL
316 **
317 ** @release 6.2.0
318 ** @@
319 ******************************************************************************/
320 
ensAssemblyexceptionNewRef(EnsPAssemblyexception ae)321 EnsPAssemblyexception ensAssemblyexceptionNewRef(
322     EnsPAssemblyexception ae)
323 {
324     if (!ae)
325         return NULL;
326 
327     ae->Use++;
328 
329     return ae;
330 }
331 
332 
333 
334 
335 /* @section destructors *******************************************************
336 **
337 ** Destruction destroys all internal data structures and frees the memory
338 ** allocated for an Ensembl Assembly Exception object.
339 **
340 ** @fdata [EnsPAssemblyexception]
341 **
342 ** @nam3rule Del Destroy (free) an Ensembl Assembly Exception object
343 **
344 ** @argrule * Pae [EnsPAssemblyexception*]
345 ** Ensembl Assembly Exception object address
346 **
347 ** @valrule * [void]
348 **
349 ** @fcategory delete
350 ******************************************************************************/
351 
352 
353 
354 
355 /* @func ensAssemblyexceptionDel **********************************************
356 **
357 ** Default destructor for an Ensembl Assembly Exception.
358 **
359 ** @param [d] Pae [EnsPAssemblyexception*] Ensembl Assembly Exception
360 ** object address
361 **
362 ** @return [void]
363 **
364 ** @release 6.2.0
365 ** @@
366 ******************************************************************************/
367 
ensAssemblyexceptionDel(EnsPAssemblyexception * Pae)368 void ensAssemblyexceptionDel(
369     EnsPAssemblyexception *Pae)
370 {
371     EnsPAssemblyexception pthis = NULL;
372 
373     if (!Pae)
374         return;
375 
376 #if defined(AJ_DEBUG) && AJ_DEBUG >= 1
377     if (ajDebugTest("ensAssemblyexceptionDel"))
378     {
379         ajDebug("ensAssemblyexceptionDel\n"
380                 "  *Pae %p\n",
381                 *Pae);
382 
383         ensAssemblyexceptionTrace(*Pae, 1);
384     }
385 #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 1 */
386 
387     if (!(pthis = *Pae) || --pthis->Use)
388     {
389         *Pae = NULL;
390 
391         return;
392     }
393 
394     ajMemFree((void **) Pae);
395 
396     return;
397 }
398 
399 
400 
401 
402 /* @section member retrieval **************************************************
403 **
404 ** Functions for returning members of an Ensembl Assembly Exception object.
405 **
406 ** @fdata [EnsPAssemblyexception]
407 **
408 ** @nam3rule Get Return Assembly Exception attribute(s)
409 ** @nam4rule Adaptor Return the Ensembl Assembly Excepton Adaptor
410 ** @nam4rule Exception Return exception Ensembl Sequence Region attribute(s)
411 ** @nam5rule End Return the exception Ensembl Sequence Region end
412 ** @nam5rule Seqregion Return the exception Ensembl Sequence Region identifier
413 ** @nam5rule Start Return the exception Ensembl Sequence Region start
414 ** @nam4rule Identifier Return the SQL database-internal identifier
415 ** @nam4rule Reference Return reference Ensembl Sequence Region attribute(s)
416 ** @nam5rule End Return the reference Ensembl Sequence Region end
417 ** @nam5rule Seqregion Return the reference Ensembl Sequence Region identifier
418 ** @nam5rule Start Return the reference Ensembl Sequence Region start
419 ** @nam4rule Orientation Return the orientation
420 ** @nam4rule Type Return the type
421 **
422 ** @argrule * ae [const EnsPAssemblyexception] Ensembl Assembly Exception
423 **
424 ** @valrule Adaptor [EnsPAssemblyexceptionadaptor]
425 ** Ensembl Assembly Exception Adaptor or NULL
426 ** @valrule End [ajuint] Ensembl Sequence Region end or 0U
427 ** @valrule Seqregion [ajuint] Ensembl Sequence Region identifier or 0U
428 ** @valrule Start [ajuint] Ensembl Sequence Region start or 0U
429 ** @valrule Identifier [ajuint] SQL database-internal identifier or 0U
430 ** @valrule Orientation [ajint] Orientation or 0
431 ** @valrule Type [EnsEAssemblyexceptionType] Type or
432 ** ensEAssemblyexceptionTypeNULL
433 **
434 ** @fcategory use
435 ******************************************************************************/
436 
437 
438 
439 
440 /* @func ensAssemblyexceptionGetAdaptor ***************************************
441 **
442 ** Get the Ensembl Assembly Exception Adaptor member of an
443 ** Ensembl Assembly Exception.
444 **
445 ** @param [r] ae [const EnsPAssemblyexception] Ensembl Assembly Exception
446 **
447 ** @return [EnsPAssemblyexceptionadaptor]
448 ** Ensembl Assembly Exception Adaptor or NULL
449 **
450 ** @release 6.2.0
451 ** @@
452 ******************************************************************************/
453 
ensAssemblyexceptionGetAdaptor(const EnsPAssemblyexception ae)454 EnsPAssemblyexceptionadaptor ensAssemblyexceptionGetAdaptor(
455     const EnsPAssemblyexception ae)
456 {
457     return (ae) ? ae->Adaptor : NULL;
458 }
459 
460 
461 
462 
463 /* @func ensAssemblyexceptionGetExceptionEnd **********************************
464 **
465 ** Get the exception Ensembl Sequence Region end member of an
466 ** Ensembl Assembly Exception.
467 **
468 ** @param [r] ae [const EnsPAssemblyexception] Ensembl Assembly Exception
469 **
470 ** @return [ajuint] Exception Ensembl Sequence Region end or 0U
471 **
472 ** @release 6.4.0
473 ** @@
474 ******************************************************************************/
475 
ensAssemblyexceptionGetExceptionEnd(const EnsPAssemblyexception ae)476 ajuint ensAssemblyexceptionGetExceptionEnd(
477     const EnsPAssemblyexception ae)
478 {
479     return (ae) ? ae->ExceptionEnd : 0U;
480 }
481 
482 
483 
484 
485 /* @func ensAssemblyexceptionGetExceptionSeqregion ****************************
486 **
487 ** Get the exception Ensembl Sequence Region identifier member of an
488 ** Ensembl Assembly Exception.
489 **
490 ** @param [r] ae [const EnsPAssemblyexception] Ensembl Assembly Exception
491 **
492 ** @return [ajuint] Exception Ensembl Sequence Region identifier or 0U
493 **
494 ** @release 6.4.0
495 ** @@
496 ******************************************************************************/
497 
ensAssemblyexceptionGetExceptionSeqregion(const EnsPAssemblyexception ae)498 ajuint ensAssemblyexceptionGetExceptionSeqregion(
499     const EnsPAssemblyexception ae)
500 {
501     return (ae) ? ae->ExceptionSeqregion : 0U;
502 }
503 
504 
505 
506 
507 /* @func ensAssemblyexceptionGetExceptionStart ********************************
508 **
509 ** Get the exception Ensembl Sequence Region start member of an
510 ** Ensembl Assembly Exception.
511 **
512 ** @param [r] ae [const EnsPAssemblyexception] Ensembl Assembly Exception
513 **
514 ** @return [ajuint] Exception Ensembl Sequence Region start or 0U
515 **
516 ** @release 6.4.0
517 ** @@
518 ******************************************************************************/
519 
ensAssemblyexceptionGetExceptionStart(const EnsPAssemblyexception ae)520 ajuint ensAssemblyexceptionGetExceptionStart(
521     const EnsPAssemblyexception ae)
522 {
523     return (ae) ? ae->ExceptionStart : 0U;
524 }
525 
526 
527 
528 
529 /* @func ensAssemblyexceptionGetIdentifier ************************************
530 **
531 ** Get the SQL database-internal identifier member of an
532 ** Ensembl Assembly Exception.
533 **
534 ** @param [r] ae [const EnsPAssemblyexception] Ensembl Assembly Exception
535 **
536 ** @return [ajuint] SQL database-internal identifier or 0U
537 **
538 ** @release 6.2.0
539 ** @@
540 ******************************************************************************/
541 
ensAssemblyexceptionGetIdentifier(const EnsPAssemblyexception ae)542 ajuint ensAssemblyexceptionGetIdentifier(
543     const EnsPAssemblyexception ae)
544 {
545     return (ae) ? ae->Identifier : 0U;
546 }
547 
548 
549 
550 
551 /* @func ensAssemblyexceptionGetOrientation ***********************************
552 **
553 ** Get the orientation member of an Ensembl Assembly Exception.
554 **
555 ** @param [r] ae [const EnsPAssemblyexception] Ensembl Assembly Exception
556 **
557 ** @return [ajint] Orientation or 0
558 **
559 ** @release 6.2.0
560 ** @@
561 ******************************************************************************/
562 
ensAssemblyexceptionGetOrientation(const EnsPAssemblyexception ae)563 ajint ensAssemblyexceptionGetOrientation(
564     const EnsPAssemblyexception ae)
565 {
566     return (ae) ? ae->Orientation : 0;
567 }
568 
569 
570 
571 
572 /* @func ensAssemblyexceptionGetReferenceEnd **********************************
573 **
574 ** Get the reference Ensembl Sequence Region end member of an
575 ** Ensembl Assembly Exception.
576 **
577 ** @param [r] ae [const EnsPAssemblyexception] Ensembl Assembly Exception
578 **
579 ** @return [ajuint] Reference Ensembl Sequence Region end or 0U
580 **
581 ** @release 6.4.0
582 ** @@
583 ******************************************************************************/
584 
ensAssemblyexceptionGetReferenceEnd(const EnsPAssemblyexception ae)585 ajuint ensAssemblyexceptionGetReferenceEnd(
586     const EnsPAssemblyexception ae)
587 {
588     return (ae) ? ae->ReferenceEnd : 0U;
589 }
590 
591 
592 
593 
594 /* @func ensAssemblyexceptionGetReferenceSeqregion ****************************
595 **
596 ** Get the reference Ensembl Sequence Region identifier member of an
597 ** Ensembl Assembly Exception.
598 **
599 ** @param [r] ae [const EnsPAssemblyexception] Ensembl Assembly Exception
600 **
601 ** @return [ajuint] Reference Ensembl Sequence Region identifier or 0U
602 **
603 ** @release 6.4.0
604 ** @@
605 ******************************************************************************/
606 
ensAssemblyexceptionGetReferenceSeqregion(const EnsPAssemblyexception ae)607 ajuint ensAssemblyexceptionGetReferenceSeqregion(
608     const EnsPAssemblyexception ae)
609 {
610     return (ae) ? ae->ReferenceSeqregion : 0U;
611 }
612 
613 
614 
615 
616 /* @func ensAssemblyexceptionGetReferenceStart ********************************
617 **
618 ** Get the reference Ensembl Sequence Region start member of an
619 ** Ensembl Assembly Exception.
620 **
621 ** @param [r] ae [const EnsPAssemblyexception] Ensembl Assembly Exception
622 **
623 ** @return [ajuint] Reference Ensembl Sequence Region start or 0U
624 **
625 ** @release 6.4.0
626 ** @@
627 ******************************************************************************/
628 
ensAssemblyexceptionGetReferenceStart(const EnsPAssemblyexception ae)629 ajuint ensAssemblyexceptionGetReferenceStart(
630     const EnsPAssemblyexception ae)
631 {
632     return (ae) ? ae->ReferenceStart : 0U;
633 }
634 
635 
636 
637 
638 /* @func ensAssemblyexceptionGetType ******************************************
639 **
640 ** Get the type member of an Ensembl Assembly Exception.
641 **
642 ** @param [r] ae [const EnsPAssemblyexception] Ensembl Assembly Exception
643 **
644 ** @return [EnsEAssemblyexceptionType] Type or ensEAssemblyexceptionTypeNULL
645 **
646 ** @release 6.2.0
647 ** @@
648 ******************************************************************************/
649 
ensAssemblyexceptionGetType(const EnsPAssemblyexception ae)650 EnsEAssemblyexceptionType ensAssemblyexceptionGetType(
651     const EnsPAssemblyexception ae)
652 {
653     return (ae) ? ae->Type : ensEAssemblyexceptionTypeNULL;
654 }
655 
656 
657 
658 
659 /* @section member assignment *************************************************
660 **
661 ** Functions for assigning members of an Ensembl Assembly Exception object.
662 **
663 ** @fdata [EnsPAssemblyexception]
664 **
665 ** @nam3rule Set Set one member of an Assembly Exception
666 ** @nam4rule Adaptor Set the Ensembl Assembly Excepton Adaptor
667 ** @nam4rule Identifier Set the SQL database-internal identifier
668 ** @nam4rule Reference Set reference Ensembl Sequence Region attribute(s)
669 ** @nam5rule End Set the reference Ensembl Sequence Region end
670 ** @nam5rule Seqregion Set thereference Ensembl Sequence Region identifier
671 ** @nam5rule Start Set the reference Ensembl Sequence Region start
672 ** @nam4rule Exception Set exception Ensembl Sequence Region attribute(s)
673 ** @nam5rule End Set the exception Ensembl Sequence Region end
674 ** @nam5rule Seqregion Set the exception Ensembl Sequence Region identifier
675 ** @nam5rule Start Set the exception Ensembl Sequence Region start
676 ** @nam4rule Orientation Set the orientation
677 ** @nam4rule Type Set the type
678 **
679 ** @argrule * ae [EnsPAssemblyexception] Assembly Exception
680 ** @argrule Adaptor aea [EnsPAssemblyexceptionadaptor]
681 ** Ensembl Assembly Exception Adaptor
682 ** @argrule ExceptionEnd erend [ajuint] Ensembl Sequence Region end
683 ** @argrule ExceptionSeqregion erid [ajuint] Ensembl Sequence Region identifier
684 ** @argrule ExceptionStart erstart [ajuint] Ensembl Sequence Region start
685 ** @argrule Identifier identifier [ajuint] SQL database-internal identifier
686 ** @argrule Orientation orientation [ajint] Orientation
687 ** @argrule ReferenceEnd srend [ajuint] Ensembl Sequence Region end
688 ** @argrule ReferenceSeqregion srid [ajuint] Ensembl Sequence Region identifier
689 ** @argrule ReferenceStart srstart [ajuint] Ensembl Sequence Region start
690 ** @argrule Type aet [EnsEAssemblyexceptionType]
691 ** Ensembl Assembly Exception Type enumeration
692 **
693 ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise
694 **
695 ** @fcategory modify
696 ******************************************************************************/
697 
698 
699 
700 
701 /* @func ensAssemblyexceptionSetAdaptor ***************************************
702 **
703 ** Set the Ensembl Assembly Exception Adaptor member of an
704 ** Ensembl Assembly Exception.
705 **
706 ** @param [u] ae [EnsPAssemblyexception] Ensembl Assembly Exception
707 ** @param [u] aea [EnsPAssemblyexceptionadaptor]
708 ** Ensembl Assembly Exception Adaptor
709 **
710 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
711 **
712 ** @release 6.2.0
713 ** @@
714 ******************************************************************************/
715 
ensAssemblyexceptionSetAdaptor(EnsPAssemblyexception ae,EnsPAssemblyexceptionadaptor aea)716 AjBool ensAssemblyexceptionSetAdaptor(
717     EnsPAssemblyexception ae,
718     EnsPAssemblyexceptionadaptor aea)
719 {
720     if (!ae)
721         return ajFalse;
722 
723     ae->Adaptor = aea;
724 
725     return ajTrue;
726 }
727 
728 
729 
730 
731 /* @func ensAssemblyexceptionSetExceptionEnd **********************************
732 **
733 ** Set the exception Ensembl Sequence Region end member of an
734 ** Ensembl Assembly Exception.
735 **
736 ** @param [u] ae [EnsPAssemblyexception] Ensembl Assembly Exception
737 ** @param [r] erend [ajuint] Exception Ensembl Sequence Region end
738 **
739 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
740 **
741 ** @release 6.4.0
742 ** @@
743 ******************************************************************************/
744 
ensAssemblyexceptionSetExceptionEnd(EnsPAssemblyexception ae,ajuint erend)745 AjBool ensAssemblyexceptionSetExceptionEnd(
746     EnsPAssemblyexception ae,
747     ajuint erend)
748 {
749     if (!ae)
750         return ajFalse;
751 
752     ae->ExceptionEnd = erend;
753 
754     return ajTrue;
755 }
756 
757 
758 
759 
760 /* @func ensAssemblyexceptionSetExceptionSeqregion ****************************
761 **
762 ** Set the exception Ensembl Sequence Region identifier member of an
763 ** Ensembl Assembly Exception.
764 **
765 ** @param [u] ae [EnsPAssemblyexception] Ensembl Assembly Exception
766 ** @param [r] erid [ajuint] Exception Ensembl Sequence Region identifier
767 **
768 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
769 **
770 ** @release 6.4.0
771 ** @@
772 ******************************************************************************/
773 
ensAssemblyexceptionSetExceptionSeqregion(EnsPAssemblyexception ae,ajuint erid)774 AjBool ensAssemblyexceptionSetExceptionSeqregion(
775     EnsPAssemblyexception ae,
776     ajuint erid)
777 {
778     if (!ae)
779         return ajFalse;
780 
781     ae->ExceptionSeqregion = erid;
782 
783     return ajTrue;
784 }
785 
786 
787 
788 
789 /* @func ensAssemblyexceptionSetExceptionStart ********************************
790 **
791 ** Set the exception Ensembl Sequence Region start member of an
792 ** Ensembl Assembly Exception.
793 **
794 ** @param [u] ae [EnsPAssemblyexception] Ensembl Assembly Exception
795 ** @param [r] erstart [ajuint] Exception Ensembl Sequence Region start
796 **
797 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
798 **
799 ** @release 6.4.0
800 ** @@
801 ******************************************************************************/
802 
ensAssemblyexceptionSetExceptionStart(EnsPAssemblyexception ae,ajuint erstart)803 AjBool ensAssemblyexceptionSetExceptionStart(
804     EnsPAssemblyexception ae,
805     ajuint erstart)
806 {
807     if (!ae)
808         return ajFalse;
809 
810     ae->ExceptionStart = erstart;
811 
812     return ajTrue;
813 }
814 
815 
816 
817 
818 /* @func ensAssemblyexceptionSetIdentifier ************************************
819 **
820 ** Set the SQL database identifier member of an Ensembl Assembly Exception.
821 **
822 ** @param [u] ae [EnsPAssemblyexception] Ensembl Assembly Exception
823 ** @param [r] identifier [ajuint] SQL database-internal identifier
824 **
825 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
826 **
827 ** @release 6.3.0
828 ** @@
829 ******************************************************************************/
830 
ensAssemblyexceptionSetIdentifier(EnsPAssemblyexception ae,ajuint identifier)831 AjBool ensAssemblyexceptionSetIdentifier(
832     EnsPAssemblyexception ae,
833     ajuint identifier)
834 {
835     if (!ae)
836         return ajFalse;
837 
838     ae->Identifier = identifier;
839 
840     return ajTrue;
841 }
842 
843 
844 
845 
846 /* @func ensAssemblyexceptionSetOrientation ***********************************
847 **
848 ** Set the orientation member of an Ensembl Assembly Exception.
849 **
850 ** @param [u] ae [EnsPAssemblyexception] Ensembl Assembly Exception
851 ** @param [r] orientation [ajint] Orientation
852 **
853 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
854 **
855 ** @release 6.2.0
856 ** @@
857 ******************************************************************************/
858 
ensAssemblyexceptionSetOrientation(EnsPAssemblyexception ae,ajint orientation)859 AjBool ensAssemblyexceptionSetOrientation(
860     EnsPAssemblyexception ae,
861     ajint orientation)
862 {
863     if (!ae)
864         return ajFalse;
865 
866     ae->Orientation = orientation;
867 
868     return ajTrue;
869 }
870 
871 
872 
873 
874 /* @func ensAssemblyexceptionSetReferenceEnd **********************************
875 **
876 ** Set the reference Ensembl Sequence Region end member of an
877 ** Ensembl Assembly Exception.
878 **
879 ** @param [u] ae [EnsPAssemblyexception] Ensembl Assembly Exception
880 ** @param [r] srend [ajuint] Reference Ensembl Sequence Region end
881 **
882 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
883 **
884 ** @release 6.4.0
885 ** @@
886 ******************************************************************************/
887 
ensAssemblyexceptionSetReferenceEnd(EnsPAssemblyexception ae,ajuint srend)888 AjBool ensAssemblyexceptionSetReferenceEnd(
889     EnsPAssemblyexception ae,
890     ajuint srend)
891 {
892     if (!ae)
893         return ajFalse;
894 
895     ae->ReferenceEnd = srend;
896 
897     return ajTrue;
898 }
899 
900 
901 
902 
903 /* @func ensAssemblyexceptionSetReferenceSeqregion ****************************
904 **
905 ** Set the reference Ensembl Sequence Region identifier member of an
906 ** Ensembl Assembly Exception.
907 **
908 ** @param [u] ae [EnsPAssemblyexception] Ensembl Assembly Exception
909 ** @param [r] srid [ajuint] Reference Ensembl Sequence Region identifier
910 **
911 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
912 **
913 ** @release 6.4.0
914 ** @@
915 ******************************************************************************/
916 
ensAssemblyexceptionSetReferenceSeqregion(EnsPAssemblyexception ae,ajuint srid)917 AjBool ensAssemblyexceptionSetReferenceSeqregion(
918     EnsPAssemblyexception ae,
919     ajuint srid)
920 {
921     if (!ae)
922         return ajFalse;
923 
924     ae->ReferenceSeqregion = srid;
925 
926     return ajTrue;
927 }
928 
929 
930 
931 
932 /* @func ensAssemblyexceptionSetReferenceStart ********************************
933 **
934 ** Set the reference Ensembl Sequence Region start member of an
935 ** Ensembl Assembly Exception.
936 **
937 ** @param [u] ae [EnsPAssemblyexception] Ensembl Assembly Exception
938 ** @param [r] srstart [ajuint] Reference Ensembl Sequence Region start
939 **
940 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
941 **
942 ** @release 6.4.0
943 ** @@
944 ******************************************************************************/
945 
ensAssemblyexceptionSetReferenceStart(EnsPAssemblyexception ae,ajuint srstart)946 AjBool ensAssemblyexceptionSetReferenceStart(
947     EnsPAssemblyexception ae,
948     ajuint srstart)
949 {
950     if (!ae)
951         return ajFalse;
952 
953     ae->ReferenceStart = srstart;
954 
955     return ajTrue;
956 }
957 
958 
959 
960 
961 /* @func ensAssemblyexceptionSetType ******************************************
962 **
963 ** Set the type member of an Ensembl Assembly Exception.
964 **
965 ** @param [u] ae [EnsPAssemblyexception] Ensembl Assembly Exception
966 ** @param [u] aet [EnsEAssemblyexceptionType]
967 ** Ensembl Assembly Exception Type enumeration
968 **
969 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
970 **
971 ** @release 6.2.0
972 ** @@
973 ******************************************************************************/
974 
ensAssemblyexceptionSetType(EnsPAssemblyexception ae,EnsEAssemblyexceptionType aet)975 AjBool ensAssemblyexceptionSetType(
976     EnsPAssemblyexception ae,
977     EnsEAssemblyexceptionType aet)
978 {
979     if (!ae)
980         return ajFalse;
981 
982     ae->Type = aet;
983 
984     return ajTrue;
985 }
986 
987 
988 
989 
990 /* @section debugging *********************************************************
991 **
992 ** Functions for reporting of an Ensembl Assembly Exception object.
993 **
994 ** @fdata [EnsPAssemblyexception]
995 **
996 ** @nam3rule Trace Report Ensembl Assembly Exception members to debug file
997 **
998 ** @argrule Trace ae [const EnsPAssemblyexception] Ensembl Assembly Exception
999 ** @argrule Trace level [ajuint] Indentation level
1000 **
1001 ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise
1002 **
1003 ** @fcategory misc
1004 ******************************************************************************/
1005 
1006 
1007 
1008 
1009 /* @func ensAssemblyexceptionTrace ********************************************
1010 **
1011 ** Trace an Ensembl Assembly Eception.
1012 **
1013 ** @param [r] ae [const EnsPAssemblyexception] Ensembl Assembly Exception
1014 ** @param [r] level [ajuint] Indentation level
1015 **
1016 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
1017 **
1018 ** @release 6.2.0
1019 ** @@
1020 ******************************************************************************/
1021 
ensAssemblyexceptionTrace(const EnsPAssemblyexception ae,ajuint level)1022 AjBool ensAssemblyexceptionTrace(
1023     const EnsPAssemblyexception ae,
1024     ajuint level)
1025 {
1026     AjPStr indent = NULL;
1027 
1028     if (!ae)
1029         return ajFalse;
1030 
1031     indent = ajStrNew();
1032 
1033     ajStrAppendCountK(&indent, ' ', level * 2);
1034 
1035     ajDebug("%SensAssemblyexceptionTrace %p\n"
1036             "%S  Use %u\n"
1037             "%S  Identifier %u\n"
1038             "%S  Adaptor %p\n"
1039             "%S  ReferenceSeqregion %u\n"
1040             "%S  ReferenceStart %u\n"
1041             "%S  ReferenceEnd %u\n"
1042             "%S  ExceptionSeqregion %u\n"
1043             "%S  ExceptionStart %u\n"
1044             "%S  ExceptionEnd %u\n"
1045             "%S  Orientation %d\n"
1046             "%S  Type '%s'\n",
1047             indent, ae,
1048             indent, ae->Use,
1049             indent, ae->Identifier,
1050             indent, ae->Adaptor,
1051             indent, ae->ReferenceSeqregion,
1052             indent, ae->ReferenceStart,
1053             indent, ae->ReferenceEnd,
1054             indent, ae->ExceptionSeqregion,
1055             indent, ae->ExceptionStart,
1056             indent, ae->ExceptionEnd,
1057             indent, ae->Orientation,
1058             indent, ensAssemblyexceptionTypeToChar(ae->Type));
1059 
1060     ajStrDel(&indent);
1061 
1062     return ajTrue;
1063 }
1064 
1065 
1066 
1067 
1068 /* @section calculate *********************************************************
1069 **
1070 ** Functions for calculating information from an
1071 ** Ensembl Assembly Exception object.
1072 **
1073 ** @fdata [EnsPAssemblyexception]
1074 **
1075 ** @nam3rule Calculate Calculate Ensembl Assembly Exception information
1076 ** @nam4rule Exception Calculate exception information
1077 ** @nam4rule Memsize Calculate the memory size in bytes
1078 ** @nam4rule Reference Calculate attriutes for the reference
1079 ** @nam5rule Length Calculate the length
1080 **
1081 ** @argrule * ae [const EnsPAssemblyexception] Ensembl Assembly Exception
1082 **
1083 ** @valrule Length [ajuint] Length or 0U
1084 ** @valrule Memsize [size_t] Memory size in bytes or 0
1085 **
1086 ** @fcategory misc
1087 ******************************************************************************/
1088 
1089 
1090 
1091 
1092 /* @func ensAssemblyexceptionCalculateExceptionLength *************************
1093 **
1094 ** Calculate the exception length of an Ensembl Assembly Exception.
1095 **
1096 ** @param [r] ae [const EnsPAssemblyexception] Ensembl Assembly Exception
1097 **
1098 ** @return [ajuint] Exception length or 0U
1099 **
1100 ** @release 6.4.0
1101 ** @@
1102 ******************************************************************************/
1103 
ensAssemblyexceptionCalculateExceptionLength(const EnsPAssemblyexception ae)1104 ajuint ensAssemblyexceptionCalculateExceptionLength(
1105     const EnsPAssemblyexception ae)
1106 {
1107     if (!ae)
1108         return 0U;
1109 
1110     return ae->ExceptionEnd - ae->ExceptionStart + 1U;
1111 }
1112 
1113 
1114 
1115 
1116 /* @func ensAssemblyexceptionCalculateMemsize *********************************
1117 **
1118 ** Calculate the memory size in bytes of an Ensembl Assembly Exception.
1119 **
1120 ** @param [r] ae [const EnsPAssemblyexception] Ensembl Assembly Exception
1121 **
1122 ** @return [size_t] Memory size in bytes or 0
1123 **
1124 ** @release 6.4.0
1125 ** @@
1126 ******************************************************************************/
1127 
ensAssemblyexceptionCalculateMemsize(const EnsPAssemblyexception ae)1128 size_t ensAssemblyexceptionCalculateMemsize(
1129     const EnsPAssemblyexception ae)
1130 {
1131     size_t size = 0;
1132 
1133     if (!ae)
1134         return 0;
1135 
1136     size += sizeof (EnsOAssemblyexception);
1137 
1138     return size;
1139 }
1140 
1141 
1142 
1143 
1144 /* @func ensAssemblyexceptionCalculateReferenceLength *************************
1145 **
1146 ** Calculate the reference length of an Ensembl Assembly Exception.
1147 **
1148 ** @param [r] ae [const EnsPAssemblyexception] Ensembl Assembly Exception
1149 **
1150 ** @return [ajuint] Reference length or 0U
1151 **
1152 ** @release 6.4.0
1153 ** @@
1154 ******************************************************************************/
1155 
ensAssemblyexceptionCalculateReferenceLength(const EnsPAssemblyexception ae)1156 ajuint ensAssemblyexceptionCalculateReferenceLength(
1157     const EnsPAssemblyexception ae)
1158 {
1159     if (!ae)
1160         return 0U;
1161 
1162     return ae->ReferenceEnd - ae->ReferenceStart + 1U;
1163 }
1164 
1165 
1166 
1167 
1168 /* @datasection [EnsEAssemblyexceptionType] Ensembl Assembly Exception Type ***
1169 **
1170 ** @nam2rule Assemblyexception Functions for manipulating
1171 ** Ensembl Assembly Exception objects
1172 ** @nam3rule Type Functions for manipulating
1173 ** Ensembl Assembly Exception Type enumerations
1174 **
1175 ******************************************************************************/
1176 
1177 
1178 
1179 
1180 /* @section cast **************************************************************
1181 **
1182 ** Functions for type casting values of an
1183 ** Ensembl Assembly Exception Type enumeration.
1184 **
1185 ** @fdata [EnsEAssemblyexceptionType]
1186 **
1187 ** @nam4rule From Ensembl Assembly Exception Type query
1188 ** @nam5rule Str AJAX String object query
1189 **
1190 ** @argrule FromStr type [const AjPStr] Type string
1191 **
1192 ** @valrule FromStr [EnsEAssemblyexceptionType] Ensembl Assembly Exception Type
1193 ** enumeration or ensEAssemblyexceptionTypeNULL
1194 **
1195 ** @fcategory misc
1196 ******************************************************************************/
1197 
1198 
1199 
1200 
1201 /* @func ensAssemblyexceptionTypeFromStr **************************************
1202 **
1203 ** Return an Ensembl Assembly Exception Type enumeration from
1204 ** an AJAX String.
1205 **
1206 ** @param [r] type [const AjPStr] Type string
1207 **
1208 ** @return [EnsEAssemblyexceptionType]
1209 ** Ensembl Assembly Exception Type enumeration or ensEAssemblyexceptionTypeNULL
1210 **
1211 ** @release 6.2.0
1212 ** @@
1213 ******************************************************************************/
1214 
ensAssemblyexceptionTypeFromStr(const AjPStr type)1215 EnsEAssemblyexceptionType ensAssemblyexceptionTypeFromStr(
1216     const AjPStr type)
1217 {
1218     register EnsEAssemblyexceptionType i = ensEAssemblyexceptionTypeNULL;
1219 
1220     EnsEAssemblyexceptionType aet = ensEAssemblyexceptionTypeNULL;
1221 
1222     for (i = ensEAssemblyexceptionTypeNULL;
1223          assemblyexceptionKType[i];
1224          i++)
1225         if (ajStrMatchC(type, assemblyexceptionKType[i]))
1226             aet = i;
1227 
1228     if (!aet)
1229         ajDebug("ensAssemblyexceptionTypeFromStr encountered "
1230                 "unexpected string '%S'.\n", type);
1231 
1232     return aet;
1233 }
1234 
1235 
1236 
1237 
1238 /* @section Cast **************************************************************
1239 **
1240 ** Functions for returning attributes of an
1241 ** Ensembl Assembly Exception Type enumeration.
1242 **
1243 ** @fdata [EnsEAssemblyexceptionType]
1244 **
1245 ** @nam4rule To Return Ensembl Assembly Exception Type enumeration
1246 ** @nam5rule Char Return C character string value
1247 **
1248 ** @argrule To aet [EnsEAssemblyexceptionType]
1249 ** Ensembl Assembly Exception Type enumeration
1250 **
1251 ** @valrule * [const char*] Ensembl Assembly Exception Type
1252 ** @valrule *Char [const char*] Ensembl Assembly Exception Type or NULL
1253 **
1254 ** @fcategory cast
1255 ******************************************************************************/
1256 
1257 
1258 
1259 
1260 /* @func ensAssemblyexceptionTypeToChar ***************************************
1261 **
1262 ** Cast an Ensembl Assembly Exception Type enumeration into a
1263 ** C-type (char *) string.
1264 **
1265 ** @param [u] aet [EnsEAssemblyexceptionType]
1266 ** Ensembl Assembly Exception Type enumeration
1267 **
1268 ** @return [const char*] Status C-type (char *) string or NULL
1269 **
1270 ** @release 6.2.0
1271 ** @@
1272 ******************************************************************************/
1273 
ensAssemblyexceptionTypeToChar(EnsEAssemblyexceptionType aet)1274 const char* ensAssemblyexceptionTypeToChar(EnsEAssemblyexceptionType aet)
1275 {
1276     register EnsEAssemblyexceptionType i = ensEAssemblyexceptionTypeNULL;
1277 
1278     for (i = ensEAssemblyexceptionTypeNULL;
1279          assemblyexceptionKType[i] && (i < aet);
1280          i++);
1281 
1282     if (!assemblyexceptionKType[i])
1283         ajDebug("ensAssemblyexceptionTypeToChar "
1284                 "encountered an out of boundary error on "
1285                 "Ensembl Assembly Exception Type "
1286                 "enumeration %d.\n",
1287                 aet);
1288 
1289     return assemblyexceptionKType[i];
1290 }
1291 
1292 
1293 
1294 
1295 /* @funcstatic listAssemblyexceptionCompareReferenceEndAscending **************
1296 **
1297 ** AJAX List of Ensembl Assembly Exception objects comparison function to sort
1298 ** by reference end coordinate in ascending order.
1299 **
1300 ** @param [r] item1 [const void*] Ensembl Assembly Exception address 1
1301 ** @param [r] item2 [const void*] Ensembl Assembly Exception address 2
1302 ** @see ajListSort
1303 **
1304 ** @return [int] The comparison function returns an integer less than,
1305 **               equal to, or greater than zero if the first argument is
1306 **               considered to be respectively less than, equal to, or
1307 **               greater than the second.
1308 **
1309 ** @release 6.4.0
1310 ** @@
1311 ******************************************************************************/
1312 
listAssemblyexceptionCompareReferenceEndAscending(const void * item1,const void * item2)1313 static int listAssemblyexceptionCompareReferenceEndAscending(
1314     const void *item1,
1315     const void *item2)
1316 {
1317     int result = 0;
1318 
1319     EnsPAssemblyexception ae1 = *(EnsOAssemblyexception *const *) item1;
1320     EnsPAssemblyexception ae2 = *(EnsOAssemblyexception *const *) item2;
1321 
1322 #if defined(AJ_DEBUG) && AJ_DEBUG >= 2
1323     if (ajDebugTest("listAssemblyexceptionCompareReferenceEndAscending"))
1324     {
1325         ajDebug("listAssemblyexceptionCompareReferenceEndAscending\n"
1326                 "  ae1 %p\n"
1327                 "  ae2 %p\n",
1328                 ae1,
1329                 ae2);
1330 
1331         ensAssemblyexceptionTrace(ae1, 1);
1332         ensAssemblyexceptionTrace(ae2, 1);
1333     }
1334 #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 2 */
1335 
1336     /* Sort empty values towards the end of the AJAX List. */
1337 
1338     if (ae1 && (!ae2))
1339         return -1;
1340 
1341     if ((!ae1) && (!ae2))
1342         return 0;
1343 
1344     if ((!ae1) && ae2)
1345         return +1;
1346 
1347     if (ae1->ReferenceEnd < ae2->ReferenceEnd)
1348         result = -1;
1349 
1350     if (ae1->ReferenceEnd > ae2->ReferenceEnd)
1351         result = +1;
1352 
1353     return result;
1354 }
1355 
1356 
1357 
1358 
1359 /* @funcstatic listAssemblyexceptionCompareReferenceEndDescending *************
1360 **
1361 ** AJAX List of Ensembl Assembly Exception objects comparison function to sort
1362 ** by reference end coordinate in descending order.
1363 **
1364 ** @param [r] item1 [const void*] Ensembl Assembly Exception address 1
1365 ** @param [r] item2 [const void*] Ensembl Assembly Exception address 2
1366 ** @see ajListSort
1367 **
1368 ** @return [int] The comparison function returns an integer less than,
1369 **               equal to, or greater than zero if the first argument is
1370 **               considered to be respectively less than, equal to, or
1371 **               greater than the second.
1372 **
1373 ** @release 6.4.0
1374 ** @@
1375 ******************************************************************************/
1376 
listAssemblyexceptionCompareReferenceEndDescending(const void * item1,const void * item2)1377 static int listAssemblyexceptionCompareReferenceEndDescending(
1378     const void *item1,
1379     const void *item2)
1380 {
1381     int result = 0;
1382 
1383     EnsPAssemblyexception ae1 = *(EnsOAssemblyexception *const *) item1;
1384     EnsPAssemblyexception ae2 = *(EnsOAssemblyexception *const *) item2;
1385 
1386 #if defined(AJ_DEBUG) && AJ_DEBUG >= 2
1387     if (ajDebugTest("listAssemblyexceptionCompareReferenceEndDescending"))
1388     {
1389         ajDebug("listAssemblyexceptionCompareReferenceEndDescending\n"
1390                 "  ae1 %p\n"
1391                 "  ae2 %p\n",
1392                 ae1,
1393                 ae2);
1394 
1395         ensAssemblyexceptionTrace(ae1, 1);
1396         ensAssemblyexceptionTrace(ae2, 1);
1397     }
1398 #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 2 */
1399 
1400     /* Sort empty values towards the end of the AJAX List. */
1401 
1402     if (ae1 && (!ae2))
1403         return -1;
1404 
1405     if ((!ae1) && (!ae2))
1406         return 0;
1407 
1408     if ((!ae1) && ae2)
1409         return +1;
1410 
1411     if (ae1->ReferenceEnd < ae2->ReferenceEnd)
1412         result = +1;
1413 
1414     if (ae1->ReferenceEnd > ae2->ReferenceEnd)
1415         result = -1;
1416 
1417     return result;
1418 }
1419 
1420 
1421 
1422 
1423 /* @datasection [AjPList] AJAX List *******************************************
1424 **
1425 ** @nam2rule List Functions for manipulating AJAX List objects
1426 **
1427 ******************************************************************************/
1428 
1429 
1430 
1431 
1432 /* @section list **************************************************************
1433 **
1434 ** Functions for manipulating AJAX List objects.
1435 **
1436 ** @fdata [AjPList]
1437 **
1438 ** @nam3rule Assemblyexception Functions for manipulating AJAX List objects of
1439 ** Ensembl Assembly Exception objects
1440 ** @nam4rule Sort Sort functions
1441 ** @nam5rule Exception Sort by exception
1442 ** @nam5rule Reference Sort by reference
1443 ** @nam6rule End Sort by end coordinate
1444 ** @nam6rule Start Sort by start coordinate
1445 ** @nam7rule Ascending Sort in ascending order
1446 ** @nam7rule Descending Sort in descending order
1447 **
1448 ** @argrule Ascending aes [AjPList] AJAX List of
1449 ** Ensembl Assembly Exception objects
1450 ** @argrule Descending aes [AjPList] AJAX List of
1451 ** Ensembl Assembly Exception objects
1452 **
1453 ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise
1454 **
1455 ** @fcategory misc
1456 ******************************************************************************/
1457 
1458 
1459 
1460 
1461 /* @func ensListAssemblyexceptionSortReferenceEndAscending ********************
1462 **
1463 ** Sort an AJAX List of Ensembl Assembly Exception objects by their
1464 ** reference end member in ascending order.
1465 **
1466 ** @param [u] aes [AjPList] AJAX List of Ensembl Assembly Exception objects
1467 **
1468 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
1469 **
1470 ** @release 6.4.0
1471 ** @@
1472 ******************************************************************************/
1473 
ensListAssemblyexceptionSortReferenceEndAscending(AjPList aes)1474 AjBool ensListAssemblyexceptionSortReferenceEndAscending(AjPList aes)
1475 {
1476     if (!aes)
1477         return ajFalse;
1478 
1479     ajListSort(aes, &listAssemblyexceptionCompareReferenceEndAscending);
1480 
1481     return ajTrue;
1482 }
1483 
1484 
1485 
1486 
1487 /* @func ensListAssemblyexceptionSortReferenceEndDescending *******************
1488 **
1489 ** Sort an AJAX List of Ensembl Assembly Exception objects by their
1490 ** reference end member in descending order.
1491 **
1492 ** @param [u] aes [AjPList] AJAX List of Ensembl Assembly Exception objects
1493 **
1494 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
1495 **
1496 ** @release 6.4.0
1497 ** @@
1498 ******************************************************************************/
1499 
ensListAssemblyexceptionSortReferenceEndDescending(AjPList aes)1500 AjBool ensListAssemblyexceptionSortReferenceEndDescending(AjPList aes)
1501 {
1502     if (!aes)
1503         return ajFalse;
1504 
1505     ajListSort(aes, &listAssemblyexceptionCompareReferenceEndDescending);
1506 
1507     return ajTrue;
1508 }
1509 
1510 
1511 
1512 
1513 /* @datasection [EnsPAssemblyexceptionadaptor] Ensembl Assembly Exception
1514 ** Adaptor
1515 **
1516 ** @nam2rule Assemblyexceptionadaptor Functions for manipulating
1517 ** Ensembl Assembly Exception Adaptor objects
1518 **
1519 ** @cc Bio::EnsEMBL::DBSQL::SliceAdaptor
1520 ** @cc CVS Revision: 1.104
1521 **
1522 ******************************************************************************/
1523 
1524 
1525 
1526 
1527 /* @section constructors ******************************************************
1528 **
1529 ** All constructors return a new Ensembl Assembly Exception Adaptor by pointer.
1530 ** It is the responsibility of the user to first destroy any previous
1531 ** Assembly Exception Adaptor. The target pointer does not need to be
1532 ** initialised to NULL, but it is good programming practice to do so anyway.
1533 **
1534 ** @fdata [EnsPAssemblyexceptionadaptor]
1535 **
1536 ** @nam3rule New Constructor
1537 **
1538 ** @argrule New dba [EnsPDatabaseadaptor] Ensembl Database Adaptor
1539 **
1540 ** @valrule * [EnsPAssemblyexceptionadaptor]
1541 ** Ensembl Assembly Exception Adaptor or NULL
1542 **
1543 ** @fcategory new
1544 ******************************************************************************/
1545 
1546 
1547 
1548 
1549 /* @funcstatic assemblyexceptionadaptorFetchAllbyStatement ********************
1550 **
1551 ** Run a SQL statement against an Ensembl Assembly Exception Adaptor and
1552 ** consolidate the results into an AJAX List of Ensembl Assembly Exception
1553 ** objects.
1554 **
1555 ** @param [u] aea [EnsPAssemblyexceptionadaptor]
1556 ** Ensembl Assembly Exception Adaptor
1557 ** @param [r] statement [const AjPStr] SQL statement
1558 ** @param [u] aes [AjPList] AJAX List of Ensembl Assembly Exception objects
1559 **
1560 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
1561 **
1562 ** @release 6.4.0
1563 ** @@
1564 ******************************************************************************/
1565 
assemblyexceptionadaptorFetchAllbyStatement(EnsPAssemblyexceptionadaptor aea,const AjPStr statement,AjPList aes)1566 static AjBool assemblyexceptionadaptorFetchAllbyStatement(
1567     EnsPAssemblyexceptionadaptor aea,
1568     const AjPStr statement,
1569     AjPList aes)
1570 {
1571     ajint ori = 0;
1572 
1573     ajuint identifier = 0U;
1574     ajuint erid       = 0U;
1575     ajuint srid       = 0U;
1576     ajuint erstart    = 0U;
1577     ajuint srstart    = 0U;
1578     ajuint erend      = 0U;
1579     ajuint srend      = 0U;
1580 
1581     AjPSqlstatement sqls = NULL;
1582     AjISqlrow sqli       = NULL;
1583     AjPSqlrow sqlr       = NULL;
1584 
1585     AjPStr typestr = NULL;
1586 
1587     EnsEAssemblyexceptionType aet = ensEAssemblyexceptionTypeNULL;
1588 
1589     EnsPAssemblyexception ae = NULL;
1590 
1591     EnsPDatabaseadaptor dba = NULL;
1592 
1593     if (!aea)
1594         return ajFalse;
1595 
1596     if (!statement)
1597         return ajFalse;
1598 
1599     if (!aes)
1600         return ajFalse;
1601 
1602     dba = ensAssemblyexceptionadaptorGetDatabaseadaptor(aea);
1603 
1604     sqls = ensDatabaseadaptorSqlstatementNew(dba, statement);
1605 
1606     sqli = ajSqlrowiterNew(sqls);
1607 
1608     while (!ajSqlrowiterDone(sqli))
1609     {
1610         identifier = 0;
1611         srid       = 0;
1612         srstart    = 0;
1613         srend      = 0;
1614         typestr    = ajStrNew();
1615         erid       = 0;
1616         erstart    = 0;
1617         erend      = 0;
1618         ori        = 0;
1619 
1620         aet = ensEAssemblyexceptionTypeNULL;
1621 
1622         sqlr = ajSqlrowiterGet(sqli);
1623 
1624         ajSqlcolumnToUint(sqlr, &identifier);
1625         ajSqlcolumnToUint(sqlr, &srid);
1626         ajSqlcolumnToUint(sqlr, &srstart);
1627         ajSqlcolumnToUint(sqlr, &srend);
1628         ajSqlcolumnToStr(sqlr, &typestr);
1629         ajSqlcolumnToUint(sqlr, &erid);
1630         ajSqlcolumnToUint(sqlr, &erstart);
1631         ajSqlcolumnToUint(sqlr, &erend);
1632         ajSqlcolumnToInt(sqlr, &ori);
1633 
1634         /* Set the Assembly Exception type. */
1635 
1636         aet = ensAssemblyexceptionTypeFromStr(typestr);
1637 
1638         if (!aet)
1639             ajFatal("assemblyexceptionadaptorFetchAllbyStatement "
1640                     "got unexpected Assembly Exception type '%S' "
1641                     "from database.\n",
1642                     typestr);
1643 
1644         ae = ensAssemblyexceptionNewIni(aea,
1645                                         identifier,
1646                                         srid,
1647                                         srstart,
1648                                         srend,
1649                                         erid,
1650                                         erstart,
1651                                         erend,
1652                                         ori,
1653                                         aet);
1654 
1655         ajListPushAppend(aes, (void *) ae);
1656 
1657         ajStrDel(&typestr);
1658     }
1659 
1660     ajSqlrowiterDel(&sqli);
1661 
1662     ensDatabaseadaptorSqlstatementDel(dba, &sqls);
1663 
1664     return ajTrue;
1665 }
1666 
1667 
1668 
1669 
1670 /* @funcstatic assemblyexceptionadaptorCacheInit ******************************
1671 **
1672 ** Initialise the Ensembl Assembly Exception cache in the
1673 ** Assembly Exception Adaptor.
1674 **
1675 ** @param [u] aea [EnsPAssemblyexceptionadaptor]
1676 ** Ensembl Assembly Exception Adaptor
1677 **
1678 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
1679 **
1680 ** @release 6.3.0
1681 ** @@
1682 ******************************************************************************/
1683 
assemblyexceptionadaptorCacheInit(EnsPAssemblyexceptionadaptor aea)1684 static AjBool assemblyexceptionadaptorCacheInit(
1685     EnsPAssemblyexceptionadaptor aea)
1686 {
1687     ajuint *Pidentifier = NULL;
1688 
1689     AjBool result = AJFALSE;
1690 
1691     AjPList list = NULL;
1692     AjPList aes  = NULL;
1693 
1694     AjPStr statement = NULL;
1695 
1696     EnsPAssemblyexception ae = NULL;
1697 
1698     if (!aea)
1699         return ajFalse;
1700 
1701     if (aea->CacheByReferenceSeqregion)
1702         return ajTrue;
1703     else
1704     {
1705         aea->CacheByReferenceSeqregion = ajTableuintNew(0U);
1706 
1707         ajTableSetDestroyvalue(
1708             aea->CacheByReferenceSeqregion,
1709             (void (*)(void **))
1710             &assemblyexceptionadaptorListAssemblyexceptionValdel);
1711     }
1712 
1713     statement = ajFmtStr(
1714         "SELECT "
1715         "assembly_exception.assembly_exception_id, "
1716         "assembly_exception.seq_region_id, "
1717         "assembly_exception.seq_region_start, "
1718         "assembly_exception.seq_region_end, "
1719         "assembly_exception.exc_type, "
1720         "assembly_exception.exc_seq_region_id, "
1721         "assembly_exception.exc_seq_region_start, "
1722         "assembly_exception.exc_seq_region_end, "
1723         "assembly_exception.ori "
1724         "FROM "
1725         "assembly_exception, "
1726         "seq_region, "
1727         "coord_system "
1728         "WHERE "
1729         "seq_region.seq_region_id = "
1730         "assembly_exception.seq_region_id "
1731         "AND "
1732         "seq_region.coord_system_id = "
1733         "coord_system.coord_system_id "
1734         "AND "
1735         "coord_system.species_id = %u",
1736         ensDatabaseadaptorGetIdentifier(
1737             ensAssemblyexceptionadaptorGetDatabaseadaptor(aea)));
1738 
1739     aes = ajListNew();
1740 
1741     result = assemblyexceptionadaptorFetchAllbyStatement(aea, statement, aes);
1742 
1743     ajStrDel(&statement);
1744 
1745     while (ajListPop(aes, (void **) &ae))
1746     {
1747         list = (AjPList) ajTableFetchmodV(
1748             aea->CacheByReferenceSeqregion,
1749             (const void *) &ae->ReferenceSeqregion);
1750 
1751         if (!list)
1752         {
1753             AJNEW0(Pidentifier);
1754 
1755             *Pidentifier = ae->ReferenceSeqregion;
1756 
1757             list = ajListNew();
1758 
1759             ajTablePut(aea->CacheByReferenceSeqregion,
1760                        (void *) Pidentifier,
1761                        (void *) list);
1762         }
1763 
1764         ajListPushAppend(list, (void *) ae);
1765     }
1766 
1767     ajListFree(&aes);
1768 
1769     return result;
1770 }
1771 
1772 
1773 
1774 
1775 /* @func ensAssemblyexceptionadaptorNew ***************************************
1776 **
1777 ** Default constructor for an Ensembl Assembly Exception Adaptor.
1778 **
1779 ** Ensembl Object Adaptors are singleton objects in the sense that a single
1780 ** instance of an Ensembl Object Adaptor connected to a particular database is
1781 ** sufficient to instantiate any number of Ensembl Objects from the database.
1782 ** Each Ensembl Object will have a weak reference to the Object Adaptor that
1783 ** instantiated it. Therefore, Ensembl Object Adaptors should not be
1784 ** instantiated directly, but rather obtained from the Ensembl Registry,
1785 ** which will in turn call this function if neccessary.
1786 **
1787 ** @see ensRegistryGetDatabaseadaptor
1788 ** @see ensRegistryGetAssemblyexceptionadaptor
1789 **
1790 ** @param [u] dba [EnsPDatabaseadaptor] Ensembl Database Adaptor
1791 **
1792 ** @return [EnsPAssemblyexceptionadaptor]
1793 ** Ensembl Assembly Exception Adaptor or NULL
1794 **
1795 ** @release 6.2.0
1796 ** @@
1797 ******************************************************************************/
1798 
ensAssemblyexceptionadaptorNew(EnsPDatabaseadaptor dba)1799 EnsPAssemblyexceptionadaptor ensAssemblyexceptionadaptorNew(
1800     EnsPDatabaseadaptor dba)
1801 {
1802     EnsPAssemblyexceptionadaptor aea = NULL;
1803 
1804     if (!dba)
1805         return NULL;
1806 
1807     AJNEW0(aea);
1808 
1809     aea->Adaptor = dba;
1810 
1811     assemblyexceptionadaptorCacheInit(aea);
1812 
1813     return aea;
1814 }
1815 
1816 
1817 
1818 
1819 /* @section destructors *******************************************************
1820 **
1821 ** Destruction destroys all internal data structures and frees the memory
1822 ** allocated for an Ensembl Assembly Exception Adaptor object.
1823 **
1824 ** @fdata [EnsPAssemblyexceptionadaptor]
1825 **
1826 ** @nam3rule Del Destroy (free) an Ensembl Assembly Exception Adaptor object
1827 **
1828 ** @argrule * Paea [EnsPAssemblyexceptionadaptor*]
1829 ** Ensembl Assembly Exception Adaptor object address
1830 **
1831 ** @valrule * [void]
1832 **
1833 ** @fcategory delete
1834 ******************************************************************************/
1835 
1836 
1837 
1838 
1839 /* @funcstatic assemblyexceptionadaptorListAssemblyexceptionValdel ************
1840 **
1841 ** An ajTableSetDestroyvalue "valdel" function to clear AJAX Table value data.
1842 ** This function removes and deletes Ensembl Assembly Exception objects
1843 ** from an AJAX List object, before deleting the AJAX List object.
1844 **
1845 ** @param [d] Pvalue [void**] AJAX List address
1846 ** @see ajTableSetDestroyvalue
1847 **
1848 ** @return [void]
1849 **
1850 ** @release 6.3.0
1851 ** @@
1852 ******************************************************************************/
1853 
assemblyexceptionadaptorListAssemblyexceptionValdel(void ** Pvalue)1854 static void assemblyexceptionadaptorListAssemblyexceptionValdel(void **Pvalue)
1855 {
1856     EnsPAssemblyexception ae = NULL;
1857 
1858     if (!Pvalue)
1859         return;
1860 
1861     if (!*Pvalue)
1862         return;
1863 
1864     while (ajListPop(*((AjPList *) Pvalue), (void **) &ae))
1865         ensAssemblyexceptionDel(&ae);
1866 
1867     ajListFree((AjPList *) Pvalue);
1868 
1869     return;
1870 }
1871 
1872 
1873 
1874 
1875 /* @func ensAssemblyexceptionadaptorDel ***************************************
1876 **
1877 ** Default destructor for an Ensembl Assembly Exception Adaptor.
1878 **
1879 ** This function also clears the internal Assembly Exception cache.
1880 **
1881 ** Ensembl Object Adaptors are singleton objects that are registered in the
1882 ** Ensembl Registry and weakly referenced by Ensembl Objects that have been
1883 ** instantiated by it. Therefore, Ensembl Object Adaptors should never be
1884 ** destroyed directly. Upon exit, the Ensembl Registry will call this function
1885 ** if required.
1886 **
1887 ** @param [d] Paea [EnsPAssemblyexceptionadaptor*]
1888 ** Ensembl Assembly Exception Adaptor object address
1889 **
1890 ** @return [void]
1891 **
1892 ** @release 6.2.0
1893 ** @@
1894 ******************************************************************************/
1895 
ensAssemblyexceptionadaptorDel(EnsPAssemblyexceptionadaptor * Paea)1896 void ensAssemblyexceptionadaptorDel(
1897     EnsPAssemblyexceptionadaptor *Paea)
1898 {
1899     EnsPAssemblyexceptionadaptor pthis = NULL;
1900 
1901     if (!Paea)
1902         return;
1903 
1904 #if defined(AJ_DEBUG) && AJ_DEBUG >= 1
1905     if (ajDebugTest("ensAssemblyexceptionadaptorDel"))
1906         ajDebug("ensAssemblyexceptionadaptorDel\n"
1907                 "  *Paea %p\n",
1908                 *Paea);
1909 #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 1 */
1910 
1911     if (!(pthis = *Paea))
1912         return;
1913 
1914     ajTableDel(&pthis->CacheByReferenceSeqregion);
1915 
1916     ajMemFree((void **) Paea);
1917 
1918     return;
1919 }
1920 
1921 
1922 
1923 
1924 /* @section member retrieval **************************************************
1925 **
1926 ** Functions for returning members of an
1927 ** Ensembl Assembly Exception Adaptor object.
1928 **
1929 ** @fdata [EnsPAssemblyexceptionadaptor]
1930 **
1931 ** @nam3rule Get Return Ensembl Assembly Exception Adaptor attribute(s)
1932 ** @nam4rule Databaseadaptor Return the Ensembl Database Adaptor
1933 **
1934 ** @argrule * aea [EnsPAssemblyexceptionadaptor]
1935 ** Ensembl Assembly Exception Adaptor
1936 **
1937 ** @valrule Databaseadaptor [EnsPDatabaseadaptor] Ensembl Database Adaptor
1938 ** or NULL
1939 **
1940 ** @fcategory use
1941 ******************************************************************************/
1942 
1943 
1944 
1945 
1946 /* @func ensAssemblyexceptionadaptorGetDatabaseadaptor ************************
1947 **
1948 ** Get the Ensembl Database Adaptor member of an
1949 ** Ensembl Assembly Exception Adaptor.
1950 **
1951 ** @param [u] aea [EnsPAssemblyexceptionadaptor]
1952 ** Ensembl Assembly Exception Adaptor
1953 **
1954 ** @return [EnsPDatabaseadaptor] Ensembl Database Adaptor or NULL
1955 **
1956 ** @release 6.4.0
1957 ** @@
1958 ******************************************************************************/
1959 
ensAssemblyexceptionadaptorGetDatabaseadaptor(EnsPAssemblyexceptionadaptor aea)1960 EnsPDatabaseadaptor ensAssemblyexceptionadaptorGetDatabaseadaptor(
1961     EnsPAssemblyexceptionadaptor aea)
1962 {
1963     return (aea) ? aea->Adaptor : NULL;
1964 }
1965 
1966 
1967 
1968 
1969 /* @section object retrieval **************************************************
1970 **
1971 ** Functions for fetching Ensembl Assembly Exception objects from an
1972 ** Ensembl SQL database.
1973 **
1974 ** @fdata [EnsPAssemblyexceptionadaptor]
1975 **
1976 ** @nam3rule Fetch     Fetch Ensembl Assembly Exception object(s)
1977 ** @nam4rule All       Fetch all Ensembl Assembly Exception objects
1978 ** @nam4rule Allby     Fetch all Ensembl Assembly Exception objects
1979 **                     matching a criterion
1980 ** @nam5rule Reference Fetch by reference
1981 ** @nam6rule Seqregion Fetch by a reference Ensembl Sequence Region identifier
1982 ** @nam4rule By        Fetch one Ensembl Assembly Exception object
1983 **                     matching a criterion
1984 **
1985 ** @argrule * aea [const EnsPAssemblyexceptionadaptor]
1986 ** Ensembl Assembly Exception Adaptor
1987 ** @argrule FetchAll aes [AjPList]
1988 ** AJAX List of Ensembl Assembly Exception objects
1989 ** @argrule FetchAllbyReferenceSeqregion srid [ajuint]
1990 ** Reference Ensembl Sequence Region
1991 ** @argrule FetchAllby aes [AjPList]
1992 ** AJAX List of Ensembl Assembly Exception objects
1993 **
1994 ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise
1995 **
1996 ** @fcategory use
1997 ******************************************************************************/
1998 
1999 
2000 
2001 
2002 /* @funcstatic assemblyexceptionadaptorFetchAll *******************************
2003 **
2004 ** An ajTableMap "apply" function to return all Ensembl Assembly Exception
2005 ** objects from the Ensembl Assembly Exception Adaptor-internal cache.
2006 **
2007 ** @param [u] key [const void*] AJAX unsigned integer key data address
2008 ** @param [u] Pvalue [void**] Ensembl Assembly Exception value data address
2009 ** @param [u] cl [void*]
2010 ** AJAX List of Ensembl Assembly Exception objects, passed in via ajTableMap
2011 ** @see ajTableMap
2012 **
2013 ** @return [void]
2014 **
2015 ** @release 6.3.0
2016 ** @@
2017 ******************************************************************************/
2018 
assemblyexceptionadaptorFetchAll(const void * key,void ** Pvalue,void * cl)2019 static void assemblyexceptionadaptorFetchAll(const void *key,
2020                                              void **Pvalue,
2021                                              void *cl)
2022 {
2023     AjIList iter = NULL;
2024 
2025     EnsPAssemblyexception ae = NULL;
2026 
2027     if (!key)
2028         return;
2029 
2030     if (!Pvalue)
2031         return;
2032 
2033     if (!*Pvalue)
2034         return;
2035 
2036     if (!cl)
2037         return;
2038 
2039     iter = ajListIterNew(*((AjPList *) Pvalue));
2040 
2041     while (!ajListIterDone(iter))
2042     {
2043         ae = (EnsPAssemblyexception) ajListIterGet(iter);
2044 
2045         ajListPushAppend((AjPList) cl,
2046                          (void *) ensAssemblyexceptionNewRef(ae));
2047     }
2048 
2049     ajListIterDel(&iter);
2050 
2051     return;
2052 }
2053 
2054 
2055 
2056 
2057 /* @func ensAssemblyexceptionadaptorFetchAll **********************************
2058 **
2059 ** Fetch all Ensembl Assembly Exception objects.
2060 **
2061 ** The caller is responsible for deleting the Ensembl Assembly Exception
2062 ** objects before deleting the AJAX List.
2063 **
2064 ** @param [r] aea [const EnsPAssemblyexceptionadaptor]
2065 ** Ensembl Assembly Exception Adaptor
2066 ** @param [u] aes [AjPList] AJAX List of Ensembl Assembly Exception objects
2067 **
2068 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
2069 **
2070 ** @release 6.2.0
2071 ** @@
2072 ******************************************************************************/
2073 
ensAssemblyexceptionadaptorFetchAll(const EnsPAssemblyexceptionadaptor aea,AjPList aes)2074 AjBool ensAssemblyexceptionadaptorFetchAll(
2075     const EnsPAssemblyexceptionadaptor aea,
2076     AjPList aes)
2077 {
2078     if (!aea)
2079         return ajFalse;
2080 
2081     if (!aes)
2082         return ajFalse;
2083 
2084     ajTableMap(aea->CacheByReferenceSeqregion,
2085                &assemblyexceptionadaptorFetchAll,
2086                (void *) aes);
2087 
2088     return ajTrue;
2089 }
2090 
2091 
2092 
2093 
2094 /* @func ensAssemblyexceptionadaptorFetchAllbyReferenceSeqregion **************
2095 **
2096 ** Fetch all Ensembl Assembly Exception objects by a reference
2097 ** Ensembl Sequence Region identifier.
2098 **
2099 ** The caller is responsible for deleting the Ensembl Assembly Exception
2100 ** objects before deleting the AJAX List.
2101 **
2102 ** @param [r] aea [const EnsPAssemblyexceptionadaptor]
2103 ** Ensembl Assembly Exception Adaptor
2104 ** @param [r] srid [ajuint] Reference Ensembl Sequence Region identifier
2105 ** @param [u] aes [AjPList] AJAX List of Ensembl Assembly Exception objects
2106 **
2107 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
2108 **
2109 ** @release 6.4.0
2110 ** @@
2111 ******************************************************************************/
2112 
ensAssemblyexceptionadaptorFetchAllbyReferenceSeqregion(const EnsPAssemblyexceptionadaptor aea,ajuint srid,AjPList aes)2113 AjBool ensAssemblyexceptionadaptorFetchAllbyReferenceSeqregion(
2114     const EnsPAssemblyexceptionadaptor aea,
2115     ajuint srid,
2116     AjPList aes)
2117 {
2118     AjIList iter = NULL;
2119     AjPList list = NULL;
2120 
2121     EnsPAssemblyexception ae = NULL;
2122 
2123     if (ajDebugTest("ensAssemblyexceptionadaptorFetchAllbyReferenceSeqregion"))
2124         ajDebug("ensAssemblyexceptionadaptorFetchAllbyReferenceSeqregion\n"
2125                 "  aea %p\n"
2126                 "  srid %u\n"
2127                 "  aes %p\n",
2128                 aea,
2129                 srid,
2130                 aes);
2131 
2132     if (!aea)
2133         return ajFalse;
2134 
2135     if (!aes)
2136         return ajFalse;
2137 
2138     list = (AjPList) ajTableFetchmodV(aea->CacheByReferenceSeqregion,
2139                                       (const void *) &srid);
2140 
2141     iter = ajListIterNew(list);
2142 
2143     while (!ajListIterDone(iter))
2144     {
2145         ae = (EnsPAssemblyexception) ajListIterGet(iter);
2146 
2147         ajListPushAppend(aes, (void *) ensAssemblyexceptionNewRef(ae));
2148     }
2149 
2150     ajListIterDel(&iter);
2151 
2152     return ajTrue;
2153 }
2154