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