1 /* @source enskaryotype *******************************************************
2 **
3 ** Ensembl Karyotype Band 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:10 $ 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 "enskaryotype.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 karyotypebandadaptorKTablenames *******************************
64 **
65 ** Array of Ensembl Karyotype Band Adaptor SQL table names
66 **
67 ******************************************************************************/
68
69 static const char *const karyotypebandadaptorKTablenames[] =
70 {
71 "karyotype",
72 (const char *) NULL
73 };
74
75
76
77
78 /* @conststatic karyotypebandadaptorKColumnnames ******************************
79 **
80 ** Array of Ensembl Karyotype Band Adaptor SQL column names
81 **
82 ******************************************************************************/
83
84 static const char *const karyotypebandadaptorKColumnnames[] =
85 {
86 "karyotype.karyotype_id",
87 "karyotype.seq_region_id",
88 "karyotype.seq_region_start",
89 "karyotype.seq_region_end",
90 "karyotype.band",
91 "karyotype.stain",
92 (const char *) NULL
93 };
94
95
96
97
98 /* ========================================================================= */
99 /* =========================== private variables =========================== */
100 /* ========================================================================= */
101
102
103
104
105 /* ========================================================================= */
106 /* =========================== private functions =========================== */
107 /* ========================================================================= */
108
109 static int listKaryotypebandCompareEndAscending(
110 const void *item1,
111 const void *item2);
112
113 static int listKaryotypebandCompareEndDescending(
114 const void *item1,
115 const void *item2);
116
117 static int listKaryotypebandCompareIdentifierAscending(
118 const void *item1,
119 const void *item2);
120
121 static int listKaryotypebandCompareStartAscending(
122 const void *item1,
123 const void *item2);
124
125 static int listKaryotypebandCompareStartDescending(
126 const void *item1,
127 const void *item2);
128
129 static AjBool karyotypebandadaptorFetchAllbyStatement(
130 EnsPBaseadaptor ba,
131 const AjPStr statement,
132 EnsPAssemblymapper am,
133 EnsPSlice slice,
134 AjPList kblist);
135
136
137
138
139 /* ========================================================================= */
140 /* ======================= All functions by section ======================== */
141 /* ========================================================================= */
142
143
144
145
146 /* @filesection enskaryotype **************************************************
147 **
148 ** @nam1rule ens Function belongs to the Ensembl library
149 **
150 ******************************************************************************/
151
152
153
154
155 /* @datasection [EnsPKaryotypeband] Ensembl Karyotype Band ********************
156 **
157 ** @nam2rule Karyotypeband Functions for manipulating
158 ** Ensembl Karyotype Band objects
159 **
160 ** @cc Bio::EnsEMBL::KaryotypeBand
161 ** @cc CVS Revision: 1.11
162 ** @cc CVS Tag: branch-ensembl-68
163 **
164 ******************************************************************************/
165
166
167
168
169 /* @section constructors ******************************************************
170 **
171 ** All constructors return a new Ensembl Karyotype Band by pointer.
172 ** It is the responsibility of the user to first destroy any previous
173 ** Karyotype Band. The target pointer does not need to be initialised to
174 ** NULL, but it is good programming practice to do so anyway.
175 **
176 ** @fdata [EnsPKaryotypeband]
177 **
178 ** @nam3rule New Constructor
179 ** @nam4rule Cpy Constructor with existing object
180 ** @nam4rule Ini Constructor with initial values
181 ** @nam4rule Ref Constructor by incrementing the reference counter
182 **
183 ** @argrule Cpy kb [const EnsPKaryotypeband] Ensembl Karyotype Band
184 ** @argrule Ini kba [EnsPKaryotypebandadaptor] Ensembl Karyotype Band Adaptor
185 ** @argrule Ini identifier [ajuint] Identifier
186 ** @argrule Ini feature [EnsPFeature] Ensembl Feature
187 ** @argrule Ini name [AjPStr] Name
188 ** @argrule Ini stain [AjPStr] Stain
189 ** @argrule Ref kb [EnsPKaryotypeband] Ensembl Karyotype Band
190 **
191 ** @valrule * [EnsPKaryotypeband] Ensembl Karyotype Band or NULL
192 **
193 ** @fcategory new
194 ******************************************************************************/
195
196
197
198
199 /* @func ensKaryotypebandNewCpy ***********************************************
200 **
201 ** Object-based constructor function, which returns an independent object.
202 **
203 ** @param [r] kb [const EnsPKaryotypeband] Ensembl Karyotype Band
204 **
205 ** @return [EnsPKaryotypeband] Ensembl Karyotype Band or NULL
206 **
207 ** @release 6.4.0
208 ** @@
209 ******************************************************************************/
210
ensKaryotypebandNewCpy(const EnsPKaryotypeband kb)211 EnsPKaryotypeband ensKaryotypebandNewCpy(const EnsPKaryotypeband kb)
212 {
213 EnsPKaryotypeband pthis = NULL;
214
215 if (!kb)
216 return NULL;
217
218 AJNEW0(pthis);
219
220 pthis->Use = 1U;
221 pthis->Identifier = kb->Identifier;
222 pthis->Adaptor = kb->Adaptor;
223 pthis->Feature = ensFeatureNewRef(kb->Feature);
224
225 if (kb->Name)
226 pthis->Name = ajStrNewRef(kb->Name);
227
228 if (kb->Stain)
229 pthis->Stain = ajStrNewRef(kb->Stain);
230
231 return pthis;
232 }
233
234
235
236
237 /* @func ensKaryotypebandNewIni ***********************************************
238 **
239 ** Constructor for an Ensembl Karyotype Band with initial values.
240 **
241 ** @cc Bio::EnsEMBL::Karyotypeband::new
242 ** @param [u] kba [EnsPKaryotypebandadaptor] Ensembl Karyotype Band Adaptor
243 ** @param [r] identifier [ajuint] Identifier
244 ** @cc Bio::EnsEMBL::Feature::new
245 ** @param [u] feature [EnsPFeature] Ensembl Feature
246 ** @param [u] name [AjPStr] Name
247 ** @param [u] stain [AjPStr] Stain
248 **
249 ** @return [EnsPKaryotypeband] Ensembl Karyotype Band or NULL
250 **
251 ** @release 6.4.0
252 ** @@
253 ******************************************************************************/
254
ensKaryotypebandNewIni(EnsPKaryotypebandadaptor kba,ajuint identifier,EnsPFeature feature,AjPStr name,AjPStr stain)255 EnsPKaryotypeband ensKaryotypebandNewIni(EnsPKaryotypebandadaptor kba,
256 ajuint identifier,
257 EnsPFeature feature,
258 AjPStr name,
259 AjPStr stain)
260 {
261 EnsPKaryotypeband kb = NULL;
262
263 if (!feature)
264 return NULL;
265
266 AJNEW0(kb);
267
268 kb->Use = 1U;
269 kb->Identifier = identifier;
270 kb->Adaptor = kba;
271 kb->Feature = ensFeatureNewRef(feature);
272
273 if (name)
274 kb->Name = ajStrNewRef(name);
275
276 if (stain)
277 kb->Stain = ajStrNewRef(stain);
278
279 return kb;
280 }
281
282
283
284
285 /* @func ensKaryotypebandNewRef ***********************************************
286 **
287 ** Ensembl Object referencing function, which returns a pointer to the
288 ** Ensembl Object passed in and increases its reference count.
289 **
290 ** @param [u] kb [EnsPKaryotypeband] Ensembl Karyotype Band
291 **
292 ** @return [EnsPKaryotypeband] Ensembl Karyotype Band or NULL
293 **
294 ** @release 6.2.0
295 ** @@
296 ******************************************************************************/
297
ensKaryotypebandNewRef(EnsPKaryotypeband kb)298 EnsPKaryotypeband ensKaryotypebandNewRef(EnsPKaryotypeband kb)
299 {
300 if (!kb)
301 return NULL;
302
303 kb->Use++;
304
305 return kb;
306 }
307
308
309
310
311 /* @section destructors *******************************************************
312 **
313 ** Destruction destroys all internal data structures and frees the memory
314 ** allocated for an Ensembl Karyotype Band object.
315 **
316 ** @fdata [EnsPKaryotypeband]
317 **
318 ** @nam3rule Del Destroy (free) an Ensembl Karyotype Band
319 **
320 ** @argrule * Pkb [EnsPKaryotypeband*] Ensembl Karyotype Band address
321 **
322 ** @valrule * [void]
323 **
324 ** @fcategory delete
325 ******************************************************************************/
326
327
328
329
330 /* @func ensKaryotypebandDel **************************************************
331 **
332 ** Default destructor for an Ensembl Karyotype Band.
333 **
334 ** @param [d] Pkb [EnsPKaryotypeband*] Ensembl Karyotype Band address
335 **
336 ** @return [void]
337 **
338 ** @release 6.2.0
339 ** @@
340 ******************************************************************************/
341
ensKaryotypebandDel(EnsPKaryotypeband * Pkb)342 void ensKaryotypebandDel(EnsPKaryotypeband *Pkb)
343 {
344 EnsPKaryotypeband pthis = NULL;
345
346 if (!Pkb)
347 return;
348
349 #if defined(AJ_DEBUG) && AJ_DEBUG >= 1
350 if (ajDebugTest("ensKaryotypebandDel"))
351 {
352 ajDebug("ensKaryotypebandDel\n"
353 " *Pkb %p\n",
354 *Pkb);
355
356 ensKaryotypebandTrace(*Pkb, 1);
357 }
358 #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 1 */
359
360 if (!(pthis = *Pkb) || --pthis->Use)
361 {
362 *Pkb = NULL;
363
364 return;
365 }
366
367 ensFeatureDel(&pthis->Feature);
368
369 ajStrDel(&pthis->Name);
370 ajStrDel(&pthis->Stain);
371
372 ajMemFree((void **) Pkb);
373
374 return;
375 }
376
377
378
379
380 /* @section member retrieval **************************************************
381 **
382 ** Functions for returning members of an Ensembl Karyotype Band object.
383 **
384 ** @fdata [EnsPKaryotypeband]
385 **
386 ** @nam3rule Get Return Karyotype Band attribute(s)
387 ** @nam4rule Adaptor Return the Ensembl Karyotype Band Adaptor
388 ** @nam4rule Feature Return the Ensembl Feature
389 ** @nam4rule Identifier Return the SQL database-internal identifier
390 ** @nam4rule Name Return the name
391 ** @nam4rule Stain Return the stain
392 **
393 ** @argrule * kb [const EnsPKaryotypeband] Karyotype Band
394 **
395 ** @valrule Adaptor [EnsPKaryotypebandadaptor] Ensembl Karyotype Band Adaptor
396 ** or NULL
397 ** @valrule Feature [EnsPFeature] Ensembl Feature or NULL
398 ** @valrule Identifier [ajuint] SQL database-internal identifier or 0U
399 ** @valrule Name [AjPStr] Name or NULL
400 ** @valrule Stain [AjPStr] Stain or NULL
401 **
402 ** @fcategory use
403 ******************************************************************************/
404
405
406
407
408 /* @func ensKaryotypebandGetAdaptor *******************************************
409 **
410 ** Get the Ensembl Karyotype Band Adaptor member of an Ensembl Karyotype Band.
411 **
412 ** @param [r] kb [const EnsPKaryotypeband] Ensembl Karyotype Band
413 **
414 ** @return [EnsPKaryotypebandadaptor] Ensembl Karyotype Band Adaptor or NULL
415 **
416 ** @release 6.2.0
417 ** @@
418 ******************************************************************************/
419
ensKaryotypebandGetAdaptor(const EnsPKaryotypeband kb)420 EnsPKaryotypebandadaptor ensKaryotypebandGetAdaptor(
421 const EnsPKaryotypeband kb)
422 {
423 return (kb) ? kb->Adaptor : NULL;
424 }
425
426
427
428
429 /* @func ensKaryotypebandGetFeature *******************************************
430 **
431 ** Get the Ensembl Feature member of an Ensembl Karyotype Band.
432 **
433 ** @param [r] kb [const EnsPKaryotypeband] Ensembl Karyotype Band
434 **
435 ** @return [EnsPFeature] Ensembl Feature or NULL
436 **
437 ** @release 6.2.0
438 ** @@
439 ******************************************************************************/
440
ensKaryotypebandGetFeature(const EnsPKaryotypeband kb)441 EnsPFeature ensKaryotypebandGetFeature(
442 const EnsPKaryotypeband kb)
443 {
444 return (kb) ? kb->Feature : NULL;
445 }
446
447
448
449
450 /* @func ensKaryotypebandGetIdentifier ****************************************
451 **
452 ** Get the SQL database-internal identifier member of an
453 ** Ensembl Karyotype Band.
454 **
455 ** @param [r] kb [const EnsPKaryotypeband] Ensembl Karyotype Band
456 **
457 ** @return [ajuint] SQL database-internal identifier or 0U
458 **
459 ** @release 6.3.0
460 ** @@
461 ******************************************************************************/
462
ensKaryotypebandGetIdentifier(const EnsPKaryotypeband kb)463 ajuint ensKaryotypebandGetIdentifier(
464 const EnsPKaryotypeband kb)
465 {
466 return (kb) ? kb->Identifier : 0U;
467 }
468
469
470
471
472 /* @func ensKaryotypebandGetName **********************************************
473 **
474 ** Get the name member of an Ensembl Karyotype Band.
475 **
476 ** @param [r] kb [const EnsPKaryotypeband] Ensembl Karyotype Band
477 **
478 ** @return [AjPStr] Name or NULL
479 **
480 ** @release 6.2.0
481 ** @@
482 ******************************************************************************/
483
ensKaryotypebandGetName(const EnsPKaryotypeband kb)484 AjPStr ensKaryotypebandGetName(
485 const EnsPKaryotypeband kb)
486 {
487 return (kb) ? kb->Name : NULL;
488 }
489
490
491
492
493 /* @func ensKaryotypebandGetStain *********************************************
494 **
495 ** Get the stain member of an Ensembl Karyotype Band.
496 **
497 ** @param [r] kb [const EnsPKaryotypeband] Ensembl Karyotype Band
498 **
499 ** @return [AjPStr] Stain or NULL
500 **
501 ** @release 6.2.0
502 ** @@
503 ******************************************************************************/
504
ensKaryotypebandGetStain(const EnsPKaryotypeband kb)505 AjPStr ensKaryotypebandGetStain(
506 const EnsPKaryotypeband kb)
507 {
508 return (kb) ? kb->Stain : NULL;
509 }
510
511
512
513
514 /* @section modifiers *********************************************************
515 **
516 ** Functions for assigning members of an Ensembl Karyotype Band object.
517 **
518 ** @fdata [EnsPKaryotypeband]
519 **
520 ** @nam3rule Set Set one member of an Karyotype Band
521 ** @nam4rule Adaptor Set the Ensembl Karyotype Band Adaptor
522 ** @nam4rule Feature Set the Ensembl Feature
523 ** @nam4rule Identifier Set the SQL database-internal identifier
524 ** @nam4rule Name Set the name
525 ** @nam4rule Stain Set the stain
526 **
527 ** @argrule * kb [EnsPKaryotypeband] Ensembl Karyotype Band object
528 ** @argrule Adaptor kba [EnsPKaryotypebandadaptor] Ensembl Karyotype Band
529 ** Adaptor
530 ** @argrule Feature feature [EnsPFeature] Ensembl Feature
531 ** @argrule Identifier identifier [ajuint] Database identifier
532 ** @argrule Name name [AjPStr] Name
533 ** @argrule Stain stain [AjPStr] Logic name
534 **
535 ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise
536 **
537 ** @fcategory modify
538 ******************************************************************************/
539
540
541
542
543 /* @func ensKaryotypebandSetAdaptor *******************************************
544 **
545 ** Set the Ensembl Karyotype Band Adaptor member of an Ensembl Karyotype Band.
546 **
547 ** @param [u] kb [EnsPKaryotypeband] Ensembl Karyotype Band
548 ** @param [u] kba [EnsPKaryotypebandadaptor] Ensembl Karyotype Band Adaptor
549 **
550 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
551 **
552 ** @release 6.2.0
553 ** @@
554 ******************************************************************************/
555
ensKaryotypebandSetAdaptor(EnsPKaryotypeband kb,EnsPKaryotypebandadaptor kba)556 AjBool ensKaryotypebandSetAdaptor(EnsPKaryotypeband kb,
557 EnsPKaryotypebandadaptor kba)
558 {
559 if (!kb)
560 return ajFalse;
561
562 kb->Adaptor = kba;
563
564 return ajTrue;
565 }
566
567
568
569
570 /* @func ensKaryotypebandSetFeature *******************************************
571 **
572 ** Set the Ensembl Feature member of an Ensembl Karyotype Band.
573 **
574 ** @param [u] kb [EnsPKaryotypeband] Ensembl Karyotype Band
575 ** @param [u] feature [EnsPFeature] Ensembl Feature
576 **
577 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
578 **
579 ** @release 6.2.0
580 ** @@
581 ******************************************************************************/
582
ensKaryotypebandSetFeature(EnsPKaryotypeband kb,EnsPFeature feature)583 AjBool ensKaryotypebandSetFeature(EnsPKaryotypeband kb,
584 EnsPFeature feature)
585 {
586 if (!kb)
587 return ajFalse;
588
589 ensFeatureDel(&kb->Feature);
590
591 kb->Feature = ensFeatureNewRef(feature);
592
593 return ajTrue;
594 }
595
596
597
598
599 /* @func ensKaryotypebandSetIdentifier ****************************************
600 **
601 ** Set the SQL database-internal identifier member of an
602 ** Ensembl Karyotype Band.
603 **
604 ** @param [u] kb [EnsPKaryotypeband] Ensembl Karyotype Band
605 ** @param [r] identifier [ajuint] Database identifier
606 **
607 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
608 **
609 ** @release 6.2.0
610 ** @@
611 ******************************************************************************/
612
ensKaryotypebandSetIdentifier(EnsPKaryotypeband kb,ajuint identifier)613 AjBool ensKaryotypebandSetIdentifier(EnsPKaryotypeband kb,
614 ajuint identifier)
615 {
616 if (!kb)
617 return ajFalse;
618
619 kb->Identifier = identifier;
620
621 return ajTrue;
622 }
623
624
625
626
627 /* @func ensKaryotypebandSetName **********************************************
628 **
629 ** Set the name member of an Ensembl Karyotype Band.
630 **
631 ** @param [u] kb [EnsPKaryotypeband] Ensembl Karyotype Band
632 ** @param [u] name [AjPStr] Name
633 **
634 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
635 **
636 ** @release 6.2.0
637 ** @@
638 ******************************************************************************/
639
ensKaryotypebandSetName(EnsPKaryotypeband kb,AjPStr name)640 AjBool ensKaryotypebandSetName(EnsPKaryotypeband kb,
641 AjPStr name)
642 {
643 if (!kb)
644 return ajFalse;
645
646 ajStrDel(&kb->Name);
647
648 kb->Name = ajStrNewRef(name);
649
650 return ajTrue;
651 }
652
653
654
655
656 /* @func ensKaryotypebandSetStain *********************************************
657 **
658 ** Set the stain member of an Ensembl Karyotype Band.
659 **
660 ** @param [u] kb [EnsPKaryotypeband] Ensembl Karyotype Band
661 ** @param [u] stain [AjPStr] Logic name
662 **
663 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
664 **
665 ** @release 6.2.0
666 ** @@
667 ******************************************************************************/
668
ensKaryotypebandSetStain(EnsPKaryotypeband kb,AjPStr stain)669 AjBool ensKaryotypebandSetStain(EnsPKaryotypeband kb,
670 AjPStr stain)
671 {
672 if (!kb)
673 return ajFalse;
674
675 ajStrDel(&kb->Stain);
676
677 kb->Stain = ajStrNewRef(stain);
678
679 return ajTrue;
680 }
681
682
683
684
685 /* @section debugging *********************************************************
686 **
687 ** Functions for reporting of an Ensembl Karyotype Band object.
688 **
689 ** @fdata [EnsPKaryotypeband]
690 **
691 ** @nam3rule Trace Report Ensembl Karyotype Band members to debug file
692 **
693 ** @argrule Trace kb [const EnsPKaryotypeband] Ensembl Karyotype Band
694 ** @argrule Trace level [ajuint] Indentation level
695 **
696 ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise
697 **
698 ** @fcategory misc
699 ******************************************************************************/
700
701
702
703
704 /* @func ensKaryotypebandTrace ************************************************
705 **
706 ** Trace an Ensembl Karyotype Band.
707 **
708 ** @param [r] kb [const EnsPKaryotypeband] Ensembl Karyotype Band
709 ** @param [r] level [ajuint] Indentation level
710 **
711 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
712 **
713 ** @release 6.2.0
714 ** @@
715 ******************************************************************************/
716
ensKaryotypebandTrace(const EnsPKaryotypeband kb,ajuint level)717 AjBool ensKaryotypebandTrace(const EnsPKaryotypeband kb, ajuint level)
718 {
719 AjPStr indent = NULL;
720
721 if (!kb)
722 return ajFalse;
723
724 indent = ajStrNew();
725
726 ajStrAppendCountK(&indent, ' ', level * 2);
727
728 ajDebug("%SensKaryotypebandTrace %p\n"
729 "%S Adaptor %p\n"
730 "%S Identifier %u\n"
731 "%S Feature %p\n"
732 "%S Name '%S'\n"
733 "%S Stain '%S'\n",
734 indent, kb,
735 indent, kb->Adaptor,
736 indent, kb->Identifier,
737 indent, kb->Feature,
738 indent, kb->Name,
739 indent, kb->Stain);
740
741 ensFeatureTrace(kb->Feature, 1);
742
743 ajStrDel(&indent);
744
745 return ajTrue;
746 }
747
748
749
750
751 /* @section calculate *********************************************************
752 **
753 ** Functions for calculating information from an Ensembl Karyotype Band object.
754 **
755 ** @fdata [EnsPKaryotypeband]
756 **
757 ** @nam3rule Calculate Calculate Ensembl Karyotype Band information
758 ** @nam4rule Memsize Calculate the memory size in bytes
759 **
760 ** @argrule * kb [const EnsPKaryotypeband] Ensembl Karyotype Band
761 **
762 ** @valrule Memsize [size_t] Memory size in bytes or 0
763 **
764 ** @fcategory misc
765 ******************************************************************************/
766
767
768
769
770 /* @func ensKaryotypebandCalculateMemsize *************************************
771 **
772 ** Get the memory size in bytes of an Ensembl Karyotype Band.
773 **
774 ** @param [r] kb [const EnsPKaryotypeband] Ensembl Karyotype Band
775 **
776 ** @return [size_t] Memory size in bytes or 0
777 **
778 ** @release 6.4.0
779 ** @@
780 ******************************************************************************/
781
ensKaryotypebandCalculateMemsize(const EnsPKaryotypeband kb)782 size_t ensKaryotypebandCalculateMemsize(const EnsPKaryotypeband kb)
783 {
784 size_t size = 0;
785
786 if (!kb)
787 return 0;
788
789 size += sizeof (EnsOKaryotypeband);
790
791 size += ensFeatureCalculateMemsize(kb->Feature);
792
793 if (kb->Name)
794 {
795 size += sizeof (AjOStr);
796
797 size += ajStrGetRes(kb->Name);
798 }
799
800 if (kb->Stain)
801 {
802 size += sizeof (AjOStr);
803
804 size += ajStrGetRes(kb->Stain);
805 }
806
807 return size;
808 }
809
810
811
812
813 /* @datasection [AjPList] AJAX List *******************************************
814 **
815 ** @nam2rule List Functions for manipulating AJAX List objects
816 **
817 ******************************************************************************/
818
819
820
821
822 /* @funcstatic listKaryotypebandCompareEndAscending ***************************
823 **
824 ** AJAX List of Ensembl Karyotype Band objects comparison function to sort by
825 ** Ensembl Feature end coordinate in ascending order.
826 **
827 ** @param [r] item1 [const void*] Ensembl Karyotype Band address 1
828 ** @param [r] item2 [const void*] Ensembl Karyotype Band address 2
829 ** @see ajListSort
830 **
831 ** @return [int] The comparison function returns an integer less than,
832 ** equal to, or greater than zero if the first argument is
833 ** considered to be respectively less than, equal to, or
834 ** greater than the second.
835 **
836 ** @release 6.4.0
837 ** @@
838 ******************************************************************************/
839
listKaryotypebandCompareEndAscending(const void * item1,const void * item2)840 static int listKaryotypebandCompareEndAscending(
841 const void *item1,
842 const void *item2)
843 {
844 EnsPKaryotypeband kb1 = *(EnsOKaryotypeband *const *) item1;
845 EnsPKaryotypeband kb2 = *(EnsOKaryotypeband *const *) item2;
846
847 #if defined(AJ_DEBUG) && AJ_DEBUG >= 2
848 if (ajDebugTest("listKaryotypebandCompareEndAscending"))
849 ajDebug("listKaryotypebandCompareEndAscending\n"
850 " kb1 %p\n"
851 " kb2 %p\n",
852 kb1,
853 kb2);
854 #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 2 */
855
856 /* Sort empty values towards the end of the AJAX List. */
857
858 if (kb1 && (!kb2))
859 return -1;
860
861 if ((!kb1) && (!kb2))
862 return 0;
863
864 if ((!kb1) && kb2)
865 return +1;
866
867 return ensFeatureCompareEndAscending(kb1->Feature, kb2->Feature);
868 }
869
870
871
872
873 /* @funcstatic listKaryotypebandCompareEndDescending **************************
874 **
875 ** AJAX List of Ensembl Karyotype Band objects comparison function to sort by
876 ** Ensembl Feature end coordinate in descending order.
877 **
878 ** @param [r] item1 [const void*] Ensembl Karyotype Band address 1
879 ** @param [r] item2 [const void*] Ensembl Karyotype Band address 2
880 ** @see ajListSort
881 **
882 ** @return [int] The comparison function returns an integer less than,
883 ** equal to, or greater than zero if the first argument is
884 ** considered to be respectively less than, equal to, or
885 ** greater than the second.
886 **
887 ** @release 6.4.0
888 ** @@
889 ******************************************************************************/
890
listKaryotypebandCompareEndDescending(const void * item1,const void * item2)891 static int listKaryotypebandCompareEndDescending(
892 const void *item1,
893 const void *item2)
894 {
895 EnsPKaryotypeband kb1 = *(EnsOKaryotypeband *const *) item1;
896 EnsPKaryotypeband kb2 = *(EnsOKaryotypeband *const *) item2;
897
898 #if defined(AJ_DEBUG) && AJ_DEBUG >= 2
899 if (ajDebugTest("listKaryotypebandCompareEndDescending"))
900 ajDebug("listKaryotypebandCompareEndDescending\n"
901 " kb1 %p\n"
902 " kb2 %p\n",
903 kb1,
904 kb2);
905 #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 2 */
906
907 /* Sort empty values towards the end of the AJAX List. */
908
909 if (kb1 && (!kb2))
910 return -1;
911
912 if ((!kb1) && (!kb2))
913 return 0;
914
915 if ((!kb1) && kb2)
916 return +1;
917
918 return ensFeatureCompareEndDescending(kb1->Feature, kb2->Feature);
919 }
920
921
922
923
924 /* @funcstatic listKaryotypebandCompareIdentifierAscending ********************
925 **
926 ** AJAX List of Ensembl Karyotype Band objects comparison function to sort by
927 ** identifier member in ascending order.
928 **
929 ** @param [r] item1 [const void*] Ensembl Karyotype Band address 1
930 ** @param [r] item2 [const void*] Ensembl Karyotype Band address 2
931 ** @see ajListSort
932 **
933 ** @return [int] The comparison function returns an integer less than,
934 ** equal to, or greater than zero if the first argument is
935 ** considered to be respectively less than, equal to, or
936 ** greater than the second.
937 **
938 ** @release 6.4.0
939 ** @@
940 ******************************************************************************/
941
listKaryotypebandCompareIdentifierAscending(const void * item1,const void * item2)942 static int listKaryotypebandCompareIdentifierAscending(
943 const void *item1,
944 const void *item2)
945 {
946 EnsPKaryotypeband kb1 = *(EnsOKaryotypeband *const *) item1;
947 EnsPKaryotypeband kb2 = *(EnsOKaryotypeband *const *) item2;
948
949 #if defined(AJ_DEBUG) && AJ_DEBUG >= 2
950 if (ajDebugTest("listKaryotypebandCompareIdentifierAscending"))
951 ajDebug("listKaryotypebandCompareIdentifierAscending\n"
952 " kb1 %p\n"
953 " kb2 %p\n",
954 kb1,
955 kb2);
956 #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 2 */
957
958 /* Sort empty values towards the end of the AJAX List. */
959
960 if (kb1 && (!kb2))
961 return -1;
962
963 if ((!kb1) && (!kb2))
964 return 0;
965
966 if ((!kb1) && kb2)
967 return +1;
968
969 if (kb1->Identifier < kb2->Identifier)
970 return -1;
971
972 if (kb1->Identifier > kb2->Identifier)
973 return +1;
974
975 return 0;
976 }
977
978
979
980
981 /* @funcstatic listKaryotypebandCompareStartAscending *************************
982 **
983 ** AJAX List of Ensembl Karyotype Band objects comparison function to sort by
984 ** Ensembl Feature start coordinate in ascending order.
985 **
986 ** @param [r] item1 [const void*] Ensembl Karyotype Band address 1
987 ** @param [r] item2 [const void*] Ensembl Karyotype Band address 2
988 ** @see ajListSort
989 **
990 ** @return [int] The comparison function returns an integer less than,
991 ** equal to, or greater than zero if the first argument is
992 ** considered to be respectively less than, equal to, or
993 ** greater than the second.
994 **
995 ** @release 6.4.0
996 ** @@
997 ******************************************************************************/
998
listKaryotypebandCompareStartAscending(const void * item1,const void * item2)999 static int listKaryotypebandCompareStartAscending(
1000 const void *item1,
1001 const void *item2)
1002 {
1003 EnsPKaryotypeband kb1 = *(EnsOKaryotypeband *const *) item1;
1004 EnsPKaryotypeband kb2 = *(EnsOKaryotypeband *const *) item2;
1005
1006 #if defined(AJ_DEBUG) && AJ_DEBUG >= 2
1007 if (ajDebugTest("listKaryotypebandCompareStartAscending"))
1008 ajDebug("listKaryotypebandCompareStartAscending\n"
1009 " kb1 %p\n"
1010 " kb2 %p\n",
1011 kb1,
1012 kb2);
1013 #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 2 */
1014
1015 /* Sort empty values towards the end of the AJAX List. */
1016
1017 if (kb1 && (!kb2))
1018 return -1;
1019
1020 if ((!kb1) && (!kb2))
1021 return 0;
1022
1023 if ((!kb1) && kb2)
1024 return +1;
1025
1026 return ensFeatureCompareStartAscending(kb1->Feature, kb2->Feature);
1027 }
1028
1029
1030
1031
1032 /* @funcstatic listKaryotypebandCompareStartDescending ************************
1033 **
1034 ** AJAX List of Ensembl Karyotype Band objects comparison function to sort by
1035 ** Ensembl Feature start coordinate in descending order.
1036 **
1037 ** @param [r] item1 [const void*] Ensembl Karyotype Band address 1
1038 ** @param [r] item2 [const void*] Ensembl Karyotype Band address 2
1039 ** @see ajListSort
1040 **
1041 ** @return [int] The comparison function returns an integer less than,
1042 ** equal to, or greater than zero if the first argument is
1043 ** considered to be respectively less than, equal to, or
1044 ** greater than the second.
1045 **
1046 ** @release 6.4.0
1047 ** @@
1048 ******************************************************************************/
1049
listKaryotypebandCompareStartDescending(const void * item1,const void * item2)1050 static int listKaryotypebandCompareStartDescending(
1051 const void *item1,
1052 const void *item2)
1053 {
1054 EnsPKaryotypeband kb1 = *(EnsOKaryotypeband *const *) item1;
1055 EnsPKaryotypeband kb2 = *(EnsOKaryotypeband *const *) item2;
1056
1057 #if defined(AJ_DEBUG) && AJ_DEBUG >= 2
1058 if (ajDebugTest("listKaryotypebandCompareStartDescending"))
1059 ajDebug("listKaryotypebandCompareStartDescending\n"
1060 " kb1 %p\n"
1061 " kb2 %p\n",
1062 kb1,
1063 kb2);
1064 #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 2 */
1065
1066 /* Sort empty values towards the end of the AJAX List. */
1067
1068 if (kb1 && (!kb2))
1069 return -1;
1070
1071 if ((!kb1) && (!kb2))
1072 return 0;
1073
1074 if ((!kb1) && kb2)
1075 return +1;
1076
1077 return ensFeatureCompareStartDescending(kb1->Feature, kb2->Feature);
1078 }
1079
1080
1081
1082
1083 /* @section list **************************************************************
1084 **
1085 ** Functions for manipulating AJAX List objects.
1086 **
1087 ** @fdata [AjPList]
1088 **
1089 ** @nam3rule Karyotypeband Functions for manipulating AJAX List objects of
1090 ** Ensembl Karyotype Band objects
1091 ** @nam4rule Sort Sort functions
1092 ** @nam5rule End Sort by Ensembl Feature end member
1093 ** @nam5rule Identifier Sort by identifier member
1094 ** @nam5rule Start Sort by Ensembl Feature start member
1095 ** @nam6rule Ascending Sort in ascending order
1096 ** @nam6rule Descending Sort in descending order
1097 **
1098 ** @argrule * kbs [AjPList] AJAX List of Ensembl Karyotype Band objects
1099 **
1100 ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise
1101 **
1102 ** @fcategory misc
1103 ******************************************************************************/
1104
1105
1106
1107
1108 /* @func ensListKaryotypebandSortEndAscending *********************************
1109 **
1110 ** Sort an AJAX List of Ensembl Karyotype Band objects by their
1111 ** Ensembl Feature end coordinate in ascending order.
1112 **
1113 ** @param [u] kbs [AjPList] AJAX List of Ensembl Karyotype Band objects
1114 **
1115 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
1116 **
1117 ** @release 6.4.0
1118 ** @@
1119 ******************************************************************************/
1120
ensListKaryotypebandSortEndAscending(AjPList kbs)1121 AjBool ensListKaryotypebandSortEndAscending(AjPList kbs)
1122 {
1123 if (!kbs)
1124 return ajFalse;
1125
1126 ajListSortTwoThree(kbs,
1127 &listKaryotypebandCompareEndAscending,
1128 &listKaryotypebandCompareStartAscending,
1129 &listKaryotypebandCompareIdentifierAscending);
1130
1131 return ajTrue;
1132 }
1133
1134
1135
1136
1137 /* @func ensListKaryotypebandSortEndDescending ********************************
1138 **
1139 ** Sort an AJAX List of Ensembl Karyotype Band objects by their
1140 ** Ensembl Feature end coordinate in descending order.
1141 **
1142 ** @param [u] kbs [AjPList] AJAX List of Ensembl Karyotype band objects
1143 **
1144 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
1145 **
1146 ** @release 6.4.0
1147 ** @@
1148 ******************************************************************************/
1149
ensListKaryotypebandSortEndDescending(AjPList kbs)1150 AjBool ensListKaryotypebandSortEndDescending(AjPList kbs)
1151 {
1152 if (!kbs)
1153 return ajFalse;
1154
1155 ajListSortTwoThree(kbs,
1156 &listKaryotypebandCompareEndDescending,
1157 &listKaryotypebandCompareStartDescending,
1158 &listKaryotypebandCompareIdentifierAscending);
1159
1160 return ajTrue;
1161 }
1162
1163
1164
1165
1166 /* @func ensListKaryotypebandSortIdentifierAscending **************************
1167 **
1168 ** Sort an AJAX List of Ensembl Karyotype Band objects by their
1169 ** identifier member in ascending order.
1170 **
1171 ** @param [u] kbs [AjPList] AJAX List of Ensembl Karyotype Band objects
1172 **
1173 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
1174 **
1175 ** @release 6.4.0
1176 ** @@
1177 ******************************************************************************/
1178
ensListKaryotypebandSortIdentifierAscending(AjPList kbs)1179 AjBool ensListKaryotypebandSortIdentifierAscending(AjPList kbs)
1180 {
1181 if (!kbs)
1182 return ajFalse;
1183
1184 ajListSort(kbs, &listKaryotypebandCompareIdentifierAscending);
1185
1186 return ajTrue;
1187 }
1188
1189
1190
1191
1192 /* @func ensListKaryotypebandSortStartAscending *******************************
1193 **
1194 ** Sort an AJAX List of Ensembl Karyotype Band objects by their
1195 ** Ensembl Feature start coordinate in ascending order.
1196 **
1197 ** @param [u] kbs [AjPList] AJAX List of Ensembl Karyotype Band objects
1198 **
1199 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
1200 **
1201 ** @release 6.4.0
1202 ** @@
1203 ******************************************************************************/
1204
ensListKaryotypebandSortStartAscending(AjPList kbs)1205 AjBool ensListKaryotypebandSortStartAscending(AjPList kbs)
1206 {
1207 if (!kbs)
1208 return ajFalse;
1209
1210 ajListSortTwoThree(kbs,
1211 &listKaryotypebandCompareStartAscending,
1212 &listKaryotypebandCompareEndAscending,
1213 &listKaryotypebandCompareIdentifierAscending);
1214
1215 return ajTrue;
1216 }
1217
1218
1219
1220
1221 /* @func ensListKaryotypebandSortStartDescending ******************************
1222 **
1223 ** Sort an AJAX List of Ensembl Karyotype Band objects by their
1224 ** Ensembl Feature start coordinate in descending order.
1225 **
1226 ** @param [u] kbs [AjPList] AJAX List of Ensembl Karyotype band objects
1227 **
1228 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
1229 **
1230 ** @release 6.4.0
1231 ** @@
1232 ******************************************************************************/
1233
ensListKaryotypebandSortStartDescending(AjPList kbs)1234 AjBool ensListKaryotypebandSortStartDescending(AjPList kbs)
1235 {
1236 if (!kbs)
1237 return ajFalse;
1238
1239 ajListSortTwoThree(kbs,
1240 &listKaryotypebandCompareStartDescending,
1241 &listKaryotypebandCompareEndDescending,
1242 &listKaryotypebandCompareIdentifierAscending);
1243
1244 return ajTrue;
1245 }
1246
1247
1248
1249
1250 /* @datasection [EnsPKaryotypebandadaptor] Ensembl Karyotype Band Adaptor *****
1251 **
1252 ** @nam2rule Karyotypebandadaptor Functions for manipulating
1253 ** Ensembl Karyotype Band Adaptor objects
1254 **
1255 ** @cc Bio::EnsEMBL::DBSQL::KaryotypeBandAdaptor
1256 ** @cc CVS Revision: 1.35
1257 ** @cc CVS Tag: branch-ensembl-68
1258 **
1259 ******************************************************************************/
1260
1261
1262
1263
1264 /* @funcstatic karyotypebandadaptorFetchAllbyStatement ************************
1265 **
1266 ** Fetch all Ensembl Karyotype Band objects via an SQL statement.
1267 **
1268 ** @param [u] ba [EnsPBaseadaptor] Ensembl Base Adaptor
1269 ** @param [r] statement [const AjPStr] SQL statement
1270 ** @param [uN] am [EnsPAssemblymapper] Ensembl Assembly Mapper
1271 ** @param [uN] slice [EnsPSlice] Ensembl Slice
1272 ** @param [u] kblist [AjPList] AJAX List of Ensembl Karyotype Band objects
1273 **
1274 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
1275 **
1276 ** @release 6.4.0
1277 ** @@
1278 ******************************************************************************/
1279
karyotypebandadaptorFetchAllbyStatement(EnsPBaseadaptor ba,const AjPStr statement,EnsPAssemblymapper am,EnsPSlice slice,AjPList kblist)1280 static AjBool karyotypebandadaptorFetchAllbyStatement(
1281 EnsPBaseadaptor ba,
1282 const AjPStr statement,
1283 EnsPAssemblymapper am,
1284 EnsPSlice slice,
1285 AjPList kblist)
1286 {
1287 ajuint identifier = 0U;
1288
1289 ajuint srid = 0U;
1290 ajuint srstart = 0U;
1291 ajuint srend = 0U;
1292 ajint srstrand = 1;
1293
1294 AjPStr name = NULL;
1295 AjPStr stain = NULL;
1296
1297 AjPSqlstatement sqls = NULL;
1298 AjISqlrow sqli = NULL;
1299 AjPSqlrow sqlr = NULL;
1300
1301 EnsPDatabaseadaptor dba = NULL;
1302
1303 EnsPFeature feature = NULL;
1304
1305 EnsPKaryotypeband kb = NULL;
1306 EnsPKaryotypebandadaptor kba = NULL;
1307
1308 if (ajDebugTest("karyotypebandadaptorFetchAllbyStatement"))
1309 ajDebug("karyotypebandadaptorFetchAllbyStatement\n"
1310 " ba %p\n"
1311 " statement %p\n"
1312 " am %p\n"
1313 " slice %p\n"
1314 " kblist %p\n",
1315 ba,
1316 statement,
1317 am,
1318 slice,
1319 kblist);
1320
1321 if (!ba)
1322 return ajFalse;
1323
1324 if (!statement)
1325 return ajFalse;
1326
1327 if (!kblist)
1328 return ajFalse;
1329
1330 dba = ensBaseadaptorGetDatabaseadaptor(ba);
1331
1332 kba = ensRegistryGetKaryotypebandadaptor(dba);
1333
1334 sqls = ensDatabaseadaptorSqlstatementNew(dba, statement);
1335
1336 sqli = ajSqlrowiterNew(sqls);
1337
1338 while (!ajSqlrowiterDone(sqli))
1339 {
1340 identifier = 0;
1341 srid = 0;
1342 srstart = 0;
1343 srend = 0;
1344 name = ajStrNew();
1345 stain = ajStrNew();
1346
1347 sqlr = ajSqlrowiterGet(sqli);
1348
1349 ajSqlcolumnToUint(sqlr, &identifier);
1350 ajSqlcolumnToUint(sqlr, &srid);
1351 ajSqlcolumnToUint(sqlr, &srstart);
1352 ajSqlcolumnToUint(sqlr, &srend);
1353 ajSqlcolumnToStr(sqlr, &name);
1354 ajSqlcolumnToStr(sqlr, &stain);
1355
1356 ensBaseadaptorRetrieveFeature(ba,
1357 0U,
1358 srid,
1359 srstart,
1360 srend,
1361 srstrand,
1362 am,
1363 slice,
1364 &feature);
1365
1366 if (!feature)
1367 {
1368 ajStrDel(&name);
1369 ajStrDel(&stain);
1370
1371 continue;
1372 }
1373
1374 kb = ensKaryotypebandNewIni(kba, identifier, feature, name, stain);
1375
1376 ajListPushAppend(kblist, (void *) kb);
1377
1378 ensFeatureDel(&feature);
1379
1380 ajStrDel(&name);
1381 ajStrDel(&stain);
1382 }
1383
1384 ajSqlrowiterDel(&sqli);
1385
1386 ensDatabaseadaptorSqlstatementDel(dba, &sqls);
1387
1388 return ajTrue;
1389 }
1390
1391
1392
1393
1394 /* @section constructors ******************************************************
1395 **
1396 ** All constructors return a new Ensembl Karyotype Band Adaptor by pointer.
1397 ** It is the responsibility of the user to first destroy any previous
1398 ** Karyotype Band Adaptor. The target pointer does not need to be
1399 ** initialised to NULL, but it is good programming practice to do so anyway.
1400 **
1401 ** @fdata [EnsPKaryotypebandadaptor]
1402 **
1403 ** @nam3rule New Constructor
1404 **
1405 ** @argrule New dba [EnsPDatabaseadaptor] Ensembl Database Adaptor
1406 **
1407 ** @valrule * [EnsPKaryotypebandadaptor] Ensembl Karyotype Band Adaptor or NULL
1408 **
1409 ** @fcategory new
1410 ******************************************************************************/
1411
1412
1413
1414
1415 /* @func ensKaryotypebandadaptorNew *******************************************
1416 **
1417 ** Default constructor for an Ensembl Karyotype Band Adaptor.
1418 **
1419 ** Ensembl Object Adaptors are singleton objects in the sense that a single
1420 ** instance of an Ensembl Object Adaptor connected to a particular database is
1421 ** sufficient to instantiate any number of Ensembl Objects from the database.
1422 ** Each Ensembl Object will have a weak reference to the Object Adaptor that
1423 ** instantiated it. Therefore, Ensembl Object Adaptors should not be
1424 ** instantiated directly, but rather obtained from the Ensembl Registry,
1425 ** which will in turn call this function if neccessary.
1426 **
1427 ** @see ensRegistryGetDatabaseadaptor
1428 ** @see ensRegistryGetKaryotypebandadaptor
1429 **
1430 ** @param [u] dba [EnsPDatabaseadaptor] Ensembl Database Adaptor
1431 **
1432 ** @return [EnsPKaryotypebandadaptor] Ensembl Karyotype Band Adaptor or NULL
1433 **
1434 ** @release 6.2.0
1435 ** @@
1436 ******************************************************************************/
1437
ensKaryotypebandadaptorNew(EnsPDatabaseadaptor dba)1438 EnsPKaryotypebandadaptor ensKaryotypebandadaptorNew(
1439 EnsPDatabaseadaptor dba)
1440 {
1441 return ensFeatureadaptorNew(
1442 dba,
1443 karyotypebandadaptorKTablenames,
1444 karyotypebandadaptorKColumnnames,
1445 (const EnsPBaseadaptorLeftjoin) NULL,
1446 (const char *) NULL,
1447 (const char *) NULL,
1448 &karyotypebandadaptorFetchAllbyStatement,
1449 (void *(*)(const void *)) NULL,
1450 (void *(*)(void *)) &ensKaryotypebandNewRef,
1451 (AjBool (*)(const void *)) NULL,
1452 (void (*)(void **)) &ensKaryotypebandDel,
1453 (size_t (*)(const void *)) &ensKaryotypebandCalculateMemsize,
1454 (EnsPFeature (*)(const void *)) &ensKaryotypebandGetFeature,
1455 "Karyotype Band");
1456 }
1457
1458
1459
1460
1461 /* @section destructors *******************************************************
1462 **
1463 ** Destruction destroys all internal data structures and frees the memory
1464 ** allocated for an Ensembl Karyotype Band Adaptor object.
1465 **
1466 ** @fdata [EnsPKaryotypebandadaptor]
1467 **
1468 ** @nam3rule Del Destroy (free) an Ensembl Karyotype Band Adaptor
1469 **
1470 ** @argrule * Pkba [EnsPKaryotypebandadaptor*]
1471 ** Ensembl Karyotype Band Adaptor address
1472 **
1473 ** @valrule * [void]
1474 **
1475 ** @fcategory delete
1476 ******************************************************************************/
1477
1478
1479
1480
1481 /* @func ensKaryotypebandadaptorDel *******************************************
1482 **
1483 ** Default destructor for an Ensembl Karyotype Band Adaptor.
1484 **
1485 ** Ensembl Object Adaptors are singleton objects that are registered in the
1486 ** Ensembl Registry and weakly referenced by Ensembl Objects that have been
1487 ** instantiated by it. Therefore, Ensembl Object Adaptors should never be
1488 ** destroyed directly. Upon exit, the Ensembl Registry will call this function
1489 ** if required.
1490 **
1491 ** @param [d] Pkba [EnsPKaryotypebandadaptor*]
1492 ** Ensembl Karyotype Band Adaptor address
1493 **
1494 ** @return [void]
1495 **
1496 ** @release 6.2.0
1497 ** @@
1498 ******************************************************************************/
1499
ensKaryotypebandadaptorDel(EnsPKaryotypebandadaptor * Pkba)1500 void ensKaryotypebandadaptorDel(EnsPKaryotypebandadaptor *Pkba)
1501 {
1502 ensFeatureadaptorDel(Pkba);
1503
1504 return;
1505 }
1506
1507
1508
1509
1510 /* @section member retrieval **************************************************
1511 **
1512 ** Functions for returning members of an
1513 ** Ensembl Karyotype Band Adaptor object.
1514 **
1515 ** @fdata [EnsPKaryotypebandadaptor]
1516 **
1517 ** @nam3rule Get Return Ensembl Karyotype Band Adaptor attribute(s)
1518 ** @nam4rule Baseadaptor Return the Ensembl Base Adaptor
1519 ** @nam4rule Databaseadaptor Return the Ensembl Database Adaptor
1520 ** @nam4rule Featureadaptor Return the Ensembl Feature Adaptor
1521 **
1522 ** @argrule * kba [EnsPKaryotypebandadaptor] Ensembl Karyotype Band Adaptor
1523 **
1524 ** @valrule Baseadaptor [EnsPBaseadaptor]
1525 ** Ensembl Base Adaptor or NULL
1526 ** @valrule Databaseadaptor [EnsPDatabaseadaptor]
1527 ** Ensembl Database Adaptor or NULL
1528 ** @valrule Featureadaptor [EnsPFeatureadaptor]
1529 ** Ensembl Feature Adaptor or NULL
1530 **
1531 ** @fcategory use
1532 ******************************************************************************/
1533
1534
1535
1536
1537 /* @func ensKaryotypebandadaptorGetBaseadaptor ********************************
1538 **
1539 ** Get the Ensembl Base Adaptor member of an
1540 ** Ensembl Karyotype Band Adaptor.
1541 **
1542 ** @param [u] kba [EnsPKaryotypebandadaptor] Ensembl Karyotype Band Adaptor
1543 **
1544 ** @return [EnsPBaseadaptor] Ensembl Base Adaptor or NULL
1545 **
1546 ** @release 6.5.0
1547 ** @@
1548 ******************************************************************************/
1549
ensKaryotypebandadaptorGetBaseadaptor(EnsPKaryotypebandadaptor kba)1550 EnsPBaseadaptor ensKaryotypebandadaptorGetBaseadaptor(
1551 EnsPKaryotypebandadaptor kba)
1552 {
1553 return ensFeatureadaptorGetBaseadaptor(
1554 ensKaryotypebandadaptorGetFeatureadaptor(kba));
1555 }
1556
1557
1558
1559
1560 /* @func ensKaryotypebandadaptorGetDatabaseadaptor ****************************
1561 **
1562 ** Get the Ensembl Database Adaptor member of an
1563 ** Ensembl Karyotype Band Adaptor.
1564 **
1565 ** @param [u] kba [EnsPKaryotypebandadaptor] Ensembl Karyotype Band Adaptor
1566 **
1567 ** @return [EnsPDatabaseadaptor] Ensembl Database Adaptor or NULL
1568 **
1569 ** @release 6.4.0
1570 ** @@
1571 ******************************************************************************/
1572
ensKaryotypebandadaptorGetDatabaseadaptor(EnsPKaryotypebandadaptor kba)1573 EnsPDatabaseadaptor ensKaryotypebandadaptorGetDatabaseadaptor(
1574 EnsPKaryotypebandadaptor kba)
1575 {
1576 return ensFeatureadaptorGetDatabaseadaptor(
1577 ensKaryotypebandadaptorGetFeatureadaptor(kba));
1578 }
1579
1580
1581
1582
1583 /* @func ensKaryotypebandadaptorGetFeatureadaptor *****************************
1584 **
1585 ** Get the Ensembl Feature Adaptor member of an
1586 ** Ensembl Karyotype Band Adaptor.
1587 **
1588 ** @param [u] kba [EnsPKaryotypebandadaptor] Ensembl Karyotype Band Adaptor
1589 **
1590 ** @return [EnsPFeatureadaptor] Ensembl Feature or NULL
1591 **
1592 ** @release 6.5.0
1593 ** @@
1594 ******************************************************************************/
1595
ensKaryotypebandadaptorGetFeatureadaptor(EnsPKaryotypebandadaptor kba)1596 EnsPFeatureadaptor ensKaryotypebandadaptorGetFeatureadaptor(
1597 EnsPKaryotypebandadaptor kba)
1598 {
1599 return kba;
1600 }
1601
1602
1603
1604
1605 /* @section canonical object retrieval ****************************************
1606 **
1607 ** Functions for fetching Ensembl Karyotype Band objects from an
1608 ** Ensembl SQL database.
1609 **
1610 ** @fdata [EnsPKaryotypebandadaptor]
1611 **
1612 ** @nam3rule Fetch Fetch Ensembl Karyotype Band object(s)
1613 ** @nam4rule All Fetch all Ensembl Karyotype Band objects
1614 ** @nam4rule Allby Fetch all Ensembl Karyotype Band objects matching a
1615 ** criterion
1616 ** @nam5rule Chromosomeband Fetch all by a chromosome band
1617 ** @nam5rule Chromosomename Fetch all by a chromosome name
1618 ** @nam5rule Slice Fetch all by an Ensembl Slice
1619 ** @nam4rule By Fetch one Ensembl Karyotype Band object matching a criterion
1620 ** @nam5rule Identifier Fetch by SQL database-internal identifier
1621 **
1622 ** @argrule * kba [EnsPKaryotypebandadaptor] Ensembl Karyotype Band Adaptor
1623 ** @argrule All kbs [AjPList] AJAX List of Ensembl Karyotype Band objects
1624 ** @argrule AllbySlice slice [EnsPSlice] Ensembl Slice
1625 ** @argrule AllbySlice constraint [const AjPStr] SQL constraint
1626 ** @argrule AllbySlice kbs [AjPList] AJAX List of Ensembl Karyotype Band
1627 ** objects
1628 ** @argrule AllbyChromosomeband name [const AjPStr] Chromosome name
1629 ** @argrule AllbyChromosomeband band [const AjPStr] Karyotype Band name
1630 ** @argrule AllbyChromosomeband kblist [AjPList] AJAX List of Ensembl
1631 ** Karyotype Band objects
1632 ** @argrule AllbyChromosomename name [const AjPStr] Chromosome name
1633 ** @argrule AllbyChromosomename kblist [AjPList] AJAX List of Ensembl
1634 ** Karyotype Band objects
1635 ** @argrule ByIdentifier identifier [ajuint] SQL database-internal identifier
1636 ** @argrule ByIdentifier Pkb [EnsPKaryotypeband*] Ensembl Karyotype Band
1637 ** address
1638 **
1639 ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise
1640 **
1641 ** @fcategory use
1642 ******************************************************************************/
1643
1644
1645
1646
1647 /* @func ensKaryotypebandadaptorFetchAllbyChromosomeband **********************
1648 **
1649 ** Fetch all Ensembl Karyotype Band objects via a chromosome and band name.
1650 **
1651 ** This function uses fuzzy matching of the band name.
1652 ** For example the bands 'q23.1' and 'q23.4' could be matched by 'q23'.
1653 **
1654 ** @cc Bio::EnsEMBL::DBSQL::Karyotypebandadaptor::fetch_all_by_chr_band
1655 ** @param [u] kba [EnsPKaryotypebandadaptor] Ensembl Karyotype Band Adaptor
1656 ** @param [r] name [const AjPStr] Chromosome name
1657 ** @param [r] band [const AjPStr] Karyotype Band name
1658 ** @param [u] kblist [AjPList] AJAX List of Ensembl Karyotype Band objects
1659 **
1660 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
1661 **
1662 ** @release 6.4.0
1663 ** @@
1664 ******************************************************************************/
1665
ensKaryotypebandadaptorFetchAllbyChromosomeband(EnsPKaryotypebandadaptor kba,const AjPStr name,const AjPStr band,AjPList kblist)1666 AjBool ensKaryotypebandadaptorFetchAllbyChromosomeband(
1667 EnsPKaryotypebandadaptor kba,
1668 const AjPStr name,
1669 const AjPStr band,
1670 AjPList kblist)
1671 {
1672 char *txtband = NULL;
1673
1674 AjBool result = AJFALSE;
1675
1676 AjPStr constraint = NULL;
1677
1678 EnsPDatabaseadaptor dba = NULL;
1679
1680 EnsPSlice slice = NULL;
1681
1682 if (!kba)
1683 return ajFalse;
1684
1685 if (!name)
1686 return ajFalse;
1687
1688 if (!band)
1689 return ajFalse;
1690
1691 if (!kblist)
1692 return ajFalse;
1693
1694 dba = ensKaryotypebandadaptorGetDatabaseadaptor(kba);
1695
1696 ensSliceadaptorFetchBySeqregionName(
1697 ensRegistryGetSliceadaptor(dba),
1698 (const AjPStr) NULL,
1699 (const AjPStr) NULL,
1700 name,
1701 &slice);
1702
1703 if (!slice)
1704 {
1705 ajDebug("ensKaryotypebandadaptorFetchAllbyChromosomeband could not "
1706 "fetch an Ensembl Slice for chromosome name '%S'.\n", name);
1707
1708 return ajFalse;
1709 }
1710
1711 ensDatabaseadaptorEscapeC(dba, &txtband, band);
1712
1713 constraint = ajFmtStr("karyotype.band LIKE '%s%%'", txtband);
1714
1715 ajCharDel(&txtband);
1716
1717 result = ensFeatureadaptorFetchAllbySlice(
1718 ensKaryotypebandadaptorGetFeatureadaptor(kba),
1719 slice,
1720 constraint,
1721 (const AjPStr) NULL,
1722 kblist);
1723
1724 ajStrDel(&constraint);
1725
1726 ensSliceDel(&slice);
1727
1728 return result;
1729 }
1730
1731
1732
1733
1734 /* @func ensKaryotypebandadaptorFetchAllbyChromosomename **********************
1735 **
1736 ** Fetch all Ensembl Karyotype Band objects via a chromosome name.
1737 **
1738 ** @cc Bio::EnsEMBL::DBSQL::Karyotypebandadaptor::fetch_all_by_chr_name
1739 ** @param [u] kba [EnsPKaryotypebandadaptor] Ensembl Karyotype Band Adaptor
1740 ** @param [r] name [const AjPStr] Chromosome name
1741 ** @param [u] kblist [AjPList] AJAX List of Ensembl Karyotype Band objects
1742 **
1743 ** @return [AjBool] ajTrue upon success, ajFalse otherwise
1744 **
1745 ** @release 6.4.0
1746 ** @@
1747 ******************************************************************************/
1748
ensKaryotypebandadaptorFetchAllbyChromosomename(EnsPKaryotypebandadaptor kba,const AjPStr name,AjPList kblist)1749 AjBool ensKaryotypebandadaptorFetchAllbyChromosomename(
1750 EnsPKaryotypebandadaptor kba,
1751 const AjPStr name,
1752 AjPList kblist)
1753 {
1754 AjBool result = AJFALSE;
1755
1756 EnsPDatabaseadaptor dba = NULL;
1757
1758 EnsPSlice slice = NULL;
1759
1760 if (!kba)
1761 return ajFalse;
1762
1763 if (!name)
1764 return ajFalse;
1765
1766 if (!kblist)
1767 return ajFalse;
1768
1769 dba = ensKaryotypebandadaptorGetDatabaseadaptor(kba);
1770
1771 ensSliceadaptorFetchBySeqregionName(
1772 ensRegistryGetSliceadaptor(dba),
1773 (const AjPStr) NULL,
1774 (const AjPStr) NULL,
1775 name,
1776 &slice);
1777
1778 if (!slice)
1779 {
1780 ajDebug("ensKaryotypebandadaptorFetchAllbyChromosomename could not "
1781 "fetch an Ensembl Slice for chromosome name '%S'.\n", name);
1782
1783 return ajFalse;
1784 }
1785
1786 result = ensFeatureadaptorFetchAllbySlice(
1787 ensKaryotypebandadaptorGetFeatureadaptor(kba),
1788 slice,
1789 (const AjPStr) NULL,
1790 (const AjPStr) NULL,
1791 kblist);
1792
1793 ensSliceDel(&slice);
1794
1795 return result;
1796 }
1797