| 1 | /* @source ensgvvariation ***************************************************** |
| 2 | ** |
| 3 | ** Ensembl Genetic Variation Variation functions |
| 4 | ** |
| 5 | ** @author Copyright (C) 1999 Ensembl Developers |
| 6 | ** @author Copyright (C) 2006 Michael K. Schuster |
| 7 | ** @version $Revision: 1.36 $ |
| 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 "ensgene.h" |
| 34 | #include "ensgvallele.h" |
| 35 | #include "ensgvattribute.h" |
| 36 | #include "ensgvbaseadaptor.h" |
| 37 | #include "ensgvdatabaseadaptor.h" |
| 38 | #include "ensgvpopulation.h" |
| 39 | #include "ensgvsource.h" |
| 40 | #include "ensgvsynonym.h" |
| 41 | #include "ensgvvariation.h" |
| 42 | #include "enstable.h" |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | /* ========================================================================= */ |
| 48 | /* =============================== constants =============================== */ |
| 49 | /* ========================================================================= */ |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | /* ========================================================================= */ |
| 55 | /* =========================== global variables ============================ */ |
| 56 | /* ========================================================================= */ |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | /* ========================================================================= */ |
| 62 | /* ============================= private data ============================== */ |
| 63 | /* ========================================================================= */ |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | /* ========================================================================= */ |
| 69 | /* =========================== private constants =========================== */ |
| 70 | /* ========================================================================= */ |
| 71 | |
| 72 | /* @conststatic gvvariationKClass ********************************************* |
| 73 | ** |
| 74 | ** The Ensembl Genetic Variation Variation class member is |
| 75 | ** enumerated in both, the SQL table definition and the data structure. |
| 76 | ** The following strings are used for conversion in database operations and |
| 77 | ** correspond to EnsEGvvariationClass and the |
| 78 | ** "variation.class_so_id" field. |
| 79 | ** |
| 80 | ** #attr [static const char *const*] gvvariationKClass |
| 81 | ** ## |
| 82 | ******************************************************************************/ |
| 83 | |
| 84 | static const char *const gvvariationKClass[] = |
| 85 | { |
| 86 | "", |
| 87 | "SO:0001483", /* SNV */ |
| 88 | "SO:1000002", /* substitution */ |
| 89 | "SO:0000667", /* insertion */ |
| 90 | "SO:0000159", /* deletion */ |
| 91 | "SO:0000705", /* tandem_repeat */ |
| 92 | "SO:1000032", /* indel */ |
| 93 | "SO:0001059", /* sequence_alteration */ |
| 94 | "SO:0001019", /* copy_number_variation */ |
| 95 | (const char *) NULL |
| 96 | }; |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | /* @conststatic gvvariationKValidation **************************************** |
| 102 | ** |
| 103 | ** The Ensembl Genetic Variation Variation validation state member is |
| 104 | ** enumerated in both, the SQL table definition and the data structure. |
| 105 | ** The following strings are used for conversion in database operations and |
| 106 | ** correspond to EnsEGvvariationValidation and the |
| 107 | ** 'variation.validation_status' field. |
| 108 | ** |
| 109 | ** #attr [static const char *const*] gvvariationKValidation |
| 110 | ** ## |
| 111 | ******************************************************************************/ |
| 112 | |
| 113 | static const char *const gvvariationKValidation[] = |
| 114 | { |
| 115 | "", |
| 116 | "cluster", |
| 117 | "freq", |
| 118 | "submitter", |
| 119 | "doublehit", |
| 120 | "hapmap", |
| 121 | "1000Genome", |
| 122 | "failed", |
| 123 | "precious", |
| 124 | (const char *) NULL |
| 125 | }; |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | /* @conststatic gvvariationadaptorKTablenames ********************************* |
| 131 | ** |
| 132 | ** Array of Ensembl Genetic Variation Variation Adaptor |
| 133 | ** SQL table names |
| 134 | ** |
| 135 | ******************************************************************************/ |
| 136 | |
| 137 | static const char *const gvvariationadaptorKTablenames[] = |
| 138 | { |
| 139 | "variation", |
| 140 | "source source1", |
| 141 | "variation_synonym", |
| 142 | "source source2", |
| 143 | (const char *) NULL |
| 144 | }; |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | /* @conststatic gvvariationadaptorKColumnnames ******************************** |
| 150 | ** |
| 151 | ** Array of Ensembl Genetic Variation Variation Adaptor |
| 152 | ** SQL column names |
| 153 | ** |
| 154 | ******************************************************************************/ |
| 155 | |
| 156 | static const char *const gvvariationadaptorKColumnnames[] = |
| 157 | { |
| 158 | "variation.variation_id", |
| 159 | "variation.source_id", |
| 160 | "variation.v.name", |
| 161 | "variation.validation_status", |
| 162 | "variation.ancestral_allele", |
| 163 | "variation.class_attrib_id", |
| 164 | "variation.somatic", |
| 165 | "variation.flipped", |
| 166 | "variation.minor_allele", |
| 167 | "variation.minor_count", |
| 168 | "variation.minor_freq", |
| 169 | "variation.clinical_significance_attrib_id", |
| 170 | "variation_synonym.variation_synonym_id", |
| 171 | "variation_synonym.subsnp_id", |
| 172 | "variation_synonym.source_id", |
| 173 | "variation_synonym.name", |
| 174 | "variation_synonym.moltype", |
| 175 | (const char *) NULL |
| 176 | }; |
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | /* @conststatic gvvariationadaptorKLeftjoins ********************************** |
| 182 | ** |
| 183 | ** Array of Ensembl Genetic Variation Adaptor SQL LEFT JOIN conditions |
| 184 | ** |
| 185 | ******************************************************************************/ |
| 186 | |
| 187 | static const EnsOBaseadaptorLeftjoin gvvariationadaptorKLeftjoins[] = |
| 188 | { |
| 189 | { |
| 190 | "variation_synonym", |
| 191 | "variation.variation_id = variation_synonym.variation_id" |
| 192 | }, |
| 193 | { |
| 194 | "source source2", |
| 195 | "variation_synonym.source_id = source2.source_id", |
| 196 | }, |
| 197 | {(const char *) NULL, (const char *) NULL} |
| 198 | }; |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | /* @conststatic gvvariationadaptorKDefaultcondition *************************** |
| 204 | ** |
| 205 | ** Ensembl Genetic Variation Variation Adaptor SQL SELECT default condition |
| 206 | ** |
| 207 | ******************************************************************************/ |
| 208 | |
| 209 | static const char *gvvariationadaptorKDefaultcondition = |
| 210 | "variation.source_id = source1.source_id"; |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | /* @conststatic gvvariationfeatureadaptorKTablenames ************************** |
| 216 | ** |
| 217 | ** Array of Ensembl Genetic Variation Variation Feature Adaptor |
| 218 | ** SQL table names |
| 219 | ** |
| 220 | ******************************************************************************/ |
| 221 | |
| 222 | static const char *const gvvariationfeatureadaptorKTablenames[] = |
| 223 | { |
| 224 | "variation_feature", |
| 225 | "source", |
| 226 | "failed_variation", |
| 227 | (const char *) NULL |
| 228 | }; |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | /* @conststatic gvvariationfeatureadaptorKColumnnames ************************* |
| 234 | ** |
| 235 | ** Array of Ensembl Genetic Variation Variation Feature Adaptor |
| 236 | ** SQL column names |
| 237 | ** |
| 238 | ******************************************************************************/ |
| 239 | |
| 240 | static const char *const gvvariationfeatureadaptorKColumnnames[] = |
| 241 | { |
| 242 | "variation_feature.variation_feature_id", |
| 243 | "variation_feature.seq_region_id", |
| 244 | "variation_feature.seq_region_start", |
| 245 | "variation_feature.seq_region_end", |
| 246 | "variation_feature.seq_region_strand", |
| 247 | "variation_feature.variation_id", |
| 248 | "variation_feature.allele_string", |
| 249 | "variation_feature.variation_name", |
| 250 | "variation_feature.map_weight", |
| 251 | "variation_feature.source_id", |
| 252 | "variation_feature.validation_status", |
| 253 | "variation_feature.consequence_type", |
| 254 | "variation_feature.class_so_id", |
| 255 | (const char *) NULL |
| 256 | }; |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | /* @conststatic gvvariationfeatureadaptorKLeftjoins *************************** |
| 262 | ** |
| 263 | ** Array of Ensembl Genetic Variation Feature Adaptor SQL LEFT JOIN conditions |
| 264 | ** |
| 265 | ******************************************************************************/ |
| 266 | |
| 267 | static const EnsOBaseadaptorLeftjoin gvvariationfeatureadaptorKLeftjoins[] = |
| 268 | { |
| 269 | { |
| 270 | "failed_variation", |
| 271 | "variation_feature.variation_id = failed_variation.variation_id" |
| 272 | }, |
| 273 | {(const char *) NULL, (const char *) NULL} |
| 274 | }; |
| 275 | |
| 276 | |
| 277 | |
| 278 | |
| 279 | /* @conststatic gvvariationfeatureadaptorKDefaultcondition ******************** |
| 280 | ** |
| 281 | ** Ensembl Genetic Variation Variation Feature Adaptor |
| 282 | ** SQL SELECT default condition |
| 283 | ** |
| 284 | ******************************************************************************/ |
| 285 | |
| 286 | static const char *gvvariationfeatureadaptorKDefaultcondition = |
| 287 | "variation_feature.source_id = source.source_id"; |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | /* @conststatic gvvariationsetadaptorKTablenames ****************************** |
| 293 | ** |
| 294 | ** Array of Ensembl Genetic Variation Variation Set Adaptor |
| 295 | ** SQL table names |
| 296 | ** |
| 297 | ******************************************************************************/ |
| 298 | |
| 299 | static const char *const gvvariationsetadaptorKTablenames[] = |
| 300 | { |
| 301 | "variation_set", |
| 302 | (const char *) NULL |
| 303 | }; |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | /* @conststatic gvvariationsetadaptorKColumnnames ***************************** |
| 309 | ** |
| 310 | ** Array of Ensembl Genetic Variation Variation Set Adaptor |
| 311 | ** SQL column names |
| 312 | ** |
| 313 | ******************************************************************************/ |
| 314 | |
| 315 | static const char *const gvvariationsetadaptorKColumnnames[] = |
| 316 | { |
| 317 | "variation_set.variation_set_id", |
| 318 | "variation_set.name", |
| 319 | "variation_set.description" |
| 320 | "variation_set.short_name_attrib_id", |
| 321 | (const char *) NULL |
| 322 | }; |
| 323 | |
| 324 | |
| 325 | |
| 326 | |
| 327 | /* ========================================================================= */ |
| 328 | /* =========================== private variables =========================== */ |
| 329 | /* ========================================================================= */ |
| 330 | |
| 331 | /* #varstatic array elements ************************************************** |
| 332 | ** |
| 333 | ** #value [ajuint] gvvariationadaptorGColumnnamesElements |
| 334 | ** Number of gvvariationsetadaptorKColumnnames elements |
| 335 | ** #value [ajuint] gvvariationadaptorGTablenamesElements |
| 336 | ** Number of gvvariationsetadaptorKTable elements |
| 337 | ** #value [ajuint] gvvariationadaptorGLeftjoinsElements |
| 338 | ** Number of gvvariationsetadaptorKLeftjoins elements |
| 339 | ** |
| 340 | ******************************************************************************/ |
| 341 | |
| 342 | static ajuint gvvariationadaptorGColumnnamesElements = 0U; |
| 343 | static ajuint gvvariationadaptorGTablenamesElements = 0U; |
| 344 | static ajuint gvvariationadaptorGLeftjoinsElements = 0U; |
| 345 | |
| 346 | |
| 347 | |
| 348 | |
| 349 | /* ========================================================================= */ |
| 350 | /* =========================== private functions =========================== */ |
| 351 | /* ========================================================================= */ |
| 352 | |
| 353 | static int listGvvariationCompareIdentifierAscending( |
| 354 | const void *item1, |
| 355 | const void *item2); |
| 356 | |
| 357 | static void listGvvariationDelete(void **Pitem, void *cl); |
| 358 | |
| 359 | static AjBool gvvariationadaptorFetchAllbyConstraint( |
| 360 | EnsPGvvariationadaptor gvva, |
| 361 | const AjPStr constraint, |
| 362 | AjBool joinallele, |
| 363 | AjBool joinflank, |
| 364 | AjBool joinsource, |
| 365 | AjPList gvvs); |
| 366 | |
| 367 | static AjBool gvvariationadaptorFetchAllbyStatement( |
| 368 | EnsPBaseadaptor ba, |
| 369 | const AjPStr statement, |
| 370 | EnsPAssemblymapper am, |
| 371 | EnsPSlice slice, |
| 372 | AjPList gvvs); |
| 373 | |
| 374 | static AjBool gvvariationadaptorFetchAllbyNames( |
| 375 | EnsPGvvariationadaptor gvva, |
| 376 | AjBool synonym, |
| 377 | AjBool subsnp, |
| 378 | AjPTable gvvnamestogvv, |
| 379 | AjPTable *Pgvvidentifiers); |
| 380 | |
| 381 | static AjBool gvvariationadaptorRetrieveAllFaileddescriptions( |
| 382 | EnsPGvvariationadaptor gvva, |
| 383 | ajuint identifier, |
| 384 | const AjPStr constraint, |
| 385 | AjPTable fvs); |
| 386 | |
| 387 | static AjBool gvvariationadaptorRetrieveFlankFromCore( |
| 388 | EnsPGvvariationadaptor gvva, |
| 389 | ajuint srid, |
| 390 | ajint srstart, |
| 391 | ajint srend, |
| 392 | ajint srstrand, |
| 393 | AjPStr *Psequence); |
| 394 | |
| 395 | static int listGvvariationfeatureCompareEndAscending( |
| 396 | const void *item1, |
| 397 | const void *item2); |
| 398 | |
| 399 | static int listGvvariationfeatureCompareEndDescending( |
| 400 | const void *item1, |
| 401 | const void *item2); |
| 402 | |
| 403 | static int listGvvariationfeatureCompareIdentifierAscending( |
| 404 | const void *item1, |
| 405 | const void *item2); |
| 406 | |
| 407 | static int listGvvariationfeatureCompareStartAscending( |
| 408 | const void *item1, |
| 409 | const void *item2); |
| 410 | |
| 411 | static int listGvvariationfeatureCompareStartDescending( |
| 412 | const void *item1, |
| 413 | const void *item2); |
| 414 | |
| 415 | static AjBool gvvariationfeatureadaptorFetchAllbyStatement( |
| 416 | EnsPBaseadaptor ba, |
| 417 | const AjPStr statement, |
| 418 | EnsPAssemblymapper am, |
| 419 | EnsPSlice slice, |
| 420 | AjPList gvvfs); |
| 421 | |
| 422 | static AjBool gvvariationsetadaptorFetchAllbyStatement( |
| 423 | EnsPBaseadaptor ba, |
| 424 | const AjPStr statement, |
| 425 | EnsPAssemblymapper am, |
| 426 | EnsPSlice slice, |
| 427 | AjPList gvvss); |
| 428 | |
| 429 | static int listGvvariationsetCompareIdentifierAscending( |
| 430 | const void *item1, |
| 431 | const void *item2); |
| 432 | |
| 433 | static void listGvvariationsetDelete(void **Pitem, void *cl); |
| 434 | |
| 435 | |
| 436 | |
| 437 | |
| 438 | /* ========================================================================= */ |
| 439 | /* ======================= All functions by section ======================== */ |
| 440 | /* ========================================================================= */ |
| 441 | |
| 442 | |
| 443 | |
| 444 | |
| 445 | /* @filesection ensgvvariation ************************************************ |
| 446 | ** |
| 447 | ** @nam1rule ens Function belongs to the Ensembl library |
| 448 | ** |
| 449 | ******************************************************************************/ |
| 450 | |
| 451 | |
| 452 | |
| 453 | |
| 454 | /* @datasection [EnsPGvvariation] Ensembl Genetic Variation Variation ********* |
| 455 | ** |
| 456 | ** @nam2rule Gvvariation Functions for manipulating |
| 457 | ** Ensembl Genetic Variation Variation objects |
| 458 | ** |
| 459 | ** @cc Bio::EnsEMBL::Variation::Variation |
| 460 | ** @cc CVS Revision: 1.68 |
| 461 | ** @cc CVS Tag: branch-ensembl-68 |
| 462 | ** |
| 463 | ******************************************************************************/ |
| 464 | |
| 465 | |
| 466 | |
| 467 | |
| 468 | /* @section constructors ****************************************************** |
| 469 | ** |
| 470 | ** All constructors return a new Ensembl Genetic Variation Variation by |
| 471 | ** pointer. It is the responsibility of the user to first destroy any previous |
| 472 | ** Genetic Variation Variation. The target pointer does not need to be |
| 473 | ** initialised to NULL, but it is good programming practice to do so anyway. |
| 474 | ** |
| 475 | ** @fdata [EnsPGvvariation] |
| 476 | ** |
| 477 | ** @nam3rule New Constructor |
| 478 | ** @nam4rule Cpy Constructor with existing object |
| 479 | ** @nam4rule Ini Constructor with initial values |
| 480 | ** @nam4rule Ref Constructor by incrementing the reference counter |
| 481 | ** |
| 482 | ** @argrule Cpy gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 483 | ** @argrule Ini gvva [EnsPGvvariationadaptor] Ensembl Genetic Variation |
| 484 | ** @argrule Ini identifier [ajuint] SQL database-internal identifier |
| 485 | ** @argrule Ini gvaclass [EnsPGvattribute] Class |
| 486 | ** @argrule Ini gvaclinical [EnsPGvattribute] Clinical Significance |
| 487 | ** @argrule Ini gvsource [EnsPGvsource] Ensembl Genetic Variation Source |
| 488 | ** @argrule Ini name [AjPStr] Name |
| 489 | ** @argrule Ini ancestralallele [AjPStr] Ancestral allele |
| 490 | ** @argrule Ini gvalleles [AjPList] |
| 491 | ** AJAX List of Ensembl Genetic Variation Allele objects |
| 492 | ** @argrule Ini gvsynonyms [AjPList] |
| 493 | ** AJAX List of Ensembl Genetic Variation Synonym objects |
| 494 | ** @argrule Ini validationstates [AjPStr] |
| 495 | ** Comma-separated list of validation states |
| 496 | ** @argrule Ini moltype [AjPStr] Molecule type |
| 497 | ** @argrule Ini flankfive [AjPStr] Five-prime flanking sequence |
| 498 | ** @argrule Ini flankthree [AjPStr] Three-prime flanking sequence |
| 499 | ** @argrule Ini flankexists [AjBool] Flanking sequence exists |
| 500 | ** @argrule Ini flipped [AjBool] Flipped from reverse to forward strand |
| 501 | ** @argrule Ini somatic [AjBool] Somatic or germline flag |
| 502 | ** @argrule Ini maallele [AjPStr] Minor allele allele |
| 503 | ** @argrule Ini macount [ajuint] Minor allele count |
| 504 | ** @argrule Ini mafrequency [float] Minor allele frequency |
| 505 | ** @argrule Ref gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 506 | ** |
| 507 | ** @valrule * [EnsPGvvariation] Ensembl Genetic Variation Variation or NULL |
| 508 | ** |
| 509 | ** @fcategory new |
| 510 | ******************************************************************************/ |
| 511 | |
| 512 | |
| 513 | |
| 514 | |
| 515 | /* @func ensGvvariationNewCpy ************************************************* |
| 516 | ** |
| 517 | ** Object-based constructor function, which returns an independent object. |
| 518 | ** |
| 519 | ** @param [r] gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 520 | ** |
| 521 | ** @return [EnsPGvvariation] Ensembl Genetic Variation Variation or NULL |
| 522 | ** |
| 523 | ** @release 6.4.0 |
| 524 | ** @@ |
| 525 | ******************************************************************************/ |
| 526 | |
| 527 | EnsPGvvariation ensGvvariationNewCpy(const EnsPGvvariation gvv) |
| 528 | { |
| 529 | AjIList iter = NULL; |
| 530 | |
| 531 | AjPStr description = NULL; |
| 532 | |
| 533 | EnsPGvallele gva = NULL; |
| 534 | |
| 535 | EnsPGvsynonym gvsynonym = NULL; |
| 536 | |
| 537 | EnsPGvvariation pthis = NULL; |
| 538 | |
| 539 | if (!gvv) |
| 540 | return NULL; |
| 541 | |
| 542 | AJNEW0(pthis); |
| 543 | |
| 544 | pthis->Use = 1U; |
| 545 | pthis->Identifier = gvv->Identifier; |
| 546 | pthis->Adaptor = gvv->Adaptor; |
| 547 | pthis->Class = ensGvattributeNewRef(gvv->Class); |
| 548 | pthis->Clinical = ensGvattributeNewRef(gvv->Clinical); |
| 549 | pthis->Gvsource = ensGvsourceNewRef(gvv->Gvsource); |
| 550 | |
| 551 | if (gvv->Name) |
| 552 | pthis->Name = ajStrNewRef(gvv->Name); |
| 553 | |
| 554 | if (gvv->Ancestralallele) |
| 555 | pthis->Ancestralallele = ajStrNewRef(gvv->Ancestralallele); |
| 556 | |
| 557 | if (gvv->MinoralleleAllele) |
| 558 | pthis->MinoralleleAllele = ajStrNewRef(gvv->MinoralleleAllele); |
| 559 | |
| 560 | /* |
| 561 | ** NOTE: Copy the AJAX List of |
| 562 | ** Ensembl Genetic Variation Allele objects. |
| 563 | */ |
| 564 | |
| 565 | if (gvv->Gvalleles) |
| 566 | { |
| 567 | pthis->Gvalleles = ajListNew(); |
| 568 | |
| 569 | iter = ajListIterNew(gvv->Gvalleles); |
| 570 | |
| 571 | while (!ajListIterDone(iter)) |
| 572 | { |
| 573 | gva = (EnsPGvallele) ajListIterGet(iter); |
| 574 | |
| 575 | ajListPushAppend(pthis->Gvalleles, |
| 576 | (void *) ensGvalleleNewRef(gva)); |
| 577 | } |
| 578 | |
| 579 | ajListIterDel(&iter); |
| 580 | } |
| 581 | |
| 582 | /* |
| 583 | ** NOTE: Copy the AJAX List of |
| 584 | ** Ensembl Genetic Variation Synonym objects. |
| 585 | */ |
| 586 | |
| 587 | if (gvv->Gvsynonyms) |
| 588 | { |
| 589 | pthis->Gvsynonyms = ajListNew(); |
| 590 | |
| 591 | iter = ajListIterNew(gvv->Gvsynonyms); |
| 592 | |
| 593 | while (!ajListIterDone(iter)) |
| 594 | { |
| 595 | gvsynonym = (EnsPGvsynonym) ajListIterGet(iter); |
| 596 | |
| 597 | ajListPushAppend(pthis->Gvsynonyms, |
| 598 | (void *) ensGvsynonymNewRef(gvsynonym)); |
| 599 | } |
| 600 | |
| 601 | ajListIterDel(&iter); |
| 602 | } |
| 603 | |
| 604 | /* NOTE: Copy the AJAX List of AJAX String (failed description) objects. */ |
| 605 | |
| 606 | if (gvv->Faileddescriptions) |
| 607 | { |
| 608 | pthis->Faileddescriptions = ajListstrNew(); |
| 609 | |
| 610 | iter = ajListIterNew(gvv->Faileddescriptions); |
| 611 | |
| 612 | while (!ajListIterDone(iter)) |
| 613 | { |
| 614 | description = ajListstrIterGet(iter); |
| 615 | |
| 616 | if (description) |
| 617 | ajListstrPushAppend(pthis->Faileddescriptions, |
| 618 | ajStrNewS(description)); |
| 619 | } |
| 620 | |
| 621 | ajListIterDel(&iter); |
| 622 | } |
| 623 | |
| 624 | if (gvv->Moleculetype) |
| 625 | pthis->Moleculetype = ajStrNewRef(gvv->Moleculetype); |
| 626 | |
| 627 | if (gvv->FlankFive) |
| 628 | pthis->FlankFive = ajStrNewRef(gvv->FlankFive); |
| 629 | |
| 630 | if (gvv->FlankThree) |
| 631 | pthis->FlankThree = ajStrNewRef(gvv->FlankThree); |
| 632 | |
| 633 | pthis->FlankExists = gvv->FlankExists; |
| 634 | pthis->Somatic = gvv->Somatic; |
| 635 | pthis->Flipped = gvv->Flipped; |
| 636 | pthis->Validations = gvv->Validations; |
| 637 | |
| 638 | pthis->MinoralleleCount = gvv->MinoralleleCount; |
| 639 | pthis->MinoralleleFrequency = gvv->MinoralleleFrequency; |
| 640 | |
| 641 | return pthis; |
| 642 | } |
| 643 | |
| 644 | |
| 645 | |
| 646 | |
| 647 | /* @func ensGvvariationNewIni ************************************************* |
| 648 | ** |
| 649 | ** Constructor for an Ensembl Genetic Variation Variation with initial values. |
| 650 | ** |
| 651 | ** @cc Bio::EnsEMBL::Storable::new |
| 652 | ** @param [u] gvva [EnsPGvvariationadaptor] |
| 653 | ** Ensembl Genetic Variation Variation Adaptor |
| 654 | ** @param [r] identifier [ajuint] SQL database-internal identifier |
| 655 | ** @cc Bio::EnsEMBL::Variation::Variation::new |
| 656 | ** @param [u] gvaclass [EnsPGvattribute] Class |
| 657 | ** @param [u] gvaclinical [EnsPGvattribute] Clinical significance |
| 658 | ** @param [u] gvsource [EnsPGvsource] Ensembl Genetic Variation Source |
| 659 | ** @param [u] name [AjPStr] Name |
| 660 | ** @param [uN] ancestralallele [AjPStr] Ancestral allele |
| 661 | ** @param [uN] gvalleles [AjPList] |
| 662 | ** AJAX List of Ensembl Genetic Variation Allele objects |
| 663 | ** @param [uN] gvsynonyms [AjPList] |
| 664 | ** AJAX List of Ensembl Genetic Variation Allele objects |
| 665 | ** @param [uN] validationstates [AjPStr] |
| 666 | ** Comma-separated list of validation states |
| 667 | ** @param [uN] moltype [AjPStr] Molecule type |
| 668 | ** @param [uN] flankfive [AjPStr] Five-prime flanking sequence |
| 669 | ** @param [uN] flankthree [AjPStr] Three-prime flanking sequence |
| 670 | ** @param [r] flankexists [AjBool] Flanking sequence exists |
| 671 | ** @param [r] flipped [AjBool] Flipped from reverse to forward strand |
| 672 | ** @param [r] somatic [AjBool] Somatic or germline flag |
| 673 | ** @param [u] maallele [AjPStr] Minor allele allele |
| 674 | ** @param [r] macount [ajuint] Minor allele count |
| 675 | ** @param [r] mafrequency [float] Minor allele frequency |
| 676 | ** |
| 677 | ** @return [EnsPGvvariation] Ensembl Genetic Variation Variation or NULL |
| 678 | ** |
| 679 | ** @release 6.4.0 |
| 680 | ** @@ |
| 681 | ******************************************************************************/ |
| 682 | |
| 683 | EnsPGvvariation ensGvvariationNewIni(EnsPGvvariationadaptor gvva, |
| 684 | ajuint identifier, |
| 685 | EnsPGvattribute gvaclass, |
| 686 | EnsPGvattribute gvaclinical, |
| 687 | EnsPGvsource gvsource, |
| 688 | AjPStr name, |
| 689 | AjPStr ancestralallele, |
| 690 | AjPList gvalleles, |
| 691 | AjPList gvsynonyms, |
| 692 | AjPStr validationstates, |
| 693 | AjPStr moltype, |
| 694 | AjPStr flankfive, |
| 695 | AjPStr flankthree, |
| 696 | AjBool flankexists, |
| 697 | AjBool flipped, |
| 698 | AjBool somatic, |
| 699 | AjPStr maallele, |
| 700 | ajuint macount, |
| 701 | float mafrequency) |
| 702 | { |
| 703 | AjIList iter = NULL; |
| 704 | |
| 705 | EnsPGvallele gva = NULL; |
| 706 | |
| 707 | EnsPGvsynonym gvsynonym = NULL; |
| 708 | |
| 709 | EnsPGvvariation gvv = NULL; |
| 710 | |
| 711 | if (!gvsource) |
| 712 | return NULL; |
| 713 | |
| 714 | if (!name) |
| 715 | return NULL; |
| 716 | |
| 717 | AJNEW0(gvv); |
| 718 | |
| 719 | gvv->Use = 1U; |
| 720 | gvv->Identifier = identifier; |
| 721 | gvv->Adaptor = gvva; |
| 722 | gvv->Class = ensGvattributeNewRef(gvaclass); |
| 723 | gvv->Clinical = ensGvattributeNewRef(gvaclinical); |
| 724 | gvv->Gvsource = ensGvsourceNewRef(gvsource); |
| 725 | |
| 726 | if (name) |
| 727 | gvv->Name = ajStrNewRef(name); |
| 728 | |
| 729 | if (ancestralallele) |
| 730 | gvv->Ancestralallele = ajStrNewRef(ancestralallele); |
| 731 | |
| 732 | if (maallele) |
| 733 | gvv->MinoralleleAllele = ajStrNewRef(maallele); |
| 734 | |
| 735 | /* Copy the AJAX List of Ensembl Genetic Variation Allele objects. */ |
| 736 | |
| 737 | if (gvalleles) |
| 738 | { |
| 739 | gvv->Gvalleles = ajListNew(); |
| 740 | |
| 741 | iter = ajListIterNew(gvalleles); |
| 742 | |
| 743 | while (!ajListIterDone(iter)) |
| 744 | { |
| 745 | gva = (EnsPGvallele) ajListIterGet(iter); |
| 746 | |
| 747 | ajListPushAppend(gvv->Gvalleles, |
| 748 | (void *) ensGvalleleNewRef(gva)); |
| 749 | } |
| 750 | |
| 751 | ajListIterDel(&iter); |
| 752 | } |
| 753 | |
| 754 | /* Copy the AJAX List of Ensembl Genetic Variation Synonym objects. */ |
| 755 | |
| 756 | if (gvsynonyms) |
| 757 | { |
| 758 | gvv->Gvsynonyms = ajListNew(); |
| 759 | |
| 760 | iter = ajListIterNew(gvsynonyms); |
| 761 | |
| 762 | while (!ajListIterDone(iter)) |
| 763 | { |
| 764 | gvsynonym = (EnsPGvsynonym) ajListIterGet(iter); |
| 765 | |
| 766 | ajListPushAppend(gvv->Gvsynonyms, |
| 767 | (void *) ensGvsynonymNewRef(gvsynonym)); |
| 768 | } |
| 769 | |
| 770 | ajListIterDel(&iter); |
| 771 | } |
| 772 | |
| 773 | if (moltype) |
| 774 | gvv->Moleculetype = ajStrNewRef(moltype); |
| 775 | |
| 776 | if (flankfive) |
| 777 | gvv->FlankFive = ajStrNewRef(flankfive); |
| 778 | |
| 779 | if (flankthree) |
| 780 | gvv->FlankThree = ajStrNewRef(flankthree); |
| 781 | |
| 782 | gvv->FlankExists = flankexists; |
| 783 | gvv->Somatic = somatic; |
| 784 | gvv->Flipped = flipped; |
| 785 | gvv->Validations = ensGvvariationValidationsFromSet(validationstates); |
| 786 | |
| 787 | gvv->MinoralleleCount = macount; |
| 788 | gvv->MinoralleleFrequency = mafrequency; |
| 789 | |
| 790 | return gvv; |
| 791 | } |
| 792 | |
| 793 | |
| 794 | |
| 795 | |
| 796 | /* @func ensGvvariationNewRef ************************************************* |
| 797 | ** |
| 798 | ** Ensembl Object referencing function, which returns a pointer to the |
| 799 | ** Ensembl Object passed in and increases its reference count. |
| 800 | ** |
| 801 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 802 | ** |
| 803 | ** @return [EnsPGvvariation] Ensembl Genetic Variation Variation or NULL |
| 804 | ** |
| 805 | ** @release 6.2.0 |
| 806 | ** @@ |
| 807 | ******************************************************************************/ |
| 808 | |
| 809 | EnsPGvvariation ensGvvariationNewRef(EnsPGvvariation gvv) |
| 810 | { |
| 811 | if (!gvv) |
| 812 | return NULL; |
| 813 | |
| 814 | gvv->Use++; |
| 815 | |
| 816 | return gvv; |
| 817 | } |
| 818 | |
| 819 | |
| 820 | |
| 821 | |
| 822 | /* @section destructors ******************************************************* |
| 823 | ** |
| 824 | ** Destruction destroys all internal data structures and frees the memory |
| 825 | ** allocated for an Ensembl Genetic Variation Variation object. |
| 826 | ** |
| 827 | ** @fdata [EnsPGvvariation] |
| 828 | ** |
| 829 | ** @nam3rule Del Destroy (free) an Ensembl Genetic Variation Variation |
| 830 | ** |
| 831 | ** @argrule * Pgvv [EnsPGvvariation*] |
| 832 | ** Ensembl Genetic Variation Variation address |
| 833 | ** |
| 834 | ** @valrule * [void] |
| 835 | ** |
| 836 | ** @fcategory delete |
| 837 | ******************************************************************************/ |
| 838 | |
| 839 | |
| 840 | |
| 841 | |
| 842 | /* @func ensGvvariationDel **************************************************** |
| 843 | ** |
| 844 | ** Default destructor for an Ensembl Genetic Variation Variation. |
| 845 | ** |
| 846 | ** @param [d] Pgvv [EnsPGvvariation*] |
| 847 | ** Ensembl Genetic Variation Variation address |
| 848 | ** |
| 849 | ** @return [void] |
| 850 | ** |
| 851 | ** @release 6.2.0 |
| 852 | ** @@ |
| 853 | ******************************************************************************/ |
| 854 | |
| 855 | void ensGvvariationDel(EnsPGvvariation *Pgvv) |
| 856 | { |
| 857 | EnsPGvallele gva = NULL; |
| 858 | |
| 859 | EnsPGvsynonym gvsynonym = NULL; |
| 860 | |
| 861 | EnsPGvvariation pthis = NULL; |
| 862 | |
| 863 | if (!Pgvv) |
| 864 | return; |
| 865 | |
| 866 | #if defined(AJ_DEBUG) && AJ_DEBUG >= 1 |
| 867 | if (ajDebugTest("ensGvvariationDel")) |
| 868 | { |
| 869 | ajDebug("ensGvvariationDel\n" |
| 870 | " *Pgvv %p\n", |
| 871 | *Pgvv); |
| 872 | |
| 873 | ensGvvariationTrace(*Pgvv, 1); |
| 874 | } |
| 875 | #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 1 */ |
| 876 | |
| 877 | if (!(pthis = *Pgvv) || --pthis->Use) |
| 878 | { |
| 879 | *Pgvv = NULL; |
| 880 | |
| 881 | return; |
| 882 | } |
| 883 | |
| 884 | ensGvattributeDel(&pthis->Class); |
| 885 | ensGvattributeDel(&pthis->Clinical); |
| 886 | |
| 887 | ensGvsourceDel(&pthis->Gvsource); |
| 888 | |
| 889 | ajStrDel(&pthis->Name); |
| 890 | |
| 891 | ajStrDel(&pthis->Ancestralallele); |
| 892 | ajStrDel(&pthis->MinoralleleAllele); |
| 893 | |
| 894 | /* Clear the AJAX List of Ensembl Genetic Variation Allele objects. */ |
| 895 | |
| 896 | while (ajListPop(pthis->Gvalleles, (void **) &gva)) |
| 897 | ensGvalleleDel(&gva); |
| 898 | |
| 899 | ajListFree(&pthis->Gvalleles); |
| 900 | |
| 901 | /* Clear the AJAX List of Ensembl Genetic Variation Synonym objects. */ |
| 902 | |
| 903 | while (ajListPop(pthis->Gvsynonyms, (void **) &gvsynonym)) |
| 904 | ensGvsynonymDel(&gvsynonym); |
| 905 | |
| 906 | ajListFree(&pthis->Gvsynonyms); |
| 907 | |
| 908 | /* Clear the AJAX List of AJAX String (failed description) objects. */ |
| 909 | |
| 910 | ajListstrFreeData(&pthis->Faileddescriptions); |
| 911 | |
| 912 | ajStrDel(&pthis->Moleculetype); |
| 913 | ajStrDel(&pthis->FlankFive); |
| 914 | ajStrDel(&pthis->FlankThree); |
| 915 | |
| 916 | ajMemFree((void **) Pgvv); |
| 917 | |
| 918 | return; |
| 919 | } |
| 920 | |
| 921 | |
| 922 | |
| 923 | |
| 924 | /* @section member retrieval ************************************************** |
| 925 | ** |
| 926 | ** Functions for returning members of an |
| 927 | ** Ensembl Genetic Variation Variation object. |
| 928 | ** |
| 929 | ** @fdata [EnsPGvvariation] |
| 930 | ** |
| 931 | ** @nam3rule Get Return Genetic Variation Variation attribute(s) |
| 932 | ** @nam4rule Adaptor Return the Ensembl Genetic Variation Variation Adaptor |
| 933 | ** @nam4rule Ancestralallele Return the ancestral allele |
| 934 | ** @nam4rule Class Return the Class Ensembl Genetic Variation Attribute |
| 935 | ** @nam4rule Clinical |
| 936 | ** Return the Clinical Significance Ensembl Genetic Variation Attribute |
| 937 | ** @nam4rule Flank Return flanking sequence members |
| 938 | ** @nam4rule Flipped Return the flipped member |
| 939 | ** @nam5rule Exists Return the flanking sequence exists |
| 940 | ** @nam5rule Five Return the five-prime flanking sequence |
| 941 | ** @nam5rule Three Return the three-prime flanking sequence |
| 942 | ** @nam4rule Gvalleles Return Ensembl Genetic Variation Allele objects |
| 943 | ** @nam4rule Gvsource Return the Ensembl Genetic Variation Source |
| 944 | ** @nam4rule Gvsynonyms Return Ensembl Genetic Variation Synonms |
| 945 | ** @nam4rule Identifier Return the SQL database-internal identifier |
| 946 | ** @nam4rule Minorallele Return minor allele members |
| 947 | ** @nam5rule Allele Return the minor allele allele |
| 948 | ** @nam5rule Count Return the minor allele count |
| 949 | ** @nam5rule Frequency Return the minor allele frequency |
| 950 | ** @nam4rule Moleculetype Return the molecule type |
| 951 | ** @nam4rule Name Return the name |
| 952 | ** @nam4rule Somatic Return the somatic or germline flag |
| 953 | ** @nam4rule Validations Return the validation state bit field |
| 954 | ** |
| 955 | ** @argrule * gvv [const EnsPGvvariation] Genetic Variation Variation |
| 956 | ** |
| 957 | ** @valrule Adaptor [EnsPGvvariationadaptor] Ensembl Genetic Variation |
| 958 | ** Variation Adaptor or NULL |
| 959 | ** @valrule Ancestralallele [AjPStr] Ancestral allele or NULL |
| 960 | ** @valrule Class [EnsPGvattribute] |
| 961 | ** Class Ensembl Genetic Variation Attribute or NULL |
| 962 | ** @valrule Clinical [EnsPGvattribute] |
| 963 | ** Clinical significance Ensembl Genetic Variation Attribute |
| 964 | ** @valrule FlankFive [AjPStr] Five-prime flanking sequence or NULL |
| 965 | ** @valrule FlankThree [AjPStr] Three-prime flanking sequence or NULL |
| 966 | ** @valrule FlankExists [AjBool] Flanking sequence exists or ajFalse |
| 967 | ** @valrule Flipped [AjBool] Flipped member or ajFalse |
| 968 | ** @valrule Gvalleles [const AjPList] |
| 969 | ** Ensembl Genetic Variation Allele objects or NULL |
| 970 | ** @valrule Gvsource [EnsPGvsource] Ensembl Genetic Variation Source or NULL |
| 971 | ** @valrule Gvsynonyms [const AjPList] |
| 972 | ** Ensembl Genetic Variation Synonym objects or NULL |
| 973 | ** @valrule Identifier [ajuint] SQL database-internal identifier or 0U |
| 974 | ** @valrule Moleculetype [AjPStr] Molecule type or NULL |
| 975 | ** @valrule MinoralleleAllele [AjPStr] Minor allele allele or NULL |
| 976 | ** @valrule MinoralleleCount [ajuint] Minor allele count or 0U |
| 977 | ** @valrule MinoralleleFrequency [float] Minor allele frequency or 0.0F |
| 978 | ** @valrule Name [AjPStr] Name or NULL |
| 979 | ** @valrule Somatic [AjBool] Somatic or germline flag or ajFalse |
| 980 | ** @valrule Validations [ajuint] Validations bit field or 0U |
| 981 | ** |
| 982 | ** @fcategory use |
| 983 | ******************************************************************************/ |
| 984 | |
| 985 | |
| 986 | |
| 987 | |
| 988 | /* @func ensGvvariationGetAdaptor ********************************************* |
| 989 | ** |
| 990 | ** Get the Ensembl Genetic Variation Variation Adaptor member of an |
| 991 | ** Ensembl Genetic Variation Variation. |
| 992 | ** |
| 993 | ** @cc Bio::EnsEMBL::Storable::adaptor |
| 994 | ** @param [r] gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 995 | ** |
| 996 | ** @return [EnsPGvvariationadaptor] |
| 997 | ** Ensembl Genetic Variation Variation Adaptor or NULL |
| 998 | ** |
| 999 | ** @release 6.2.0 |
| 1000 | ** @@ |
| 1001 | ******************************************************************************/ |
| 1002 | |
| 1003 | EnsPGvvariationadaptor ensGvvariationGetAdaptor(const EnsPGvvariation gvv) |
| 1004 | { |
| 1005 | return (gvv) ? gvv->Adaptor : NULL; |
| 1006 | } |
| 1007 | |
| 1008 | |
| 1009 | |
| 1010 | |
| 1011 | /* @func ensGvvariationGetAncestralallele ************************************* |
| 1012 | ** |
| 1013 | ** Get the ancestral allele member of an Ensembl Genetic Variation Variation. |
| 1014 | ** |
| 1015 | ** @cc Bio::EnsEMBL::Variation::Variation::ancestral_allele |
| 1016 | ** @param [r] gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1017 | ** |
| 1018 | ** @return [AjPStr] Ancestral allele or NULL |
| 1019 | ** |
| 1020 | ** @release 6.4.0 |
| 1021 | ** @@ |
| 1022 | ******************************************************************************/ |
| 1023 | |
| 1024 | AjPStr ensGvvariationGetAncestralallele(const EnsPGvvariation gvv) |
| 1025 | { |
| 1026 | return (gvv) ? gvv->Ancestralallele : NULL; |
| 1027 | } |
| 1028 | |
| 1029 | |
| 1030 | |
| 1031 | |
| 1032 | /* @func ensGvvariationGetClass *********************************************** |
| 1033 | ** |
| 1034 | ** Get the class Ensembl Genetic Variation Attribute member of an |
| 1035 | ** Ensembl Genetic Variation Variation. |
| 1036 | ** |
| 1037 | ** @cc Bio::EnsEMBL::Variation::Variation::var_class |
| 1038 | ** @param [r] gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1039 | ** |
| 1040 | ** @return [EnsPGvattribute] Class Ensembl Genetic Variation Attribute or NULL |
| 1041 | ** |
| 1042 | ** @release 6.4.0 |
| 1043 | ** @@ |
| 1044 | ** FIXME: The Perl Bio::EnsEMBL::Variation::Variation::var_class method is not |
| 1045 | ** a simple accessor method, it rather assembles the class from |
| 1046 | ** Ensembl Genetic Variation Allele objects, but depends on |
| 1047 | ** Bio::EnsEMBL::Variation::Utils::Sequence::SO_variation_class. |
| 1048 | ******************************************************************************/ |
| 1049 | |
| 1050 | EnsPGvattribute ensGvvariationGetClass(const EnsPGvvariation gvv) |
| 1051 | { |
| 1052 | return (gvv) ? gvv->Class : NULL; |
| 1053 | } |
| 1054 | |
| 1055 | |
| 1056 | |
| 1057 | |
| 1058 | /* @func ensGvvariationGetClinical ******************************************** |
| 1059 | ** |
| 1060 | ** Get the clinical significance Ensembl Genetic Variation Attribute member |
| 1061 | ** of an Ensembl Genetic Variation Variation. |
| 1062 | ** |
| 1063 | ** @cc Bio::EnsEMBL::Variation::Variation::clinical_significance |
| 1064 | ** @param [r] gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1065 | ** |
| 1066 | ** @return [EnsPGvattribute] |
| 1067 | ** Clinical significance Ensembl Genetic Variation Attribute or NULL |
| 1068 | ** |
| 1069 | ** @release 6.5.0 |
| 1070 | ** @@ |
| 1071 | ******************************************************************************/ |
| 1072 | |
| 1073 | EnsPGvattribute ensGvvariationGetClinical(const EnsPGvvariation gvv) |
| 1074 | { |
| 1075 | return (gvv) ? gvv->Clinical : NULL; |
| 1076 | } |
| 1077 | |
| 1078 | |
| 1079 | |
| 1080 | |
| 1081 | /* @func ensGvvariationGetFlankExists ***************************************** |
| 1082 | ** |
| 1083 | ** Get the flanking sequence exists member of an |
| 1084 | ** Ensembl Genetic Variation Variation. |
| 1085 | ** |
| 1086 | ** @cc Bio::EnsEMBL::Variation::Variation::flank_flag |
| 1087 | ** @param [r] gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1088 | ** |
| 1089 | ** @return [AjBool] Flanking sequence exists or ajFalse |
| 1090 | ** |
| 1091 | ** @release 6.4.0 |
| 1092 | ** @@ |
| 1093 | ******************************************************************************/ |
| 1094 | |
| 1095 | AjBool ensGvvariationGetFlankExists(const EnsPGvvariation gvv) |
| 1096 | { |
| 1097 | return (gvv) ? gvv->FlankExists : ajFalse; |
| 1098 | } |
| 1099 | |
| 1100 | |
| 1101 | |
| 1102 | |
| 1103 | /* @func ensGvvariationGetFlipped ********************************************* |
| 1104 | ** |
| 1105 | ** Get the flipped member of an |
| 1106 | ** Ensembl Genetic Variation Variation. |
| 1107 | ** |
| 1108 | ** @cc Bio::EnsEMBL::Variation::Variation::flipped |
| 1109 | ** @param [r] gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1110 | ** |
| 1111 | ** @return [AjBool] Flipped member or ajFalse |
| 1112 | ** |
| 1113 | ** @release 6.4.0 |
| 1114 | ** @@ |
| 1115 | ******************************************************************************/ |
| 1116 | |
| 1117 | AjBool ensGvvariationGetFlipped(const EnsPGvvariation gvv) |
| 1118 | { |
| 1119 | return (gvv) ? gvv->Flipped : ajFalse; |
| 1120 | } |
| 1121 | |
| 1122 | |
| 1123 | |
| 1124 | |
| 1125 | /* @func ensGvvariationGetGvalleles ******************************************* |
| 1126 | ** |
| 1127 | ** Get all Ensembl Genetic Variation Allele objects of an |
| 1128 | ** Ensembl Genetic Variation Variation. |
| 1129 | ** |
| 1130 | ** @cc Bio::EnsEMBL::Variation::Variation::get_all_Alleles |
| 1131 | ** @param [r] gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1132 | ** |
| 1133 | ** @return [const AjPList] |
| 1134 | ** AJAX List of Ensembl Genetic Variation Allele objects or NULL |
| 1135 | ** |
| 1136 | ** @release 6.2.0 |
| 1137 | ** @@ |
| 1138 | ******************************************************************************/ |
| 1139 | |
| 1140 | const AjPList ensGvvariationGetGvalleles(const EnsPGvvariation gvv) |
| 1141 | { |
| 1142 | return (gvv) ? gvv->Gvalleles : NULL; |
| 1143 | } |
| 1144 | |
| 1145 | |
| 1146 | |
| 1147 | |
| 1148 | /* @func ensGvvariationGetGvsource ******************************************** |
| 1149 | ** |
| 1150 | ** Get the Ensembl Genetic Variation Source member of an |
| 1151 | ** Ensembl Genetic Variation Variation. |
| 1152 | ** |
| 1153 | ** @cc Bio::EnsEMBL::Variation::Variation::source |
| 1154 | ** @cc Bio::EnsEMBL::Variation::Variation::source_description |
| 1155 | ** @cc Bio::EnsEMBL::Variation::Variation::source_url |
| 1156 | ** @cc Bio::EnsEMBL::Variation::Variation::is_somatic |
| 1157 | ** @param [r] gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1158 | ** |
| 1159 | ** @return [EnsPGvsource] Ensembl Genetic Variation Source or NULL |
| 1160 | ** |
| 1161 | ** @release 6.3.0 |
| 1162 | ** @@ |
| 1163 | ******************************************************************************/ |
| 1164 | |
| 1165 | EnsPGvsource ensGvvariationGetGvsource(const EnsPGvvariation gvv) |
| 1166 | { |
| 1167 | return (gvv) ? gvv->Gvsource : NULL; |
| 1168 | } |
| 1169 | |
| 1170 | |
| 1171 | |
| 1172 | |
| 1173 | /* @func ensGvvariationGetGvsynonyms ****************************************** |
| 1174 | ** |
| 1175 | ** Get the AJAX List of Ensembl Genetic Variation Synonym objects member |
| 1176 | ** of an Ensembl Genetic Variation Variation. |
| 1177 | ** |
| 1178 | ** @cc Bio::EnsEMBL::Variation::Variation::get_all_synonyms |
| 1179 | ** @param [r] gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1180 | ** @see ensGvvariationFetchAllGvsynonyms |
| 1181 | ** @see ensGvvariationFetchAllGvsources |
| 1182 | ** |
| 1183 | ** @return [const AjPList] |
| 1184 | ** AJAX List of Ensembl Genetic Variation Synonym objects or NULL |
| 1185 | ** |
| 1186 | ** @release 6.4.0 |
| 1187 | ** @@ |
| 1188 | ******************************************************************************/ |
| 1189 | |
| 1190 | const AjPList ensGvvariationGetGvsynonyms(const EnsPGvvariation gvv) |
| 1191 | { |
| 1192 | return (gvv) ? gvv->Gvsynonyms : NULL; |
| 1193 | } |
| 1194 | |
| 1195 | |
| 1196 | |
| 1197 | |
| 1198 | /* @func ensGvvariationGetIdentifier ****************************************** |
| 1199 | ** |
| 1200 | ** Get the SQL database-internal identifier member of an |
| 1201 | ** Ensembl Genetic Variation Variation. |
| 1202 | ** |
| 1203 | ** @cc Bio::EnsEMBL::Storable::dbID |
| 1204 | ** @param [r] gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1205 | ** |
| 1206 | ** @return [ajuint] SQL database-internal identifier or 0U |
| 1207 | ** |
| 1208 | ** @release 6.2.0 |
| 1209 | ** @@ |
| 1210 | ******************************************************************************/ |
| 1211 | |
| 1212 | ajuint ensGvvariationGetIdentifier(const EnsPGvvariation gvv) |
| 1213 | { |
| 1214 | return (gvv) ? gvv->Identifier : 0U; |
| 1215 | } |
| 1216 | |
| 1217 | |
| 1218 | |
| 1219 | |
| 1220 | /* @func ensGvvariationGetMinoralleleAllele *********************************** |
| 1221 | ** |
| 1222 | ** Get the minor allele allele member of an |
| 1223 | ** Ensembl Genetic Variation Variation. |
| 1224 | ** |
| 1225 | ** @cc Bio::EnsEMBL::Variation::Variation::minor_allele |
| 1226 | ** @param [r] gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1227 | ** |
| 1228 | ** @return [AjPStr] Minor allele allele or NULL |
| 1229 | ** |
| 1230 | ** @release 6.5.0 |
| 1231 | ** @@ |
| 1232 | ******************************************************************************/ |
| 1233 | |
| 1234 | AjPStr ensGvvariationGetMinoralleleAllele(const EnsPGvvariation gvv) |
| 1235 | { |
| 1236 | return (gvv) ? gvv->MinoralleleAllele : NULL; |
| 1237 | } |
| 1238 | |
| 1239 | |
| 1240 | |
| 1241 | |
| 1242 | /* @func ensGvvariationGetMinoralleleCount ************************************ |
| 1243 | ** |
| 1244 | ** Get the minor allele count member of an |
| 1245 | ** Ensembl Genetic Variation Variation. |
| 1246 | ** |
| 1247 | ** @cc Bio::EnsEMBL::Variation::Variation::minor_allele_count |
| 1248 | ** @param [r] gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1249 | ** |
| 1250 | ** @return [ajuint] Minor allele count or 0U |
| 1251 | ** |
| 1252 | ** @release 6.5.0 |
| 1253 | ** @@ |
| 1254 | ******************************************************************************/ |
| 1255 | |
| 1256 | ajuint ensGvvariationGetMinoralleleCount(const EnsPGvvariation gvv) |
| 1257 | { |
| 1258 | return (gvv) ? gvv->MinoralleleCount : 0U; |
| 1259 | } |
| 1260 | |
| 1261 | |
| 1262 | |
| 1263 | |
| 1264 | /* @func ensGvvariationGetMinoralleleFrequency ******************************** |
| 1265 | ** |
| 1266 | ** Get the minor allele frequency member of an |
| 1267 | ** Ensembl Genetic Variation Variation. |
| 1268 | ** |
| 1269 | ** @cc Bio::EnsEMBL::Variation::Variation::minor_allele_frequency |
| 1270 | ** @param [r] gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1271 | ** |
| 1272 | ** @return [float] Minor allele frequency or 0.0F |
| 1273 | ** |
| 1274 | ** @release 6.5.0 |
| 1275 | ** @@ |
| 1276 | ******************************************************************************/ |
| 1277 | |
| 1278 | float ensGvvariationGetMinoralleleFrequency(const EnsPGvvariation gvv) |
| 1279 | { |
| 1280 | return (gvv) ? gvv->MinoralleleFrequency : 0.0F; |
| 1281 | } |
| 1282 | |
| 1283 | |
| 1284 | |
| 1285 | |
| 1286 | /* @func ensGvvariationGetMoleculetype **************************************** |
| 1287 | ** |
| 1288 | ** Get the molecule type member of an Ensembl Genetic Variation Variation. |
| 1289 | ** |
| 1290 | ** @cc Bio::EnsEMBL::Variation::Variation::moltype |
| 1291 | ** @param [r] gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1292 | ** |
| 1293 | ** @return [AjPStr] Molecule type or NULL |
| 1294 | ** |
| 1295 | ** @release 6.4.0 |
| 1296 | ** @@ |
| 1297 | ******************************************************************************/ |
| 1298 | |
| 1299 | AjPStr ensGvvariationGetMoleculetype(const EnsPGvvariation gvv) |
| 1300 | { |
| 1301 | return (gvv) ? gvv->Moleculetype : NULL; |
| 1302 | } |
| 1303 | |
| 1304 | |
| 1305 | |
| 1306 | |
| 1307 | /* @func ensGvvariationGetName ************************************************ |
| 1308 | ** |
| 1309 | ** Get the name member of an Ensembl Genetic Variation Variation. |
| 1310 | ** |
| 1311 | ** @cc Bio::EnsEMBL::Variation::Variation::name |
| 1312 | ** @param [r] gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1313 | ** |
| 1314 | ** @return [AjPStr] Name or NULL |
| 1315 | ** |
| 1316 | ** @release 6.2.0 |
| 1317 | ** @@ |
| 1318 | ******************************************************************************/ |
| 1319 | |
| 1320 | AjPStr ensGvvariationGetName(const EnsPGvvariation gvv) |
| 1321 | { |
| 1322 | return (gvv) ? gvv->Name : NULL; |
| 1323 | } |
| 1324 | |
| 1325 | |
| 1326 | |
| 1327 | |
| 1328 | /* @func ensGvvariationGetSomatic ********************************************* |
| 1329 | ** |
| 1330 | ** Get the somatic or germline member of an |
| 1331 | ** Ensembl Genetic Variation Variation. |
| 1332 | ** |
| 1333 | ** @cc Bio::EnsEMBL::Variation::Variation::is_somatic |
| 1334 | ** @param [r] gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1335 | ** |
| 1336 | ** @return [AjBool] Somatic or germline flag or ajFalse |
| 1337 | ** |
| 1338 | ** @release 6.4.0 |
| 1339 | ** @@ |
| 1340 | ******************************************************************************/ |
| 1341 | |
| 1342 | AjBool ensGvvariationGetSomatic(const EnsPGvvariation gvv) |
| 1343 | { |
| 1344 | return (gvv) ? gvv->Somatic : ajFalse; |
| 1345 | } |
| 1346 | |
| 1347 | |
| 1348 | |
| 1349 | |
| 1350 | /* @func ensGvvariationGetValidations ***************************************** |
| 1351 | ** |
| 1352 | ** Get the validations bit field of an Ensembl Genetic Variation Variation. |
| 1353 | ** |
| 1354 | ** @cc Bio::EnsEMBL::Variation::Variation::get_all_validation_states |
| 1355 | ** @param [r] gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1356 | ** |
| 1357 | ** @return [ajuint] Validations bit field or 0U |
| 1358 | ** |
| 1359 | ** @release 6.4.0 |
| 1360 | ** @@ |
| 1361 | ******************************************************************************/ |
| 1362 | |
| 1363 | ajuint ensGvvariationGetValidations(const EnsPGvvariation gvv) |
| 1364 | { |
| 1365 | return (gvv) ? gvv->Validations : 0U; |
| 1366 | } |
| 1367 | |
| 1368 | |
| 1369 | |
| 1370 | |
| 1371 | /* @section load on demand **************************************************** |
| 1372 | ** |
| 1373 | ** Functions for returning members of an Ensembl Genetic Variation Variation |
| 1374 | ** object, which may need loading from an Ensembl SQL database on demand. |
| 1375 | ** |
| 1376 | ** @fdata [EnsPGvvariation] |
| 1377 | ** |
| 1378 | ** @nam3rule Load Return Ensembl Genetic Variation Variation attribute(s) |
| 1379 | ** loaded on demand |
| 1380 | ** @nam4rule All Returns all Ensembl Genetic Variation Variation members |
| 1381 | ** loaded on demand |
| 1382 | ** @nam5rule Faileddescriptions Returns an AJAX List of AJAX String |
| 1383 | ** (failed description) objects |
| 1384 | ** @nam5rule Gvalleles |
| 1385 | ** Return an AJAX List of Ensembl Genetic Variation Allele obects |
| 1386 | ** @nam4rule Flank Return a flanking sequence |
| 1387 | ** @nam5rule Five Return the five-prime flanking sequence |
| 1388 | ** @nam5rule Three Return the three-prime flanking sequence |
| 1389 | ** |
| 1390 | ** @argrule * gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1391 | ** |
| 1392 | ** @valrule Faileddescriptions [const AjPList] |
| 1393 | ** AJAX List of AJAX String (failed description) objects |
| 1394 | ** @valrule Gvalleles [const AjPList] |
| 1395 | ** AJAX List of Ensembl Genetic Variation Allele objects |
| 1396 | ** @valrule Flank [AjPStr] Flanking sequence or NULL |
| 1397 | ** |
| 1398 | ** @fcategory use |
| 1399 | ******************************************************************************/ |
| 1400 | |
| 1401 | |
| 1402 | |
| 1403 | |
| 1404 | /* @func ensGvvariationLoadAllFaileddescriptions ****************************** |
| 1405 | ** |
| 1406 | ** Load all failed descriptions of an |
| 1407 | ** Ensembl Genetic Variation Variation. |
| 1408 | ** |
| 1409 | ** @cc Bio::EnsEMBL::Variation::Variation::get_all_failed_descriptions |
| 1410 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1411 | ** |
| 1412 | ** @return [const AjPList] |
| 1413 | ** AJAX List of AJAX String (failed description) objects or NULL |
| 1414 | ** |
| 1415 | ** @release 6.4.0 |
| 1416 | ** @@ |
| 1417 | ******************************************************************************/ |
| 1418 | |
| 1419 | const AjPList ensGvvariationLoadAllFaileddescriptions(EnsPGvvariation gvv) |
| 1420 | { |
| 1421 | if (!gvv) |
| 1422 | return ajFalse; |
| 1423 | |
| 1424 | if (gvv->Faileddescriptions) |
| 1425 | return gvv->Faileddescriptions; |
| 1426 | |
| 1427 | if (!gvv->Adaptor) |
| 1428 | { |
| 1429 | ajDebug("ensGvvariationLoadAllFaileddescriptions cannot retrieve " |
| 1430 | "AJAX String (failed description) objects for an " |
| 1431 | "Ensembl Genetic Variation Variation without an " |
| 1432 | "Ensembl Genetic Variation Variation Adaptor.\n"); |
| 1433 | |
| 1434 | return NULL; |
| 1435 | } |
| 1436 | |
| 1437 | gvv->Faileddescriptions = ajListstrNew(); |
| 1438 | |
| 1439 | ensGvvariationadaptorRetrieveAllFaileddescriptions( |
| 1440 | gvv->Adaptor, |
| 1441 | gvv->Identifier, |
| 1442 | gvv->Faileddescriptions); |
| 1443 | |
| 1444 | return gvv->Faileddescriptions; |
| 1445 | } |
| 1446 | |
| 1447 | |
| 1448 | |
| 1449 | |
| 1450 | /* @func ensGvvariationLoadAllGvalleles *************************************** |
| 1451 | ** |
| 1452 | ** Load all Ensembl Genetic Variation Allele objects of an |
| 1453 | ** Ensembl Genetic Variation Variation. |
| 1454 | ** |
| 1455 | ** @cc Bio::EnsEMBL::Variation::Variation::get_all_Alleles |
| 1456 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1457 | ** |
| 1458 | ** @return [const AjPList] |
| 1459 | ** AJAX List of Ensembl Genetic Variation Allele objects or NULL |
| 1460 | ** |
| 1461 | ** @release 6.4.0 |
| 1462 | ** @@ |
| 1463 | ******************************************************************************/ |
| 1464 | |
| 1465 | const AjPList ensGvvariationLoadAllGvalleles(EnsPGvvariation gvv) |
| 1466 | { |
| 1467 | if (!gvv) |
| 1468 | return NULL; |
| 1469 | |
| 1470 | if (gvv->Gvalleles) |
| 1471 | return gvv->Gvalleles; |
| 1472 | |
| 1473 | if (!gvv->Adaptor) |
| 1474 | { |
| 1475 | ajDebug("ensGvvariationLoadAllGvalleles cannot retrieve " |
| 1476 | "Ensembl Genetic Variation Allele objects for an " |
| 1477 | "Ensembl Genetic Variation Variation without an " |
| 1478 | "Ensembl Genetic Variation Variation Adaptor.\n"); |
| 1479 | |
| 1480 | return NULL; |
| 1481 | } |
| 1482 | |
| 1483 | gvv->Gvalleles = ajListNew(); |
| 1484 | |
| 1485 | ensGvalleleadaptorFetchAllbyGvvariation( |
| 1486 | ensRegistryGetGvalleleadaptor( |
| 1487 | ensGvvariationadaptorGetDatabaseadaptor(gvv->Adaptor)), |
| 1488 | gvv, |
| 1489 | (EnsPGvpopulation) NULL, |
| 1490 | gvv->Gvalleles); |
| 1491 | |
| 1492 | return gvv->Gvalleles; |
| 1493 | } |
| 1494 | |
| 1495 | |
| 1496 | |
| 1497 | |
| 1498 | /* @func ensGvvariationLoadFlankFive ****************************************** |
| 1499 | ** |
| 1500 | ** Get the five-prime flank member of an Ensembl Genetic Variation Variation. |
| 1501 | ** |
| 1502 | ** This is not a simple accessor function, it will fetch the five-prime |
| 1503 | ** flanking sequence from the Ensembl Genetic Variation database in case it is |
| 1504 | ** not defined. |
| 1505 | ** |
| 1506 | ** @cc Bio::EnsEMBL::Variation::Variation::five_prime_flanking_seq |
| 1507 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1508 | ** |
| 1509 | ** @return [AjPStr] Five-prime flank or NULL |
| 1510 | ** |
| 1511 | ** @release 6.4.0 |
| 1512 | ** @@ |
| 1513 | ******************************************************************************/ |
| 1514 | |
| 1515 | AjPStr ensGvvariationLoadFlankFive(EnsPGvvariation gvv) |
| 1516 | { |
| 1517 | if (!gvv) |
| 1518 | return NULL; |
| 1519 | |
| 1520 | if (gvv->FlankFive) |
| 1521 | return gvv->FlankFive; |
| 1522 | |
| 1523 | if (gvv->Adaptor) |
| 1524 | ensGvvariationadaptorRetrieveFlank( |
| 1525 | gvv->Adaptor, |
| 1526 | gvv->Identifier, |
| 1527 | &gvv->FlankFive, |
| 1528 | &gvv->FlankThree); |
| 1529 | |
| 1530 | return gvv->FlankFive; |
| 1531 | } |
| 1532 | |
| 1533 | |
| 1534 | |
| 1535 | |
| 1536 | /* @func ensGvvariationLoadFlankThree ***************************************** |
| 1537 | ** |
| 1538 | ** Get the three-prime flank member of an Ensembl Genetic Variation Variation. |
| 1539 | ** |
| 1540 | ** This is not a simple accessor function, it will fetch the three-prime |
| 1541 | ** flanking sequence from the Ensembl Genetic Variation database in case it is |
| 1542 | ** not defined. |
| 1543 | ** |
| 1544 | ** @cc Bio::EnsEMBL::Variation::Variation::three_prime_flanking_seq |
| 1545 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1546 | ** |
| 1547 | ** @return [AjPStr] Three-prime flank or NULL |
| 1548 | ** |
| 1549 | ** @release 6.4.0 |
| 1550 | ** @@ |
| 1551 | ******************************************************************************/ |
| 1552 | |
| 1553 | AjPStr ensGvvariationLoadFlankThree(EnsPGvvariation gvv) |
| 1554 | { |
| 1555 | if (!gvv) |
| 1556 | return NULL; |
| 1557 | |
| 1558 | if (gvv->FlankThree) |
| 1559 | return gvv->FlankThree; |
| 1560 | |
| 1561 | if (gvv->Adaptor) |
| 1562 | ensGvvariationadaptorRetrieveFlank( |
| 1563 | gvv->Adaptor, |
| 1564 | gvv->Identifier, |
| 1565 | &gvv->FlankFive, |
| 1566 | &gvv->FlankThree); |
| 1567 | |
| 1568 | return gvv->FlankThree; |
| 1569 | } |
| 1570 | |
| 1571 | |
| 1572 | |
| 1573 | |
| 1574 | /* @section member assignment ************************************************* |
| 1575 | ** |
| 1576 | ** Functions for assigning members of an |
| 1577 | ** Ensembl Genetic Variation Variation object. |
| 1578 | ** |
| 1579 | ** @fdata [EnsPGvvariation] |
| 1580 | ** |
| 1581 | ** @nam3rule Set Set one member of a Genetic Variation Variation |
| 1582 | ** @nam4rule Adaptor Set the Ensembl Genetic Variation Variation Adaptor |
| 1583 | ** @nam4rule Ancestralallele Set the ancestral allele |
| 1584 | ** @nam4rule Class Set the |
| 1585 | ** Class Ensembl Genetic Variation Attribute |
| 1586 | ** @nam4rule Clinical Set the |
| 1587 | ** Clinical significance Ensembl Genetic Variation Attribute |
| 1588 | ** @nam4rule Flank Set flanking sequence members |
| 1589 | ** @nam5rule Exists Set the flanking sequence exists |
| 1590 | ** @nam5rule Five Set the five-prime flank |
| 1591 | ** @nam5rule Three Set the three-prime flank |
| 1592 | ** @nam4rule Flipped Set the flipped member |
| 1593 | ** @nam4rule Gvsource Set the Ensembl Genetic Variation Source |
| 1594 | ** @nam4rule Identifier Set the SQL database-internal identifier |
| 1595 | ** @nam4rule Minorallele Set minor allele members |
| 1596 | ** @nam5rule Allele Set the minor allele allele |
| 1597 | ** @nam5rule Count Set the minor allele count |
| 1598 | ** @nam5rule Frequency Set the minor allele frequency |
| 1599 | ** @nam4rule Moleculetype Set the molecule type |
| 1600 | ** @nam4rule Name Set the name |
| 1601 | ** @nam4rule Somatic Set the somatic or germline flag |
| 1602 | ** |
| 1603 | ** @argrule * gvv [EnsPGvvariation] Ensembl Genetic Variation Variation object |
| 1604 | ** @argrule Adaptor gvva [EnsPGvvariationadaptor] Ensembl Genetic Variation |
| 1605 | ** @argrule Ancestralallele ancestralallele [AjPStr] Ancestral allele |
| 1606 | ** @argrule Class gvaclass [EnsPGvattribute] |
| 1607 | ** Class Ensembl Genetic Variation Attribute |
| 1608 | ** @argrule Clinical gvaclinical [EnsPGvattribute] |
| 1609 | ** Clinical significance Ensembl Genetic Variation Attribute |
| 1610 | ** @argrule FlankExists flankexists [AjBool] Flank |
| 1611 | ** @argrule FlankFive flankfive [AjPStr] Five-prime flank |
| 1612 | ** @argrule FlankThree flankthree [AjPStr] Three-prime flank |
| 1613 | ** @argrule Flipped flipped [AjBool] Flipped member |
| 1614 | ** @argrule Gvsource gvs [EnsPGvsource] Ensembl Genetic Variation Source |
| 1615 | ** @argrule Identifier identifier [ajuint] SQL database-internal identifier |
| 1616 | ** @argrule MinoralleleAllele maallele [AjPStr] Minor allele allele |
| 1617 | ** @argrule MinoralleleCount macount [ajuint] Minot allele count |
| 1618 | ** @argrule MinoralleleFrequency mafrequency [float] Minor allele frequency |
| 1619 | ** @argrule Moleculetype moltype [AjPStr] Molecule type |
| 1620 | ** @argrule Name name [AjPStr] Name |
| 1621 | ** @argrule Somatic somatic [AjBool] Somatic or germline flag |
| 1622 | ** |
| 1623 | ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise |
| 1624 | ** |
| 1625 | ** @fcategory modify |
| 1626 | ******************************************************************************/ |
| 1627 | |
| 1628 | |
| 1629 | |
| 1630 | |
| 1631 | /* @func ensGvvariationSetAdaptor ********************************************* |
| 1632 | ** |
| 1633 | ** Set the Ensembl Genetic Variation Variation Adaptor member of an |
| 1634 | ** Ensembl Genetic Variation Variation. |
| 1635 | ** |
| 1636 | ** @cc Bio::EnsEMBL::Storable::adaptor |
| 1637 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1638 | ** @param [u] gvva [EnsPGvvariationadaptor] |
| 1639 | ** Ensembl Genetic Variation Variation Adaptor |
| 1640 | ** |
| 1641 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 1642 | ** |
| 1643 | ** @release 6.2.0 |
| 1644 | ** @@ |
| 1645 | ******************************************************************************/ |
| 1646 | |
| 1647 | AjBool ensGvvariationSetAdaptor(EnsPGvvariation gvv, |
| 1648 | EnsPGvvariationadaptor gvva) |
| 1649 | { |
| 1650 | if (!gvv) |
| 1651 | return ajFalse; |
| 1652 | |
| 1653 | gvv->Adaptor = gvva; |
| 1654 | |
| 1655 | return ajTrue; |
| 1656 | } |
| 1657 | |
| 1658 | |
| 1659 | |
| 1660 | |
| 1661 | /* @func ensGvvariationSetAncestralallele ************************************* |
| 1662 | ** |
| 1663 | ** Set the ancestral allele member of an Ensembl Genetic Variation Variation. |
| 1664 | ** |
| 1665 | ** @cc Bio::EnsEMBL::Variation::Variation::ancestral_allele |
| 1666 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1667 | ** @param [u] ancestralallele [AjPStr] Ancestral allele |
| 1668 | ** |
| 1669 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 1670 | ** |
| 1671 | ** @release 6.4.0 |
| 1672 | ** @@ |
| 1673 | ******************************************************************************/ |
| 1674 | |
| 1675 | AjBool ensGvvariationSetAncestralallele(EnsPGvvariation gvv, |
| 1676 | AjPStr ancestralallele) |
| 1677 | { |
| 1678 | if (!gvv) |
| 1679 | return ajFalse; |
| 1680 | |
| 1681 | ajStrDel(&gvv->Ancestralallele); |
| 1682 | |
| 1683 | if (ancestralallele) |
| 1684 | gvv->Ancestralallele = ajStrNewRef(ancestralallele); |
| 1685 | |
| 1686 | return ajTrue; |
| 1687 | } |
| 1688 | |
| 1689 | |
| 1690 | |
| 1691 | |
| 1692 | /* @func ensGvvariationSetClass *********************************************** |
| 1693 | ** |
| 1694 | ** Set the class Ensembl Genetic Variation Attribute member of an |
| 1695 | ** Ensembl Genetic Variation Variation. |
| 1696 | ** |
| 1697 | ** @cc Bio::EnsEMBL::Variation::Variation::var_class |
| 1698 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1699 | ** @param [u] gvaclass [EnsPGvattribute] |
| 1700 | ** Class Ensembl Genetic Variation Attribute |
| 1701 | ** |
| 1702 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 1703 | ** |
| 1704 | ** @release 6.4.0 |
| 1705 | ** @@ |
| 1706 | ******************************************************************************/ |
| 1707 | |
| 1708 | AjBool ensGvvariationSetClass(EnsPGvvariation gvv, |
| 1709 | EnsPGvattribute gvaclass) |
| 1710 | { |
| 1711 | if (!gvv) |
| 1712 | return ajFalse; |
| 1713 | |
| 1714 | ensGvattributeDel(&gvv->Class); |
| 1715 | |
| 1716 | gvv->Class = ensGvattributeNewRef(gvaclass); |
| 1717 | |
| 1718 | return ajTrue; |
| 1719 | } |
| 1720 | |
| 1721 | |
| 1722 | |
| 1723 | |
| 1724 | /* @func ensGvvariationSetClinical ******************************************** |
| 1725 | ** |
| 1726 | ** Set the clinical significance Ensembl Genetic Variation Attribute member |
| 1727 | ** of an Ensembl Genetic Variation Variation. |
| 1728 | ** |
| 1729 | ** @cc Bio::EnsEMBL::Variation::Variation::clinical_significance |
| 1730 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1731 | ** @param [u] gvaclinical [EnsPGvattribute] |
| 1732 | ** Clinical significance Ensembl Genetic Variation Attribute |
| 1733 | ** |
| 1734 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 1735 | ** |
| 1736 | ** @release 6.4.0 |
| 1737 | ** @@ |
| 1738 | ******************************************************************************/ |
| 1739 | |
| 1740 | AjBool ensGvvariationSetClinical(EnsPGvvariation gvv, |
| 1741 | EnsPGvattribute gvaclinical) |
| 1742 | { |
| 1743 | if (!gvv) |
| 1744 | return ajFalse; |
| 1745 | |
| 1746 | ensGvattributeDel(&gvv->Clinical); |
| 1747 | |
| 1748 | gvv->Clinical = ensGvattributeNewRef(gvaclinical); |
| 1749 | |
| 1750 | return ajTrue; |
| 1751 | } |
| 1752 | |
| 1753 | |
| 1754 | |
| 1755 | |
| 1756 | /* @func ensGvvariationSetFlankExists ***************************************** |
| 1757 | ** |
| 1758 | ** Set the flanking sequence exists member of an |
| 1759 | ** Ensembl Genetic Variation Variation. |
| 1760 | ** |
| 1761 | ** @cc Bio::EnsEMBL::Variation::Variation::flank_flag |
| 1762 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1763 | ** @param [r] flankexists [AjBool] Flank |
| 1764 | ** |
| 1765 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 1766 | ** |
| 1767 | ** @release 6.4.0 |
| 1768 | ** @@ |
| 1769 | ******************************************************************************/ |
| 1770 | |
| 1771 | AjBool ensGvvariationSetFlankExists(EnsPGvvariation gvv, |
| 1772 | AjBool flankexists) |
| 1773 | { |
| 1774 | if (!gvv) |
| 1775 | return ajFalse; |
| 1776 | |
| 1777 | gvv->FlankExists = flankexists; |
| 1778 | |
| 1779 | return ajTrue; |
| 1780 | } |
| 1781 | |
| 1782 | |
| 1783 | |
| 1784 | |
| 1785 | /* @func ensGvvariationSetFlankFive ******************************************* |
| 1786 | ** |
| 1787 | ** Set the five-prime flank member of an Ensembl Genetic Variation Variation. |
| 1788 | ** |
| 1789 | ** @cc Bio::EnsEMBL::Variation::Variation::five_prime_flanking_seq |
| 1790 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1791 | ** @param [u] flankfive [AjPStr] Five-prime flank |
| 1792 | ** |
| 1793 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 1794 | ** |
| 1795 | ** @release 6.4.0 |
| 1796 | ** @@ |
| 1797 | ******************************************************************************/ |
| 1798 | |
| 1799 | AjBool ensGvvariationSetFlankFive(EnsPGvvariation gvv, |
| 1800 | AjPStr flankfive) |
| 1801 | { |
| 1802 | if (!gvv) |
| 1803 | return ajFalse; |
| 1804 | |
| 1805 | ajStrDel(&gvv->FlankFive); |
| 1806 | |
| 1807 | if (flankfive) |
| 1808 | gvv->FlankFive = ajStrNewRef(flankfive); |
| 1809 | |
| 1810 | return ajTrue; |
| 1811 | } |
| 1812 | |
| 1813 | |
| 1814 | |
| 1815 | |
| 1816 | /* @func ensGvvariationSetFlankThree ****************************************** |
| 1817 | ** |
| 1818 | ** Set the three-prime flank member of an Ensembl Genetic Variation Variation. |
| 1819 | ** |
| 1820 | ** @cc Bio::EnsEMBL::Variation::Variation::three_prime_flanking_seq |
| 1821 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1822 | ** @param [u] flankthree [AjPStr] Three-prime flank |
| 1823 | ** |
| 1824 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 1825 | ** |
| 1826 | ** @release 6.4.0 |
| 1827 | ** @@ |
| 1828 | ******************************************************************************/ |
| 1829 | |
| 1830 | AjBool ensGvvariationSetFlankThree(EnsPGvvariation gvv, |
| 1831 | AjPStr flankthree) |
| 1832 | { |
| 1833 | if (!gvv) |
| 1834 | return ajFalse; |
| 1835 | |
| 1836 | ajStrDel(&gvv->FlankThree); |
| 1837 | |
| 1838 | if (flankthree) |
| 1839 | gvv->FlankThree = ajStrNewRef(flankthree); |
| 1840 | |
| 1841 | return ajTrue; |
| 1842 | } |
| 1843 | |
| 1844 | |
| 1845 | |
| 1846 | |
| 1847 | /* @func ensGvvariationSetFlipped ********************************************* |
| 1848 | ** |
| 1849 | ** Set the flipped member of an |
| 1850 | ** Ensembl Genetic Variation Variation. |
| 1851 | ** |
| 1852 | ** @cc Bio::EnsEMBL::Variation::Variation::flipped |
| 1853 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1854 | ** @param [r] flipped [AjBool] Flank |
| 1855 | ** |
| 1856 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 1857 | ** |
| 1858 | ** @release 6.4.0 |
| 1859 | ** @@ |
| 1860 | ******************************************************************************/ |
| 1861 | |
| 1862 | AjBool ensGvvariationSetFlipped(EnsPGvvariation gvv, |
| 1863 | AjBool flipped) |
| 1864 | { |
| 1865 | if (!gvv) |
| 1866 | return ajFalse; |
| 1867 | |
| 1868 | gvv->Flipped = flipped; |
| 1869 | |
| 1870 | return ajTrue; |
| 1871 | } |
| 1872 | |
| 1873 | |
| 1874 | |
| 1875 | |
| 1876 | /* @func ensGvvariationSetGvsource ******************************************** |
| 1877 | ** |
| 1878 | ** Set the Ensembl Genetic Variation Source member of an |
| 1879 | ** Ensembl Genetic Variation Variation. |
| 1880 | ** |
| 1881 | ** @cc Bio::EnsEMBL::Variation::Variation::source |
| 1882 | ** @cc Bio::EnsEMBL::Variation::Variation::source_description |
| 1883 | ** @cc Bio::EnsEMBL::Variation::Variation::source_url |
| 1884 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1885 | ** @param [u] gvs [EnsPGvsource] Ensembl Genetic Variation Source |
| 1886 | ** |
| 1887 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 1888 | ** |
| 1889 | ** @release 6.3.0 |
| 1890 | ** @@ |
| 1891 | ******************************************************************************/ |
| 1892 | |
| 1893 | AjBool ensGvvariationSetGvsource(EnsPGvvariation gvv, |
| 1894 | EnsPGvsource gvs) |
| 1895 | { |
| 1896 | if (!gvv) |
| 1897 | return ajFalse; |
| 1898 | |
| 1899 | ensGvsourceDel(&gvv->Gvsource); |
| 1900 | |
| 1901 | gvv->Gvsource = ensGvsourceNewRef(gvs); |
| 1902 | |
| 1903 | return ajTrue; |
| 1904 | } |
| 1905 | |
| 1906 | |
| 1907 | |
| 1908 | |
| 1909 | /* @func ensGvvariationSetIdentifier ****************************************** |
| 1910 | ** |
| 1911 | ** Set the SQL database-internal identifier member of an |
| 1912 | ** Ensembl Genetic Variation Variation. |
| 1913 | ** |
| 1914 | ** @cc Bio::EnsEMBL::Storable::dbID |
| 1915 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1916 | ** @param [r] identifier [ajuint] SQL database-internal identifier |
| 1917 | ** |
| 1918 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 1919 | ** |
| 1920 | ** @release 6.2.0 |
| 1921 | ** @@ |
| 1922 | ******************************************************************************/ |
| 1923 | |
| 1924 | AjBool ensGvvariationSetIdentifier(EnsPGvvariation gvv, |
| 1925 | ajuint identifier) |
| 1926 | { |
| 1927 | if (!gvv) |
| 1928 | return ajFalse; |
| 1929 | |
| 1930 | gvv->Identifier = identifier; |
| 1931 | |
| 1932 | return ajTrue; |
| 1933 | } |
| 1934 | |
| 1935 | |
| 1936 | |
| 1937 | |
| 1938 | /* @func ensGvvariationSetMinoralleleAllele *********************************** |
| 1939 | ** |
| 1940 | ** Set the minor allele allele member of an |
| 1941 | ** Ensembl Genetic Variation Variation. |
| 1942 | ** |
| 1943 | ** @cc Bio::EnsEMBL::Variation::Variation::minor_allele |
| 1944 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1945 | ** @param [u] maallele [AjPStr] Minor allele allele |
| 1946 | ** |
| 1947 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 1948 | ** |
| 1949 | ** @release 6.4.0 |
| 1950 | ** @@ |
| 1951 | ******************************************************************************/ |
| 1952 | |
| 1953 | AjBool ensGvvariationSetMinoralleleAllele(EnsPGvvariation gvv, |
| 1954 | AjPStr maallele) |
| 1955 | { |
| 1956 | if (!gvv) |
| 1957 | return ajFalse; |
| 1958 | |
| 1959 | ajStrDel(&gvv->MinoralleleAllele); |
| 1960 | |
| 1961 | if (maallele) |
| 1962 | gvv->MinoralleleAllele = ajStrNewRef(maallele); |
| 1963 | |
| 1964 | return ajTrue; |
| 1965 | } |
| 1966 | |
| 1967 | |
| 1968 | |
| 1969 | |
| 1970 | /* @func ensGvvariationSetMinoralleleCount ************************************ |
| 1971 | ** |
| 1972 | ** Set the minor allele count member of an |
| 1973 | ** Ensembl Genetic Variation Variation. |
| 1974 | ** |
| 1975 | ** @cc Bio::EnsEMBL::Variation::Variation::minor_allele_count |
| 1976 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 1977 | ** @param [r] macount [ajuint] Minor allele count |
| 1978 | ** |
| 1979 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 1980 | ** |
| 1981 | ** @release 6.4.0 |
| 1982 | ** @@ |
| 1983 | ******************************************************************************/ |
| 1984 | |
| 1985 | AjBool ensGvvariationSetMinoralleleCount(EnsPGvvariation gvv, |
| 1986 | ajuint macount) |
| 1987 | { |
| 1988 | if (!gvv) |
| 1989 | return ajFalse; |
| 1990 | |
| 1991 | gvv->MinoralleleCount = macount; |
| 1992 | |
| 1993 | return ajTrue; |
| 1994 | } |
| 1995 | |
| 1996 | |
| 1997 | |
| 1998 | |
| 1999 | /* @func ensGvvariationSetMinoralleleFrequency ******************************** |
| 2000 | ** |
| 2001 | ** Set the minor allele frequency member of an |
| 2002 | ** Ensembl Genetic Variation Variation. |
| 2003 | ** |
| 2004 | ** @cc Bio::EnsEMBL::Variation::Variation::minor_allele_frequency |
| 2005 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 2006 | ** @param [r] mafrequency [float] Minor allele frequency |
| 2007 | ** |
| 2008 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 2009 | ** |
| 2010 | ** @release 6.4.0 |
| 2011 | ** @@ |
| 2012 | ******************************************************************************/ |
| 2013 | |
| 2014 | AjBool ensGvvariationSetMinoralleleFrequency(EnsPGvvariation gvv, |
| 2015 | float mafrequency) |
| 2016 | { |
| 2017 | if (!gvv) |
| 2018 | return ajFalse; |
| 2019 | |
| 2020 | gvv->MinoralleleFrequency = mafrequency; |
| 2021 | |
| 2022 | return ajTrue; |
| 2023 | } |
| 2024 | |
| 2025 | |
| 2026 | |
| 2027 | |
| 2028 | /* @func ensGvvariationSetMoleculetype **************************************** |
| 2029 | ** |
| 2030 | ** Set the molecule type member of an Ensembl Genetic Variation Variation. |
| 2031 | ** |
| 2032 | ** @cc Bio::EnsEMBL::Variation::Variation::moltype |
| 2033 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 2034 | ** @param [u] moltype [AjPStr] Molecule type |
| 2035 | ** |
| 2036 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 2037 | ** |
| 2038 | ** @release 6.4.0 |
| 2039 | ** @@ |
| 2040 | ******************************************************************************/ |
| 2041 | |
| 2042 | AjBool ensGvvariationSetMoleculetype(EnsPGvvariation gvv, |
| 2043 | AjPStr moltype) |
| 2044 | { |
| 2045 | if (!gvv) |
| 2046 | return ajFalse; |
| 2047 | |
| 2048 | ajStrDel(&gvv->Moleculetype); |
| 2049 | |
| 2050 | if (moltype) |
| 2051 | gvv->Moleculetype = ajStrNewRef(moltype); |
| 2052 | |
| 2053 | return ajTrue; |
| 2054 | } |
| 2055 | |
| 2056 | |
| 2057 | |
| 2058 | |
| 2059 | /* @func ensGvvariationSetName ************************************************ |
| 2060 | ** |
| 2061 | ** Set the name member of an Ensembl Genetic Variation Variation. |
| 2062 | ** |
| 2063 | ** @cc Bio::EnsEMBL::Variation::Variation::name |
| 2064 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 2065 | ** @param [u] name [AjPStr] Name |
| 2066 | ** |
| 2067 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 2068 | ** |
| 2069 | ** @release 6.2.0 |
| 2070 | ** @@ |
| 2071 | ******************************************************************************/ |
| 2072 | |
| 2073 | AjBool ensGvvariationSetName(EnsPGvvariation gvv, |
| 2074 | AjPStr name) |
| 2075 | { |
| 2076 | if (!gvv) |
| 2077 | return ajFalse; |
| 2078 | |
| 2079 | ajStrDel(&gvv->Name); |
| 2080 | |
| 2081 | if (name) |
| 2082 | gvv->Name = ajStrNewRef(name); |
| 2083 | |
| 2084 | return ajTrue; |
| 2085 | } |
| 2086 | |
| 2087 | |
| 2088 | |
| 2089 | |
| 2090 | /* @func ensGvvariationSetSomatic ********************************************* |
| 2091 | ** |
| 2092 | ** Set the somatic or germline member of an |
| 2093 | ** Ensembl Genetic Variation Variation. |
| 2094 | ** |
| 2095 | ** @cc Bio::EnsEMBL::Variation::Variation::is_somatic |
| 2096 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 2097 | ** @param [r] somatic [AjBool] Somatic or germline flag |
| 2098 | ** |
| 2099 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 2100 | ** |
| 2101 | ** @release 6.4.0 |
| 2102 | ** @@ |
| 2103 | ******************************************************************************/ |
| 2104 | |
| 2105 | AjBool ensGvvariationSetSomatic(EnsPGvvariation gvv, |
| 2106 | AjBool somatic) |
| 2107 | { |
| 2108 | if (!gvv) |
| 2109 | return ajFalse; |
| 2110 | |
| 2111 | gvv->Somatic = somatic; |
| 2112 | |
| 2113 | return ajTrue; |
| 2114 | } |
| 2115 | |
| 2116 | |
| 2117 | |
| 2118 | |
| 2119 | /* @section debugging ********************************************************* |
| 2120 | ** |
| 2121 | ** Functions for reporting of an Ensembl Genetic Variation Variation object. |
| 2122 | ** |
| 2123 | ** @fdata [EnsPGvvariation] |
| 2124 | ** |
| 2125 | ** @nam3rule Trace Report Ensembl Genetic Variation Variation members |
| 2126 | ** to debug file |
| 2127 | ** |
| 2128 | ** @argrule Trace gvv [const EnsPGvvariation] |
| 2129 | ** Ensembl Genetic Variation Variation |
| 2130 | ** @argrule Trace level [ajuint] Indentation level |
| 2131 | ** |
| 2132 | ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise |
| 2133 | ** |
| 2134 | ** @fcategory misc |
| 2135 | ******************************************************************************/ |
| 2136 | |
| 2137 | |
| 2138 | |
| 2139 | |
| 2140 | /* @func ensGvvariationTrace ************************************************** |
| 2141 | ** |
| 2142 | ** Trace an Ensembl Genetic Variation Variation. |
| 2143 | ** |
| 2144 | ** @param [r] gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 2145 | ** @param [r] level [ajuint] Indentation level |
| 2146 | ** |
| 2147 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 2148 | ** |
| 2149 | ** @release 6.2.0 |
| 2150 | ** @@ |
| 2151 | ******************************************************************************/ |
| 2152 | |
| 2153 | AjBool ensGvvariationTrace(const EnsPGvvariation gvv, ajuint level) |
| 2154 | { |
| 2155 | AjIList iter = NULL; |
| 2156 | |
| 2157 | AjPStr indent = NULL; |
| 2158 | AjPStr states = NULL; |
| 2159 | |
| 2160 | EnsPGvallele gva = NULL; |
| 2161 | |
| 2162 | EnsPGvsynonym gvs = NULL; |
| 2163 | |
| 2164 | if (!gvv) |
| 2165 | return ajFalse; |
| 2166 | |
| 2167 | indent = ajStrNew(); |
| 2168 | |
| 2169 | ajStrAppendCountK(&indent, ' ', level * 2); |
| 2170 | |
| 2171 | ajDebug("%SensGvvariationTrace %p\n" |
| 2172 | "%S Use %u\n" |
| 2173 | "%S Identifier %u\n" |
| 2174 | "%S Adaptor %p\n" |
| 2175 | "%S Class %p\n" |
| 2176 | "%S Clinical %p\n" |
| 2177 | "%S Gvsource %p\n" |
| 2178 | "%S Name '%S'\n" |
| 2179 | "%S Ancestralallele '%S'\n" |
| 2180 | "%S MinoralleleAllele '%S'\n" |
| 2181 | "%S Gvalleles %p\n" |
| 2182 | "%S Gvsynonyms %p\n" |
| 2183 | "%S Moleculetype '%S'\n" |
| 2184 | "%S FlankFive '%S'\n" |
| 2185 | "%S FlankThree '%S'\n" |
| 2186 | "%S FlankExists '%B'\n" |
| 2187 | "%S Flipped '%B'\n" |
| 2188 | "%S Somatic '%B'\n" |
| 2189 | "%S Validations %u\n" |
| 2190 | "%S MinoralleleCount %u\n" |
| 2191 | "%S MinoralleleFrequency %f\n", |
| 2192 | indent, gvv, |
| 2193 | indent, gvv->Use, |
| 2194 | indent, gvv->Identifier, |
| 2195 | indent, gvv->Adaptor, |
| 2196 | indent, gvv->Class, |
| 2197 | indent, gvv->Clinical, |
| 2198 | indent, gvv->Gvsource, |
| 2199 | indent, gvv->Name, |
| 2200 | indent, gvv->Ancestralallele, |
| 2201 | indent, gvv->MinoralleleAllele, |
| 2202 | indent, gvv->Gvalleles, |
| 2203 | indent, gvv->Gvsynonyms, |
| 2204 | indent, gvv->Moleculetype, |
| 2205 | indent, gvv->FlankFive, |
| 2206 | indent, gvv->FlankThree, |
| 2207 | indent, gvv->FlankExists, |
| 2208 | indent, gvv->Flipped, |
| 2209 | indent, gvv->Somatic, |
| 2210 | indent, gvv->Validations, |
| 2211 | indent, gvv->MinoralleleCount, |
| 2212 | indent, gvv->MinoralleleFrequency); |
| 2213 | |
| 2214 | ensGvattributeTrace(gvv->Class, level + 1); |
| 2215 | ensGvattributeTrace(gvv->Clinical, level + 1); |
| 2216 | |
| 2217 | ensGvsourceTrace(gvv->Gvsource, level + 1); |
| 2218 | |
| 2219 | states = ajStrNew(); |
| 2220 | |
| 2221 | ensGvvariationValidationsToSet(gvv->Validations, &states); |
| 2222 | |
| 2223 | ajDebug("%S Validation states SQL set: '%S'\n", indent, states); |
| 2224 | |
| 2225 | ajStrDel(&states); |
| 2226 | |
| 2227 | /* Trace the AJAX List of Ensembl Genetic Variation Allele objects. */ |
| 2228 | |
| 2229 | ajDebug("%S Ensembl Genetic Variation Allele objects:\n", indent); |
| 2230 | |
| 2231 | iter = ajListIterNew(gvv->Gvalleles); |
| 2232 | |
| 2233 | while (!ajListIterDone(iter)) |
| 2234 | { |
| 2235 | gva = (EnsPGvallele) ajListIterGet(iter); |
| 2236 | |
| 2237 | ensGvalleleTrace(gva, level + 1); |
| 2238 | } |
| 2239 | |
| 2240 | ajListIterDel(&iter); |
| 2241 | |
| 2242 | /* Trace the AJAX List of Ensembl Genetic Variation Synonym objects. */ |
| 2243 | |
| 2244 | ajDebug("%S Ensembl Genetic Variation Synonym objects:\n", indent); |
| 2245 | |
| 2246 | iter = ajListIterNew(gvv->Gvsynonyms); |
| 2247 | |
| 2248 | while (!ajListIterDone(iter)) |
| 2249 | { |
| 2250 | gvs = (EnsPGvsynonym) ajListIterGet(iter); |
| 2251 | |
| 2252 | ensGvsynonymTrace(gvs, level + 1); |
| 2253 | } |
| 2254 | |
| 2255 | ajStrDel(&indent); |
| 2256 | |
| 2257 | return ajTrue; |
| 2258 | } |
| 2259 | |
| 2260 | |
| 2261 | |
| 2262 | |
| 2263 | /* @section calculate ********************************************************* |
| 2264 | ** |
| 2265 | ** Functions for calculating information from an |
| 2266 | ** Ensembl Genetic Variation Variation object. |
| 2267 | ** |
| 2268 | ** @fdata [EnsPGvvariation] |
| 2269 | ** |
| 2270 | ** @nam3rule Calculate |
| 2271 | ** Calculate Ensembl Genetic Variation Variation information |
| 2272 | ** @nam4rule Memsize Calculate the memory size in bytes |
| 2273 | ** |
| 2274 | ** @argrule * gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 2275 | ** |
| 2276 | ** @valrule Memsize [size_t] Memory size in bytes or 0 |
| 2277 | ** |
| 2278 | ** @fcategory misc |
| 2279 | ******************************************************************************/ |
| 2280 | |
| 2281 | |
| 2282 | |
| 2283 | |
| 2284 | /* @func ensGvvariationCalculateMemsize *************************************** |
| 2285 | ** |
| 2286 | ** Calculate the memory size in bytes of an |
| 2287 | ** Ensembl Genetic Variation Variation. |
| 2288 | ** |
| 2289 | ** @param [r] gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 2290 | ** |
| 2291 | ** @return [size_t] Memory size in bytes or 0 |
| 2292 | ** |
| 2293 | ** @release 6.4.0 |
| 2294 | ** @@ |
| 2295 | ******************************************************************************/ |
| 2296 | |
| 2297 | size_t ensGvvariationCalculateMemsize(const EnsPGvvariation gvv) |
| 2298 | { |
| 2299 | size_t size = 0; |
| 2300 | |
| 2301 | AjIList iter = NULL; |
| 2302 | |
| 2303 | EnsPGvallele gva = NULL; |
| 2304 | |
| 2305 | EnsPGvsynonym gvsynonym = NULL; |
| 2306 | |
| 2307 | if (!gvv) |
| 2308 | return 0; |
| 2309 | |
| 2310 | size += sizeof (EnsOGvvariation); |
| 2311 | |
| 2312 | size += ensGvattributeCalculateMemsize(gvv->Class); |
| 2313 | size += ensGvattributeCalculateMemsize(gvv->Clinical); |
| 2314 | |
| 2315 | size += ensGvsourceCalculateMemsize(gvv->Gvsource); |
| 2316 | |
| 2317 | if (gvv->Name) |
| 2318 | { |
| 2319 | size += sizeof (AjOStr); |
| 2320 | |
| 2321 | size += ajStrGetRes(gvv->Name); |
| 2322 | } |
| 2323 | |
| 2324 | if (gvv->Ancestralallele) |
| 2325 | { |
| 2326 | size += sizeof (AjOStr); |
| 2327 | |
| 2328 | size += ajStrGetRes(gvv->Ancestralallele); |
| 2329 | } |
| 2330 | |
| 2331 | if (gvv->MinoralleleAllele) |
| 2332 | { |
| 2333 | size += sizeof (AjOStr); |
| 2334 | |
| 2335 | size += ajStrGetRes(gvv->MinoralleleAllele); |
| 2336 | } |
| 2337 | |
| 2338 | /* Summarise the AJAX List of Ensembl Genetic Variation Allele objects. */ |
| 2339 | |
| 2340 | iter = ajListIterNewread(gvv->Gvalleles); |
| 2341 | |
| 2342 | while (!ajListIterDone(iter)) |
| 2343 | { |
| 2344 | gva = (EnsPGvallele) ajListIterGet(iter); |
| 2345 | |
| 2346 | size += ensGvalleleCalculateMemsize(gva); |
| 2347 | } |
| 2348 | |
| 2349 | ajListIterDel(&iter); |
| 2350 | |
| 2351 | /* Summarise the AJAX List of Ensembl Genetic Variation Synonym objects. */ |
| 2352 | |
| 2353 | iter = ajListIterNewread(gvv->Gvsynonyms); |
| 2354 | |
| 2355 | while (!ajListIterDone(iter)) |
| 2356 | { |
| 2357 | gvsynonym = (EnsPGvsynonym) ajListIterGet(iter); |
| 2358 | |
| 2359 | size += ensGvsynonymCalculateMemsize(gvsynonym); |
| 2360 | } |
| 2361 | |
| 2362 | ajListIterDel(&iter); |
| 2363 | |
| 2364 | if (gvv->Moleculetype) |
| 2365 | { |
| 2366 | size += sizeof (AjOStr); |
| 2367 | |
| 2368 | size += ajStrGetRes(gvv->Moleculetype); |
| 2369 | } |
| 2370 | |
| 2371 | if (gvv->FlankFive) |
| 2372 | { |
| 2373 | size += sizeof (AjOStr); |
| 2374 | |
| 2375 | size += ajStrGetRes(gvv->FlankFive); |
| 2376 | } |
| 2377 | |
| 2378 | if (gvv->FlankThree) |
| 2379 | { |
| 2380 | size += sizeof (AjOStr); |
| 2381 | |
| 2382 | size += ajStrGetRes(gvv->FlankThree); |
| 2383 | } |
| 2384 | |
| 2385 | return size; |
| 2386 | } |
| 2387 | |
| 2388 | |
| 2389 | |
| 2390 | |
| 2391 | /* @section member addition *************************************************** |
| 2392 | ** |
| 2393 | ** Functions for adding members to an |
| 2394 | ** Ensembl Genetic Variation Variation object. |
| 2395 | ** |
| 2396 | ** @fdata [EnsPGvvariation] |
| 2397 | ** |
| 2398 | ** @nam3rule Add Add one object to an Ensembl Genetic Variation Variation |
| 2399 | ** @nam4rule Faileddescription Add a failed description |
| 2400 | ** @nam4rule Gvallele Add an Ensembl Genetic Variation Allele |
| 2401 | ** @nam4rule Gvsynonym Add an Ensembl Genetic Variation Synonym |
| 2402 | ** @nam4rule Validation |
| 2403 | ** Add an Ensembl Genetic Variation Variation Validation enumeration |
| 2404 | ** |
| 2405 | ** @argrule * gvv [EnsPGvvariation] Ensembl Genetic Variation Variation object |
| 2406 | ** @argrule Faileddescription description [AjPStr] Failed description |
| 2407 | ** @argrule Gvallele gva [EnsPGvallele] Ensembl Genetic Variation Allele |
| 2408 | ** @argrule Gvsynonym gvs [EnsPGvsynonym] Ensembl Genetic Variation Synonym |
| 2409 | ** @argrule Validation gvvv [EnsEGvvariationValidation] |
| 2410 | ** Ensembl Genetic Variation Validation enumeration |
| 2411 | ** |
| 2412 | ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise |
| 2413 | ** |
| 2414 | ** @fcategory modify |
| 2415 | ******************************************************************************/ |
| 2416 | |
| 2417 | |
| 2418 | |
| 2419 | |
| 2420 | /* @func ensGvvariationAddFaileddescription *********************************** |
| 2421 | ** |
| 2422 | ** Add a failed description to an |
| 2423 | ** Ensembl Genetic Variation Variation. |
| 2424 | ** |
| 2425 | ** @cc Bio::EnsEMBL::Variation::Variation::failed_description |
| 2426 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 2427 | ** @param [u] description [AjPStr] Failed description |
| 2428 | ** |
| 2429 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 2430 | ** |
| 2431 | ** @release 6.4.0 |
| 2432 | ** @@ |
| 2433 | ******************************************************************************/ |
| 2434 | |
| 2435 | AjBool ensGvvariationAddFaileddescription(EnsPGvvariation gvv, |
| 2436 | AjPStr description) |
| 2437 | { |
| 2438 | if (!gvv) |
| 2439 | return ajFalse; |
| 2440 | |
| 2441 | if (!description) |
| 2442 | return ajFalse; |
| 2443 | |
| 2444 | if (!gvv->Faileddescriptions) |
| 2445 | gvv->Faileddescriptions = ajListstrNew(); |
| 2446 | |
| 2447 | ajListstrPushAppend(gvv->Faileddescriptions, ajStrNewS(description)); |
| 2448 | |
| 2449 | return ajTrue; |
| 2450 | } |
| 2451 | |
| 2452 | |
| 2453 | |
| 2454 | |
| 2455 | /* @func ensGvvariationAddGvallele ******************************************** |
| 2456 | ** |
| 2457 | ** Add an Ensembl Genetic Variation Allele to an |
| 2458 | ** Ensembl Genetic Variation Variation. |
| 2459 | ** |
| 2460 | ** @cc Bio::EnsEMBL::Variation::Variation::add_Allele |
| 2461 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 2462 | ** @param [u] gva [EnsPGvallele] Ensembl Genetic Variation Allele |
| 2463 | ** |
| 2464 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 2465 | ** |
| 2466 | ** @release 6.2.0 |
| 2467 | ** @@ |
| 2468 | ******************************************************************************/ |
| 2469 | |
| 2470 | AjBool ensGvvariationAddGvallele(EnsPGvvariation gvv, |
| 2471 | EnsPGvallele gva) |
| 2472 | { |
| 2473 | if (!gvv) |
| 2474 | return ajFalse; |
| 2475 | |
| 2476 | if (!gva) |
| 2477 | return ajFalse; |
| 2478 | |
| 2479 | if (!gvv->Gvalleles) |
| 2480 | gvv->Gvalleles = ajListNew(); |
| 2481 | |
| 2482 | ajListPushAppend(gvv->Gvalleles, (void *) ensGvalleleNewRef(gva)); |
| 2483 | |
| 2484 | return ajTrue; |
| 2485 | } |
| 2486 | |
| 2487 | |
| 2488 | |
| 2489 | |
| 2490 | /* @func ensGvvariationAddGvsynonym ******************************************* |
| 2491 | ** |
| 2492 | ** Add an Ensembl Genetic Variation Synonym to an |
| 2493 | ** Ensembl Genetic Variation Variation. |
| 2494 | ** |
| 2495 | ** @cc Bio::EnsEMBL::Variation::Variation::add_synonym |
| 2496 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 2497 | ** @param [u] gvs [EnsPGvsynonym] Ensembl Genetic Variation Synonym |
| 2498 | ** |
| 2499 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 2500 | ** |
| 2501 | ** @release 6.4.0 |
| 2502 | ** @@ |
| 2503 | ******************************************************************************/ |
| 2504 | |
| 2505 | AjBool ensGvvariationAddGvsynonym(EnsPGvvariation gvv, |
| 2506 | EnsPGvsynonym gvs) |
| 2507 | { |
| 2508 | if (!gvv) |
| 2509 | return ajFalse; |
| 2510 | |
| 2511 | if (!gvs) |
| 2512 | return ajFalse; |
| 2513 | |
| 2514 | if (!gvv->Gvsynonyms) |
| 2515 | gvv->Gvsynonyms = ajListNew(); |
| 2516 | |
| 2517 | ajListPushAppend(gvv->Gvsynonyms, (void *) ensGvsynonymNewRef(gvs)); |
| 2518 | |
| 2519 | return ajTrue; |
| 2520 | } |
| 2521 | |
| 2522 | |
| 2523 | |
| 2524 | |
| 2525 | /* @func ensGvvariationAddValidation ****************************************** |
| 2526 | ** |
| 2527 | ** Add a validation state to an Ensembl Genetic Variation Variation. |
| 2528 | ** |
| 2529 | ** @cc Bio::EnsEMBL::Variation::Variation::add_validation_state |
| 2530 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 2531 | ** @param [u] gvvv [EnsEGvvariationValidation] |
| 2532 | ** Ensembl Genetic Variation Variation Validation enumeration |
| 2533 | ** |
| 2534 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 2535 | ** |
| 2536 | ** @release 6.4.0 |
| 2537 | ** @@ |
| 2538 | ******************************************************************************/ |
| 2539 | |
| 2540 | AjBool ensGvvariationAddValidation(EnsPGvvariation gvv, |
| 2541 | EnsEGvvariationValidation gvvv) |
| 2542 | { |
| 2543 | if (!gvv) |
| 2544 | return ajFalse; |
| 2545 | |
| 2546 | gvv->Validations |= (1 << gvvv); |
| 2547 | |
| 2548 | return ajTrue; |
| 2549 | } |
| 2550 | |
| 2551 | |
| 2552 | |
| 2553 | |
| 2554 | /* @section fetch ************************************************************* |
| 2555 | ** |
| 2556 | ** Functions for fetching information from an |
| 2557 | ** Ensembl Genetic Variation Variation object. |
| 2558 | ** |
| 2559 | ** @fdata [EnsPGvvariation] |
| 2560 | ** |
| 2561 | ** @nam3rule Fetch Fetch Ensembl Genetic Variation Variation information |
| 2562 | ** @nam4rule All Fetch all objects |
| 2563 | ** @nam5rule Genes Fetch all Ensembl Gene objects |
| 2564 | ** @nam5rule Gvsources Fetch all Ensembl Genetic Variation Source objects |
| 2565 | ** @nam5rule Gvsynonyms Fetch all Ensembl Genetic Variation Synonym objects |
| 2566 | ** @nam5rule Gvvariationfeatures |
| 2567 | ** Fetch all Ensembl Genetic Variation Variation Feature objects |
| 2568 | ** |
| 2569 | ** @argrule AllGenes gvv [EnsPGvvariation] |
| 2570 | ** Ensembl Genetic Variation Variation |
| 2571 | ** @argrule AllGenes flank [ajint] |
| 2572 | ** Overlap between Gene and Variation Feature objects, defaults to 5000 base |
| 2573 | ** pairs |
| 2574 | ** @argrule AllGenes genes [AjPList] AJAX List of Ensembl Gene objects |
| 2575 | ** @argrule AllGvsources gvv [const EnsPGvvariation] |
| 2576 | ** Ensembl Genetic Variation Variation |
| 2577 | ** @argrule AllGvsources gvss [AjPList] |
| 2578 | ** AJAX List of Ensembl Genetic Variation Source objects |
| 2579 | ** @argrule AllGvsynonyms gvv [const EnsPGvvariation] |
| 2580 | ** Ensembl Genetic Variation Variation |
| 2581 | ** @argrule AllGvsynonyms gvsourcename [const AjPStr] |
| 2582 | ** Ensembl Genetic Variation Source name |
| 2583 | ** @argrule AllGvsynonyms gvss [AjPList] |
| 2584 | ** AJAX List of Ensembl Genetic Variation Synonym objects |
| 2585 | ** @argrule AllGvvariationfeatures gvv [EnsPGvvariation] |
| 2586 | ** Ensembl Genetic Variation Variation |
| 2587 | ** @argrule AllGvvariationfeatures gvvfs [AjPList] |
| 2588 | ** AJAX List of Ensembl Genetic Variation Variation Feature objects |
| 2589 | ** |
| 2590 | ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise |
| 2591 | ** |
| 2592 | ** @fcategory misc |
| 2593 | ******************************************************************************/ |
| 2594 | |
| 2595 | |
| 2596 | |
| 2597 | |
| 2598 | /* @func ensGvvariationFetchAllGenes ****************************************** |
| 2599 | ** |
| 2600 | ** Fetch all Ensembl Gene objects where an Ensembl Genetic Variation Variation |
| 2601 | ** has a consequence. |
| 2602 | ** |
| 2603 | ** @cc Bio::EnsEMBL::Variation::Variation::get_all_Genes |
| 2604 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 2605 | ** @param [r] flank [ajint] |
| 2606 | ** Overlap between Gene and Variation Feature objects, defaults to 5000 base |
| 2607 | ** pairs |
| 2608 | ** @param [u] genes [AjPList] AJAX List of Ensembl Gene objects |
| 2609 | ** |
| 2610 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 2611 | ** |
| 2612 | ** @release 6.4.0 |
| 2613 | ** @@ |
| 2614 | ******************************************************************************/ |
| 2615 | |
| 2616 | AjBool ensGvvariationFetchAllGenes(EnsPGvvariation gvv, |
| 2617 | ajint flank, |
| 2618 | AjPList genes) |
| 2619 | { |
| 2620 | ajuint *Pidentifier = NULL; |
| 2621 | |
| 2622 | ajuint identifier = 0U; |
| 2623 | |
| 2624 | AjPList genelist = NULL; |
| 2625 | AjPList gvvfs = NULL; |
| 2626 | |
| 2627 | AjPTable genetable = NULL; |
| 2628 | |
| 2629 | EnsPDatabaseadaptor csdba = NULL; |
| 2630 | EnsPDatabaseadaptor gvdba = NULL; |
| 2631 | |
| 2632 | EnsPFeature gfeature = NULL; |
| 2633 | EnsPFeature vfeature = NULL; |
| 2634 | |
| 2635 | EnsPGene gene = NULL; |
| 2636 | EnsPGeneadaptor genea = NULL; |
| 2637 | |
| 2638 | EnsPGvvariationfeature gvvf = NULL; |
| 2639 | EnsPGvvariationfeatureadaptor gvvfa = NULL; |
| 2640 | |
| 2641 | EnsPSlice slice = NULL; |
| 2642 | EnsPSlice newslice = NULL; |
| 2643 | EnsPSliceadaptor sla = NULL; |
| 2644 | |
| 2645 | if (!gvv) |
| 2646 | return ajFalse; |
| 2647 | |
| 2648 | if (!flank) |
| 2649 | flank = 5000; |
| 2650 | |
| 2651 | if (!genes) |
| 2652 | return ajFalse; |
| 2653 | |
| 2654 | if (!gvv->Adaptor) |
| 2655 | return ajTrue; |
| 2656 | |
| 2657 | genetable = ajTableuintNew(0U); |
| 2658 | |
| 2659 | ajTableSetDestroyvalue(genetable, (void (*)(void **)) &ensGeneDel); |
| 2660 | |
| 2661 | gvdba = ensGvvariationadaptorGetDatabaseadaptor(gvv->Adaptor); |
| 2662 | |
| 2663 | csdba = ensRegistryGetDatabaseadaptor( |
| 2664 | ensEDatabaseadaptorGroupCore, |
| 2665 | ensDatabaseadaptorGetSpecies(gvdba)); |
| 2666 | |
| 2667 | sla = ensRegistryGetSliceadaptor(csdba); |
| 2668 | |
| 2669 | genea = ensRegistryGetGeneadaptor(csdba); |
| 2670 | |
| 2671 | genelist = ajListNew(); |
| 2672 | |
| 2673 | gvvfa = ensRegistryGetGvvariationfeatureadaptor(gvdba); |
| 2674 | |
| 2675 | gvvfs = ajListNew(); |
| 2676 | |
| 2677 | ensGvvariationfeatureadaptorFetchAllbyGvvariation(gvvfa, gvv, gvvfs); |
| 2678 | |
| 2679 | /* |
| 2680 | ** For each Ensembl Genetic Variation Variation Feature, get the Slice |
| 2681 | ** is on, use the USTREAM and DOWNSTREAM limits to get all the Gene |
| 2682 | ** objects, and see if the Ensembl Genetic Variation Variation Feature is |
| 2683 | ** within the gene. |
| 2684 | */ |
| 2685 | |
| 2686 | while (ajListPop(gvvfs, (void **) &gvvf)) |
| 2687 | { |
| 2688 | /* Fetch an expanded Feature Slice. */ |
| 2689 | |
| 2690 | vfeature = ensGvvariationfeatureGetFeature(gvvf); |
| 2691 | |
| 2692 | ensSliceadaptorFetchByFeature(sla, vfeature, flank, &slice); |
| 2693 | |
| 2694 | /* Fetch all Ensembl Gene objects on the new Ensembl Slice. */ |
| 2695 | |
| 2696 | ensGeneadaptorFetchAllbySlice(genea, |
| 2697 | newslice, |
| 2698 | (AjPStr) NULL, |
| 2699 | (AjPStr) NULL, |
| 2700 | (AjPStr) NULL, |
| 2701 | ajFalse, |
| 2702 | genelist); |
| 2703 | |
| 2704 | while (ajListPop(genelist, (void **) &gene)) |
| 2705 | { |
| 2706 | if ((ensFeatureGetSeqregionStart(vfeature) |
| 2707 | >= (ensFeatureGetSeqregionStart(gfeature) - flank)) |
| 2708 | && |
| 2709 | (ensFeatureGetSeqregionStart(vfeature) |
| 2710 | <= (ensFeatureGetSeqregionEnd(gfeature) + flank)) |
| 2711 | && |
| 2712 | (ensFeatureGetSeqregionEnd(vfeature) |
| 2713 | <= (ensFeatureGetSeqregionEnd(gfeature) + flank))) |
| 2714 | { |
| 2715 | /* |
| 2716 | ** The Ensembl Genetic Variation Variation Feature is |
| 2717 | ** affecting the Gene, add to the AJAX Table if not present |
| 2718 | ** already |
| 2719 | */ |
| 2720 | |
| 2721 | identifier = ensGeneGetIdentifier(gene); |
| 2722 | |
| 2723 | if (!ajTableMatchV(genetable, (const void *) &identifier)) |
| 2724 | { |
| 2725 | AJNEW0(Pidentifier); |
| 2726 | |
| 2727 | *Pidentifier = ensGeneGetIdentifier(gene); |
| 2728 | |
| 2729 | ajTablePut(genetable, |
| 2730 | (void *) Pidentifier, |
| 2731 | (void *) ensGeneNewRef(gene)); |
| 2732 | } |
| 2733 | |
| 2734 | ensGeneDel(&gene); |
| 2735 | } |
| 2736 | } |
| 2737 | |
| 2738 | ensSliceDel(&slice); |
| 2739 | |
| 2740 | ensGvvariationfeatureDel(&gvvf); |
| 2741 | } |
| 2742 | |
| 2743 | ajListFree(&genelist); |
| 2744 | ajListFree(&gvvfs); |
| 2745 | |
| 2746 | /* Move all Ensembl Gene objects from the AJAX Table onto the AJAX List. */ |
| 2747 | |
| 2748 | ensTableuintToList(genetable, genes); |
| 2749 | |
| 2750 | ajTableFree(&genetable); |
| 2751 | |
| 2752 | return ajTrue; |
| 2753 | } |
| 2754 | |
| 2755 | |
| 2756 | |
| 2757 | |
| 2758 | /* @func ensGvvariationFetchAllGvsources ************************************** |
| 2759 | ** |
| 2760 | ** Fetch all Ensembl Genetic Variation Source objects of |
| 2761 | ** Ensembl Genetic Variation Synonym objects of an |
| 2762 | ** Ensembl Genetic Variation Variation. |
| 2763 | ** |
| 2764 | ** @cc Bio::EnsEMBL::Variation::Variation::get_all_synonym_sources |
| 2765 | ** @param [r] gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 2766 | ** @param [u] gvss [AjPList] |
| 2767 | ** AJAX List of Ensembl Genetic Variation Source objects |
| 2768 | ** |
| 2769 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 2770 | ** |
| 2771 | ** @release 6.4.0 |
| 2772 | ** @@ |
| 2773 | ******************************************************************************/ |
| 2774 | |
| 2775 | AjBool ensGvvariationFetchAllGvsources(const EnsPGvvariation gvv, |
| 2776 | AjPList gvss) |
| 2777 | { |
| 2778 | AjBool found = AJFALSE; |
| 2779 | |
| 2780 | AjIList iter1 = NULL; |
| 2781 | AjIList iter2 = NULL; |
| 2782 | |
| 2783 | EnsPGvsource gvs1 = NULL; |
| 2784 | EnsPGvsource gvs2 = NULL; |
| 2785 | |
| 2786 | if (!gvv) |
| 2787 | return ajFalse; |
| 2788 | |
| 2789 | if (!gvss) |
| 2790 | return ajFalse; |
| 2791 | |
| 2792 | iter1 = ajListIterNew(gvv->Gvsynonyms); |
| 2793 | iter2 = ajListIterNew(gvss); |
| 2794 | |
| 2795 | while (!ajListIterDone(iter1)) |
| 2796 | { |
| 2797 | gvs1 = (EnsPGvsource) ajListIterGet(iter1); |
| 2798 | |
| 2799 | ajListIterRewind(iter2); |
| 2800 | |
| 2801 | found = ajFalse; |
| 2802 | |
| 2803 | while (!ajListIterDone(iter2)) |
| 2804 | { |
| 2805 | gvs2 = (EnsPGvsource) ajListIterGet(iter2); |
| 2806 | |
| 2807 | if (ensGvsourceMatch(gvs1, gvs2)) |
| 2808 | { |
| 2809 | found = ajTrue; |
| 2810 | |
| 2811 | break; |
| 2812 | } |
| 2813 | } |
| 2814 | |
| 2815 | if (!found) |
| 2816 | ajListPushAppend(gvss, (void *) ensGvsourceNewRef(gvs1)); |
| 2817 | } |
| 2818 | |
| 2819 | ajListIterDel(&iter1); |
| 2820 | ajListIterDel(&iter2); |
| 2821 | |
| 2822 | return ajTrue; |
| 2823 | } |
| 2824 | |
| 2825 | |
| 2826 | |
| 2827 | |
| 2828 | /* @func ensGvvariationFetchAllGvsynonyms ************************************* |
| 2829 | ** |
| 2830 | ** Fetch all Ensembl Genetic Variation Synonym objects of an |
| 2831 | ** Ensembl Genetic Variation Variation. |
| 2832 | ** |
| 2833 | ** @cc Bio::EnsEMBL::Variation::Variation::get_all_synonyms |
| 2834 | ** @param [r] gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 2835 | ** @param [r] gvsourcename [const AjPStr] Ensembl Genetic Variation Source name |
| 2836 | ** @param [u] gvss [AjPList] |
| 2837 | ** AJAX List of Ensembl Genetic Variation Synonym objects |
| 2838 | ** |
| 2839 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 2840 | ** |
| 2841 | ** @release 6.4.0 |
| 2842 | ** @@ |
| 2843 | ******************************************************************************/ |
| 2844 | |
| 2845 | AjBool ensGvvariationFetchAllGvsynonyms(const EnsPGvvariation gvv, |
| 2846 | const AjPStr gvsourcename, |
| 2847 | AjPList gvss) |
| 2848 | { |
| 2849 | AjIList iter = NULL; |
| 2850 | |
| 2851 | EnsPGvsource gvsource = NULL; |
| 2852 | |
| 2853 | EnsPGvsynonym gvsynonym = NULL; |
| 2854 | |
| 2855 | if (!gvv) |
| 2856 | return ajFalse; |
| 2857 | |
| 2858 | if (!gvss) |
| 2859 | return ajFalse; |
| 2860 | |
| 2861 | iter = ajListIterNew(gvv->Gvsynonyms); |
| 2862 | |
| 2863 | while (!ajListIterDone(iter)) |
| 2864 | { |
| 2865 | gvsynonym = (EnsPGvsynonym) ajListIterGet(iter); |
| 2866 | |
| 2867 | if (gvsourcename && ajStrGetLen(gvsourcename)) |
| 2868 | { |
| 2869 | gvsource = ensGvsynonymGetGvsource(gvsynonym); |
| 2870 | |
| 2871 | if (ajStrMatchS(ensGvsourceGetName(gvsource), gvsourcename)) |
| 2872 | ajListPushAppend(gvss, (void *) ensGvsynonymNewRef(gvsynonym)); |
| 2873 | } |
| 2874 | else |
| 2875 | ajListPushAppend(gvss, (void *) ensGvsynonymNewRef(gvsynonym)); |
| 2876 | } |
| 2877 | |
| 2878 | ajListIterDel(&iter); |
| 2879 | |
| 2880 | return ajTrue; |
| 2881 | } |
| 2882 | |
| 2883 | |
| 2884 | |
| 2885 | |
| 2886 | /* @func ensGvvariationFetchAllGvvariationfeatures **************************** |
| 2887 | ** |
| 2888 | ** Fetch all Ensembl Genetic Variation Variation Feature objects of an |
| 2889 | ** Ensembl Genetic Variation Variation. |
| 2890 | ** |
| 2891 | ** @cc Bio::EnsEMBL::Variation::Variation::get_all_VariationFeatures |
| 2892 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 2893 | ** @param [u] gvvfs [AjPList] |
| 2894 | ** AJAX List of Ensembl Genetic Variation Variation Feature objects |
| 2895 | ** |
| 2896 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 2897 | ** |
| 2898 | ** @release 6.4.0 |
| 2899 | ** @@ |
| 2900 | ******************************************************************************/ |
| 2901 | |
| 2902 | AjBool ensGvvariationFetchAllGvvariationfeatures(EnsPGvvariation gvv, |
| 2903 | AjPList gvvfs) |
| 2904 | { |
| 2905 | if (!gvv) |
| 2906 | return ajFalse; |
| 2907 | |
| 2908 | if (!gvvfs) |
| 2909 | return ajFalse; |
| 2910 | |
| 2911 | if (!gvv->Adaptor) |
| 2912 | { |
| 2913 | ajDebug("ensGvvariationFetchAllGvvariationfeatures got an " |
| 2914 | "Ensembl Genetic Variation Variation without an " |
| 2915 | "Ensembl Genetic Variation Variation Adaptor attached.\n"); |
| 2916 | |
| 2917 | return ajTrue; |
| 2918 | } |
| 2919 | |
| 2920 | return ensGvvariationfeatureadaptorFetchAllbyGvvariation( |
| 2921 | ensRegistryGetGvvariationfeatureadaptor( |
| 2922 | ensGvvariationadaptorGetDatabaseadaptor(gvv->Adaptor)), |
| 2923 | gvv, |
| 2924 | gvvfs); |
| 2925 | } |
| 2926 | |
| 2927 | |
| 2928 | |
| 2929 | |
| 2930 | /* @section query ************************************************************* |
| 2931 | ** |
| 2932 | ** Functions for querying the properties of an |
| 2933 | ** Ensembl Genetic Variation Variation. |
| 2934 | ** |
| 2935 | ** @fdata [EnsPGvvariation] |
| 2936 | ** |
| 2937 | ** @nam3rule Has |
| 2938 | ** Check whether an Ensembl Genetic Variation Variation has a certain property |
| 2939 | ** @nam4rule Failedgvalleles |
| 2940 | ** Check for failed Ensembl Genetic Variation Allele objects |
| 2941 | ** @nam3rule Is |
| 2942 | ** Check whether an Ensembl Genetic Variation Variation represents a certain |
| 2943 | ** property |
| 2944 | ** @nam4rule Failed |
| 2945 | ** Check whether an Ensembl Genetic Variation Variation has been failed |
| 2946 | ** |
| 2947 | ** @argrule * gvv [EnsPGvvariation] |
| 2948 | ** Ensembl Genetic Variation Variation |
| 2949 | ** @argrule * Presult [AjBool*] Boolean result |
| 2950 | ** |
| 2951 | ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise |
| 2952 | ** |
| 2953 | ** @fcategory use |
| 2954 | ******************************************************************************/ |
| 2955 | |
| 2956 | |
| 2957 | |
| 2958 | |
| 2959 | /* @func ensGvvariationHasFailedgvalleles ************************************* |
| 2960 | ** |
| 2961 | ** Check if an Ensembl Genetic Variation Variation has failed |
| 2962 | ** Ensembl Genetic Variation Allele objects. |
| 2963 | ** |
| 2964 | ** @cc Bio::EnsEMBL::Variation::Variation::has_failed_alleles |
| 2965 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 2966 | ** @param [u] Presult [AjBool*] |
| 2967 | ** ajTrue, if at least one Ensembl Genetic Variation Allele has been failed |
| 2968 | ** |
| 2969 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 2970 | ** |
| 2971 | ** @release 6.4.0 |
| 2972 | ** @@ |
| 2973 | ******************************************************************************/ |
| 2974 | |
| 2975 | AjBool ensGvvariationHasFailedgvalleles(EnsPGvvariation gvv, AjBool *Presult) |
| 2976 | { |
| 2977 | AjBool result = AJFALSE; |
| 2978 | |
| 2979 | AjIList iter = NULL; |
| 2980 | |
| 2981 | EnsPGvallele gva = NULL; |
| 2982 | |
| 2983 | if (!gvv) |
| 2984 | return ajFalse; |
| 2985 | |
| 2986 | if (!Presult) |
| 2987 | return ajFalse; |
| 2988 | |
| 2989 | *Presult = ajFalse; |
| 2990 | |
| 2991 | if (!gvv->Gvalleles) |
| 2992 | return ajTrue; |
| 2993 | |
| 2994 | iter = ajListIterNewread(gvv->Gvalleles); |
| 2995 | |
| 2996 | while (!ajListIterDone(iter)) |
| 2997 | { |
| 2998 | gva = (EnsPGvallele) ajListIterGet(iter); |
| 2999 | |
| 3000 | ensGvalleleIsFailed(gva, &result); |
| 3001 | |
| 3002 | if (result == ajTrue) |
| 3003 | { |
| 3004 | *Presult = ajTrue; |
| 3005 | break; |
| 3006 | } |
| 3007 | } |
| 3008 | |
| 3009 | ajListIterDel(&iter); |
| 3010 | |
| 3011 | return ajTrue; |
| 3012 | } |
| 3013 | |
| 3014 | |
| 3015 | |
| 3016 | |
| 3017 | /* @func ensGvvariationIsFailed *********************************************** |
| 3018 | ** |
| 3019 | ** Check if an Ensembl Genetic Variation Variation has been failed. |
| 3020 | ** This function calls ensGvvariationLoadAllFaileddescriptions to find out if |
| 3021 | ** failed descriptiosn are available. |
| 3022 | ** |
| 3023 | ** @cc Bio::EnsEMBL::Variation::Variation::is_failed |
| 3024 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 3025 | ** @param [u] Presult [AjBool*] |
| 3026 | ** ajTrue, if an Ensembl Genetic Variation Variation has been failed |
| 3027 | ** |
| 3028 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 3029 | ** |
| 3030 | ** @release 6.4.0 |
| 3031 | ** @@ |
| 3032 | ******************************************************************************/ |
| 3033 | |
| 3034 | AjBool ensGvvariationIsFailed(EnsPGvvariation gvv, AjBool *Presult) |
| 3035 | { |
| 3036 | const AjPList descriptions = NULL; |
| 3037 | |
| 3038 | if (!gvv) |
| 3039 | return ajFalse; |
| 3040 | |
| 3041 | if (!Presult) |
| 3042 | return ajFalse; |
| 3043 | |
| 3044 | descriptions = ensGvvariationLoadAllFaileddescriptions(gvv); |
| 3045 | |
| 3046 | if (ajListGetLength(descriptions) > 0) |
| 3047 | *Presult = ajTrue; |
| 3048 | else |
| 3049 | *Presult = ajFalse; |
| 3050 | |
| 3051 | return ajTrue; |
| 3052 | } |
| 3053 | |
| 3054 | |
| 3055 | |
| 3056 | |
| 3057 | /* @datasection [EnsEGvvariationClass] Ensembl Genetic Variation |
| 3058 | ** Variation Class enumeration |
| 3059 | ** |
| 3060 | ** @nam2rule Gvvariation Functions for manipulating |
| 3061 | ** Ensembl Genetic Variation Variation objects |
| 3062 | ** @nam3rule GvvariationClass Functions for manipulating |
| 3063 | ** Ensembl Genetic Variation Variation Class enumerations |
| 3064 | ** |
| 3065 | ******************************************************************************/ |
| 3066 | |
| 3067 | |
| 3068 | |
| 3069 | |
| 3070 | /* @section Misc ************************************************************** |
| 3071 | ** |
| 3072 | ** Functions for returning an Ensembl Genetic Variation Variation Class |
| 3073 | ** enumeration. |
| 3074 | ** |
| 3075 | ** @fdata [EnsEGvvariationClass] |
| 3076 | ** |
| 3077 | ** @nam4rule From Ensembl Genetic Variation Variation Class query |
| 3078 | ** @nam5rule Str AJAX String object query |
| 3079 | ** |
| 3080 | ** @argrule Str class [const AjPStr] Class string |
| 3081 | ** |
| 3082 | ** @valrule * [EnsEGvvariationClass] |
| 3083 | ** Ensembl Genetic Variation Variation Class enumeration or |
| 3084 | ** ensEGvvariationClassNULL |
| 3085 | ** |
| 3086 | ** @fcategory misc |
| 3087 | ******************************************************************************/ |
| 3088 | |
| 3089 | |
| 3090 | |
| 3091 | |
| 3092 | /* @func ensGvvariationClassFromStr ******************************************* |
| 3093 | ** |
| 3094 | ** Convert an AJAX String into an Ensembl Genetic Variation Variation |
| 3095 | ** Class enumeration. |
| 3096 | ** |
| 3097 | ** @param [r] class [const AjPStr] Class string |
| 3098 | ** |
| 3099 | ** @return [EnsEGvvariationClass] |
| 3100 | ** Ensembl Genetic Variation Variation Class enumeration or |
| 3101 | ** ensEGvvariationClassNULL |
| 3102 | ** |
| 3103 | ** @release 6.4.0 |
| 3104 | ** @@ |
| 3105 | ******************************************************************************/ |
| 3106 | |
| 3107 | EnsEGvvariationClass ensGvvariationClassFromStr( |
| 3108 | const AjPStr class) |
| 3109 | { |
| 3110 | register EnsEGvvariationClass i = |
| 3111 | ensEGvvariationClassNULL; |
| 3112 | |
| 3113 | EnsEGvvariationClass gvvc = |
| 3114 | ensEGvvariationClassNULL; |
| 3115 | |
| 3116 | for (i = ensEGvvariationClassNULL; |
| 3117 | gvvariationKClass[i]; |
| 3118 | i++) |
| 3119 | if (ajStrMatchC(class, gvvariationKClass[i])) |
| 3120 | gvvc = i; |
| 3121 | |
| 3122 | if (!gvvc) |
| 3123 | ajDebug("ensGvvariationClassFromStr encountered " |
| 3124 | "unexpected string '%S'.\n", class); |
| 3125 | |
| 3126 | return gvvc; |
| 3127 | } |
| 3128 | |
| 3129 | |
| 3130 | |
| 3131 | |
| 3132 | /* @section Cast ************************************************************** |
| 3133 | ** |
| 3134 | ** Functions for returning attributes of an |
| 3135 | ** Ensembl Genetic Variation Variation Class enumeration. |
| 3136 | ** |
| 3137 | ** @fdata [EnsEGvvariationClass] |
| 3138 | ** |
| 3139 | ** @nam4rule To Return Ensembl Genetic Variation Variation Class |
| 3140 | ** enumeration |
| 3141 | ** @nam5rule Char Return C character string value |
| 3142 | ** |
| 3143 | ** @argrule To gvvc [EnsEGvvariationClass] |
| 3144 | ** Ensembl Genetic Variation Variation Class enumeration |
| 3145 | ** |
| 3146 | ** @valrule Char [const char*] |
| 3147 | ** Ensembl Genetic Variation Variation Class C-type (char *) string |
| 3148 | ** |
| 3149 | ** @fcategory cast |
| 3150 | ******************************************************************************/ |
| 3151 | |
| 3152 | |
| 3153 | |
| 3154 | |
| 3155 | /* @func ensGvvariationClassToChar ******************************************** |
| 3156 | ** |
| 3157 | ** Convert an Ensembl Genetic Variation Variation Class enumeration |
| 3158 | ** into a C-type (char *) string. |
| 3159 | ** |
| 3160 | ** @param [u] gvvc [EnsEGvvariationClass] |
| 3161 | ** Ensembl Genetic Variation Variation Class enumeration |
| 3162 | ** |
| 3163 | ** @return [const char*] |
| 3164 | ** Ensembl Genetic Variation Variation Class C-type (char *) string |
| 3165 | ** |
| 3166 | ** @release 6.4.0 |
| 3167 | ** @@ |
| 3168 | ******************************************************************************/ |
| 3169 | |
| 3170 | const char* ensGvvariationClassToChar( |
| 3171 | EnsEGvvariationClass gvvc) |
| 3172 | { |
| 3173 | register EnsEGvvariationClass i = |
| 3174 | ensEGvvariationClassNULL; |
| 3175 | |
| 3176 | for (i = ensEGvvariationClassNULL; |
| 3177 | gvvariationKClass[i] && (i < gvvc); |
| 3178 | i++); |
| 3179 | |
| 3180 | if (!gvvariationKClass[i]) |
| 3181 | ajDebug("ensGvvariationClassToChar " |
| 3182 | "encountered an out of boundary error on " |
| 3183 | "Ensembl Genetic Variation Variation Class " |
| 3184 | "enumeration %d.\n", |
| 3185 | gvvc); |
| 3186 | |
| 3187 | return gvvariationKClass[i]; |
| 3188 | } |
| 3189 | |
| 3190 | |
| 3191 | |
| 3192 | |
| 3193 | /* @datasection [EnsEGvvariationValidation] Ensembl Genetic Variation |
| 3194 | ** Variation Validation enumeration |
| 3195 | ** |
| 3196 | ** @nam2rule Gvvariation Functions for manipulating |
| 3197 | ** Ensembl Genetic Variation Variation objects |
| 3198 | ** @nam3rule GvvariationValidation Functions for manipulating |
| 3199 | ** Ensembl Genetic Variation Variation Validation enumerations |
| 3200 | ** |
| 3201 | ******************************************************************************/ |
| 3202 | |
| 3203 | |
| 3204 | |
| 3205 | |
| 3206 | /* @section Misc ************************************************************** |
| 3207 | ** |
| 3208 | ** Functions for returning an Ensembl Genetic Variation Variation Validation |
| 3209 | ** enumeration. |
| 3210 | ** |
| 3211 | ** @fdata [EnsEGvvariationValidation] |
| 3212 | ** |
| 3213 | ** @nam4rule From Ensembl Genetic Variation Variation Validation query |
| 3214 | ** @nam5rule Str AJAX String object query |
| 3215 | ** |
| 3216 | ** @argrule Str validation [const AjPStr] Validation string |
| 3217 | ** |
| 3218 | ** @valrule * [EnsEGvvariationValidation] |
| 3219 | ** Ensembl Genetic Variation Variation Validation enumeration or |
| 3220 | ** ensEGvvariationValidationNULL |
| 3221 | ** |
| 3222 | ** @fcategory misc |
| 3223 | ******************************************************************************/ |
| 3224 | |
| 3225 | |
| 3226 | |
| 3227 | |
| 3228 | /* @func ensGvvariationValidationFromStr ************************************** |
| 3229 | ** |
| 3230 | ** Convert an AJAX String into an Ensembl Genetic Variation Variation |
| 3231 | ** Validation enumeration. |
| 3232 | ** |
| 3233 | ** @param [r] validation [const AjPStr] Validation string |
| 3234 | ** |
| 3235 | ** @return [EnsEGvvariationValidation] |
| 3236 | ** Ensembl Genetic Variation Variation Validation enumeration or |
| 3237 | ** ensEGvvariationValidationNULL |
| 3238 | ** |
| 3239 | ** @release 6.4.0 |
| 3240 | ** @@ |
| 3241 | ******************************************************************************/ |
| 3242 | |
| 3243 | EnsEGvvariationValidation ensGvvariationValidationFromStr( |
| 3244 | const AjPStr validation) |
| 3245 | { |
| 3246 | register EnsEGvvariationValidation i = |
| 3247 | ensEGvvariationValidationNULL; |
| 3248 | |
| 3249 | EnsEGvvariationValidation gvvv = |
| 3250 | ensEGvvariationValidationNULL; |
| 3251 | |
| 3252 | for (i = ensEGvvariationValidationNULL; |
| 3253 | gvvariationKValidation[i]; |
| 3254 | i++) |
| 3255 | if (ajStrMatchC(validation, gvvariationKValidation[i])) |
| 3256 | gvvv = i; |
| 3257 | |
| 3258 | if (!gvvv) |
| 3259 | ajDebug("ensGvvariationValidationFromStr encountered " |
| 3260 | "unexpected string '%S'.\n", validation); |
| 3261 | |
| 3262 | return gvvv; |
| 3263 | } |
| 3264 | |
| 3265 | |
| 3266 | |
| 3267 | |
| 3268 | /* @section Cast ************************************************************** |
| 3269 | ** |
| 3270 | ** Functions for returning attributes of an |
| 3271 | ** Ensembl Genetic Variation Variation Validation enumeration. |
| 3272 | ** |
| 3273 | ** @fdata [EnsEGvvariationValidation] |
| 3274 | ** |
| 3275 | ** @nam4rule To Return Ensembl Genetic Variation Variation Validation |
| 3276 | ** enumeration |
| 3277 | ** @nam5rule Char Return C character string value |
| 3278 | ** |
| 3279 | ** @argrule To gvvv [EnsEGvvariationValidation] |
| 3280 | ** Ensembl Genetic Variation Variation Validation enumeration |
| 3281 | ** |
| 3282 | ** @valrule Char [const char*] |
| 3283 | ** Ensembl Genetic Variation Variation Validation C-type (char *) string |
| 3284 | ** |
| 3285 | ** @fcategory cast |
| 3286 | ******************************************************************************/ |
| 3287 | |
| 3288 | |
| 3289 | |
| 3290 | |
| 3291 | /* @func ensGvvariationValidationToChar *************************************** |
| 3292 | ** |
| 3293 | ** Convert an Ensembl Genetic Variation Variation Validation enumeration |
| 3294 | ** into a C-type (char *) string. |
| 3295 | ** |
| 3296 | ** @param [u] gvvv [EnsEGvvariationValidation] |
| 3297 | ** Ensembl Genetic Variation Variation Validation enumeration |
| 3298 | ** |
| 3299 | ** @return [const char*] |
| 3300 | ** Ensembl Genetic Variation Variation Validation C-type (char *) string |
| 3301 | ** |
| 3302 | ** @release 6.4.0 |
| 3303 | ** @@ |
| 3304 | ******************************************************************************/ |
| 3305 | |
| 3306 | const char* ensGvvariationValidationToChar( |
| 3307 | EnsEGvvariationValidation gvvv) |
| 3308 | { |
| 3309 | register EnsEGvvariationValidation i = |
| 3310 | ensEGvvariationValidationNULL; |
| 3311 | |
| 3312 | for (i = ensEGvvariationValidationNULL; |
| 3313 | gvvariationKValidation[i] && (i < gvvv); |
| 3314 | i++); |
| 3315 | |
| 3316 | if (!gvvariationKValidation[i]) |
| 3317 | ajDebug("ensGvvariationValidationToChar " |
| 3318 | "encountered an out of boundary error on " |
| 3319 | "Ensembl Genetic Variation Variation Validation " |
| 3320 | "enumeration %d.\n", |
| 3321 | gvvv); |
| 3322 | |
| 3323 | return gvvariationKValidation[i]; |
| 3324 | } |
| 3325 | |
| 3326 | |
| 3327 | |
| 3328 | |
| 3329 | /* @datasection [none] C-types ************************************************ |
| 3330 | ** |
| 3331 | ** @nam2rule Gvvariation Functions for manipulating |
| 3332 | ** Ensembl Genetic Variation Variation objects |
| 3333 | ** @nam3rule GvvariationValidations Functions for manipulating |
| 3334 | ** Ensembl Genetic Variation Variation Validation (AJAX unsigned integer) |
| 3335 | ** bit fields |
| 3336 | ** |
| 3337 | ******************************************************************************/ |
| 3338 | |
| 3339 | |
| 3340 | |
| 3341 | |
| 3342 | /* @section Misc ************************************************************** |
| 3343 | ** |
| 3344 | ** Functions for returning an Ensembl Genetic Variation Variation Validation |
| 3345 | ** bit field. |
| 3346 | ** |
| 3347 | ** @fdata [none] |
| 3348 | ** |
| 3349 | ** @nam4rule From Ensembl Genetic Variation Variation Validation |
| 3350 | ** bit field query |
| 3351 | ** @nam5rule Set SQL set (comma-separated strings) query |
| 3352 | ** |
| 3353 | ** @argrule Set gvvvset [const AjPStr] SQL set (comma-separated strings) |
| 3354 | ** |
| 3355 | ** @valrule * [ajuint] |
| 3356 | ** Ensembl Genetic Variation Variation Validation bit field or 0U |
| 3357 | ** |
| 3358 | ** @fcategory misc |
| 3359 | ******************************************************************************/ |
| 3360 | |
| 3361 | |
| 3362 | |
| 3363 | |
| 3364 | /* @func ensGvvariationValidationsFromSet ************************************* |
| 3365 | ** |
| 3366 | ** Convert an AJAX String representing a comma-separared SQL set of |
| 3367 | ** validation states into an Ensembl Genetic Variation Variation Validation |
| 3368 | ** (AJAX unsigned integer) bit field. |
| 3369 | ** |
| 3370 | ** @cc Bio::EnsEMBL::Variation::Utils::Sequence::array_to_bitval |
| 3371 | ** @param [r] gvvvset [const AjPStr] SQL set |
| 3372 | ** |
| 3373 | ** @return [ajuint] |
| 3374 | ** Ensembl Genetic Variation Variation Validation bit field or 0U |
| 3375 | ** |
| 3376 | ** @release 6.4.0 |
| 3377 | ** @@ |
| 3378 | ******************************************************************************/ |
| 3379 | |
| 3380 | ajuint ensGvvariationValidationsFromSet(const AjPStr gvvvset) |
| 3381 | { |
| 3382 | ajuint gvvvbf = 0U; |
| 3383 | |
| 3384 | AjPStr gvvvstring = NULL; |
| 3385 | |
| 3386 | AjPStrTok token = NULL; |
| 3387 | |
| 3388 | if (!gvvvset) |
| 3389 | return 0; |
| 3390 | |
| 3391 | /* Split the comma-separated list of validation states. */ |
| 3392 | |
| 3393 | token = ajStrTokenNewC(gvvvset, ","); |
| 3394 | |
| 3395 | gvvvstring = ajStrNew(); |
| 3396 | |
| 3397 | while (ajStrTokenNextParse(token, &gvvvstring)) |
| 3398 | gvvvbf |= (1 << ensGvvariationValidationFromStr(gvvvstring)); |
| 3399 | |
| 3400 | ajStrDel(&gvvvstring); |
| 3401 | |
| 3402 | ajStrTokenDel(&token); |
| 3403 | |
| 3404 | return gvvvbf; |
| 3405 | } |
| 3406 | |
| 3407 | |
| 3408 | |
| 3409 | |
| 3410 | /* @section Cast ************************************************************** |
| 3411 | ** |
| 3412 | ** Functions for returning attributes of an |
| 3413 | ** Ensembl Genetic Variation Variation Validation bit field. |
| 3414 | ** |
| 3415 | ** @fdata [none] |
| 3416 | ** |
| 3417 | ** @nam4rule To Cast an Ensembl Genetic Variation Variation Validation |
| 3418 | ** bit field |
| 3419 | ** @nam5rule Set Cast into an SQL set (comma-separated strings) |
| 3420 | ** |
| 3421 | ** @argrule To gvvvbf [ajuint] |
| 3422 | ** Ensembl Genetic Variation Variation Validation bit field |
| 3423 | ** @argrule Set Pgvvvset [AjPStr*] SQL set |
| 3424 | ** |
| 3425 | ** @valrule * [AjBool] True on success, false on failure |
| 3426 | ** |
| 3427 | ** @fcategory cast |
| 3428 | ******************************************************************************/ |
| 3429 | |
| 3430 | |
| 3431 | |
| 3432 | |
| 3433 | /* @func ensGvvariationValidationsToSet *************************************** |
| 3434 | ** |
| 3435 | ** Cast an Ensembl Genetic Variation Variation Validation bit field |
| 3436 | ** (AJAX unsigned integer) into an SQL set (comma-separared strings). |
| 3437 | ** |
| 3438 | ** The caller is responsible for deleting the AJAX String. |
| 3439 | ** |
| 3440 | ** @cc Bio::EnsEMBL::Variation::Utils::Sequence::bitval_to_array |
| 3441 | ** @param [r] gvvvbf [ajuint] |
| 3442 | ** Ensembl Genetic Variation Variation Validation bit field |
| 3443 | ** @param [w] Pgvvvset [AjPStr*] SQL set |
| 3444 | ** |
| 3445 | ** @return [AjBool] True on success, false on failure |
| 3446 | ** |
| 3447 | ** @release 6.4.0 |
| 3448 | ** @@ |
| 3449 | ******************************************************************************/ |
| 3450 | |
| 3451 | AjBool ensGvvariationValidationsToSet(ajuint gvvvbf, AjPStr *Pgvvvset) |
| 3452 | { |
| 3453 | register ajuint i = 0U; |
| 3454 | |
| 3455 | if (*Pgvvvset) |
| 3456 | ajStrAssignClear(Pgvvvset); |
| 3457 | else |
| 3458 | *Pgvvvset = ajStrNew(); |
| 3459 | |
| 3460 | for (i = 1U; gvvariationKValidation[i]; i++) |
| 3461 | if (gvvvbf & (1U << i)) |
| 3462 | { |
| 3463 | ajStrAppendC(Pgvvvset, gvvariationKValidation[i]); |
| 3464 | ajStrAppendC(Pgvvvset, ","); |
| 3465 | } |
| 3466 | |
| 3467 | /* Remove the last comma if one exists. */ |
| 3468 | |
| 3469 | if (ajStrGetLen(*Pgvvvset) > 0U) |
| 3470 | ajStrCutEnd(Pgvvvset, 1); |
| 3471 | |
| 3472 | return ajTrue; |
| 3473 | } |
| 3474 | |
| 3475 | |
| 3476 | |
| 3477 | |
| 3478 | /* @funcstatic listGvvariationCompareIdentifierAscending ********************** |
| 3479 | ** |
| 3480 | ** AJAX List comparison function to sort Ensembl Genetic Variation Variation |
| 3481 | ** objects by identifier in ascending order. |
| 3482 | ** |
| 3483 | ** @param [r] item1 [const void*] Ensembl Genetic Variation Variation 1 |
| 3484 | ** @param [r] item2 [const void*] Ensembl Genetic Variation Variation 2 |
| 3485 | ** @see ajListSort |
| 3486 | ** @see ajListSortUnique |
| 3487 | ** |
| 3488 | ** @return [int] The comparison function returns an integer less than, |
| 3489 | ** equal to, or greater than zero if the first argument is |
| 3490 | ** considered to be respectively less than, equal to, or |
| 3491 | ** greater than the second. |
| 3492 | ** |
| 3493 | ** @release 6.4.0 |
| 3494 | ** @@ |
| 3495 | ******************************************************************************/ |
| 3496 | |
| 3497 | static int listGvvariationCompareIdentifierAscending( |
| 3498 | const void *item1, |
| 3499 | const void *item2) |
| 3500 | { |
| 3501 | int result = 0; |
| 3502 | |
| 3503 | EnsPGvvariation gvv1 = *(EnsOGvvariation *const *) item1; |
| 3504 | EnsPGvvariation gvv2 = *(EnsOGvvariation *const *) item2; |
| 3505 | |
| 3506 | #if defined(AJ_DEBUG) && AJ_DEBUG >= 2 |
| 3507 | if (ajDebugTest("listGvvariationCompareIdentifierAscending")) |
| 3508 | ajDebug("listGvvariationCompareIdentifierAscending\n" |
| 3509 | " gvv1 %p\n" |
| 3510 | " gvv2 %p\n", |
| 3511 | gvv1, |
| 3512 | gvv2); |
| 3513 | #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 2 */ |
| 3514 | |
| 3515 | if (gvv1->Identifier < gvv2->Identifier) |
| 3516 | result = -1; |
| 3517 | |
| 3518 | if (gvv1->Identifier > gvv2->Identifier) |
| 3519 | result = +1; |
| 3520 | |
| 3521 | return result; |
| 3522 | } |
| 3523 | |
| 3524 | |
| 3525 | |
| 3526 | |
| 3527 | /* @funcstatic listGvvariationDelete ****************************************** |
| 3528 | ** |
| 3529 | ** ajListSortUnique "itemdel" function to delete Ensembl Genetic Variation |
| 3530 | ** Variation objects that are redundant. |
| 3531 | ** |
| 3532 | ** @param [r] Pitem [void**] Ensembl Genetic Variation Variation address |
| 3533 | ** @param [r] cl [void*] Standard, passed in from ajListSortUnique |
| 3534 | ** @see ajListSortUnique |
| 3535 | ** |
| 3536 | ** @return [void] |
| 3537 | ** |
| 3538 | ** @release 6.4.0 |
| 3539 | ** @@ |
| 3540 | ******************************************************************************/ |
| 3541 | |
| 3542 | static void listGvvariationDelete(void **Pitem, void *cl) |
| 3543 | { |
| 3544 | if (!Pitem) |
| 3545 | return; |
| 3546 | |
| 3547 | (void) cl; |
| 3548 | |
| 3549 | ensGvvariationDel((EnsPGvvariation *) Pitem); |
| 3550 | |
| 3551 | return; |
| 3552 | } |
| 3553 | |
| 3554 | |
| 3555 | |
| 3556 | |
| 3557 | /* |
| 3558 | ** TODO: The following methods are not implemented: |
| 3559 | ** failed_description |
| 3560 | ** get_VariationFeature_by_dbID |
| 3561 | ** get_all_IndividualGenotypes |
| 3562 | ** get_all_PopulationGenotypes |
| 3563 | ** add_PopulationGenotype |
| 3564 | ** ambig_code |
| 3565 | ** derived_allele_frequency |
| 3566 | ** derived_allele |
| 3567 | */ |
| 3568 | |
| 3569 | |
| 3570 | |
| 3571 | |
| 3572 | /* @datasection [EnsPGvvariationadaptor] Ensembl Genetic Variation Variation |
| 3573 | ** Adaptor |
| 3574 | ** |
| 3575 | ** @nam2rule Gvvariationadaptor Functions for manipulating |
| 3576 | ** Ensembl Genetic Variation Variation Adaptor objects |
| 3577 | ** |
| 3578 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationAdaptor |
| 3579 | ** @cc CVS Revision: 1.90 |
| 3580 | ** @cc CVS Tag: branch-ensembl-68 |
| 3581 | ** |
| 3582 | ** NOTE: Since the "source" SQL table contains only a small number of records |
| 3583 | ** linked to a potentially large number of records in other SQL tables, the |
| 3584 | ** contents have been modelled as independent objects. The EnsPGvsourceadaptor |
| 3585 | ** caches all EnsPGvsource entries, which should help reduce memory |
| 3586 | ** requirements. Consequently, neither the "variation" nor "variation_synonym" |
| 3587 | ** SQL tables need joining to the "source" table. |
| 3588 | ******************************************************************************/ |
| 3589 | |
| 3590 | |
| 3591 | |
| 3592 | |
| 3593 | /* @funcstatic gvvariationadaptorFetchAllbyConstraint ************************* |
| 3594 | ** |
| 3595 | ** Fetch all Ensembl Genetic Variation Variation objects via an SQL constraint. |
| 3596 | ** |
| 3597 | ** @param [u] gvva [EnsPGvvariationadaptor] |
| 3598 | ** Ensembl Genetic Variation Variation Adaptor |
| 3599 | ** @param [r] constraint [const AjPStr] SQL constraint |
| 3600 | ** @param [r] joinallele [AjBool] Join the "allele" SQL table |
| 3601 | ** @param [r] joinflank [AjBool] Join the "flanking_sequence" SQL table |
| 3602 | ** @param [r] joinsource [AjBool] Join the "source" SQL table |
| 3603 | ** @param [u] gvvs [AjPList] |
| 3604 | ** AJAX List of Ensembl Genetic Variation Variation objects |
| 3605 | ** |
| 3606 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 3607 | ** |
| 3608 | ** @release 6.5.0 |
| 3609 | ** @@ |
| 3610 | ******************************************************************************/ |
| 3611 | |
| 3612 | static AjBool gvvariationadaptorFetchAllbyConstraint( |
| 3613 | EnsPGvvariationadaptor gvva, |
| 3614 | const AjPStr constraint, |
| 3615 | AjBool joinallele, |
| 3616 | AjBool joinflank, |
| 3617 | AjBool joinsource, |
| 3618 | AjPList gvvs) |
| 3619 | { |
| 3620 | register ajuint i = 0U; |
| 3621 | register ajuint j = 0U; |
| 3622 | register ajuint k = 0U; |
| 3623 | |
| 3624 | AjPStr defaultcondition = NULL; |
| 3625 | AjPStr fvsconstraint = NULL; |
| 3626 | |
| 3627 | if (!gvva) |
| 3628 | return ajFalse; |
| 3629 | |
| 3630 | if (!gvvs) |
| 3631 | return ajFalse; |
| 3632 | |
| 3633 | /* |
| 3634 | ** The SQL column name, SQL table name and Leftjoin arrays have been |
| 3635 | ** allocated to their maximum size. |
| 3636 | ** Set the iterators to their last common array element. |
| 3637 | */ |
| 3638 | |
| 3639 | for (i = 0U; gvvariationadaptorKColumnnames[i]; i++); |
| 3640 | |
| 3641 | for (j = 0U; gvvariationadaptorKTablenames[j]; j++); |
| 3642 | |
| 3643 | for (k = 0U; gvvariationadaptorKLeftjoins[k].Tablename; k++); |
| 3644 | |
| 3645 | ajCharDel(&gvva->Defaultcondition); |
| 3646 | |
| 3647 | defaultcondition = ajStrNewC(gvvariationadaptorKDefaultcondition); |
| 3648 | |
| 3649 | if (joinallele == ajTrue) |
| 3650 | { |
| 3651 | gvva->Tablenames[j] = ajCharNewC("allele"); |
| 3652 | j++; |
| 3653 | |
| 3654 | if (ajStrGetLen(defaultcondition)) |
| 3655 | ajStrAppendC(&defaultcondition, |
| 3656 | " AND " |
| 3657 | "allele.variation_id = " |
| 3658 | "variation.variation_id"); |
| 3659 | else |
| 3660 | ajStrAppendC(&defaultcondition, |
| 3661 | "allele.variation_id = " |
| 3662 | "variation.variation_id"); |
| 3663 | } |
| 3664 | |
| 3665 | if (!ensGvbaseadaptorGetFailedvariations( |
| 3666 | ensGvvariationadaptorGetGvbaseadaptor(gvva))) |
| 3667 | { |
| 3668 | gvva->Tablenames[j] = ajCharNewC("failed_variation"); |
| 3669 | j++; |
| 3670 | |
| 3671 | gvva->Leftjoins[k].Tablename = |
| 3672 | ajCharNewC("failed_variation"); |
| 3673 | gvva->Leftjoins[k].Condition = |
| 3674 | ajCharNewC("variation.variation_id = " |
| 3675 | "failed_variation.variation_id"); |
| 3676 | k++; |
| 3677 | } |
| 3678 | |
| 3679 | if (joinflank == ajTrue) |
| 3680 | { |
| 3681 | gvva->Columnnames[i] = ajCharNewC( |
| 3682 | "(" |
| 3683 | "flanking_sequence.up_seq IS NOT NULL " |
| 3684 | "OR " |
| 3685 | "flanking_sequence.down_seq IS NOT NULL" |
| 3686 | ")"); |
| 3687 | i++; |
| 3688 | |
| 3689 | gvva->Tablenames[j] = ajCharNewC("flanking_sequence"); |
| 3690 | j++; |
| 3691 | |
| 3692 | gvva->Leftjoins[k].Tablename = |
| 3693 | ajCharNewC("flanking_sequence"); |
| 3694 | gvva->Leftjoins[k].Condition = |
| 3695 | ajCharNewC("variation.variation_id = " |
| 3696 | "flanking_sequence.variation_id"); |
| 3697 | k++; |
| 3698 | } |
| 3699 | else |
| 3700 | { |
| 3701 | gvva->Columnnames[i] = ajCharNewC("0"); |
| 3702 | i++; |
| 3703 | } |
| 3704 | |
| 3705 | if (joinsource) |
| 3706 | { |
| 3707 | gvva->Tablenames[i] = ajCharNewC("source"); |
| 3708 | i++; |
| 3709 | |
| 3710 | if (ajStrGetLen(defaultcondition)) |
| 3711 | ajStrAppendC(&defaultcondition, |
| 3712 | " AND variation.source_id = source.source_id"); |
| 3713 | else |
| 3714 | ajStrAppendC(&defaultcondition, |
| 3715 | "variation.source_id = source.source_id"); |
| 3716 | } |
| 3717 | |
| 3718 | gvva->Columnnames[i] = NULL; |
| 3719 | gvva->Tablenames[j] = NULL; |
| 3720 | gvva->Leftjoins[k].Tablename = NULL; |
| 3721 | gvva->Leftjoins[k].Condition = NULL; |
| 3722 | |
| 3723 | /* |
| 3724 | ** FIXME: Not sure, but this may have to add the failed_variation |
| 3725 | ** condition here. |
| 3726 | */ |
| 3727 | |
| 3728 | ensGvdatabaseadaptorFailedvariationsconstraint( |
| 3729 | ensGvvariationadaptorGetGvdatabaseadaptor(gvva), |
| 3730 | (const AjPStr) NULL, |
| 3731 | &fvsconstraint); |
| 3732 | |
| 3733 | ajStrAppendC(&defaultcondition, " AND "); |
| 3734 | ajStrAppendS(&defaultcondition, fvsconstraint); |
| 3735 | |
| 3736 | ajStrDel(&fvsconstraint); |
| 3737 | |
| 3738 | gvva->Defaultcondition = ajCharNewC(ajStrGetPtr(defaultcondition)); |
| 3739 | |
| 3740 | ajStrDel(&defaultcondition); |
| 3741 | |
| 3742 | return ensBaseadaptorFetchAllbyConstraint( |
| 3743 | ensGvvariationadaptorGetBaseadaptor(gvva), |
| 3744 | constraint, |
| 3745 | (EnsPAssemblymapper) NULL, |
| 3746 | (EnsPSlice) NULL, |
| 3747 | gvvs); |
| 3748 | } |
| 3749 | |
| 3750 | |
| 3751 | |
| 3752 | |
| 3753 | /* @funcstatic gvvariationadaptorFetchAllbyStatement ************************** |
| 3754 | ** |
| 3755 | ** Fetch all Ensembl Genetic Variation Variation objects via an SQL statement. |
| 3756 | ** |
| 3757 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationAdaptor::_objs_from_sth |
| 3758 | ** @param [u] ba [EnsPBaseadaptor] Ensembl Base Adaptor |
| 3759 | ** @param [r] statement [const AjPStr] SQL statement |
| 3760 | ** @param [uN] am [EnsPAssemblymapper] Ensembl Assembly Mapper |
| 3761 | ** @param [uN] slice [EnsPSlice] Ensembl Slice |
| 3762 | ** @param [u] gvvs [AjPList] |
| 3763 | ** AJAX List of Ensembl Genetic Variation Variation objects |
| 3764 | ** |
| 3765 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 3766 | ** |
| 3767 | ** @release 6.4.0 |
| 3768 | ** @@ |
| 3769 | ******************************************************************************/ |
| 3770 | |
| 3771 | static AjBool gvvariationadaptorFetchAllbyStatement( |
| 3772 | EnsPBaseadaptor ba, |
| 3773 | const AjPStr statement, |
| 3774 | EnsPAssemblymapper am, |
| 3775 | EnsPSlice slice, |
| 3776 | AjPList gvvs) |
| 3777 | { |
| 3778 | float gvafrequency = 0.0F; |
| 3779 | float gvvmafrequency = 0.0F; |
| 3780 | |
| 3781 | ajuint gvvidentifier = 0U; |
| 3782 | ajuint gvvidentifierold = 0U; |
| 3783 | ajuint gvasubidentifier = 0U; |
| 3784 | ajuint gvvgvaclassid = 0U; |
| 3785 | ajuint gvvgvaclinicalid = 0U; |
| 3786 | ajuint gvvsourceid = 0U; |
| 3787 | ajuint gvaidentifier = 0U; |
| 3788 | ajuint gvaidentifierold = 0U; |
| 3789 | ajuint gvacount = 0U; |
| 3790 | ajuint gvagvsampleid = 0U; |
| 3791 | ajuint gvvsidentifier = 0U; |
| 3792 | ajuint gvvssubidentifier = 0U; |
| 3793 | ajuint gvvssourceid = 0U; |
| 3794 | ajuint gvvmacount = 0U; |
| 3795 | |
| 3796 | ajuint *Pidentifier = NULL; |
| 3797 | |
| 3798 | AjBool gvvflank = AJFALSE; |
| 3799 | AjBool gvvflipped = AJFALSE; |
| 3800 | AjBool gvvsomatic = AJFALSE; |
| 3801 | |
| 3802 | AjPSqlstatement sqls = NULL; |
| 3803 | AjISqlrow sqli = NULL; |
| 3804 | AjPSqlrow sqlr = NULL; |
| 3805 | |
| 3806 | AjPStr gvvname = NULL; |
| 3807 | AjPStr gvvvalidation = NULL; |
| 3808 | AjPStr gvvancestral = NULL; |
| 3809 | AjPStr gvaallele = NULL; |
| 3810 | AjPStr gvvsmoleculetype = NULL; |
| 3811 | AjPStr gvvsname = NULL; |
| 3812 | AjPStr gvvmaallele = NULL; |
| 3813 | |
| 3814 | AjPTable gvpopulations = NULL; |
| 3815 | AjPTable gvsynonyms = NULL; |
| 3816 | |
| 3817 | EnsPDatabaseadaptor dba = NULL; |
| 3818 | |
| 3819 | EnsPGvallele gvallele = NULL; |
| 3820 | EnsPGvalleleadaptor gvallelea = NULL; |
| 3821 | |
| 3822 | EnsPGvattribute gvaclass = NULL; |
| 3823 | EnsPGvattribute gvaclinical = NULL; |
| 3824 | EnsPGvattributeadaptor gvattributea = NULL; |
| 3825 | |
| 3826 | EnsPGvpopulation gvp = NULL; |
| 3827 | EnsPGvpopulationadaptor gvpa = NULL; |
| 3828 | |
| 3829 | EnsPGvvariation gvv = NULL; |
| 3830 | EnsPGvvariationadaptor gvva = NULL; |
| 3831 | |
| 3832 | EnsPGvsource gvsource = NULL; |
| 3833 | EnsPGvsourceadaptor gvsourcea = NULL; |
| 3834 | |
| 3835 | EnsPGvsynonym gvsynonym = NULL; |
| 3836 | EnsPGvsynonymadaptor gvsynonyma = NULL; |
| 3837 | |
| 3838 | if (ajDebugTest("gvvariationadaptorFetchAllbyStatement")) |
| 3839 | ajDebug("gvvariationadaptorFetchAllbyStatement\n" |
| 3840 | " ba %p\n" |
| 3841 | " statement %p\n" |
| 3842 | " am %p\n" |
| 3843 | " slice %p\n" |
| 3844 | " gvvs %p\n", |
| 3845 | ba, |
| 3846 | statement, |
| 3847 | am, |
| 3848 | slice, |
| 3849 | gvvs); |
| 3850 | |
| 3851 | if (!ba) |
| 3852 | return ajFalse; |
| 3853 | |
| 3854 | if (!statement) |
| 3855 | return ajFalse; |
| 3856 | |
| 3857 | if (!gvvs) |
| 3858 | return ajFalse; |
| 3859 | |
| 3860 | /* |
| 3861 | ** Initialise AJAX Table objects with AJAX unsigned integer key and |
| 3862 | ** Ensembl Genetic Variation Population and Ensembl Genetic Variation |
| 3863 | ** Synonym value data. |
| 3864 | */ |
| 3865 | gvpopulations = ajTableuintNew(0U); |
| 3866 | gvsynonyms = ajTableuintNew(0U); |
| 3867 | |
| 3868 | ajTableSetDestroyvalue(gvpopulations, |
| 3869 | (void (*)(void **)) &ensGvpopulationDel); |
| 3870 | |
| 3871 | ajTableSetDestroyvalue(gvsynonyms, |
| 3872 | (void (*)(void **)) &ensGvsynonymDel); |
| 3873 | |
| 3874 | dba = ensBaseadaptorGetDatabaseadaptor(ba); |
| 3875 | |
| 3876 | gvallelea = ensRegistryGetGvalleleadaptor(dba); |
| 3877 | gvattributea = ensRegistryGetGvattributeadaptor(dba); |
| 3878 | gvpa = ensRegistryGetGvpopulationadaptor(dba); |
| 3879 | gvsourcea = ensRegistryGetGvsourceadaptor(dba); |
| 3880 | gvsynonyma = ensRegistryGetGvsynonymadaptor(dba); |
| 3881 | gvva = ensRegistryGetGvvariationadaptor(dba); |
| 3882 | |
| 3883 | sqls = ensDatabaseadaptorSqlstatementNew(dba, statement); |
| 3884 | |
| 3885 | sqli = ajSqlrowiterNew(sqls); |
| 3886 | |
| 3887 | while (!ajSqlrowiterDone(sqli)) |
| 3888 | { |
| 3889 | /* "variation" SQL table */ |
| 3890 | gvvidentifier = 0U; |
| 3891 | gvvsourceid = 0U; |
| 3892 | gvvname = ajStrNew(); |
| 3893 | gvvvalidation = ajStrNew(); |
| 3894 | gvvancestral = ajStrNew(); |
| 3895 | gvvgvaclassid = 0U; |
| 3896 | gvvsomatic = ajFalse; |
| 3897 | gvvflipped = ajFalse; |
| 3898 | gvvmaallele = ajStrNew(); |
| 3899 | gvvmacount = 0U; |
| 3900 | gvvmafrequency = 0.0F; |
| 3901 | gvvgvaclinicalid = 0U; |
| 3902 | /* "allele" SQL table */ |
| 3903 | gvaidentifier = 0U; |
| 3904 | gvasubidentifier = 0U; |
| 3905 | gvaallele = ajStrNew(); |
| 3906 | gvafrequency = 0.0F; |
| 3907 | gvacount = 0U; |
| 3908 | gvagvsampleid = 0U; |
| 3909 | /* "variation_synonym" SQL table */ |
| 3910 | gvvsidentifier = 0U; |
| 3911 | gvvssubidentifier = 0U; |
| 3912 | gvvsourceid = 0U; |
| 3913 | gvvsname = ajStrNew(); |
| 3914 | gvvsmoleculetype = ajStrNew(); |
| 3915 | /* */ |
| 3916 | gvvflank = ajFalse; |
| 3917 | |
| 3918 | sqlr = ajSqlrowiterGet(sqli); |
| 3919 | |
| 3920 | /* "variation" SQL table */ |
| 3921 | ajSqlcolumnToUint(sqlr, &gvvidentifier); |
| 3922 | ajSqlcolumnToUint(sqlr, &gvvsourceid); |
| 3923 | ajSqlcolumnToStr(sqlr, &gvvname); |
| 3924 | ajSqlcolumnToStr(sqlr, &gvvvalidation); |
| 3925 | ajSqlcolumnToStr(sqlr, &gvvancestral); |
| 3926 | ajSqlcolumnToUint(sqlr, &gvvgvaclassid); |
| 3927 | ajSqlcolumnToBool(sqlr, &gvvsomatic); |
| 3928 | ajSqlcolumnToBool(sqlr, &gvvflipped); |
| 3929 | ajSqlcolumnToStr(sqlr, &gvvmaallele); |
| 3930 | ajSqlcolumnToUint(sqlr, &gvvmacount); |
| 3931 | ajSqlcolumnToFloat(sqlr, &gvvmafrequency); |
| 3932 | ajSqlcolumnToUint(sqlr, &gvvgvaclinicalid); |
| 3933 | /* "allele" SQL table */ |
| 3934 | ajSqlcolumnToUint(sqlr, &gvaidentifier); |
| 3935 | ajSqlcolumnToUint(sqlr, &gvasubidentifier); |
| 3936 | ajSqlcolumnToStr(sqlr, &gvaallele); |
| 3937 | ajSqlcolumnToFloat(sqlr, &gvafrequency); |
| 3938 | ajSqlcolumnToUint(sqlr, &gvacount); |
| 3939 | ajSqlcolumnToUint(sqlr, &gvagvsampleid); |
| 3940 | /* "variation_synonym" SQL table */ |
| 3941 | ajSqlcolumnToUint(sqlr, &gvvsidentifier); |
| 3942 | ajSqlcolumnToUint(sqlr, &gvvssubidentifier); |
| 3943 | ajSqlcolumnToUint(sqlr, &gvvssourceid); |
| 3944 | ajSqlcolumnToStr(sqlr, &gvvsname); |
| 3945 | ajSqlcolumnToStr(sqlr, &gvvsmoleculetype); |
| 3946 | /* |
| 3947 | ** (flanking_sequence.up_seq IS NOT NULL |
| 3948 | ** OR |
| 3949 | ** flanking_sequence.down_seq IS NOT NULL) |
| 3950 | */ |
| 3951 | ajSqlcolumnToBool(sqlr, &gvvflank); |
| 3952 | |
| 3953 | if (gvvidentifier != gvvidentifierold) |
| 3954 | { |
| 3955 | ensGvattributeadaptorFetchByIdentifier(gvattributea, |
| 3956 | gvvgvaclassid, |
| 3957 | &gvaclass); |
| 3958 | |
| 3959 | ensGvattributeadaptorFetchByIdentifier(gvattributea, |
| 3960 | gvvgvaclinicalid, |
| 3961 | &gvaclinical); |
| 3962 | |
| 3963 | /* |
| 3964 | ** NOTE: Because information from the "source" SQL table is |
| 3965 | ** modelled as independent EnsPGvsource object, neither |
| 3966 | ** "variation" nor "variation_synonym" need joining. |
| 3967 | */ |
| 3968 | |
| 3969 | ensGvsourceadaptorFetchByIdentifier(gvsourcea, |
| 3970 | gvvsourceid, |
| 3971 | &gvsource); |
| 3972 | |
| 3973 | gvv = ensGvvariationNewIni(gvva, |
| 3974 | gvvidentifier, |
| 3975 | gvaclass, |
| 3976 | gvaclinical, |
| 3977 | gvsource, |
| 3978 | gvvname, |
| 3979 | gvvancestral, |
| 3980 | (AjPList) NULL, /* synonyms */ |
| 3981 | (AjPList) NULL, /* alleles */ |
| 3982 | gvvvalidation, |
| 3983 | gvvsmoleculetype, |
| 3984 | (AjPStr) NULL, /* flankfive */ |
| 3985 | (AjPStr) NULL, /* flankthree */ |
| 3986 | gvvflank, |
| 3987 | gvvsomatic, |
| 3988 | gvvflipped, |
| 3989 | gvvmaallele, |
| 3990 | gvvmacount, |
| 3991 | gvvmafrequency); |
| 3992 | |
| 3993 | ajListPushAppend(gvvs, (void *) gvv); |
| 3994 | |
| 3995 | ensGvattributeDel(&gvaclass); |
| 3996 | |
| 3997 | ensGvsourceDel(&gvsource); |
| 3998 | |
| 3999 | gvvidentifierold = gvvidentifier; |
| 4000 | } |
| 4001 | |
| 4002 | if (gvaidentifier != gvaidentifierold) |
| 4003 | { |
| 4004 | /* Fetch the Ensembl Genetic Variation Population. */ |
| 4005 | |
| 4006 | if (gvagvsampleid) |
| 4007 | { |
| 4008 | gvp = (EnsPGvpopulation) ajTableFetchmodV( |
| 4009 | gvpopulations, |
| 4010 | (const void *) &gvagvsampleid); |
| 4011 | |
| 4012 | if (!gvp) |
| 4013 | { |
| 4014 | ensGvpopulationadaptorFetchByIdentifier(gvpa, |
| 4015 | gvagvsampleid, |
| 4016 | &gvp); |
| 4017 | |
| 4018 | if (gvp) |
| 4019 | { |
| 4020 | AJNEW0(Pidentifier); |
| 4021 | |
| 4022 | *Pidentifier = ensGvpopulationGetIdentifier(gvp); |
| 4023 | |
| 4024 | ajTablePut(gvpopulations, |
| 4025 | (void *) Pidentifier, |
| 4026 | (void *) gvp); |
| 4027 | } |
| 4028 | } |
| 4029 | } |
| 4030 | else |
| 4031 | gvp = NULL; |
| 4032 | |
| 4033 | if (gvaidentifier) |
| 4034 | { |
| 4035 | gvallele = ensGvalleleNewIni(gvallelea, |
| 4036 | gvaidentifier, |
| 4037 | gvp, |
| 4038 | gvaallele, |
| 4039 | gvafrequency, |
| 4040 | gvasubidentifier, |
| 4041 | gvacount, |
| 4042 | gvvidentifier); |
| 4043 | |
| 4044 | ensGvvariationAddGvallele(gvv, gvallele); |
| 4045 | |
| 4046 | ensGvalleleDel(&gvallele); |
| 4047 | |
| 4048 | gvaidentifierold = gvaidentifier; |
| 4049 | } |
| 4050 | else |
| 4051 | gvallele = NULL; |
| 4052 | } |
| 4053 | |
| 4054 | if (gvvsidentifier) |
| 4055 | { |
| 4056 | gvsynonym = (EnsPGvsynonym) ajTableFetchmodV( |
| 4057 | gvsynonyms, |
| 4058 | (const void *) &gvvsidentifier); |
| 4059 | |
| 4060 | if (!gvsynonym) |
| 4061 | { |
| 4062 | ensGvsourceadaptorFetchByIdentifier(gvsourcea, |
| 4063 | gvvssourceid, |
| 4064 | &gvsource); |
| 4065 | |
| 4066 | gvsynonym = ensGvsynonymNewIni(gvsynonyma, |
| 4067 | gvvsidentifier, |
| 4068 | gvsource, |
| 4069 | gvvsname, |
| 4070 | gvvsmoleculetype, |
| 4071 | gvvidentifier, |
| 4072 | gvvssubidentifier); |
| 4073 | |
| 4074 | ensGvsourceDel(&gvsource); |
| 4075 | |
| 4076 | if (gvsynonym) |
| 4077 | { |
| 4078 | AJNEW0(Pidentifier); |
| 4079 | |
| 4080 | *Pidentifier = gvvsidentifier; |
| 4081 | |
| 4082 | ajTablePut(gvsynonyms, |
| 4083 | (void *) Pidentifier, |
| 4084 | (void *) gvsynonym); |
| 4085 | } |
| 4086 | } |
| 4087 | |
| 4088 | ensGvvariationAddGvsynonym(gvv, gvsynonym); |
| 4089 | } |
| 4090 | |
| 4091 | ajStrDel(&gvvname); |
| 4092 | ajStrDel(&gvvvalidation); |
| 4093 | ajStrDel(&gvvancestral); |
| 4094 | ajStrDel(&gvaallele); |
| 4095 | ajStrDel(&gvvsmoleculetype); |
| 4096 | ajStrDel(&gvvsname); |
| 4097 | } |
| 4098 | |
| 4099 | ajSqlrowiterDel(&sqli); |
| 4100 | |
| 4101 | ensDatabaseadaptorSqlstatementDel(dba, &sqls); |
| 4102 | |
| 4103 | ajTableDel(&gvpopulations); |
| 4104 | ajTableDel(&gvsynonyms); |
| 4105 | |
| 4106 | return ajTrue; |
| 4107 | } |
| 4108 | |
| 4109 | |
| 4110 | |
| 4111 | |
| 4112 | /* @section constructors ****************************************************** |
| 4113 | ** |
| 4114 | ** All constructors return a new Ensembl Genetic Variation Variation Adaptor |
| 4115 | ** by pointer. |
| 4116 | ** It is the responsibility of the user to first destroy any previous |
| 4117 | ** Genetic Variation Variation Adaptor. |
| 4118 | ** The target pointer does not need to be initialised to NULL, |
| 4119 | ** but it is good programming practice to do so anyway. |
| 4120 | ** |
| 4121 | ** @fdata [EnsPGvvariationadaptor] |
| 4122 | ** |
| 4123 | ** @nam3rule New Constructor |
| 4124 | ** |
| 4125 | ** @argrule New dba [EnsPDatabaseadaptor] Ensembl Database Adaptor |
| 4126 | ** |
| 4127 | ** @valrule * [EnsPGvvariationadaptor] |
| 4128 | ** Ensembl Genetic Variation Variation Adaptor or NULL |
| 4129 | ** |
| 4130 | ** @fcategory new |
| 4131 | ******************************************************************************/ |
| 4132 | |
| 4133 | |
| 4134 | |
| 4135 | |
| 4136 | /* @func ensGvvariationadaptorNew ********************************************* |
| 4137 | ** |
| 4138 | ** Default constructor for an |
| 4139 | ** Ensembl Genetic Variation Variation Adaptor. |
| 4140 | ** |
| 4141 | ** Ensembl Object Adaptors are singleton objects in the sense that a single |
| 4142 | ** instance of an Ensembl Object Adaptor connected to a particular database is |
| 4143 | ** sufficient to instantiate any number of Ensembl Objects from the database. |
| 4144 | ** Each Ensembl Object will have a weak reference to the Object Adaptor that |
| 4145 | ** instantiated it. Therefore, Ensembl Object Adaptors should not be |
| 4146 | ** instantiated directly, but rather obtained from the Ensembl Registry, |
| 4147 | ** which will in turn call this function if neccessary. |
| 4148 | ** |
| 4149 | ** @see ensRegistryGetDatabaseadaptor |
| 4150 | ** @see ensRegistryGetGvvariationadaptor |
| 4151 | ** |
| 4152 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationAdaptor::new |
| 4153 | ** @param [u] dba [EnsPDatabaseadaptor] Ensembl Database Adaptor |
| 4154 | ** |
| 4155 | ** @return [EnsPGvvariationadaptor] |
| 4156 | ** Ensembl Genetic Variation Variation Adaptor or NULL |
| 4157 | ** |
| 4158 | ** @release 6.5.0 |
| 4159 | ** @@ |
| 4160 | ******************************************************************************/ |
| 4161 | |
| 4162 | EnsPGvvariationadaptor ensGvvariationadaptorNew( |
| 4163 | EnsPDatabaseadaptor dba) |
| 4164 | { |
| 4165 | register ajuint i = 0U; |
| 4166 | |
| 4167 | EnsPGvbaseadaptor gvba = NULL; |
| 4168 | |
| 4169 | EnsPGvvariationadaptor gvva = NULL; |
| 4170 | |
| 4171 | if (!dba) |
| 4172 | return NULL; |
| 4173 | |
| 4174 | gvba = ensGvbaseadaptorNew( |
| 4175 | ensRegistryGetGvdatabaseadaptor(dba), |
| 4176 | gvvariationadaptorKTablenames, |
| 4177 | gvvariationadaptorKColumnnames, |
| 4178 | gvvariationadaptorKLeftjoins, |
| 4179 | gvvariationadaptorKDefaultcondition, |
| 4180 | (const char *) NULL, |
| 4181 | gvvariationadaptorFetchAllbyStatement); |
| 4182 | |
| 4183 | if (!gvba) |
| 4184 | return NULL; |
| 4185 | |
| 4186 | AJNEW0(gvva); |
| 4187 | |
| 4188 | gvva->Adaptor = gvba; |
| 4189 | |
| 4190 | /* |
| 4191 | ** Allocate SQL column name, SQL table name and Leftjoin arrays to their |
| 4192 | ** maximum size and populate them with unghangeable values. |
| 4193 | */ |
| 4194 | |
| 4195 | /* |
| 4196 | ** The SQL column name array needs additional space for the |
| 4197 | ** flanking sequence flag SQL column. |
| 4198 | */ |
| 4199 | |
| 4200 | for (i = 0U; gvvariationadaptorKColumnnames[i]; i++); |
| 4201 | |
| 4202 | gvvariationadaptorGColumnnamesElements = i + 1U + 1U; |
| 4203 | |
| 4204 | gvva->Columnnames = AJCALLOC0(gvvariationadaptorGColumnnamesElements, |
| 4205 | sizeof (char *)); |
| 4206 | |
| 4207 | for (i = 0U; gvvariationadaptorKColumnnames[i]; i++) |
| 4208 | gvva->Columnnames[i] = ajCharNewC(gvvariationadaptorKColumnnames[i]); |
| 4209 | |
| 4210 | /* |
| 4211 | ** The SQL table name array needs additional space for |
| 4212 | ** "allele", "failed_variation", "flanking_sequence", |
| 4213 | ** and "source" SQL table names. |
| 4214 | */ |
| 4215 | |
| 4216 | for (i = 0U; gvvariationadaptorKTablenames[i]; i++); |
| 4217 | |
| 4218 | gvvariationadaptorGTablenamesElements = i + 1U + 4U; |
| 4219 | |
| 4220 | gvva->Tablenames = AJCALLOC0(gvvariationadaptorGTablenamesElements, |
| 4221 | sizeof (char *)); |
| 4222 | |
| 4223 | for (i = 0U; gvvariationadaptorKTablenames[i]; i++) |
| 4224 | gvva->Tablenames[i] = ajCharNewC(gvvariationadaptorKTablenames[i]); |
| 4225 | |
| 4226 | /* |
| 4227 | ** The Leftjoins array needs additional space for |
| 4228 | ** "failed_variation" and "flanking_sequence" |
| 4229 | ** SQL LEFT JOIN conditions. |
| 4230 | */ |
| 4231 | |
| 4232 | for (i = 0U; gvvariationadaptorKLeftjoins[i].Tablename; i++); |
| 4233 | |
| 4234 | gvvariationadaptorGLeftjoinsElements = i + 1U + 2U; |
| 4235 | |
| 4236 | gvva->Leftjoins = AJCALLOC0(gvvariationadaptorGLeftjoinsElements, |
| 4237 | sizeof (EnsOBaseadaptorLeftjoin)); |
| 4238 | |
| 4239 | for (i = 0U; gvvariationadaptorKLeftjoins[i].Tablename; i++) |
| 4240 | { |
| 4241 | gvva->Leftjoins[i].Tablename = |
| 4242 | ajCharNewC(gvvariationadaptorKLeftjoins[i].Tablename); |
| 4243 | |
| 4244 | gvva->Leftjoins[i].Condition = |
| 4245 | ajCharNewC(gvvariationadaptorKLeftjoins[i].Condition); |
| 4246 | } |
| 4247 | |
| 4248 | return gvva; |
| 4249 | } |
| 4250 | |
| 4251 | |
| 4252 | |
| 4253 | |
| 4254 | /* @section destructors ******************************************************* |
| 4255 | ** |
| 4256 | ** Destruction destroys all internal data structures and frees the memory |
| 4257 | ** allocated for an Ensembl Genetic Variation Variation Adaptor object. |
| 4258 | ** |
| 4259 | ** @fdata [EnsPGvvariationadaptor] |
| 4260 | ** |
| 4261 | ** @nam3rule Del Destroy (free) an |
| 4262 | ** Ensembl Genetic Variation Variation Adaptor |
| 4263 | ** |
| 4264 | ** @argrule * Pgvva [EnsPGvvariationadaptor*] |
| 4265 | ** Ensembl Genetic Variation Variation Adaptor address |
| 4266 | ** |
| 4267 | ** @valrule * [void] |
| 4268 | ** |
| 4269 | ** @fcategory delete |
| 4270 | ******************************************************************************/ |
| 4271 | |
| 4272 | |
| 4273 | |
| 4274 | |
| 4275 | /* @func ensGvvariationadaptorDel ********************************************* |
| 4276 | ** |
| 4277 | ** Default destructor for an |
| 4278 | ** Ensembl Genetic Variation Variation Adaptor. |
| 4279 | ** |
| 4280 | ** Ensembl Object Adaptors are singleton objects that are registered in the |
| 4281 | ** Ensembl Registry and weakly referenced by Ensembl Objects that have been |
| 4282 | ** instantiated by it. Therefore, Ensembl Object Adaptors should never be |
| 4283 | ** destroyed directly. Upon exit, the Ensembl Registry will call this function |
| 4284 | ** if required. |
| 4285 | ** |
| 4286 | ** @param [d] Pgvva [EnsPGvvariationadaptor*] |
| 4287 | ** Ensembl Genetic Variation Variation Adaptor address |
| 4288 | ** |
| 4289 | ** @return [void] |
| 4290 | ** |
| 4291 | ** @release 6.4.0 |
| 4292 | ** @@ |
| 4293 | ******************************************************************************/ |
| 4294 | |
| 4295 | void ensGvvariationadaptorDel(EnsPGvvariationadaptor *Pgvva) |
| 4296 | { |
| 4297 | register ajuint i = 0U; |
| 4298 | |
| 4299 | EnsPGvvariationadaptor pthis = NULL; |
| 4300 | |
| 4301 | if (!Pgvva) |
| 4302 | return; |
| 4303 | |
| 4304 | #if defined(AJ_DEBUG) && AJ_DEBUG >= 1 |
| 4305 | if (ajDebugTest("ensGvvariationadaptorDel")) |
| 4306 | ajDebug("ensGvvariationadaptorDel\n" |
| 4307 | " *Pgvva %p\n", |
| 4308 | *Pgvva); |
| 4309 | #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 1 */ |
| 4310 | |
| 4311 | if (!(pthis = *Pgvva)) |
| 4312 | return; |
| 4313 | |
| 4314 | ensGvbaseadaptorDel(&pthis->Adaptor); |
| 4315 | |
| 4316 | for (i = 0U; i < gvvariationadaptorGTablenamesElements; i++) |
| 4317 | ajCharDel(&pthis->Tablenames[i]); |
| 4318 | |
| 4319 | AJFREE(pthis->Tablenames); |
| 4320 | |
| 4321 | for (i = 0U; i < gvvariationadaptorGColumnnamesElements; i++) |
| 4322 | ajCharDel(&pthis->Columnnames[i]); |
| 4323 | |
| 4324 | AJFREE(pthis->Columnnames); |
| 4325 | |
| 4326 | for (i = 0U; i < gvvariationadaptorGLeftjoinsElements; i++) |
| 4327 | { |
| 4328 | ajCharDel(&(pthis->Leftjoins[i].Tablename)); |
| 4329 | ajCharDel(&(pthis->Leftjoins[i].Condition)); |
| 4330 | } |
| 4331 | |
| 4332 | AJFREE(pthis->Leftjoins); |
| 4333 | |
| 4334 | ajCharDel(&pthis->Defaultcondition); |
| 4335 | |
| 4336 | ajMemFree((void **) Pgvva); |
| 4337 | |
| 4338 | return; |
| 4339 | } |
| 4340 | |
| 4341 | |
| 4342 | |
| 4343 | |
| 4344 | /* @section member retrieval ************************************************** |
| 4345 | ** |
| 4346 | ** Functions for returning members of an |
| 4347 | ** Ensembl Genetic Variation Variation Adaptor object. |
| 4348 | ** |
| 4349 | ** @fdata [EnsPGvvariationadaptor] |
| 4350 | ** |
| 4351 | ** @nam3rule Get Return Ensembl Genetic Variation Variation Adaptor |
| 4352 | ** attribute(s) |
| 4353 | ** @nam4rule Baseadaptor |
| 4354 | ** Return the Ensembl Base Adaptor |
| 4355 | ** @nam4rule Databaseadaptor |
| 4356 | ** Return the Ensembl Database Adaptor |
| 4357 | ** @nam4rule Gvbaseadaptor |
| 4358 | ** Return the Ensembl Genetic Variation Base Adaptor |
| 4359 | ** @nam4rule Gvdatabaseadaptor |
| 4360 | ** Return the Ensembl Genetic Variation Database Adaptor |
| 4361 | ** |
| 4362 | ** @argrule * gvva [EnsPGvvariationadaptor] |
| 4363 | ** Ensembl Genetic Variation Variation Adaptor |
| 4364 | ** |
| 4365 | ** @valrule Baseadaptor [EnsPBaseadaptor] |
| 4366 | ** Ensembl Base Adaptor or NULL |
| 4367 | ** @valrule Databaseadaptor [EnsPDatabaseadaptor] |
| 4368 | ** Ensembl Database Adaptor or NULL |
| 4369 | ** @valrule Gvbaseadaptor [EnsPGvbaseadaptor] |
| 4370 | ** Ensembl Genetic Variation Base Adaptor or NULL |
| 4371 | ** @valrule Gvdatabaseadaptor [EnsPGvdatabaseadaptor] |
| 4372 | ** Ensembl Genetic Variation Database Adaptor or NULL |
| 4373 | ** |
| 4374 | ** @fcategory use |
| 4375 | ******************************************************************************/ |
| 4376 | |
| 4377 | |
| 4378 | |
| 4379 | |
| 4380 | /* @func ensGvvariationadaptorGetBaseadaptor ********************************** |
| 4381 | ** |
| 4382 | ** Get the Ensembl Base Adaptor member of an |
| 4383 | ** Ensembl Genetic Variation Variation Adaptor. |
| 4384 | ** |
| 4385 | ** @param [u] gvva [EnsPGvvariationadaptor] |
| 4386 | ** Ensembl Genetic Variation Variation Adaptor |
| 4387 | ** |
| 4388 | ** @return [EnsPBaseadaptor] Ensembl Base Adaptor or NULL |
| 4389 | ** |
| 4390 | ** @release 6.5.0 |
| 4391 | ** @@ |
| 4392 | ******************************************************************************/ |
| 4393 | |
| 4394 | EnsPBaseadaptor ensGvvariationadaptorGetBaseadaptor( |
| 4395 | EnsPGvvariationadaptor gvva) |
| 4396 | { |
| 4397 | return ensGvbaseadaptorGetBaseadaptor( |
| 4398 | ensGvvariationadaptorGetGvbaseadaptor(gvva)); |
| 4399 | } |
| 4400 | |
| 4401 | |
| 4402 | |
| 4403 | |
| 4404 | /* @func ensGvvariationadaptorGetDatabaseadaptor ****************************** |
| 4405 | ** |
| 4406 | ** Get the Ensembl Database Adaptor member of an |
| 4407 | ** Ensembl Genetic Variation Variation Adaptor. |
| 4408 | ** |
| 4409 | ** @param [u] gvva [EnsPGvvariationadaptor] |
| 4410 | ** Ensembl Genetic Variation Variation Adaptor |
| 4411 | ** |
| 4412 | ** @return [EnsPDatabaseadaptor] Ensembl Database Adaptor or NULL |
| 4413 | ** |
| 4414 | ** @release 6.5.0 |
| 4415 | ** @@ |
| 4416 | ******************************************************************************/ |
| 4417 | |
| 4418 | EnsPDatabaseadaptor ensGvvariationadaptorGetDatabaseadaptor( |
| 4419 | EnsPGvvariationadaptor gvva) |
| 4420 | { |
| 4421 | return ensGvbaseadaptorGetDatabaseadaptor( |
| 4422 | ensGvvariationadaptorGetGvbaseadaptor(gvva)); |
| 4423 | } |
| 4424 | |
| 4425 | |
| 4426 | |
| 4427 | |
| 4428 | /* @func ensGvvariationadaptorGetGvbaseadaptor ******************************** |
| 4429 | ** |
| 4430 | ** Get the Ensembl Genetic Variation Base Adaptor member of an |
| 4431 | ** Ensembl Genetic Variation Variation Adaptor. |
| 4432 | ** |
| 4433 | ** @param [u] gvva [EnsPGvvariationadaptor] |
| 4434 | ** Ensembl Genetic Variation Variation Adaptor |
| 4435 | ** |
| 4436 | ** @return [EnsPGvbaseadaptor] Ensembl Genetic Variation Base Adaptor or NULL |
| 4437 | ** |
| 4438 | ** @release 6.5.0 |
| 4439 | ** @@ |
| 4440 | ******************************************************************************/ |
| 4441 | |
| 4442 | EnsPGvbaseadaptor ensGvvariationadaptorGetGvbaseadaptor( |
| 4443 | EnsPGvvariationadaptor gvva) |
| 4444 | { |
| 4445 | return (gvva) ? gvva->Adaptor : NULL; |
| 4446 | } |
| 4447 | |
| 4448 | |
| 4449 | |
| 4450 | |
| 4451 | /* @func ensGvvariationadaptorGetGvdatabaseadaptor **************************** |
| 4452 | ** |
| 4453 | ** Get the Ensembl Genetic Variation Database Adaptor member of an |
| 4454 | ** Ensembl Genetic Variation Variation Adaptor. |
| 4455 | ** |
| 4456 | ** @param [u] gvva [EnsPGvvariationadaptor] |
| 4457 | ** Ensembl Genetic Variation Variation Adaptor |
| 4458 | ** |
| 4459 | ** @return [EnsPGvdatabaseadaptor] |
| 4460 | ** Ensembl Genetic Variation Database Adaptor or NULL |
| 4461 | ** |
| 4462 | ** @release 6.5.0 |
| 4463 | ** @@ |
| 4464 | ******************************************************************************/ |
| 4465 | |
| 4466 | EnsPGvdatabaseadaptor ensGvvariationadaptorGetGvdatabaseadaptor( |
| 4467 | EnsPGvvariationadaptor gvva) |
| 4468 | { |
| 4469 | return ensGvbaseadaptorGetGvdatabaseadaptor( |
| 4470 | ensGvvariationadaptorGetGvbaseadaptor(gvva)); |
| 4471 | } |
| 4472 | |
| 4473 | |
| 4474 | |
| 4475 | |
| 4476 | /* @section object retrieval ************************************************** |
| 4477 | ** |
| 4478 | ** Functions for fetching Ensembl Genetic Variation Variation objects from an |
| 4479 | ** Ensembl SQL database. |
| 4480 | ** |
| 4481 | ** @fdata [EnsPGvvariationadaptor] |
| 4482 | ** |
| 4483 | ** @nam3rule Fetch Fetch Ensembl Genetic Variation Variation object(s) |
| 4484 | ** @nam4rule All Fetch all Ensembl Genetic Variation Variation objects |
| 4485 | ** @nam4rule Allby |
| 4486 | ** Fetch all Ensembl Genetic Variation Variation objects matching a criterion |
| 4487 | ** @nam5rule Gvpopulation Fetch by an Ensembl Genetic Variation Population |
| 4488 | ** @nam5rule Gvpopulationfrequency Fetch by an Ensembl Genetic Variation |
| 4489 | ** Population and frequency |
| 4490 | ** @nam5rule Gvsource Fetch all by an Ensembl Genetic Variation Source |
| 4491 | ** @nam6rule GvsourceType |
| 4492 | ** Fetch all by an Ensembl Genetic Variation Source Type enumeration |
| 4493 | ** @nam5rule Gvvariationset Fetch by an Ensembl Genetic Variation Variation Set |
| 4494 | ** @nam5rule Identifiers Fetch by an AJAX Table of AJAX unsigned integer |
| 4495 | ** (identifier) key data |
| 4496 | ** @nam5rule Names Fetch by names |
| 4497 | ** @nam5rule Source Fetch by a source |
| 4498 | ** @nam4rule Allsomatic |
| 4499 | ** Fetch all somatic Ensembl Genetic Variation Variation objects |
| 4500 | ** @nam4rule By Fetch one Ensembl Genetic Variation Variation |
| 4501 | ** object matching a criterion |
| 4502 | ** @nam5rule Identifier Fetch by an SQL database-internal identifier |
| 4503 | ** @nam5rule Name Fetch by a name |
| 4504 | ** @nam5rule Subidentifier Fetch by a Sub-SNP identifier |
| 4505 | ** @nam5rule Synonym Fetch by a synonym |
| 4506 | ** |
| 4507 | ** @argrule * gvva [EnsPGvvariationadaptor] |
| 4508 | ** Ensembl Genetic Variation Variation Adaptor |
| 4509 | ** @argrule All gvvs [AjPList] AJAX List of |
| 4510 | ** Ensembl Genetic Variation Variation objects |
| 4511 | ** @argrule Allsomatic gvvs [AjPList] AJAX List of |
| 4512 | ** Ensembl Genetic Variation Variation objects |
| 4513 | ** @argrule AllbyGvpopulation gvp [const EnsPGvpopulation] |
| 4514 | ** Ensembl Genetic Variation Population |
| 4515 | ** @argrule AllbyGvpopulation gvvs [AjPList] AJAX List of |
| 4516 | ** Ensembl Genetic Variation Variation objects |
| 4517 | ** @argrule AllbyGvpopulationfrequency gvp [const EnsPGvpopulation] |
| 4518 | ** Ensembl Genetic Variation Population |
| 4519 | ** @argrule AllbyGvpopulationfrequency frequency [float] |
| 4520 | ** Lower minor allele frequency (MAF) threshold |
| 4521 | ** @argrule AllbyGvpopulationfrequency gvvs [AjPList] AJAX List of |
| 4522 | ** Ensembl Genetic Variation Variation objects |
| 4523 | ** @argrule AllbyGvsourceType gvst [EnsEGvsourceType] |
| 4524 | ** Ensembl Genetic Variation Source Type enumeration |
| 4525 | ** @argrule AllbyGvsourceType primary [AjBool] Primary |
| 4526 | ** @argrule AllbyGvsourceType gvvs [AjPList] AJAX List of |
| 4527 | ** Ensembl Genetic Variation Variation objects |
| 4528 | ** @argrule AllbyGvvariationset gvvset [EnsPGvvariationset] |
| 4529 | ** Ensembl Genetic Variation Variation Set |
| 4530 | ** @argrule AllbyGvvariationset gvvs [AjPList] AJAX List of |
| 4531 | ** Ensembl Genetic Variation Variation objects |
| 4532 | ** @argrule AllbyIdentifiers gvvs [AjPTable] AJAX Table of |
| 4533 | ** AJAX unsigned integer identifier key data and |
| 4534 | ** Ensembl Genetic Variation Variation value data |
| 4535 | ** @argrule AllbyNames gvvs [AjPTable] AJAX Table of |
| 4536 | ** AJAX String (name) key data and |
| 4537 | ** AJAX Genetic Variation Variation value data |
| 4538 | ** @argrule AllbySource source [const AjPStr] Source |
| 4539 | ** @argrule AllbySource primary [AjBool] Primary |
| 4540 | ** @argrule AllbySource gvvs [AjPList] AJAX List of |
| 4541 | ** Ensembl Genetic Variation Variation objects |
| 4542 | ** @argrule ByIdentifier identifier [ajuint] |
| 4543 | ** SQL database-internal identifier |
| 4544 | ** @argrule ByName name [const AjPStr] |
| 4545 | ** Ensembl Genetic Variation Variation name |
| 4546 | ** @argrule ByName source [const AjPStr] Source |
| 4547 | ** @argrule BySubidentifier name [const AjPStr] Name |
| 4548 | ** @argrule BySynonym synonym [const AjPStr] Synonym |
| 4549 | ** @argrule BySynonym source [const AjPStr] Source |
| 4550 | ** @argrule By Pgvv [EnsPGvvariation*] |
| 4551 | ** Ensembl Genetic Variation Variation address |
| 4552 | ** |
| 4553 | ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise |
| 4554 | ** |
| 4555 | ** @fcategory use |
| 4556 | ******************************************************************************/ |
| 4557 | |
| 4558 | |
| 4559 | |
| 4560 | |
| 4561 | /* @func ensGvvariationadaptorFetchAll **************************************** |
| 4562 | ** |
| 4563 | ** Fetch all Ensembl Genetic Variation Variation objects via |
| 4564 | ** an Ensembl Genetic Variation Variation Adaptor. |
| 4565 | ** |
| 4566 | ** Please note that it is probably not a good idea to use this function on |
| 4567 | ** very large tables quite common in the Ensembl genome annotation system. |
| 4568 | ** |
| 4569 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationAdaptor::fetch_all |
| 4570 | ** @param [u] gvva [EnsPGvvariationadaptor] |
| 4571 | ** Ensembl Genetic Variation Variation Adaptor |
| 4572 | ** @param [u] gvvs [AjPList] |
| 4573 | ** AJAX List of Ensembl Genetic Variation Variation objects |
| 4574 | ** |
| 4575 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 4576 | ** |
| 4577 | ** @release 6.4.0 |
| 4578 | ** @@ |
| 4579 | ******************************************************************************/ |
| 4580 | |
| 4581 | AjBool ensGvvariationadaptorFetchAll(EnsPGvvariationadaptor gvva, |
| 4582 | AjPList gvvs) |
| 4583 | { |
| 4584 | AjBool joinallele = AJFALSE; |
| 4585 | AjBool joinflank = AJFALSE; |
| 4586 | AjBool joinsource = AJFALSE; |
| 4587 | AjBool result = AJFALSE; |
| 4588 | |
| 4589 | AjPStr constraint = NULL; |
| 4590 | |
| 4591 | if (!gvva) |
| 4592 | return ajFalse; |
| 4593 | |
| 4594 | if (!gvvs) |
| 4595 | return ajFalse; |
| 4596 | |
| 4597 | constraint = ajStrNewC("variation.somatic = 0"); |
| 4598 | |
| 4599 | result = gvvariationadaptorFetchAllbyConstraint(gvva, |
| 4600 | constraint, |
| 4601 | joinallele, |
| 4602 | joinflank, |
| 4603 | joinsource, |
| 4604 | gvvs); |
| 4605 | |
| 4606 | ajStrDel(&constraint); |
| 4607 | |
| 4608 | return result; |
| 4609 | } |
| 4610 | |
| 4611 | |
| 4612 | |
| 4613 | |
| 4614 | /* @func ensGvvariationadaptorFetchAllbyGvpopulation ************************** |
| 4615 | ** |
| 4616 | ** Fetch all Ensembl Genetic Variation Variation objects via an |
| 4617 | ** Ensembl Genetic Variation Population. |
| 4618 | ** |
| 4619 | ** The caller is responsible for deleting the |
| 4620 | ** Ensembl Genetic Variation Variation objects before deleting the AJAX List. |
| 4621 | ** |
| 4622 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationAdaptor:: |
| 4623 | ** fetch_all_by_Population |
| 4624 | ** @param [u] gvva [EnsPGvvariationadaptor] |
| 4625 | ** Ensembl Genetic Variation Variation Adaptor |
| 4626 | ** @param [r] gvp [const EnsPGvpopulation] |
| 4627 | ** Ensembl Genetic Variation Population |
| 4628 | ** @param [u] gvvs [AjPList] |
| 4629 | ** AJAX List of Ensembl Genetic Variation Variation objects |
| 4630 | ** |
| 4631 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 4632 | ** |
| 4633 | ** @release 6.4.0 |
| 4634 | ** @@ |
| 4635 | ******************************************************************************/ |
| 4636 | |
| 4637 | AjBool ensGvvariationadaptorFetchAllbyGvpopulation( |
| 4638 | EnsPGvvariationadaptor gvva, |
| 4639 | const EnsPGvpopulation gvp, |
| 4640 | AjPList gvvs) |
| 4641 | { |
| 4642 | /* This function needs to join the to the allele SQL table. */ |
| 4643 | |
| 4644 | AjBool joinallele = AJTRUE; |
| 4645 | AjBool joinflank = AJFALSE; |
| 4646 | AjBool joinsource = AJFALSE; |
| 4647 | AjBool result = AJFALSE; |
| 4648 | |
| 4649 | AjPStr constraint = NULL; |
| 4650 | |
| 4651 | if (!gvva) |
| 4652 | return ajFalse; |
| 4653 | |
| 4654 | if (!gvp) |
| 4655 | return ajFalse; |
| 4656 | |
| 4657 | if (!gvvs) |
| 4658 | return ajFalse; |
| 4659 | |
| 4660 | constraint = ajFmtStr( |
| 4661 | "allele.sample_id = %u", |
| 4662 | ensGvpopulationGetIdentifier(gvp)); |
| 4663 | |
| 4664 | result = gvvariationadaptorFetchAllbyConstraint(gvva, |
| 4665 | constraint, |
| 4666 | joinallele, |
| 4667 | joinflank, |
| 4668 | joinsource, |
| 4669 | gvvs); |
| 4670 | |
| 4671 | ajStrDel(&constraint); |
| 4672 | |
| 4673 | return result; |
| 4674 | } |
| 4675 | |
| 4676 | |
| 4677 | |
| 4678 | |
| 4679 | /* @func ensGvvariationadaptorFetchAllbyGvpopulationfrequency ***************** |
| 4680 | ** |
| 4681 | ** Fetch all Ensembl Genetic Variation Variation objects via an |
| 4682 | ** Ensembl Genetic Variation Population and frequency information. |
| 4683 | ** |
| 4684 | ** The caller is responsible for deleting the |
| 4685 | ** Ensembl Genetic Variation Variation objects before deleting the AJAX List. |
| 4686 | ** |
| 4687 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationAdaptor:: |
| 4688 | ** fetch_all_by_Population |
| 4689 | ** @param [u] gvva [EnsPGvvariationadaptor] |
| 4690 | ** Ensembl Genetic Variation Variation Adaptor |
| 4691 | ** @param [r] gvp [const EnsPGvpopulation] Ensembl Genetic Variation Population |
| 4692 | ** @param [r] frequency [float] Lower minor allele frequency (MAF) threshold |
| 4693 | ** @param [u] gvvs [AjPList] |
| 4694 | ** AJAX List of Ensembl Genetic Variation Variation objects |
| 4695 | ** |
| 4696 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 4697 | ** |
| 4698 | ** @release 6.4.0 |
| 4699 | ** @@ |
| 4700 | ******************************************************************************/ |
| 4701 | |
| 4702 | AjBool ensGvvariationadaptorFetchAllbyGvpopulationfrequency( |
| 4703 | EnsPGvvariationadaptor gvva, |
| 4704 | const EnsPGvpopulation gvp, |
| 4705 | float frequency, |
| 4706 | AjPList gvvs) |
| 4707 | { |
| 4708 | /* This function needs to join the to the allele SQL table. */ |
| 4709 | |
| 4710 | AjBool joinallele = AJTRUE; |
| 4711 | AjBool joinflank = AJFALSE; |
| 4712 | AjBool joinsource = AJFALSE; |
| 4713 | AjBool result = AJFALSE; |
| 4714 | |
| 4715 | AjPStr constraint = NULL; |
| 4716 | |
| 4717 | if (!gvva) |
| 4718 | return ajFalse; |
| 4719 | |
| 4720 | if (!gvp) |
| 4721 | return ajFalse; |
| 4722 | |
| 4723 | if (!gvvs) |
| 4724 | return ajFalse; |
| 4725 | |
| 4726 | /* Adjust the frequency if given a percentage. */ |
| 4727 | |
| 4728 | if (frequency > 1.0F) |
| 4729 | frequency /= 100.0F; |
| 4730 | |
| 4731 | constraint = ajFmtStr( |
| 4732 | "allele.sample_id = %u " |
| 4733 | "AND " |
| 4734 | "(" |
| 4735 | "IF(" |
| 4736 | "allele.frequency > 0.5, " |
| 4737 | "1 - allele.frequency, " |
| 4738 | "allele.frequency" |
| 4739 | ") > %f" |
| 4740 | ")", |
| 4741 | ensGvpopulationGetIdentifier(gvp), |
| 4742 | frequency); |
| 4743 | |
| 4744 | result = gvvariationadaptorFetchAllbyConstraint(gvva, |
| 4745 | constraint, |
| 4746 | joinallele, |
| 4747 | joinflank, |
| 4748 | joinsource, |
| 4749 | gvvs); |
| 4750 | |
| 4751 | ajStrDel(&constraint); |
| 4752 | |
| 4753 | return result; |
| 4754 | } |
| 4755 | |
| 4756 | |
| 4757 | |
| 4758 | |
| 4759 | /* @func ensGvvariationadaptorFetchAllbyGvsourceType ************************** |
| 4760 | ** |
| 4761 | ** Fetch all Ensembl Genetic Variation Variation objects via an |
| 4762 | ** Ensembl Genetic Variation Source Type enumeration. |
| 4763 | ** |
| 4764 | ** The caller is responsible for deleting the |
| 4765 | ** Ensembl Genetic Variation Variation objects before deleting the AJAX List. |
| 4766 | ** |
| 4767 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationAdaptor:: |
| 4768 | ** fetch_all_by_source_type |
| 4769 | ** @param [u] gvva [EnsPGvvariationadaptor] |
| 4770 | ** Ensembl Genetic Variation Variation Adaptor |
| 4771 | ** @param [u] gvst [EnsEGvsourceType] |
| 4772 | ** Ensembl Genetic Variation Source Type enumeration |
| 4773 | ** @param [r] primary [AjBool] Primary |
| 4774 | ** @param [u] gvvs [AjPList] |
| 4775 | ** AJAX List of Ensembl Genetic Variation Variation objects |
| 4776 | ** |
| 4777 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 4778 | ** |
| 4779 | ** @release 6.4.0 |
| 4780 | ** @@ |
| 4781 | ******************************************************************************/ |
| 4782 | |
| 4783 | AjBool ensGvvariationadaptorFetchAllbyGvsourceType( |
| 4784 | EnsPGvvariationadaptor gvva, |
| 4785 | EnsEGvsourceType gvst, |
| 4786 | AjBool primary, |
| 4787 | AjPList gvvs) |
| 4788 | { |
| 4789 | AjPList gvss = NULL; |
| 4790 | |
| 4791 | EnsPDatabaseadaptor dba = NULL; |
| 4792 | |
| 4793 | EnsPGvsource gvs = NULL; |
| 4794 | EnsPGvsourceadaptor gvsa = NULL; |
| 4795 | |
| 4796 | if (!gvva) |
| 4797 | return ajFalse; |
| 4798 | |
| 4799 | if (!gvst) |
| 4800 | return ajFalse; |
| 4801 | |
| 4802 | if (!gvvs) |
| 4803 | return ajFalse; |
| 4804 | |
| 4805 | dba = ensGvbaseadaptorGetDatabaseadaptor(gvva->Adaptor); |
| 4806 | |
| 4807 | gvsa = ensRegistryGetGvsourceadaptor(dba); |
| 4808 | |
| 4809 | gvss = ajListNew(); |
| 4810 | |
| 4811 | ensGvsourceadaptorFetchAllbyGvsourceType(gvsa, gvst, gvss); |
| 4812 | |
| 4813 | while (ajListPop(gvss, (void *) &gvs)) |
| 4814 | { |
| 4815 | ensGvvariationadaptorFetchAllbySource( |
| 4816 | gvva, |
| 4817 | ensGvsourceGetName(gvs), |
| 4818 | primary, |
| 4819 | gvvs); |
| 4820 | |
| 4821 | ensGvsourceDel(&gvs); |
| 4822 | } |
| 4823 | |
| 4824 | ajListFree(&gvss); |
| 4825 | |
| 4826 | /* |
| 4827 | ** Remove duplicate Ensembl Genetic Variation Variation objects |
| 4828 | ** from the AJAX List. |
| 4829 | */ |
| 4830 | |
| 4831 | ajListSortUnique(gvvs, |
| 4832 | &listGvvariationCompareIdentifierAscending, |
| 4833 | &listGvvariationDelete); |
| 4834 | |
| 4835 | return ajTrue; |
| 4836 | } |
| 4837 | |
| 4838 | |
| 4839 | |
| 4840 | |
| 4841 | /* @func ensGvvariationadaptorFetchAllbyGvvariationset ************************ |
| 4842 | ** |
| 4843 | ** Fetch all Ensembl Genetic Variation Variation objects via an |
| 4844 | ** Ensembl Genetic Variation Variation Set. |
| 4845 | ** |
| 4846 | ** The caller is responsible for deleting the |
| 4847 | ** Ensembl Genetic Variation Variation objects before deleting the AJAX List. |
| 4848 | ** |
| 4849 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationAdaptor:: |
| 4850 | ** fetch_all_by_VariationSet |
| 4851 | ** @param [u] gvva [EnsPGvvariationadaptor] |
| 4852 | ** Ensembl Genetic Variation Variation Adaptor |
| 4853 | ** @param [u] gvvset [EnsPGvvariationset] |
| 4854 | ** Ensembl Genetic Variation Variation Set |
| 4855 | ** @param [u] gvvs [AjPList] |
| 4856 | ** AJAX List of Ensembl Genetic Variation Variation objects |
| 4857 | ** |
| 4858 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 4859 | ** |
| 4860 | ** @release 6.4.0 |
| 4861 | ** @@ |
| 4862 | ** NOTE: Since the Bio::EnsEMBL::Utils::Iterator class is not implemented yet, |
| 4863 | ** this function has not been changed since Ensembl version 60. |
| 4864 | ******************************************************************************/ |
| 4865 | |
| 4866 | AjBool ensGvvariationadaptorFetchAllbyGvvariationset( |
| 4867 | EnsPGvvariationadaptor gvva, |
| 4868 | EnsPGvvariationset gvvset, |
| 4869 | AjPList gvvs) |
| 4870 | { |
| 4871 | AjPList variationsets = NULL; |
| 4872 | |
| 4873 | AjPStr statement = NULL; |
| 4874 | |
| 4875 | EnsPGvvariationset variationset = NULL; |
| 4876 | |
| 4877 | if (!gvva) |
| 4878 | return ajFalse; |
| 4879 | |
| 4880 | if (!gvvs) |
| 4881 | return ajFalse; |
| 4882 | |
| 4883 | if (!gvvs) |
| 4884 | return ajFalse; |
| 4885 | |
| 4886 | if (!gvvset->Adaptor) |
| 4887 | return ajFalse; |
| 4888 | |
| 4889 | if (!gvvset->Identifier) |
| 4890 | return ajFalse; |
| 4891 | |
| 4892 | variationsets = ajListNew(); |
| 4893 | |
| 4894 | /* |
| 4895 | ** First, get all immediate subsets of the specified Ensembl Genetic |
| 4896 | ** Variation Variation Set and get their Ensembl Genetic Variation |
| 4897 | ** Variation objects. |
| 4898 | */ |
| 4899 | |
| 4900 | ensGvvariationsetFetchAllSub(gvvset, ajFalse, variationsets); |
| 4901 | |
| 4902 | while (ajListPop(variationsets, (void **) &variationset)) |
| 4903 | { |
| 4904 | /* |
| 4905 | ** FIXME: This recursive approach may not work because fetching |
| 4906 | ** sub-sets of sub-sets can be problematic. |
| 4907 | */ |
| 4908 | ensGvvariationadaptorFetchAllbyGvvariationset(gvva, |
| 4909 | variationset, |
| 4910 | gvvs); |
| 4911 | |
| 4912 | ensGvvariationsetDel(&variationset); |
| 4913 | } |
| 4914 | |
| 4915 | ajListFree(&variationsets); |
| 4916 | |
| 4917 | /* |
| 4918 | ** Then get all Ensembl Genetic Variation Variation objects belonging to |
| 4919 | ** this Ensembl Genetic Variation Variation Set. |
| 4920 | */ |
| 4921 | |
| 4922 | /* FIXME: The SQL statement needs to be changed to an SQL constraint. */ |
| 4923 | statement = ajFmtStr( |
| 4924 | "SELECT " |
| 4925 | "variation.variation_id, " |
| 4926 | "variation.source_id, " |
| 4927 | "variation.name, " |
| 4928 | "variation.validation_status, " |
| 4929 | "variation.ancestral_allele, " |
| 4930 | "variation.class_attrib_id, " |
| 4931 | "variation.somatic, " |
| 4932 | "allele.allele_id, " |
| 4933 | "allele.subsnp_id, " |
| 4934 | "allele.allele, " |
| 4935 | "allele.frequency, " |
| 4936 | "allele.count, " |
| 4937 | "allele.sample_id, " |
| 4938 | "variation_synonym.variation_synonym_id, " |
| 4939 | "variation_synonym.subsnp_id, " |
| 4940 | "variation_synonym.source_id, " |
| 4941 | "variation_synonym.name, " |
| 4942 | "variation_synonym.moltype, " |
| 4943 | "0 " /* "flanking_sequence" flag */ |
| 4944 | "FROM " |
| 4945 | "(variation, allele, variation_set_variation) " |
| 4946 | "LEFT JOIN " |
| 4947 | "allele " |
| 4948 | "ON " |
| 4949 | "variation.variation_id = allele.variation_id " |
| 4950 | "LEFT JOIN " |
| 4951 | "variation_synonym " |
| 4952 | "ON " |
| 4953 | "variation.variation_id = variation_synonym.variation_id " |
| 4954 | "LEFT JOIN " |
| 4955 | "failed_variation " |
| 4956 | "ON " |
| 4957 | "variation.variation_id = " |
| 4958 | "failed_variation.variation_id " |
| 4959 | "WHERE " |
| 4960 | "variation.variation_id = variation_set_variation.variation_id ", |
| 4961 | "AND " |
| 4962 | "variation_set_variation.variation_set_id = %u", |
| 4963 | ensGvvariationsetGetIdentifier(gvvset)); |
| 4964 | |
| 4965 | gvvariationadaptorFetchAllbyStatement( |
| 4966 | ensGvvariationadaptorGetBaseadaptor(gvva), |
| 4967 | statement, |
| 4968 | (EnsPAssemblymapper) NULL, |
| 4969 | (EnsPSlice) NULL, |
| 4970 | gvvs); |
| 4971 | |
| 4972 | ajStrDel(&statement); |
| 4973 | |
| 4974 | /* |
| 4975 | ** Remove duplicate Ensembl Genetic Variation Variation objects |
| 4976 | ** from the AJAX List. |
| 4977 | */ |
| 4978 | |
| 4979 | ajListSortUnique(gvvs, |
| 4980 | &listGvvariationCompareIdentifierAscending, |
| 4981 | &listGvvariationDelete); |
| 4982 | |
| 4983 | return ajTrue; |
| 4984 | } |
| 4985 | |
| 4986 | |
| 4987 | |
| 4988 | |
| 4989 | /* @func ensGvvariationadaptorFetchAllbyIdentifiers *************************** |
| 4990 | ** |
| 4991 | ** Fetch all Ensembl Genetic Variation Variation objects by an AJAX Table of |
| 4992 | ** AJAX unsigned integer key data and assign them as value data. |
| 4993 | ** |
| 4994 | ** The caller is responsible for deleting the |
| 4995 | ** AJAX unsigned integer key data and |
| 4996 | ** Ensembl Genetic Variation Variation value data before deleting the |
| 4997 | ** AJAX Table. |
| 4998 | ** |
| 4999 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationAdaptor::fetch_all_by_dbID_list |
| 5000 | ** @param [u] gvva [EnsPGvvariationadaptor] |
| 5001 | ** Ensembl Genetic Variation Variation Adaptor |
| 5002 | ** @param [u] gvvs [AjPTable] |
| 5003 | ** AJAX Table of AJAX unsigned integer (identifier) |
| 5004 | ** key data and Ensembl Genetic Variation |
| 5005 | ** Variation value data |
| 5006 | ** |
| 5007 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 5008 | ** |
| 5009 | ** @release 6.4.0 |
| 5010 | ** @@ |
| 5011 | ******************************************************************************/ |
| 5012 | |
| 5013 | AjBool ensGvvariationadaptorFetchAllbyIdentifiers( |
| 5014 | EnsPGvvariationadaptor gvva, |
| 5015 | AjPTable gvvs) |
| 5016 | { |
| 5017 | void **keyarray = NULL; |
| 5018 | |
| 5019 | /* This function needs to join the to the flanking_sequence SQL table. */ |
| 5020 | |
| 5021 | AjBool joinallele = AJFALSE; |
| 5022 | AjBool joinflank = AJFALSE; |
| 5023 | AjBool joinsource = AJFALSE; |
| 5024 | AjBool result = AJFALSE; |
| 5025 | |
| 5026 | const char *template = "variation.variation_id IN (%S)"; |
| 5027 | |
| 5028 | register ajuint i = 0U; |
| 5029 | |
| 5030 | AjPList lgvvs = NULL; |
| 5031 | |
| 5032 | AjPStr constraint = NULL; |
| 5033 | AjPStr csv = NULL; |
| 5034 | |
| 5035 | if (!gvva) |
| 5036 | return ajFalse; |
| 5037 | |
| 5038 | if (!gvvs) |
| 5039 | return ajFalse; |
| 5040 | |
| 5041 | lgvvs = ajListNew(); |
| 5042 | |
| 5043 | csv = ajStrNew(); |
| 5044 | |
| 5045 | /* |
| 5046 | ** Large queries are split into smaller ones on the basis of the maximum |
| 5047 | ** number of identifier instances configured in the |
| 5048 | ** Ensembl Base Adaptor module. |
| 5049 | ** This ensures that MySQL is faster and the maximum query size is not |
| 5050 | ** exceeded. |
| 5051 | */ |
| 5052 | |
| 5053 | ajTableToarrayKeys(gvvs, &keyarray); |
| 5054 | |
| 5055 | for (i = 0U; keyarray[i]; i++) |
| 5056 | { |
| 5057 | ajFmtPrintAppS(&csv, "%u, ", *((ajuint *) keyarray[i])); |
| 5058 | |
| 5059 | /* |
| 5060 | ** Run the statement if the maximum chunk size is exceed or |
| 5061 | ** if there are no more array elements to process. |
| 5062 | */ |
| 5063 | |
| 5064 | if ((((i + 1U) % ensKBaseadaptorMaximumIdentifiers) == 0) |
| 5065 | || (keyarray[i + 1U] == NULL)) |
| 5066 | { |
| 5067 | /* Remove the last comma and space. */ |
| 5068 | |
| 5069 | ajStrCutEnd(&csv, 2); |
| 5070 | |
| 5071 | if (ajStrGetLen(csv)) |
| 5072 | { |
| 5073 | constraint = ajFmtStr(template, csv); |
| 5074 | |
| 5075 | result = gvvariationadaptorFetchAllbyConstraint(gvva, |
| 5076 | constraint, |
| 5077 | joinallele, |
| 5078 | joinflank, |
| 5079 | joinsource, |
| 5080 | lgvvs); |
| 5081 | |
| 5082 | ajStrDel(&constraint); |
| 5083 | } |
| 5084 | |
| 5085 | ajStrAssignClear(&csv); |
| 5086 | } |
| 5087 | } |
| 5088 | |
| 5089 | AJFREE(keyarray); |
| 5090 | |
| 5091 | ajStrDel(&csv); |
| 5092 | |
| 5093 | /* |
| 5094 | ** Move Ensembl Genetic Variation Variation objects from the AJAX List |
| 5095 | ** to the AJAX Table. |
| 5096 | */ |
| 5097 | |
| 5098 | ensTableuintFromList( |
| 5099 | gvvs, |
| 5100 | (ajuint (*)(const void *)) &ensGvvariationGetIdentifier, |
| 5101 | lgvvs); |
| 5102 | |
| 5103 | ajListFree(&lgvvs); |
| 5104 | |
| 5105 | return result; |
| 5106 | } |
| 5107 | |
| 5108 | |
| 5109 | |
| 5110 | |
| 5111 | /* |
| 5112 | ** Internal method for getting the internal dbIDs for a list of names. |
| 5113 | ** Will also query the variation_synonym and allele (for subsnp_ids) tables. |
| 5114 | */ |
| 5115 | |
| 5116 | static AjBool gvvariationadaptorFetchAllbyNames( |
| 5117 | EnsPGvvariationadaptor gvva, |
| 5118 | AjBool synonym, |
| 5119 | AjBool subsnp, |
| 5120 | AjPTable gvvnamestogvv, |
| 5121 | AjPTable *Pgvvidentifiers) |
| 5122 | { |
| 5123 | void **keyarray = NULL; |
| 5124 | |
| 5125 | /* Statement to get the dbIDs from variation or variation_synonym. */ |
| 5126 | const char *template = "SELECT %s FROM %s v WHERE %s IN (%S)"; |
| 5127 | |
| 5128 | register ajuint i = 0U; |
| 5129 | |
| 5130 | ajuint *Pgvvidentifier = NULL; |
| 5131 | |
| 5132 | AjPSqlstatement sqls = NULL; |
| 5133 | AjISqlrow sqli = NULL; |
| 5134 | AjPSqlrow sqlr = NULL; |
| 5135 | |
| 5136 | AjPStr csv = NULL; |
| 5137 | AjPStr gvvname = NULL; |
| 5138 | AjPStr statement = NULL; |
| 5139 | |
| 5140 | AjPTable table = NULL; |
| 5141 | |
| 5142 | EnsPDatabaseadaptor dba = NULL; |
| 5143 | |
| 5144 | if (!gvva) |
| 5145 | return ajFalse; |
| 5146 | |
| 5147 | if (!gvvnamestogvv) |
| 5148 | return ajFalse; |
| 5149 | |
| 5150 | if (!Pgvvidentifiers) |
| 5151 | return ajFalse; |
| 5152 | |
| 5153 | if (!*Pgvvidentifiers) |
| 5154 | { |
| 5155 | /* |
| 5156 | ** If not initialised already create an AJAX Table of |
| 5157 | ** AJAX String key and AJAX unsigned integer value data. |
| 5158 | */ |
| 5159 | |
| 5160 | *Pgvvidentifiers = ajTablestrNew(ajTableGetSize(gvvnamestogvv)); |
| 5161 | |
| 5162 | ajTableSetDestroyvalue(*Pgvvidentifiers, &ajMemFree); |
| 5163 | } |
| 5164 | |
| 5165 | dba = ensGvvariationadaptorGetDatabaseadaptor(gvva); |
| 5166 | |
| 5167 | /* |
| 5168 | ** Large queries are split into smaller ones on the basis of the maximum |
| 5169 | ** number of identifier instances configured in the |
| 5170 | ** Ensembl Base Adaptor module. |
| 5171 | ** This ensures that MySQL is faster and the maximum query size is not |
| 5172 | ** exceeded. |
| 5173 | */ |
| 5174 | |
| 5175 | csv = ajStrNew(); |
| 5176 | |
| 5177 | ajTableToarrayKeys(gvvnamestogvv, &keyarray); |
| 5178 | |
| 5179 | for (i = 0U; keyarray[i]; i++) |
| 5180 | { |
| 5181 | ajFmtPrintAppS(&csv, "'%S', ", (AjPStr) keyarray[i]); |
| 5182 | |
| 5183 | /* |
| 5184 | ** Run the statement if the maximum chunk size is exceed or |
| 5185 | ** if there are no more array elements to process. |
| 5186 | */ |
| 5187 | |
| 5188 | if ((((i + 1U) % ensKBaseadaptorMaximumIdentifiers) == 0) |
| 5189 | || (keyarray[i + 1U] == NULL)) |
| 5190 | { |
| 5191 | /* Remove the last comma and space. */ |
| 5192 | |
| 5193 | ajStrCutEnd(&csv, 2); |
| 5194 | |
| 5195 | if (ajStrGetLen(csv)) |
| 5196 | { |
| 5197 | statement = ajFmtStr( |
| 5198 | template, |
| 5199 | /* SQL column name array */ |
| 5200 | (synonym && subsnp) ? |
| 5201 | "CONCAT('ss',variation.subsnp_id) AS name, v.variation_id" : |
| 5202 | "v.name, v.variation_id", |
| 5203 | /* SQL table name array */ |
| 5204 | synonym ? |
| 5205 | (subsnp ? "allele" : "variation_synonym") : |
| 5206 | "variation", |
| 5207 | /* SQL SELECT default condition */ |
| 5208 | (synonym && subsnp ? "v.subsnp_id" : "v.name"), |
| 5209 | /* Name list */ |
| 5210 | csv); |
| 5211 | |
| 5212 | sqls = ensDatabaseadaptorSqlstatementNew(dba, statement); |
| 5213 | |
| 5214 | sqli = ajSqlrowiterNew(sqls); |
| 5215 | |
| 5216 | while (!ajSqlrowiterDone(sqli)) |
| 5217 | { |
| 5218 | gvvname = ajStrNew(); |
| 5219 | AJNEW0(Pgvvidentifier); |
| 5220 | *Pgvvidentifier = 0U; |
| 5221 | |
| 5222 | sqlr = ajSqlrowiterGet(sqli); |
| 5223 | |
| 5224 | ajSqlcolumnToStr(sqlr, &gvvname); |
| 5225 | ajSqlcolumnToUint(sqlr, Pgvvidentifier); |
| 5226 | |
| 5227 | ajTablePut(*Pgvvidentifiers, |
| 5228 | (void *) gvvname, |
| 5229 | Pgvvidentifier); |
| 5230 | } |
| 5231 | |
| 5232 | ajSqlrowiterDel(&sqli); |
| 5233 | |
| 5234 | ensDatabaseadaptorSqlstatementDel(dba, &sqls); |
| 5235 | |
| 5236 | ajStrDel(&statement); |
| 5237 | } |
| 5238 | |
| 5239 | ajStrAssignClear(&csv); |
| 5240 | } |
| 5241 | } |
| 5242 | |
| 5243 | AJFREE(keyarray); |
| 5244 | |
| 5245 | ajStrDel(&csv); |
| 5246 | |
| 5247 | /* |
| 5248 | ** For queries against the "variation" SQL table and unmapped names, |
| 5249 | ** also query the "variation_synonym" and "allele" SQL tables. |
| 5250 | */ |
| 5251 | |
| 5252 | if (!synonym || !subsnp) |
| 5253 | { |
| 5254 | /* |
| 5255 | ** Find the unmapped names and put them into a new AJAX Table of |
| 5256 | ** AJAX String key and |
| 5257 | ** Ensembl Genetic Variation Variation value data. |
| 5258 | */ |
| 5259 | |
| 5260 | table = ajTablestrNew(ajTableGetSize(gvvnamestogvv)); |
| 5261 | |
| 5262 | ajTableSetDestroyvalue(table, (void (*)(void **)) &ensGvvariationDel); |
| 5263 | |
| 5264 | ajTableToarrayKeys(gvvnamestogvv, &keyarray); |
| 5265 | |
| 5266 | for (i = 0U; keyarray[i]; i++) |
| 5267 | { |
| 5268 | if (!ajTableMatchS(table, (const AjPStr) keyarray[i])) |
| 5269 | ajTablePut(table, |
| 5270 | (void *) ajStrNewS((const AjPStr) keyarray[i]), |
| 5271 | (void *) NULL); |
| 5272 | } |
| 5273 | |
| 5274 | AJFREE(keyarray); |
| 5275 | |
| 5276 | /* |
| 5277 | ** TODO: If we are going to query for subsnp_ids, get the names that |
| 5278 | ** look like ssIds and strip the ss prefix. |
| 5279 | */ |
| 5280 | /* |
| 5281 | if ($synonym) { |
| 5282 | (at)unmapped = grep {$_ =~ s/^ss(\d+)$/$1/} (at)unmapped; |
| 5283 | } |
| 5284 | */ |
| 5285 | |
| 5286 | /* FIXME: Why is synonym passed in in third position? |
| 5287 | ** my $names = $self->_name_to_dbID(\(at)unmapped,1,$synonym); |
| 5288 | */ |
| 5289 | gvvariationadaptorFetchAllbyNames(gvva, |
| 5290 | ajTrue, |
| 5291 | synonym, |
| 5292 | table, |
| 5293 | Pgvvidentifiers); |
| 5294 | |
| 5295 | ajTableDel(&table); |
| 5296 | } |
| 5297 | |
| 5298 | return ajTrue; |
| 5299 | } |
| 5300 | |
| 5301 | |
| 5302 | |
| 5303 | |
| 5304 | /* @func ensGvvariationadaptorFetchAllbyNames ********************************* |
| 5305 | ** |
| 5306 | ** Fetch all Ensembl Genetic Variation Variation objects by an |
| 5307 | ** AJAX List of AJAX Sring (name) objects. |
| 5308 | ** |
| 5309 | ** The caller is responsible for deleting the Ensembl Genetic Variation |
| 5310 | ** Variation objects before deleting the AJAX List. |
| 5311 | ** |
| 5312 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationAdaptor::fetch_all_by_name_list |
| 5313 | ** @param [u] gvva [EnsPGvvariationadaptor] |
| 5314 | ** Ensembl Genetic Variation Variation Adaptor |
| 5315 | ** @param [u] gvvs [AjPTable] AJAX Table of |
| 5316 | ** AJAX String (name) key data and |
| 5317 | ** Ensembl Genetic Variation Variation value data |
| 5318 | ** |
| 5319 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 5320 | ** |
| 5321 | ** @release 6.4.0 |
| 5322 | ** @@ |
| 5323 | ******************************************************************************/ |
| 5324 | |
| 5325 | AjBool ensGvvariationadaptorFetchAllbyNames( |
| 5326 | EnsPGvvariationadaptor gvva, |
| 5327 | AjPTable gvvs) |
| 5328 | { |
| 5329 | void **keyarray = NULL; |
| 5330 | |
| 5331 | /* |
| 5332 | ** NOTE: Because information from the "source" SQL table is |
| 5333 | ** modelled as independent EnsPGvsource object, neither |
| 5334 | ** "variation" nor "variation_synonym" need joining. |
| 5335 | */ |
| 5336 | |
| 5337 | const char *template1 = |
| 5338 | "SELECT " |
| 5339 | "variation.variation_id, " |
| 5340 | "variation.source_id, " |
| 5341 | "variation.name, " |
| 5342 | "variation.validation_status, " |
| 5343 | "variation.ancestral_allele, " |
| 5344 | "variation.class_attrib_id, " |
| 5345 | "variation.somatic, " |
| 5346 | "allele.allele_id, " |
| 5347 | "allele.subsnp_id, " |
| 5348 | "allele.allele, " |
| 5349 | "allele.frequency, " |
| 5350 | "allele.count, " |
| 5351 | "allele.sample_id, " |
| 5352 | "variation_synonym.variation_synonym_id, " |
| 5353 | "variation_synonym.subsnp_id, " |
| 5354 | "variation_synonym.source_id, " |
| 5355 | "variation_synonym.name, " |
| 5356 | "variation_synonym.moltype, " |
| 5357 | "0 " /* "flanking_sequence" flag */ |
| 5358 | "FROM (variation) " |
| 5359 | "LEFT JOIN " |
| 5360 | "allele " |
| 5361 | "ON " |
| 5362 | "variation.variation_id = allele.variation_id " |
| 5363 | "LEFT JOIN " |
| 5364 | "variation_synonym " |
| 5365 | "ON " |
| 5366 | "variation.variation_id = variation_synonym.variation_id " |
| 5367 | "LEFT JOIN " |
| 5368 | "failed_variation " |
| 5369 | "ON " |
| 5370 | "variation.variation_id = failed_variation.variation_id " |
| 5371 | "WHERE " |
| 5372 | "variation.name IN (%S)"; |
| 5373 | |
| 5374 | /* |
| 5375 | ** NOTE: Values are extracted from variation_synonym1, |
| 5376 | ** while variation_synonym2 is included in the condition. |
| 5377 | */ |
| 5378 | |
| 5379 | const char *template2 = |
| 5380 | "SELECT " |
| 5381 | "variation.variation_id, " |
| 5382 | "variation.source_id, " |
| 5383 | "variation.name, " |
| 5384 | "variation.validation_status, " |
| 5385 | "variation.ancestral_allele, " |
| 5386 | "variation.class_attrib_id, " |
| 5387 | "variation.somatic, " |
| 5388 | "allele.allele_id, " |
| 5389 | "allele.subsnp_id, " |
| 5390 | "allele.allele, " |
| 5391 | "allele.frequency, " |
| 5392 | "allele.count, " |
| 5393 | "allele.sample_id, " |
| 5394 | "variation_synonym1.variation_synonym_id, " |
| 5395 | "variation_synonym1.subsnp_id, " |
| 5396 | "variation_synonym1.source_id, " |
| 5397 | "variation_synonym1.name, " |
| 5398 | "variation_synonym1.moltype, " |
| 5399 | "0 " /* "flanking_sequence" flag */ |
| 5400 | "FROM " |
| 5401 | "variation, " |
| 5402 | "allele, " |
| 5403 | "variation_synonym variation_synonym1, " |
| 5404 | "variation_synonym variation_synonym2, " |
| 5405 | /* FIXME: Why is "flanking_sequence" SQL table joined in? It doesn't seem to be used. */ |
| 5406 | "flanking_sequence " |
| 5407 | "WHERE " |
| 5408 | "variation.variation_id = allele.variation_id " |
| 5409 | "AND " |
| 5410 | "variation.variation_id = variation_synonym1.variation_id " |
| 5411 | "AND " |
| 5412 | "variation.variation_id = variation_synonym2.variation_id " |
| 5413 | "AND " |
| 5414 | "variation.variation_id = flanking_sequence.variation_id " |
| 5415 | "AND " |
| 5416 | "variation_synonym2.name IN (%S) " |
| 5417 | "ORDER BY " |
| 5418 | "allele.allele_id"; |
| 5419 | |
| 5420 | register ajuint i = 0U; |
| 5421 | register ajuint j = 0U; |
| 5422 | |
| 5423 | AjPList lgvvs = NULL; |
| 5424 | |
| 5425 | AjPStr statement = NULL; |
| 5426 | AjPStr csv = NULL; |
| 5427 | |
| 5428 | EnsPBaseadaptor ba = NULL; |
| 5429 | |
| 5430 | EnsPGvvariation gvv = NULL; |
| 5431 | |
| 5432 | if (!gvva) |
| 5433 | return ajFalse; |
| 5434 | |
| 5435 | if (!gvvs) |
| 5436 | return ajFalse; |
| 5437 | |
| 5438 | /* FIXME: This is just here to use the function temporarily. */ |
| 5439 | gvvariationadaptorFetchAllbyNames(gvva, |
| 5440 | ajFalse, |
| 5441 | ajFalse, |
| 5442 | (AjPTable) NULL, |
| 5443 | (AjPTable *) NULL); |
| 5444 | |
| 5445 | ba = ensGvvariationadaptorGetBaseadaptor(gvva); |
| 5446 | |
| 5447 | lgvvs = ajListNew(); |
| 5448 | |
| 5449 | csv = ajStrNew(); |
| 5450 | |
| 5451 | /* |
| 5452 | ** MySQL is faster and we ensure that we do not exceed the maximum |
| 5453 | ** query size by splitting large queries into smaller queries of |
| 5454 | ** up to 200 names. |
| 5455 | */ |
| 5456 | |
| 5457 | ajTableToarrayKeys(gvvs, &keyarray); |
| 5458 | |
| 5459 | for (i = 0U; keyarray[i]; i++) |
| 5460 | { |
| 5461 | ajFmtPrintAppS(&csv, "'%S', ", (AjPStr) keyarray[i]); |
| 5462 | |
| 5463 | /* |
| 5464 | ** Run the statement if the maximum chunk size is exceed or |
| 5465 | ** if there are no more array elements to process. |
| 5466 | ** Assume that average name strings are 4 times longer than |
| 5467 | ** integer strings. |
| 5468 | */ |
| 5469 | |
| 5470 | if ((((i + 1U) % (ensKBaseadaptorMaximumIdentifiers / 4U)) == 0) |
| 5471 | || (keyarray[i + 1U] == NULL)) |
| 5472 | { |
| 5473 | /* Remove the last comma and space. */ |
| 5474 | |
| 5475 | ajStrCutEnd(&csv, 2); |
| 5476 | |
| 5477 | if (ajStrGetLen(csv)) |
| 5478 | { |
| 5479 | statement = ajFmtStr(template1, csv); |
| 5480 | |
| 5481 | gvvariationadaptorFetchAllbyStatement( |
| 5482 | ba, |
| 5483 | statement, |
| 5484 | (EnsPAssemblymapper) NULL, |
| 5485 | (EnsPSlice) NULL, |
| 5486 | lgvvs); |
| 5487 | |
| 5488 | ajStrDel(&statement); |
| 5489 | } |
| 5490 | |
| 5491 | ajStrAssignClear(&csv); |
| 5492 | } |
| 5493 | } |
| 5494 | |
| 5495 | AJFREE(keyarray); |
| 5496 | |
| 5497 | /* |
| 5498 | ** Move Ensembl Genetic Variation Variation objects from the AJAX List |
| 5499 | ** to the AJAX Table. |
| 5500 | */ |
| 5501 | |
| 5502 | ensTablestrFromList( |
| 5503 | gvvs, |
| 5504 | (AjPStr (*)(const void *)) &ensGvvariationGetName, |
| 5505 | lgvvs); |
| 5506 | |
| 5507 | /* Check, which names yielded no result above and search for synonyms. */ |
| 5508 | |
| 5509 | ajTableToarrayKeys(gvvs, &keyarray); |
| 5510 | |
| 5511 | for (i = 0U; keyarray[i]; i++) |
| 5512 | { |
| 5513 | gvv = (EnsPGvvariation) ajTableFetchmodV(gvvs, |
| 5514 | (const void *) keyarray[i]); |
| 5515 | |
| 5516 | if (gvv == NULL) |
| 5517 | { |
| 5518 | ajFmtPrintAppS(&csv, "'%S', ", (AjPStr) keyarray[i]); |
| 5519 | |
| 5520 | j++; |
| 5521 | } |
| 5522 | |
| 5523 | /* |
| 5524 | ** Run the statement if the maximum chunk size is exceed or |
| 5525 | ** if there are no more array elements to process. |
| 5526 | ** Assume that average name strings are 4 times longer than |
| 5527 | ** integer strings. |
| 5528 | */ |
| 5529 | |
| 5530 | if ((((j + 1U) % (ensKBaseadaptorMaximumIdentifiers / 4U)) == 0) |
| 5531 | || (keyarray[i + 1U] == NULL)) |
| 5532 | { |
| 5533 | /* Remove the last comma and space. */ |
| 5534 | |
| 5535 | ajStrCutEnd(&csv, 2); |
| 5536 | |
| 5537 | if (ajStrGetLen(csv)) |
| 5538 | { |
| 5539 | statement = ajFmtStr(template2, csv); |
| 5540 | |
| 5541 | gvvariationadaptorFetchAllbyStatement( |
| 5542 | ba, |
| 5543 | statement, |
| 5544 | (EnsPAssemblymapper) NULL, |
| 5545 | (EnsPSlice) NULL, |
| 5546 | lgvvs); |
| 5547 | |
| 5548 | ajStrDel(&statement); |
| 5549 | } |
| 5550 | |
| 5551 | ajStrAssignClear(&csv); |
| 5552 | } |
| 5553 | } |
| 5554 | |
| 5555 | AJFREE(keyarray); |
| 5556 | |
| 5557 | /* |
| 5558 | ** Move Ensembl Genetic Variation Variation objects from the AJAX List |
| 5559 | ** to the AJAX Table based on a synonym. |
| 5560 | */ |
| 5561 | |
| 5562 | ensTablestrFromList( |
| 5563 | gvvs, |
| 5564 | (AjPStr (*)(const void *)) &ensGvvariationGetName, |
| 5565 | lgvvs); |
| 5566 | |
| 5567 | ajListFree(&lgvvs); |
| 5568 | |
| 5569 | ajStrDel(&csv); |
| 5570 | |
| 5571 | return ajTrue; |
| 5572 | } |
| 5573 | |
| 5574 | |
| 5575 | |
| 5576 | |
| 5577 | /* @func ensGvvariationadaptorFetchAllbySource ******************************** |
| 5578 | ** |
| 5579 | ** Fetch all Ensembl Genetic Variation Variation objects via a source. |
| 5580 | ** |
| 5581 | ** The caller is responsible for deleting the |
| 5582 | ** Ensembl Genetic Variation Variation objects before deleting the AJAX List. |
| 5583 | ** |
| 5584 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationAdaptor::fetch_all_by_source |
| 5585 | ** @param [u] gvva [EnsPGvvariationadaptor] |
| 5586 | ** Ensembl Genetic Variation Variation Adaptor |
| 5587 | ** @param [r] source [const AjPStr] Source |
| 5588 | ** @param [r] primary [AjBool] Primary |
| 5589 | ** @param [u] gvvs [AjPList] |
| 5590 | ** AJAX List of Ensembl Genetic Variation Variation objects |
| 5591 | ** |
| 5592 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 5593 | ** |
| 5594 | ** @release 6.4.0 |
| 5595 | ** @@ |
| 5596 | ******************************************************************************/ |
| 5597 | |
| 5598 | AjBool ensGvvariationadaptorFetchAllbySource( |
| 5599 | EnsPGvvariationadaptor gvva, |
| 5600 | const AjPStr source, |
| 5601 | AjBool primary, |
| 5602 | AjPList gvvs) |
| 5603 | { |
| 5604 | char *txtsource = NULL; |
| 5605 | |
| 5606 | AjBool joinallele = AJFALSE; |
| 5607 | AjBool joinflank = AJFALSE; |
| 5608 | AjBool joinsource = AJFALSE; |
| 5609 | AjBool result = AJFALSE; |
| 5610 | |
| 5611 | AjPStr constraint = NULL; |
| 5612 | |
| 5613 | EnsPBaseadaptor ba = NULL; |
| 5614 | |
| 5615 | if (!gvva) |
| 5616 | return ajFalse; |
| 5617 | |
| 5618 | if (!source) |
| 5619 | return ajFalse; |
| 5620 | |
| 5621 | if (!gvvs) |
| 5622 | return ajFalse; |
| 5623 | |
| 5624 | ba = ensGvvariationadaptorGetBaseadaptor(gvva); |
| 5625 | |
| 5626 | ensBaseadaptorEscapeC(ba, &txtsource, source); |
| 5627 | |
| 5628 | constraint = ajFmtStr("source1.name = '%s'", txtsource); |
| 5629 | |
| 5630 | if (primary == ajFalse) |
| 5631 | ajFmtPrintAppS(&constraint, " OR source2.name = '%s'", txtsource); |
| 5632 | |
| 5633 | ajCharDel(&txtsource); |
| 5634 | |
| 5635 | result = gvvariationadaptorFetchAllbyConstraint(gvva, |
| 5636 | constraint, |
| 5637 | joinallele, |
| 5638 | joinflank, |
| 5639 | joinsource, |
| 5640 | gvvs); |
| 5641 | |
| 5642 | ajStrDel(&constraint); |
| 5643 | |
| 5644 | return result; |
| 5645 | } |
| 5646 | |
| 5647 | |
| 5648 | |
| 5649 | |
| 5650 | /* @func ensGvvariationadaptorFetchAllsomatic ********************************* |
| 5651 | ** |
| 5652 | ** Fetch all somatic Ensembl Genetic Variation Objects via |
| 5653 | ** an Ensembl Genetic Variation Variation Adaptor. |
| 5654 | ** |
| 5655 | ** Please note that it is probably not a good idea to use this function on |
| 5656 | ** very large tables quite common in the Ensembl genome annotation system. |
| 5657 | ** |
| 5658 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationAdaptor::fetch_all_somatic |
| 5659 | ** @param [u] gvva [EnsPGvvariationadaptor] |
| 5660 | ** Ensembl Genetic Variation Variation Adaptor |
| 5661 | ** @param [u] gvvs [AjPList] |
| 5662 | ** AJAX List of Ensembl Genetic Variation Variation objects |
| 5663 | ** |
| 5664 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 5665 | ** |
| 5666 | ** @release 6.4.0 |
| 5667 | ** @@ |
| 5668 | ******************************************************************************/ |
| 5669 | |
| 5670 | AjBool ensGvvariationadaptorFetchAllsomatic(EnsPGvvariationadaptor gvva, |
| 5671 | AjPList gvvs) |
| 5672 | { |
| 5673 | AjBool joinallele = AJFALSE; |
| 5674 | AjBool joinflank = AJFALSE; |
| 5675 | AjBool joinsource = AJFALSE; |
| 5676 | AjBool result = AJFALSE; |
| 5677 | |
| 5678 | AjPStr constraint = NULL; |
| 5679 | |
| 5680 | if (!gvva) |
| 5681 | return ajFalse; |
| 5682 | |
| 5683 | if (!gvvs) |
| 5684 | return ajFalse; |
| 5685 | |
| 5686 | constraint = ajStrNewC("variation.somatic = 1"); |
| 5687 | |
| 5688 | result = gvvariationadaptorFetchAllbyConstraint(gvva, |
| 5689 | constraint, |
| 5690 | joinallele, |
| 5691 | joinflank, |
| 5692 | joinsource, |
| 5693 | gvvs); |
| 5694 | |
| 5695 | ajStrDel(&constraint); |
| 5696 | |
| 5697 | return result; |
| 5698 | } |
| 5699 | |
| 5700 | |
| 5701 | |
| 5702 | |
| 5703 | /* @func ensGvvariationadaptorFetchByIdentifier ******************************* |
| 5704 | ** |
| 5705 | ** Fetch an Ensembl Genetic Variation Variation via its |
| 5706 | ** SQL database-internal identifier. |
| 5707 | ** The caller is responsible for deleting the |
| 5708 | ** Ensembl Genetic Variation Variation. |
| 5709 | ** |
| 5710 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationAdaptor::fetch_by_dbID |
| 5711 | ** @param [u] gvva [EnsPGvvariationadaptor] |
| 5712 | ** Ensembl Genetic Variation Variation Adaptor |
| 5713 | ** @param [r] identifier [ajuint] SQL database-internal identifier |
| 5714 | ** @param [wP] Pgvv [EnsPGvvariation*] |
| 5715 | ** Ensembl Genetic Variation Variation address |
| 5716 | ** |
| 5717 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 5718 | ** |
| 5719 | ** @release 6.2.0 |
| 5720 | ** @@ |
| 5721 | ******************************************************************************/ |
| 5722 | |
| 5723 | AjBool ensGvvariationadaptorFetchByIdentifier( |
| 5724 | EnsPGvvariationadaptor gvva, |
| 5725 | ajuint identifier, |
| 5726 | EnsPGvvariation *Pgvv) |
| 5727 | { |
| 5728 | /* This function needs to join the to the flanking_sequence SQL table. */ |
| 5729 | |
| 5730 | AjBool joinallele = AJFALSE; |
| 5731 | AjBool joinflank = AJTRUE; |
| 5732 | AjBool joinsource = AJFALSE; |
| 5733 | AjBool result = AJFALSE; |
| 5734 | |
| 5735 | AjPList gvvs = NULL; |
| 5736 | |
| 5737 | AjPStr constraint = NULL; |
| 5738 | |
| 5739 | EnsPGvvariation gvv = NULL; |
| 5740 | |
| 5741 | if (!gvva) |
| 5742 | return ajFalse; |
| 5743 | |
| 5744 | if (!identifier) |
| 5745 | return ajFalse; |
| 5746 | |
| 5747 | if (!Pgvv) |
| 5748 | return ajFalse; |
| 5749 | |
| 5750 | *Pgvv = NULL; |
| 5751 | |
| 5752 | constraint = ajFmtStr("variation.variation_id = %u", identifier); |
| 5753 | |
| 5754 | gvvs = ajListNew(); |
| 5755 | |
| 5756 | /* Join the flanking_sequence SQL table. */ |
| 5757 | |
| 5758 | result = gvvariationadaptorFetchAllbyConstraint(gvva, |
| 5759 | constraint, |
| 5760 | joinallele, |
| 5761 | joinflank, |
| 5762 | joinsource, |
| 5763 | gvvs); |
| 5764 | |
| 5765 | if (ajListGetLength(gvvs) > 1) |
| 5766 | ajWarn("ensGvvariationadaptorFetchByIdentifier got more than one " |
| 5767 | "Ensembl Genetic Variation Variation for identifier %u.", |
| 5768 | identifier); |
| 5769 | |
| 5770 | ajListPop(gvvs, (void **) Pgvv); |
| 5771 | |
| 5772 | while (ajListPop(gvvs, (void **) &gvv)) |
| 5773 | ensGvvariationDel(&gvv); |
| 5774 | |
| 5775 | ajListFree(&gvvs); |
| 5776 | |
| 5777 | ajStrDel(&constraint); |
| 5778 | |
| 5779 | return result; |
| 5780 | } |
| 5781 | |
| 5782 | |
| 5783 | |
| 5784 | |
| 5785 | /* @func ensGvvariationadaptorFetchByName ************************************* |
| 5786 | ** |
| 5787 | ** Fetch an Ensembl Genetic Variation Variation via its name. |
| 5788 | ** The caller is responsible for deleting the |
| 5789 | ** Ensembl Genetic Variation Variation. |
| 5790 | ** |
| 5791 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationAdaptor::fetch_by_name |
| 5792 | ** @param [u] gvva [EnsPGvvariationadaptor] |
| 5793 | ** Ensembl Genetic Variation Variation Adaptor |
| 5794 | ** @param [r] name [const AjPStr] Name |
| 5795 | ** @param [rN] source [const AjPStr] Source |
| 5796 | ** @param [wP] Pgvv [EnsPGvvariation*] |
| 5797 | ** Ensembl Genetic Variation Variation address |
| 5798 | ** |
| 5799 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 5800 | ** |
| 5801 | ** @release 6.2.0 |
| 5802 | ** @@ |
| 5803 | ******************************************************************************/ |
| 5804 | |
| 5805 | AjBool ensGvvariationadaptorFetchByName( |
| 5806 | EnsPGvvariationadaptor gvva, |
| 5807 | const AjPStr name, |
| 5808 | const AjPStr source, |
| 5809 | EnsPGvvariation *Pgvv) |
| 5810 | { |
| 5811 | char *txtname = NULL; |
| 5812 | char *txtsource = NULL; |
| 5813 | |
| 5814 | /* This function needs to join the to the flanking_sequence SQL table. */ |
| 5815 | |
| 5816 | AjBool joinallele = AJFALSE; |
| 5817 | AjBool joinflank = AJTRUE; |
| 5818 | AjBool joinsource = AJFALSE; |
| 5819 | AjBool result = AJFALSE; |
| 5820 | |
| 5821 | AjPList gvvs = NULL; |
| 5822 | |
| 5823 | AjPStr constraint = NULL; |
| 5824 | |
| 5825 | EnsPBaseadaptor ba = NULL; |
| 5826 | |
| 5827 | EnsPGvvariation gvv = NULL; |
| 5828 | |
| 5829 | if (!gvva) |
| 5830 | return ajFalse; |
| 5831 | |
| 5832 | if (!name) |
| 5833 | return ajFalse; |
| 5834 | |
| 5835 | if (!Pgvv) |
| 5836 | return ajFalse; |
| 5837 | |
| 5838 | *Pgvv = NULL; |
| 5839 | |
| 5840 | /* |
| 5841 | ** NOTE: Because information from the "source" SQL table is |
| 5842 | ** modelled as independent EnsPGvsource object, neither |
| 5843 | ** "variation" nor "variation_synonym" need joining. |
| 5844 | ** NOTE: The "flanking_sequence" SQL table is joined here and in |
| 5845 | ** ensGvvariationadaptorFetchByIdentifier so that the flank_flag can be |
| 5846 | ** set where the flanking sequence differs from the reference. It is just |
| 5847 | ** set to 0 when fetching Ensembl Geentic Variation Variation objects by |
| 5848 | ** other methods since otherwise the join takes too long. |
| 5849 | */ |
| 5850 | |
| 5851 | ba = ensGvvariationadaptorGetBaseadaptor(gvva); |
| 5852 | |
| 5853 | ensBaseadaptorEscapeC(ba, &txtname, name); |
| 5854 | |
| 5855 | constraint = ajFmtStr("source.name = '%s'", txtname); |
| 5856 | |
| 5857 | ajCharDel(&txtname); |
| 5858 | |
| 5859 | if (source && ajStrGetLen(source)) |
| 5860 | { |
| 5861 | joinsource = ajTrue; |
| 5862 | |
| 5863 | ensBaseadaptorEscapeC(ba, &txtsource, source); |
| 5864 | |
| 5865 | ajFmtPrintAppS(&constraint, " AND source.name = '%s'", txtsource); |
| 5866 | |
| 5867 | ajCharDel(&txtsource); |
| 5868 | } |
| 5869 | else |
| 5870 | joinsource = ajFalse; |
| 5871 | |
| 5872 | gvvs = ajListNew(); |
| 5873 | |
| 5874 | result = gvvariationadaptorFetchAllbyConstraint(gvva, |
| 5875 | constraint, |
| 5876 | joinallele, |
| 5877 | joinflank, |
| 5878 | joinsource, |
| 5879 | gvvs); |
| 5880 | |
| 5881 | ajStrDel(&constraint); |
| 5882 | |
| 5883 | if (ajListGetLength(gvvs) > 1) |
| 5884 | ajWarn("ensGvvariationadaptorFetchByName got more than one " |
| 5885 | "Ensembl Genetic Variation Variation for " |
| 5886 | "name '%S' and source '%S'.", name, source); |
| 5887 | |
| 5888 | ajListPop(gvvs, (void **) Pgvv); |
| 5889 | |
| 5890 | while (ajListPop(gvvs, (void **) &gvv)) |
| 5891 | ensGvvariationDel(&gvv); |
| 5892 | |
| 5893 | ajListFree(&gvvs); |
| 5894 | |
| 5895 | /* |
| 5896 | ** Check the variation_synonym SQL table if the name was not found in the |
| 5897 | ** variation SQL table. |
| 5898 | */ |
| 5899 | |
| 5900 | if (*Pgvv == NULL) |
| 5901 | result = ensGvvariationadaptorFetchBySynonym(gvva, |
| 5902 | name, |
| 5903 | source, |
| 5904 | Pgvv); |
| 5905 | |
| 5906 | /* |
| 5907 | ** If the query yielded no result and the name looks like a |
| 5908 | ** Sub-SNP identifier, query again. |
| 5909 | */ |
| 5910 | |
| 5911 | if ((*Pgvv == NULL) && (ajStrPrefixC(name, "ss") == ajTrue)) |
| 5912 | result = ensGvvariationadaptorFetchBySubidentifier(gvva, name, Pgvv); |
| 5913 | |
| 5914 | return result; |
| 5915 | } |
| 5916 | |
| 5917 | |
| 5918 | |
| 5919 | |
| 5920 | /* @func ensGvvariationadaptorFetchBySubidentifier **************************** |
| 5921 | ** |
| 5922 | ** Fetch an Ensembl Genetic Variation Variation via its sub-identifier. |
| 5923 | ** The caller is responsible for deleting the |
| 5924 | ** Ensembl Genetic Variation Variation. |
| 5925 | ** |
| 5926 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationAdaptor::fetch_by_subsnp_id |
| 5927 | ** @param [u] gvva [EnsPGvvariationadaptor] |
| 5928 | ** Ensembl Genetic Variation Variation Adaptor |
| 5929 | ** @param [r] name [const AjPStr] Name |
| 5930 | ** @param [wP] Pgvv [EnsPGvvariation*] |
| 5931 | ** Ensembl Genetic Variation Variation address |
| 5932 | ** |
| 5933 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 5934 | ** |
| 5935 | ** @release 6.4.0 |
| 5936 | ** @@ |
| 5937 | ******************************************************************************/ |
| 5938 | |
| 5939 | AjBool ensGvvariationadaptorFetchBySubidentifier( |
| 5940 | EnsPGvvariationadaptor gvva, |
| 5941 | const AjPStr name, |
| 5942 | EnsPGvvariation *Pgvv) |
| 5943 | { |
| 5944 | char *txtname = NULL; |
| 5945 | |
| 5946 | /* |
| 5947 | ** This function needs to join the to the flanking_sequence and |
| 5948 | ** allele SQL tables. |
| 5949 | */ |
| 5950 | |
| 5951 | AjBool joinallele = AJTRUE; |
| 5952 | AjBool joinflank = AJTRUE; |
| 5953 | AjBool joinsource = AJFALSE; |
| 5954 | AjBool result = AJFALSE; |
| 5955 | |
| 5956 | AjPList gvvs = NULL; |
| 5957 | |
| 5958 | AjPStr constraint = NULL; |
| 5959 | AjPStr subidentifier = NULL; |
| 5960 | |
| 5961 | EnsPDatabaseadaptor dba = NULL; |
| 5962 | |
| 5963 | EnsPGvvariation gvv = NULL; |
| 5964 | |
| 5965 | if (!gvva) |
| 5966 | return ajFalse; |
| 5967 | |
| 5968 | if (!name) |
| 5969 | return ajFalse; |
| 5970 | |
| 5971 | if (!Pgvv) |
| 5972 | return ajFalse; |
| 5973 | |
| 5974 | *Pgvv = NULL; |
| 5975 | |
| 5976 | dba = ensGvvariationadaptorGetDatabaseadaptor(gvva); |
| 5977 | |
| 5978 | if (ajStrPrefixC(name, "ss")) |
| 5979 | { |
| 5980 | subidentifier = ajStrNew(); |
| 5981 | ajStrAssignSubS(&subidentifier, name, 0, 2); |
| 5982 | ensDatabaseadaptorEscapeC(dba, &txtname, subidentifier); |
| 5983 | ajStrDel(&subidentifier); |
| 5984 | } |
| 5985 | else |
| 5986 | ensDatabaseadaptorEscapeC(dba, &txtname, name); |
| 5987 | |
| 5988 | constraint = ajFmtStr("allele.subsnp_id = '%s'", txtname); |
| 5989 | |
| 5990 | ajCharDel(&txtname); |
| 5991 | |
| 5992 | gvvs = ajListNew(); |
| 5993 | |
| 5994 | result = gvvariationadaptorFetchAllbyConstraint(gvva, |
| 5995 | constraint, |
| 5996 | joinallele, |
| 5997 | joinflank, |
| 5998 | joinsource, |
| 5999 | gvvs); |
| 6000 | |
| 6001 | if (ajListGetLength(gvvs) > 1) |
| 6002 | ajWarn("ensGvvariationadaptorFetchBySubidentifier got more than one " |
| 6003 | "Ensembl Genetic Variation Variation for " |
| 6004 | "sub-identifier '%S'.", name); |
| 6005 | |
| 6006 | ajListPop(gvvs, (void **) Pgvv); |
| 6007 | |
| 6008 | while (ajListPop(gvvs, (void **) &gvv)) |
| 6009 | ensGvvariationDel(&gvv); |
| 6010 | |
| 6011 | ajListFree(&gvvs); |
| 6012 | |
| 6013 | ajStrDel(&constraint); |
| 6014 | |
| 6015 | return result; |
| 6016 | } |
| 6017 | |
| 6018 | |
| 6019 | |
| 6020 | |
| 6021 | /* @func ensGvvariationadaptorFetchBySynonym ********************************** |
| 6022 | ** |
| 6023 | ** Fetch an Ensembl Genetic Variation Variation via a synonym. |
| 6024 | ** |
| 6025 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationAdaptor::fetch_by_synonym |
| 6026 | ** @param [u] gvva [EnsPGvvariationadaptor] |
| 6027 | ** Ensembl Genetic Variation Variation Adaptor |
| 6028 | ** @param [r] synonym [const AjPStr] Synonym |
| 6029 | ** @param [rN] source [const AjPStr] Source |
| 6030 | ** @param [wP] Pgvv [EnsPGvvariation*] |
| 6031 | ** Ensembl Genetic Variation Variation address |
| 6032 | ** |
| 6033 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 6034 | ** |
| 6035 | ** @release 6.5.0 |
| 6036 | ** @@ |
| 6037 | ******************************************************************************/ |
| 6038 | |
| 6039 | AjBool ensGvvariationadaptorFetchBySynonym( |
| 6040 | EnsPGvvariationadaptor gvva, |
| 6041 | const AjPStr synonym, |
| 6042 | const AjPStr source, |
| 6043 | EnsPGvvariation *Pgvv) |
| 6044 | { |
| 6045 | char *txtname = NULL; |
| 6046 | |
| 6047 | ajuint gvvidentifier = 0U; |
| 6048 | |
| 6049 | AjPSqlstatement sqls = NULL; |
| 6050 | AjISqlrow sqli = NULL; |
| 6051 | AjPSqlrow sqlr = NULL; |
| 6052 | |
| 6053 | AjPStr constraint = NULL; |
| 6054 | AjPStr statement = NULL; |
| 6055 | |
| 6056 | EnsPDatabaseadaptor dba = NULL; |
| 6057 | |
| 6058 | if (!gvva) |
| 6059 | return ajFalse; |
| 6060 | |
| 6061 | if (!synonym) |
| 6062 | return ajFalse; |
| 6063 | |
| 6064 | if (!Pgvv) |
| 6065 | return ajFalse; |
| 6066 | |
| 6067 | *Pgvv = NULL; |
| 6068 | |
| 6069 | dba = ensGvvariationadaptorGetDatabaseadaptor(gvva); |
| 6070 | |
| 6071 | ensDatabaseadaptorEscapeC(dba, &txtname, synonym); |
| 6072 | |
| 6073 | constraint = ajFmtStr("variation_synonym.name = '%s'", txtname); |
| 6074 | |
| 6075 | ajCharDel(&txtname); |
| 6076 | |
| 6077 | if (source && ajStrGetLen(source)) |
| 6078 | { |
| 6079 | ensDatabaseadaptorEscapeC(dba, &txtname, source); |
| 6080 | |
| 6081 | ajFmtPrintAppS(&constraint, " AND source.name = '%s'", txtname); |
| 6082 | |
| 6083 | ajCharDel(&txtname); |
| 6084 | } |
| 6085 | |
| 6086 | statement = ajFmtStr( |
| 6087 | "SELECT " |
| 6088 | "variation_synonym.variation_id " |
| 6089 | "FROM " |
| 6090 | "variation_synonym " |
| 6091 | "JOIN " |
| 6092 | "source " |
| 6093 | "ON " |
| 6094 | "(" |
| 6095 | "source.source_id = variation_synonym.source_id" |
| 6096 | ")" |
| 6097 | "WHERE " |
| 6098 | "%S" |
| 6099 | "LIMIT 1 ", |
| 6100 | constraint); |
| 6101 | |
| 6102 | /* |
| 6103 | ** This statement will only return one row which is consistent with the |
| 6104 | ** behaviour of ensGvvariationadaptorFetchByName. |
| 6105 | ** However, the synonym name is only guaranteed to be unique in |
| 6106 | ** combination with the source |
| 6107 | */ |
| 6108 | |
| 6109 | sqls = ensDatabaseadaptorSqlstatementNew(dba, statement); |
| 6110 | |
| 6111 | sqli = ajSqlrowiterNew(sqls); |
| 6112 | |
| 6113 | while (!ajSqlrowiterDone(sqli)) |
| 6114 | { |
| 6115 | gvvidentifier = 0U; |
| 6116 | |
| 6117 | sqlr = ajSqlrowiterGet(sqli); |
| 6118 | |
| 6119 | ajSqlcolumnToUint(sqlr, &gvvidentifier); |
| 6120 | |
| 6121 | ensGvvariationadaptorFetchByIdentifier(gvva, gvvidentifier, Pgvv); |
| 6122 | } |
| 6123 | |
| 6124 | ajSqlrowiterDel(&sqli); |
| 6125 | |
| 6126 | ensDatabaseadaptorSqlstatementDel(dba, &sqls); |
| 6127 | |
| 6128 | ajStrDel(&constraint); |
| 6129 | ajStrDel(&statement); |
| 6130 | |
| 6131 | return ajTrue; |
| 6132 | } |
| 6133 | |
| 6134 | |
| 6135 | |
| 6136 | |
| 6137 | /* @section object retrieval ************************************************** |
| 6138 | ** |
| 6139 | ** Functions for retrieving Ensembl Genetic Variation Variation-releated |
| 6140 | ** objects from an Ensembl SQL database. |
| 6141 | ** |
| 6142 | ** @fdata [EnsPGvvariationadaptor] |
| 6143 | ** |
| 6144 | ** @nam3rule Retrieve Retrieve Ensembl Genetic Variation Variation-related |
| 6145 | ** object(s) |
| 6146 | ** @nam4rule All Retrieve all related objects |
| 6147 | ** @nam5rule Faileddescriptions Retrieve all failed descriptions for |
| 6148 | ** Ensembl Genetic Variation Variation objects |
| 6149 | ** @nam4rule Flank Retrieve flanking sequences |
| 6150 | ** |
| 6151 | ** @argrule * gvva [EnsPGvvariationadaptor] |
| 6152 | ** Ensembl Genetic Variation Variation Adaptor |
| 6153 | ** @argrule Faileddescriptions identifier [ajuint] |
| 6154 | ** Ensembl Genetic Variation Variation identifier |
| 6155 | ** @argrule Faileddescriptions fvs [AjPList] |
| 6156 | ** AJAX List of AJAX String (description) objects |
| 6157 | ** @argrule Flank identifier [ajuint] |
| 6158 | ** Ensembl Genetic Variation Variation identifier |
| 6159 | ** @argrule Flank Pfiveseq [AjPStr*] Five-prime flanking sequence |
| 6160 | ** @argrule Flank Pthreeseq [AjPStr*] Three-prime flanking sequence |
| 6161 | ** |
| 6162 | ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise |
| 6163 | ** |
| 6164 | ** @fcategory use |
| 6165 | ******************************************************************************/ |
| 6166 | |
| 6167 | |
| 6168 | |
| 6169 | |
| 6170 | /* @funcstatic gvvariationadaptorRetrieveAllFaileddescriptions **************** |
| 6171 | ** |
| 6172 | ** Retrieve all failed descriptions of an |
| 6173 | ** Ensembl Genetic Variation Variation objects. |
| 6174 | ** |
| 6175 | ** The caller is responsible for deleting the AJAX Table. |
| 6176 | ** |
| 6177 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationAdaptor:: |
| 6178 | ** _internal_get_failed_descriptions |
| 6179 | ** @param [u] gvva [EnsPGvvariationadaptor] |
| 6180 | ** Ensembl Genetic Variation Variation Adaptor |
| 6181 | ** @param [r] identifier [ajuint] |
| 6182 | ** Ensembl Genetic Variation Variation identifier |
| 6183 | ** @param [r] constraint [const AjPStr] SQL constraint |
| 6184 | ** @param [u] fvs [AjPTable] AJAX Table of |
| 6185 | ** AJAX unsigned integer (Ensembl Genetic Variation Variation identifier) |
| 6186 | ** key data and |
| 6187 | ** AJAX Table value data. |
| 6188 | ** Second-level AJAX Table of |
| 6189 | ** AJAX unsigned integer (sub-SNP identifier) key data and |
| 6190 | ** AJAX String (description) value data. |
| 6191 | ** |
| 6192 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 6193 | ** |
| 6194 | ** @release 6.4.0 |
| 6195 | ** @@ |
| 6196 | ******************************************************************************/ |
| 6197 | |
| 6198 | static AjBool gvvariationadaptorRetrieveAllFaileddescriptions( |
| 6199 | EnsPGvvariationadaptor gvva, |
| 6200 | ajuint identifier, |
| 6201 | const AjPStr constraint, |
| 6202 | AjPTable fvs) |
| 6203 | { |
| 6204 | ajuint gvvidentifier = 0U; |
| 6205 | ajuint subsnpid = 0U; |
| 6206 | |
| 6207 | ajuint *Pgvvidentifier = NULL; |
| 6208 | ajuint *Psubsnpid = NULL; |
| 6209 | |
| 6210 | AjPSqlstatement sqls = NULL; |
| 6211 | AjISqlrow sqli = NULL; |
| 6212 | AjPSqlrow sqlr = NULL; |
| 6213 | |
| 6214 | AjPStr description = NULL; |
| 6215 | AjPStr statement = NULL; |
| 6216 | |
| 6217 | AjPTable table = NULL; |
| 6218 | |
| 6219 | EnsPDatabaseadaptor dba = NULL; |
| 6220 | |
| 6221 | if (!gvva) |
| 6222 | return ajFalse; |
| 6223 | |
| 6224 | if (!identifier) |
| 6225 | return ajFalse; |
| 6226 | |
| 6227 | if (!fvs) |
| 6228 | return ajFalse; |
| 6229 | |
| 6230 | dba = ensGvvariationadaptorGetDatabaseadaptor(gvva); |
| 6231 | |
| 6232 | /* |
| 6233 | ** NOTE: The Perl API uses the following construct ... |
| 6234 | ** IFNULL(failed_variation.subsnp_id, 'rs') AS subsnp_id |
| 6235 | ** ... which is not compatible with the unsigned integer type. |
| 6236 | */ |
| 6237 | |
| 6238 | statement = ajFmtStr( |
| 6239 | "SELECT " |
| 6240 | "failed_variation.variation_id, " |
| 6241 | "failed_variation.subsnp_id, " |
| 6242 | "failed_description.description " |
| 6243 | "FROM " |
| 6244 | "failed_variation " |
| 6245 | "JOIN " |
| 6246 | "failed_description " |
| 6247 | "ON " |
| 6248 | "(failed_variation.failed_description_id = " |
| 6249 | "failed_description.failed_description_id) " |
| 6250 | "WHERE " |
| 6251 | "failed_variation.variation_id = %u", |
| 6252 | identifier); |
| 6253 | |
| 6254 | if ((constraint != NULL) && (ajStrGetLen(constraint) > 0)) |
| 6255 | { |
| 6256 | ajStrAppendC(&statement, " AND "); |
| 6257 | ajStrAppendS(&statement, constraint); |
| 6258 | } |
| 6259 | |
| 6260 | sqls = ensDatabaseadaptorSqlstatementNew(dba, statement); |
| 6261 | |
| 6262 | sqli = ajSqlrowiterNew(sqls); |
| 6263 | |
| 6264 | while (!ajSqlrowiterDone(sqli)) |
| 6265 | { |
| 6266 | gvvidentifier = 0; |
| 6267 | subsnpid = 0; |
| 6268 | description = ajStrNew(); |
| 6269 | |
| 6270 | sqlr = ajSqlrowiterGet(sqli); |
| 6271 | |
| 6272 | ajSqlcolumnToUint(sqlr, &gvvidentifier); |
| 6273 | ajSqlcolumnToUint(sqlr, &subsnpid); |
| 6274 | ajSqlcolumnToStr(sqlr, &description); |
| 6275 | |
| 6276 | table = (AjPTable) ajTableFetchmodV(fvs, (const void *) &gvvidentifier); |
| 6277 | |
| 6278 | if (!table) |
| 6279 | { |
| 6280 | AJNEW0(Pgvvidentifier); |
| 6281 | |
| 6282 | *Pgvvidentifier = gvvidentifier; |
| 6283 | |
| 6284 | table = ajTableuintNew(0U); |
| 6285 | |
| 6286 | ajTableSetDestroyvalue(table, (void (*)(void **)) &ajStrDel); |
| 6287 | |
| 6288 | ajTablePut(fvs, (void *) Pgvvidentifier, (void *) table); |
| 6289 | } |
| 6290 | |
| 6291 | if (!ajTableMatchV(table, (const void *) &subsnpid)) |
| 6292 | { |
| 6293 | AJNEW0(Psubsnpid); |
| 6294 | |
| 6295 | *Psubsnpid = subsnpid; |
| 6296 | |
| 6297 | ajTablePut(table, (void *) Psubsnpid, (void *) description); |
| 6298 | } |
| 6299 | else |
| 6300 | ajStrDel(&description); |
| 6301 | } |
| 6302 | |
| 6303 | ajSqlrowiterDel(&sqli); |
| 6304 | |
| 6305 | ensDatabaseadaptorSqlstatementDel(dba, &sqls); |
| 6306 | |
| 6307 | ajStrDel(&statement); |
| 6308 | |
| 6309 | return ajTrue; |
| 6310 | } |
| 6311 | |
| 6312 | |
| 6313 | |
| 6314 | |
| 6315 | /* @func ensGvvariationadaptorRetrieveAllFaileddescriptions ******************* |
| 6316 | ** |
| 6317 | ** Retrieve all failed descriptions for an Ensembl Genetic Variation Variation. |
| 6318 | ** |
| 6319 | ** The caller is responsible for deleting the AJAX String objects |
| 6320 | ** before deleting the AJAX List. |
| 6321 | ** |
| 6322 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationAdaptor:: |
| 6323 | ** get_all_failed_descriptions |
| 6324 | ** @param [u] gvva [EnsPGvvariationadaptor] |
| 6325 | ** Ensembl Genetic Variation Variation Adaptor |
| 6326 | ** @param [r] identifier [ajuint] |
| 6327 | ** Ensembl Genetic Variation Variation identifier |
| 6328 | ** @param [u] fvs [AjPList] AJAX List of AJAX String (description) objects |
| 6329 | ** |
| 6330 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 6331 | ** |
| 6332 | ** @release 6.4.0 |
| 6333 | ** @@ |
| 6334 | ******************************************************************************/ |
| 6335 | |
| 6336 | AjBool ensGvvariationadaptorRetrieveAllFaileddescriptions( |
| 6337 | EnsPGvvariationadaptor gvva, |
| 6338 | ajuint identifier, |
| 6339 | AjPList fvs) |
| 6340 | { |
| 6341 | void **keyarray = NULL; |
| 6342 | void **valarray = NULL; |
| 6343 | |
| 6344 | register ajuint i = 0U; |
| 6345 | |
| 6346 | AjPTable fvstable1 = NULL; |
| 6347 | AjPTable fvstable2 = NULL; |
| 6348 | AjPTable strtable = NULL; |
| 6349 | |
| 6350 | if (!gvva) |
| 6351 | return ajFalse; |
| 6352 | |
| 6353 | if (!identifier) |
| 6354 | return ajFalse; |
| 6355 | |
| 6356 | if (!fvs) |
| 6357 | return ajFalse; |
| 6358 | |
| 6359 | fvstable1 = ajTableuintNew(0U); |
| 6360 | |
| 6361 | ajTableSetDestroyvalue(fvstable1, (void (*)(void **)) &ajTableDel); |
| 6362 | |
| 6363 | gvvariationadaptorRetrieveAllFaileddescriptions( |
| 6364 | gvva, |
| 6365 | identifier, |
| 6366 | (AjPStr) NULL, |
| 6367 | fvstable1); |
| 6368 | |
| 6369 | fvstable2 = (AjPTable) ajTableFetchmodV(fvstable1, |
| 6370 | (const void *) &identifier); |
| 6371 | |
| 6372 | if (!fvstable2) |
| 6373 | return ajFalse; |
| 6374 | |
| 6375 | strtable = ajTablestrNew(0U); |
| 6376 | |
| 6377 | ajTableSetDestroyvalue(strtable, &ajMemFree); |
| 6378 | |
| 6379 | ajTableToarrayValues(fvstable2, &valarray); |
| 6380 | |
| 6381 | for (i = 0U; valarray[i]; i++) |
| 6382 | if (!ajTableMatchV(strtable, (const void *) valarray[i])) |
| 6383 | ajTablePut(strtable, |
| 6384 | (void *) ajStrNewS((AjPStr) valarray[i]), |
| 6385 | NULL); |
| 6386 | |
| 6387 | AJFREE(valarray); |
| 6388 | |
| 6389 | ajTableToarrayKeys(strtable, &keyarray); |
| 6390 | |
| 6391 | for (i = 0U; keyarray[i]; i++) |
| 6392 | ajListPushAppend(fvs, (void *) keyarray[i]); |
| 6393 | |
| 6394 | ajTableDel(&fvstable1); |
| 6395 | ajTableDel(&strtable); |
| 6396 | |
| 6397 | return ajTrue; |
| 6398 | } |
| 6399 | |
| 6400 | |
| 6401 | |
| 6402 | |
| 6403 | /* |
| 6404 | ** TODO: The following methods are not implemented: |
| 6405 | ** is_failed |
| 6406 | ** has_failed_subsnps |
| 6407 | ** get_failed_description |
| 6408 | */ |
| 6409 | |
| 6410 | |
| 6411 | |
| 6412 | |
| 6413 | /* @funcstatic gvvariationadaptorRetrieveFlankFromCore ************************ |
| 6414 | ** |
| 6415 | ** Retrieve the flanking sequence from the corresponding Ensembl Core Database. |
| 6416 | ** |
| 6417 | ** The caller is responsible for deleting the AJAX String. |
| 6418 | ** |
| 6419 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationAdaptor::_get_flank_from_core |
| 6420 | ** @param [u] gvva [EnsPGvvariationadaptor] |
| 6421 | ** Ensembl Genetic Variation Variation Adaptor |
| 6422 | ** @param [r] srid [ajuint] Ensembl Sequence Region identifier |
| 6423 | ** @param [r] srstart [ajint] Ensembl Sequence Region start |
| 6424 | ** @param [r] srend [ajint] Ensembl Sequence Region end |
| 6425 | ** @param [r] srstrand [ajint] Ensembl Sequence Region strand |
| 6426 | ** @param [wP] Psequence [AjPStr*] Flanking sequence |
| 6427 | ** |
| 6428 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 6429 | ** |
| 6430 | ** @release 6.4.0 |
| 6431 | ** @@ |
| 6432 | ******************************************************************************/ |
| 6433 | |
| 6434 | static AjBool gvvariationadaptorRetrieveFlankFromCore( |
| 6435 | EnsPGvvariationadaptor gvva, |
| 6436 | ajuint srid, |
| 6437 | ajint srstart, |
| 6438 | ajint srend, |
| 6439 | ajint srstrand, |
| 6440 | AjPStr *Psequence) |
| 6441 | { |
| 6442 | EnsPDatabaseadaptor dba = NULL; |
| 6443 | EnsPDatabaseadaptor rsa = NULL; |
| 6444 | |
| 6445 | EnsPSlice slice = NULL; |
| 6446 | EnsPSliceadaptor sla = NULL; |
| 6447 | |
| 6448 | if (!gvva) |
| 6449 | return ajFalse; |
| 6450 | |
| 6451 | if (!srid) |
| 6452 | return ajFalse; |
| 6453 | |
| 6454 | if (!Psequence) |
| 6455 | return ajFalse; |
| 6456 | |
| 6457 | dba = ensGvvariationadaptorGetDatabaseadaptor(gvva); |
| 6458 | |
| 6459 | rsa = ensRegistryGetReferenceadaptor(dba); |
| 6460 | |
| 6461 | sla = ensRegistryGetSliceadaptor(rsa); |
| 6462 | |
| 6463 | if (sla) |
| 6464 | { |
| 6465 | ensSliceadaptorFetchBySeqregionIdentifier(sla, srid, 0, 0, 0, &slice); |
| 6466 | |
| 6467 | if (!slice) |
| 6468 | ajWarn("gvvariationadaptorRetrieveFlankFromCore could not get an " |
| 6469 | "Ensembl Slice for Ensembl Sequence region identifier %u.", |
| 6470 | srid); |
| 6471 | |
| 6472 | ensSliceFetchSequenceSubStr(slice, |
| 6473 | srstart, |
| 6474 | srend, |
| 6475 | srstrand, |
| 6476 | Psequence); |
| 6477 | } |
| 6478 | |
| 6479 | return ajTrue; |
| 6480 | } |
| 6481 | |
| 6482 | |
| 6483 | |
| 6484 | |
| 6485 | /* @func ensGvvariationadaptorRetrieveFlank *********************************** |
| 6486 | ** |
| 6487 | ** Retrieve the flanking sequence of an Ensembl Genetic Variation Variation. |
| 6488 | ** |
| 6489 | ** If the flanking sequence is not in the flankinq_sequence table of the |
| 6490 | ** Ensembl Genetic Variation database the sequence is retrieved from the |
| 6491 | ** corresponding Ensembl Core database. |
| 6492 | ** |
| 6493 | ** The caller is responsible for deleting the AJAX String objects. |
| 6494 | ** |
| 6495 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationAdaptor::get_flanking_sequence |
| 6496 | ** @param [u] gvva [EnsPGvvariationadaptor] |
| 6497 | ** Ensembl Genetic Variation Variation Adaptor |
| 6498 | ** @param [r] identifier [ajuint] |
| 6499 | ** Ensembl Genetic Variation Variation identifier |
| 6500 | ** @param [wP] Pfiveseq [AjPStr*] Five-prime flanking sequence |
| 6501 | ** @param [wP] Pthreeseq [AjPStr*] Three-prime flanking sequence |
| 6502 | ** |
| 6503 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 6504 | ** |
| 6505 | ** @release 6.4.0 |
| 6506 | ** @@ |
| 6507 | ******************************************************************************/ |
| 6508 | |
| 6509 | AjBool ensGvvariationadaptorRetrieveFlank(EnsPGvvariationadaptor gvva, |
| 6510 | ajuint identifier, |
| 6511 | AjPStr *Pfiveseq, |
| 6512 | AjPStr *Pthreeseq) |
| 6513 | { |
| 6514 | ajint srstrand = 0; |
| 6515 | |
| 6516 | ajuint srid = 0U; |
| 6517 | ajuint srstart = 0U; |
| 6518 | ajuint srend = 0U; |
| 6519 | ajuint usrstart = 0U; |
| 6520 | ajuint usrend = 0U; |
| 6521 | ajuint dsrstart = 0U; |
| 6522 | ajuint dsrend = 0U; |
| 6523 | |
| 6524 | AjPSqlstatement sqls = NULL; |
| 6525 | AjISqlrow sqli = NULL; |
| 6526 | AjPSqlrow sqlr = NULL; |
| 6527 | |
| 6528 | AjPStr statement = NULL; |
| 6529 | AjPStr useq = NULL; |
| 6530 | AjPStr dseq = NULL; |
| 6531 | |
| 6532 | EnsPDatabaseadaptor dba = NULL; |
| 6533 | |
| 6534 | if (!gvva) |
| 6535 | return ajFalse; |
| 6536 | |
| 6537 | if (!identifier) |
| 6538 | return ajFalse; |
| 6539 | |
| 6540 | if (!Pfiveseq) |
| 6541 | return ajFalse; |
| 6542 | |
| 6543 | if (!Pthreeseq) |
| 6544 | return ajFalse; |
| 6545 | |
| 6546 | dba = ensGvvariationadaptorGetDatabaseadaptor(gvva); |
| 6547 | |
| 6548 | statement = ajFmtStr( |
| 6549 | "SELECT " |
| 6550 | "flanking_sequence.seq_region_id, " |
| 6551 | "flanking_sequence.seq_region_strand, " |
| 6552 | "flanking_sequence.up_seq, " |
| 6553 | "flanking_sequence.down_seq, " |
| 6554 | "flanking_sequence.up_seq_region_start, " |
| 6555 | "flanking_sequence.up_seq_region_end, " |
| 6556 | "flanking_sequence.down_seq_region_start, " |
| 6557 | "flanking_sequence.down_seq_region_end " |
| 6558 | "FROM " |
| 6559 | "flanking_sequence " |
| 6560 | "WHERE " |
| 6561 | "flanking_sequence.variation_id = %u", |
| 6562 | identifier); |
| 6563 | |
| 6564 | sqls = ensDatabaseadaptorSqlstatementNew(dba, statement); |
| 6565 | |
| 6566 | sqli = ajSqlrowiterNew(sqls); |
| 6567 | |
| 6568 | while (!ajSqlrowiterDone(sqli)) |
| 6569 | { |
| 6570 | srid = 0U; |
| 6571 | srstrand = 0; |
| 6572 | useq = ajStrNew(); |
| 6573 | dseq = ajStrNew(); |
| 6574 | usrstart = 0U; |
| 6575 | usrend = 0U; |
| 6576 | dsrstart = 0U; |
| 6577 | dsrend = 0U; |
| 6578 | |
| 6579 | sqlr = ajSqlrowiterGet(sqli); |
| 6580 | |
| 6581 | ajSqlcolumnToUint(sqlr, &srid); |
| 6582 | ajSqlcolumnToInt(sqlr, &srstrand); |
| 6583 | ajSqlcolumnToStr(sqlr, &useq); |
| 6584 | ajSqlcolumnToStr(sqlr, &dseq); |
| 6585 | ajSqlcolumnToUint(sqlr, &usrstart); |
| 6586 | ajSqlcolumnToUint(sqlr, &usrend); |
| 6587 | ajSqlcolumnToUint(sqlr, &dsrstart); |
| 6588 | ajSqlcolumnToUint(sqlr, &dsrend); |
| 6589 | |
| 6590 | if (!ajStrGetLen(useq)) |
| 6591 | { |
| 6592 | if (srid) |
| 6593 | { |
| 6594 | if (usrend < usrstart) |
| 6595 | { |
| 6596 | srstart = usrend; |
| 6597 | srend = usrstart; |
| 6598 | } |
| 6599 | else |
| 6600 | { |
| 6601 | srstart = usrstart; |
| 6602 | srend = usrend; |
| 6603 | } |
| 6604 | |
| 6605 | gvvariationadaptorRetrieveFlankFromCore(gvva, |
| 6606 | srid, |
| 6607 | srstart, |
| 6608 | srend, |
| 6609 | srstrand, |
| 6610 | &useq); |
| 6611 | } |
| 6612 | else |
| 6613 | ajWarn("ensGvvariationadaptorRetrieveFlank " |
| 6614 | "could not get " |
| 6615 | "Ensembl Sequence Region identifier for " |
| 6616 | "Ensembl Genetic Variation Variation %u.", |
| 6617 | identifier); |
| 6618 | } |
| 6619 | |
| 6620 | ajStrAssignS(Pfiveseq, useq); |
| 6621 | |
| 6622 | if (!ajStrGetLen(dseq)) |
| 6623 | { |
| 6624 | if (srid) |
| 6625 | { |
| 6626 | if (dsrend < dsrstart) |
| 6627 | { |
| 6628 | srstart = dsrend; |
| 6629 | srend = dsrstart; |
| 6630 | } |
| 6631 | else |
| 6632 | { |
| 6633 | srstart = dsrstart; |
| 6634 | srend = dsrend; |
| 6635 | } |
| 6636 | |
| 6637 | gvvariationadaptorRetrieveFlankFromCore(gvva, |
| 6638 | srid, |
| 6639 | srstart, |
| 6640 | srend, |
| 6641 | srstrand, |
| 6642 | &dseq); |
| 6643 | } |
| 6644 | else |
| 6645 | ajWarn("ensGvvariationadaptorRetrieveFlank " |
| 6646 | "could not get " |
| 6647 | "Ensembl Sequence Region identifier for " |
| 6648 | "Ensembl Genetic Variation Variation %u.", |
| 6649 | identifier); |
| 6650 | } |
| 6651 | |
| 6652 | ajStrAssignS(Pthreeseq, dseq); |
| 6653 | |
| 6654 | ajStrDel(&useq); |
| 6655 | ajStrDel(&dseq); |
| 6656 | } |
| 6657 | |
| 6658 | ajSqlrowiterDel(&sqli); |
| 6659 | |
| 6660 | ensDatabaseadaptorSqlstatementDel(dba, &sqls); |
| 6661 | |
| 6662 | ajStrDel(&statement); |
| 6663 | |
| 6664 | return ajTrue; |
| 6665 | } |
| 6666 | |
| 6667 | |
| 6668 | |
| 6669 | |
| 6670 | /* @datasection [EnsPGvvariationfeature] Ensembl Genetic Variation Variation |
| 6671 | ** Feature |
| 6672 | ** |
| 6673 | ** @nam2rule Gvvariationfeature Functions for manipulating |
| 6674 | ** Ensembl Genetic Variation Variation Feature objects |
| 6675 | ** |
| 6676 | ** @cc Bio::EnsEMBL::Variation::VariationFeature |
| 6677 | ** @cc CVS Revision: 1.90 |
| 6678 | ** @cc CVS Tag: branch-ensembl-61 |
| 6679 | ** |
| 6680 | ******************************************************************************/ |
| 6681 | |
| 6682 | |
| 6683 | |
| 6684 | |
| 6685 | /* @section constructors ****************************************************** |
| 6686 | ** |
| 6687 | ** All constructors return a new Ensembl Genetic Variation Variation Feature by |
| 6688 | ** pointer. It is the responsibility of the user to first destroy any previous |
| 6689 | ** Genetic Variation Variation Feature. The target pointer does not need to be |
| 6690 | ** initialised to NULL, but it is good programming practice to do so anyway. |
| 6691 | ** |
| 6692 | ** @fdata [EnsPGvvariationfeature] |
| 6693 | ** |
| 6694 | ** @nam3rule New Constructor |
| 6695 | ** @nam4rule Cpy Constructor with existing object |
| 6696 | ** @nam4rule Identifier Constructor with an Ensembl Genetic Variation Variation |
| 6697 | ** identifier |
| 6698 | ** @nam4rule Ini Constructor with initial values |
| 6699 | ** @nam4rule Ref Constructor by incrementing the reference counter |
| 6700 | ** |
| 6701 | ** @argrule Cpy gvvf [const EnsPGvvariationfeature] |
| 6702 | ** Ensembl Genetic Variation Variation Feature |
| 6703 | ** @argrule Identifier gvvfa [EnsPGvvariationfeatureadaptor] |
| 6704 | ** Ensembl Genetic Variation Variation Feature Adaptor |
| 6705 | ** @argrule Identifier identifier [ajuint] SQL database-internal identifier |
| 6706 | ** @argrule Identifier feature [EnsPFeature] Ensembl Feature |
| 6707 | ** @argrule Identifier gvsource [EnsPGvsource] Ensembl Genetic Variation Source |
| 6708 | ** @argrule Identifier gvvc [EnsEGvvariationClass] |
| 6709 | ** Ensembl Genetic Variation Variation Class enumeration |
| 6710 | ** @argrule Identifier gvvidentifier [ajuint] |
| 6711 | ** Ensembl Genetic Variation Variation identifier |
| 6712 | ** @argrule Identifier allele [AjPStr] Allele |
| 6713 | ** @argrule Identifier name [AjPStr] Name |
| 6714 | ** @argrule Identifier validation [AjPStr] Validation code |
| 6715 | ** @argrule Identifier consequence [AjPStr] Consequence type |
| 6716 | ** @argrule Identifier mapweight [ajuint] Map weight |
| 6717 | ** @argrule Ini gvvfa [EnsPGvvariationfeatureadaptor] |
| 6718 | ** Ensembl Genetic Variation Variation Feature Adaptor |
| 6719 | ** @argrule Ini identifier [ajuint] SQL database-internal identifier |
| 6720 | ** @argrule Ini feature [EnsPFeature] Ensembl Feature |
| 6721 | ** @argrule Ini gvsource [EnsPGvsource] Ensembl Genetic Variation Source |
| 6722 | ** @argrule Ini gvvc [EnsEGvvariationClass] |
| 6723 | ** Ensembl Genetic Variation Variation Class enumeration |
| 6724 | ** @argrule Ini gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 6725 | ** @argrule Ini allele [AjPStr] Allele |
| 6726 | ** @argrule Ini name [AjPStr] Name |
| 6727 | ** @argrule Ini validation [AjPStr] Validation code |
| 6728 | ** @argrule Ini consequence [AjPStr] Consequence type |
| 6729 | ** @argrule Ini mapweight [ajuint] Map weight |
| 6730 | ** @argrule Ref gvvf [EnsPGvvariationfeature] |
| 6731 | ** Ensembl Genetic Variation Variation Feature |
| 6732 | ** |
| 6733 | ** @valrule * [EnsPGvvariationfeature] |
| 6734 | ** Ensembl Genetic Variation Variation Feature or NULL |
| 6735 | ** |
| 6736 | ** @fcategory new |
| 6737 | ******************************************************************************/ |
| 6738 | |
| 6739 | |
| 6740 | |
| 6741 | |
| 6742 | /* @func ensGvvariationfeatureNewCpy ****************************************** |
| 6743 | ** |
| 6744 | ** Object-based constructor function, which returns an independent object. |
| 6745 | ** |
| 6746 | ** @param [r] gvvf [const EnsPGvvariationfeature] |
| 6747 | ** Ensembl Genetic Variation Variation Feature |
| 6748 | ** |
| 6749 | ** @return [EnsPGvvariationfeature] |
| 6750 | ** Ensembl Genetic Variation Variation Feature or NULL |
| 6751 | ** |
| 6752 | ** @release 6.4.0 |
| 6753 | ** @@ |
| 6754 | ******************************************************************************/ |
| 6755 | |
| 6756 | EnsPGvvariationfeature ensGvvariationfeatureNewCpy( |
| 6757 | const EnsPGvvariationfeature gvvf) |
| 6758 | { |
| 6759 | EnsPGvvariationfeature pthis = NULL; |
| 6760 | |
| 6761 | if (!gvvf) |
| 6762 | return NULL; |
| 6763 | |
| 6764 | AJNEW0(pthis); |
| 6765 | |
| 6766 | pthis->Use = 1U; |
| 6767 | pthis->Identifier = gvvf->Identifier; |
| 6768 | pthis->Adaptor = gvvf->Adaptor; |
| 6769 | pthis->Feature = ensFeatureNewRef(gvvf->Feature); |
| 6770 | pthis->Gvsource = ensGvsourceNewRef(gvvf->Gvsource); |
| 6771 | pthis->Gvvariation = ensGvvariationNewRef(gvvf->Gvvariation); |
| 6772 | |
| 6773 | if (gvvf->Allele) |
| 6774 | pthis->Allele = ajStrNewRef(gvvf->Allele); |
| 6775 | |
| 6776 | if (gvvf->Name) |
| 6777 | pthis->Name = ajStrNewRef(gvvf->Name); |
| 6778 | |
| 6779 | if (gvvf->Validationcode) |
| 6780 | pthis->Validationcode = ajStrNewRef(gvvf->Validationcode); |
| 6781 | |
| 6782 | if (gvvf->Consequencetype) |
| 6783 | pthis->Consequencetype = ajStrNewRef(gvvf->Consequencetype); |
| 6784 | |
| 6785 | pthis->Mapweight = gvvf->Mapweight; |
| 6786 | pthis->Gvvariationidentifier = gvvf->Gvvariationidentifier; |
| 6787 | pthis->GvvariationClass = gvvf->GvvariationClass; |
| 6788 | |
| 6789 | return pthis; |
| 6790 | } |
| 6791 | |
| 6792 | |
| 6793 | |
| 6794 | |
| 6795 | /* @func ensGvvariationfeatureNewIdentifier *********************************** |
| 6796 | ** |
| 6797 | ** Constructor for an Ensembl Genetic Variation Variation Feature. |
| 6798 | ** |
| 6799 | ** @cc Bio::EnsEMBL::Storable::new |
| 6800 | ** @param [u] gvvfa [EnsPGvvariationfeatureadaptor] |
| 6801 | ** Ensembl Genetic Variation Variation Feature Adaptor |
| 6802 | ** @param [r] identifier [ajuint] SQL database-internal identifier |
| 6803 | ** @cc Bio::EnsEMBL::Variation::VariationFeature::new |
| 6804 | ** @param [u] feature [EnsPFeature] Ensembl Feature |
| 6805 | ** @param [u] gvsource [EnsPGvsource] Ensembl Genetic Variation Source |
| 6806 | ** Ensembl Genetic Variation Variation identifier |
| 6807 | ** @param [u] gvvc [EnsEGvvariationClass] |
| 6808 | ** Ensembl Genetic Variation Variation Class enumeration |
| 6809 | ** @param [r] gvvidentifier [ajuint] |
| 6810 | ** Ensembl Genetic Variation Variation identifier |
| 6811 | ** @param [u] allele [AjPStr] Allele |
| 6812 | ** @param [u] name [AjPStr] Name |
| 6813 | ** @param [u] validation [AjPStr] Validation code |
| 6814 | ** @param [u] consequence [AjPStr] Consequence type |
| 6815 | ** @param [r] mapweight [ajuint] Map weight |
| 6816 | ** |
| 6817 | ** @return [EnsPGvvariationfeature] |
| 6818 | ** Ensembl Genetic Variation Variation Feature or NULL |
| 6819 | ** |
| 6820 | ** @release 6.4.0 |
| 6821 | ** @@ |
| 6822 | ******************************************************************************/ |
| 6823 | |
| 6824 | EnsPGvvariationfeature ensGvvariationfeatureNewIdentifier( |
| 6825 | EnsPGvvariationfeatureadaptor gvvfa, |
| 6826 | ajuint identifier, |
| 6827 | EnsPFeature feature, |
| 6828 | EnsPGvsource gvsource, |
| 6829 | EnsEGvvariationClass gvvc, |
| 6830 | ajuint gvvidentifier, |
| 6831 | AjPStr allele, |
| 6832 | AjPStr name, |
| 6833 | AjPStr validation, |
| 6834 | AjPStr consequence, |
| 6835 | ajuint mapweight) |
| 6836 | { |
| 6837 | EnsPGvvariationfeature gvvf = NULL; |
| 6838 | |
| 6839 | if (!feature) |
| 6840 | return NULL; |
| 6841 | |
| 6842 | if (!gvvidentifier) |
| 6843 | return NULL; |
| 6844 | |
| 6845 | AJNEW0(gvvf); |
| 6846 | |
| 6847 | gvvf->Use = 1U; |
| 6848 | gvvf->Identifier = identifier; |
| 6849 | gvvf->Adaptor = gvvfa; |
| 6850 | gvvf->Feature = ensFeatureNewRef(feature); |
| 6851 | gvvf->Gvsource = ensGvsourceNewRef(gvsource); |
| 6852 | gvvf->Gvvariationidentifier = gvvidentifier; |
| 6853 | |
| 6854 | if (allele) |
| 6855 | gvvf->Allele = ajStrNewRef(allele); |
| 6856 | |
| 6857 | if (name) |
| 6858 | gvvf->Name = ajStrNewRef(name); |
| 6859 | |
| 6860 | if (validation) |
| 6861 | gvvf->Validationcode = ajStrNewRef(validation); |
| 6862 | |
| 6863 | if (consequence) |
| 6864 | gvvf->Consequencetype = ajStrNewRef(consequence); |
| 6865 | |
| 6866 | gvvf->Mapweight = mapweight; |
| 6867 | |
| 6868 | gvvf->GvvariationClass = gvvc; |
| 6869 | |
| 6870 | return gvvf; |
| 6871 | } |
| 6872 | |
| 6873 | |
| 6874 | |
| 6875 | |
| 6876 | /* @func ensGvvariationfeatureNewIni ****************************************** |
| 6877 | ** |
| 6878 | ** Constructor for an Ensembl Genetic Variation Variation Feature with initial |
| 6879 | ** values. |
| 6880 | ** |
| 6881 | ** @cc Bio::EnsEMBL::Storable::new |
| 6882 | ** @param [u] gvvfa [EnsPGvvariationfeatureadaptor] |
| 6883 | ** Ensembl Genetic Variation Variation Feature Adaptor |
| 6884 | ** @param [r] identifier [ajuint] SQL database-internal identifier |
| 6885 | ** @cc Bio::EnsEMBL::Variation::VariationFeature::new |
| 6886 | ** @param [u] feature [EnsPFeature] Ensembl Feature |
| 6887 | ** @param [u] gvsource [EnsPGvsource] Ensembl Genetic Variation Source |
| 6888 | ** @param [u] gvvc [EnsEGvvariationClass] |
| 6889 | ** Ensembl Genetic Variation Variation Class enumeration |
| 6890 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 6891 | ** @param [u] allele [AjPStr] Allele |
| 6892 | ** @param [u] name [AjPStr] Name |
| 6893 | ** @param [u] validation [AjPStr] Validation code |
| 6894 | ** @param [u] consequence [AjPStr] Consequence type |
| 6895 | ** @param [r] mapweight [ajuint] Map weight |
| 6896 | ** |
| 6897 | ** @return [EnsPGvvariationfeature] |
| 6898 | ** Ensembl Genetic Variation Variation Feature or NULL |
| 6899 | ** |
| 6900 | ** @release 6.4.0 |
| 6901 | ** @@ |
| 6902 | ******************************************************************************/ |
| 6903 | |
| 6904 | EnsPGvvariationfeature ensGvvariationfeatureNewIni( |
| 6905 | EnsPGvvariationfeatureadaptor gvvfa, |
| 6906 | ajuint identifier, |
| 6907 | EnsPFeature feature, |
| 6908 | EnsPGvsource gvsource, |
| 6909 | EnsEGvvariationClass gvvc, |
| 6910 | EnsPGvvariation gvv, |
| 6911 | AjPStr allele, |
| 6912 | AjPStr name, |
| 6913 | AjPStr validation, |
| 6914 | AjPStr consequence, |
| 6915 | ajuint mapweight) |
| 6916 | { |
| 6917 | EnsPGvvariationfeature gvvf = NULL; |
| 6918 | |
| 6919 | if (!feature) |
| 6920 | return NULL; |
| 6921 | |
| 6922 | if (!gvv) |
| 6923 | return NULL; |
| 6924 | |
| 6925 | AJNEW0(gvvf); |
| 6926 | |
| 6927 | gvvf->Use = 1; |
| 6928 | gvvf->Identifier = identifier; |
| 6929 | gvvf->Adaptor = gvvfa; |
| 6930 | gvvf->Feature = ensFeatureNewRef(feature); |
| 6931 | gvvf->Gvsource = ensGvsourceNewRef(gvsource); |
| 6932 | gvvf->Gvvariation = ensGvvariationNewRef(gvv); |
| 6933 | |
| 6934 | if (allele) |
| 6935 | gvvf->Allele = ajStrNewRef(allele); |
| 6936 | |
| 6937 | if (name) |
| 6938 | gvvf->Name = ajStrNewRef(name); |
| 6939 | |
| 6940 | if (validation) |
| 6941 | gvvf->Validationcode = ajStrNewRef(validation); |
| 6942 | |
| 6943 | if (consequence) |
| 6944 | gvvf->Consequencetype = ajStrNewRef(consequence); |
| 6945 | |
| 6946 | gvvf->Mapweight = mapweight; |
| 6947 | gvvf->GvvariationClass = gvvc; |
| 6948 | |
| 6949 | return gvvf; |
| 6950 | } |
| 6951 | |
| 6952 | |
| 6953 | |
| 6954 | |
| 6955 | /* @func ensGvvariationfeatureNewRef ****************************************** |
| 6956 | ** |
| 6957 | ** Ensembl Object referencing function, which returns a pointer to the |
| 6958 | ** Ensembl Object passed in and increases its reference count. |
| 6959 | ** |
| 6960 | ** @param [u] gvvf [EnsPGvvariationfeature] |
| 6961 | ** Ensembl Genetic Variation Variation Feature |
| 6962 | ** |
| 6963 | ** @return [EnsPGvvariationfeature] |
| 6964 | ** Ensembl Genetic Variation Variation Feature or NULL |
| 6965 | ** |
| 6966 | ** @release 6.2.0 |
| 6967 | ** @@ |
| 6968 | ******************************************************************************/ |
| 6969 | |
| 6970 | EnsPGvvariationfeature ensGvvariationfeatureNewRef( |
| 6971 | EnsPGvvariationfeature gvvf) |
| 6972 | { |
| 6973 | if (!gvvf) |
| 6974 | return NULL; |
| 6975 | |
| 6976 | gvvf->Use++; |
| 6977 | |
| 6978 | return gvvf; |
| 6979 | } |
| 6980 | |
| 6981 | |
| 6982 | |
| 6983 | |
| 6984 | /* @section destructors ******************************************************* |
| 6985 | ** |
| 6986 | ** Destruction destroys all internal data structures and frees the memory |
| 6987 | ** allocated for an Ensembl Genetic Variation Variation Feature object. |
| 6988 | ** |
| 6989 | ** @fdata [EnsPGvvariationfeature] |
| 6990 | ** |
| 6991 | ** @nam3rule Del Destroy (free) an |
| 6992 | ** Ensembl Genetic Variation Variation Feature |
| 6993 | ** |
| 6994 | ** @argrule * Pgvvf [EnsPGvvariationfeature*] |
| 6995 | ** Ensembl Genetic Variation Variation Feature address |
| 6996 | ** |
| 6997 | ** @valrule * [void] |
| 6998 | ** |
| 6999 | ** @fcategory delete |
| 7000 | ******************************************************************************/ |
| 7001 | |
| 7002 | |
| 7003 | |
| 7004 | |
| 7005 | /* @func ensGvvariationfeatureDel ********************************************* |
| 7006 | ** |
| 7007 | ** Default destructor for an Ensembl Genetic Variation Variation Feature. |
| 7008 | ** |
| 7009 | ** @param [d] Pgvvf [EnsPGvvariationfeature*] |
| 7010 | ** Ensembl Genetic Variation Variation Feature address |
| 7011 | ** |
| 7012 | ** @return [void] |
| 7013 | ** |
| 7014 | ** @release 6.2.0 |
| 7015 | ** @@ |
| 7016 | ******************************************************************************/ |
| 7017 | |
| 7018 | void ensGvvariationfeatureDel(EnsPGvvariationfeature *Pgvvf) |
| 7019 | { |
| 7020 | EnsPGvvariationfeature pthis = NULL; |
| 7021 | |
| 7022 | if (!Pgvvf) |
| 7023 | return; |
| 7024 | |
| 7025 | #if defined(AJ_DEBUG) && AJ_DEBUG >= 1 |
| 7026 | if (ajDebugTest("ensGvvariationfeatureDel")) |
| 7027 | { |
| 7028 | ajDebug("ensGvvariationfeatureDel\n" |
| 7029 | " *Pgvvf %p\n", |
| 7030 | *Pgvvf); |
| 7031 | |
| 7032 | ensGvvariationfeatureTrace(*Pgvvf, 1); |
| 7033 | } |
| 7034 | #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 1 */ |
| 7035 | |
| 7036 | if (!(pthis = *Pgvvf) || --pthis->Use) |
| 7037 | { |
| 7038 | *Pgvvf = NULL; |
| 7039 | |
| 7040 | return; |
| 7041 | } |
| 7042 | |
| 7043 | ensFeatureDel(&pthis->Feature); |
| 7044 | |
| 7045 | ensGvsourceDel(&pthis->Gvsource); |
| 7046 | |
| 7047 | ensGvvariationDel(&pthis->Gvvariation); |
| 7048 | |
| 7049 | ajStrDel(&pthis->Allele); |
| 7050 | ajStrDel(&pthis->Name); |
| 7051 | ajStrDel(&pthis->Validationcode); |
| 7052 | ajStrDel(&pthis->Consequencetype); |
| 7053 | |
| 7054 | ajMemFree((void **) Pgvvf); |
| 7055 | |
| 7056 | return; |
| 7057 | } |
| 7058 | |
| 7059 | |
| 7060 | |
| 7061 | |
| 7062 | /* @section member retrieval ************************************************** |
| 7063 | ** |
| 7064 | ** Functions for returning members of an |
| 7065 | ** Ensembl Genetic Variation Variation Feature object. |
| 7066 | ** |
| 7067 | ** @fdata [EnsPGvvariationfeature] |
| 7068 | ** |
| 7069 | ** @nam3rule Get Return Genetic Variation Variation Feature attribute(s) |
| 7070 | ** @nam4rule Adaptor Return the Ensembl Genetic Variation |
| 7071 | ** Variation Feature Adaptor |
| 7072 | ** @nam4rule Allele Return the allele |
| 7073 | ** @nam4rule Consequencetype Return the consequence type |
| 7074 | ** @nam4rule Feature Return the Ensembl Feature |
| 7075 | ** @nam4rule Gvsource Return the Ensemb Genetic Variation Source |
| 7076 | ** @nam4rule Gvvariation Return the Ensembl Genetic Variation Variation |
| 7077 | ** @nam4rule Gvvariationclass |
| 7078 | ** Return the Ensembl Geentic Variation Variation Class enumeration |
| 7079 | ** @nam4rule Identifier Return the SQL database-internal identifier |
| 7080 | ** @nam4rule Mapweight Return the map weight |
| 7081 | ** @nam4rule Name Return the name |
| 7082 | ** @nam4rule Validationcode Return the validation code |
| 7083 | ** |
| 7084 | ** @argrule * gvvf [const EnsPGvvariationfeature] Genetic Variation |
| 7085 | ** Variation Feature |
| 7086 | ** |
| 7087 | ** @valrule Adaptor [EnsPGvvariationfeatureadaptor] Ensembl Genetic Variation |
| 7088 | ** Variation Feature Adaptor or NULL |
| 7089 | ** @valrule Allele [AjPStr] Allele or NULL |
| 7090 | ** @valrule Consequencetype [AjPStr] Consequence type or NULL |
| 7091 | ** @valrule Feature [EnsPFeature] Ensembl Feature or NULL |
| 7092 | ** @valrule Gvsource [EnsPGvsource] Ensembl Genetic Variation Source or NULL |
| 7093 | ** @valrule Gvvariation [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 7094 | ** or NULL |
| 7095 | ** @valrule Gvvariationclass [EnsEGvvariationClass] |
| 7096 | ** Ensembl Genetic Variation Variation Class or ensEGvvariationClassNULL |
| 7097 | ** @valrule Identifier [ajuint] SQL database-internal identifier or 0U |
| 7098 | ** @valrule Mapweight [ajuint] Map weight or 0U |
| 7099 | ** @valrule Name [AjPStr] Name or NULL |
| 7100 | ** @valrule Validationcode [AjPStr] Validation code or NULL |
| 7101 | ** |
| 7102 | ** @fcategory use |
| 7103 | ******************************************************************************/ |
| 7104 | |
| 7105 | |
| 7106 | |
| 7107 | |
| 7108 | /* @func ensGvvariationfeatureGetAdaptor ************************************** |
| 7109 | ** |
| 7110 | ** Get the Ensembl Genetic Variation Variation Feature Adaptor member of an |
| 7111 | ** Ensembl Genetic Variation Variation Feature. |
| 7112 | ** |
| 7113 | ** @param [r] gvvf [const EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7114 | ** Variation Feature |
| 7115 | ** |
| 7116 | ** @return [EnsPGvvariationfeatureadaptor] Ensembl Genetic Variation |
| 7117 | ** Variation Feature Adaptor or NULL |
| 7118 | ** |
| 7119 | ** @release 6.2.0 |
| 7120 | ** @@ |
| 7121 | ******************************************************************************/ |
| 7122 | |
| 7123 | EnsPGvvariationfeatureadaptor ensGvvariationfeatureGetAdaptor( |
| 7124 | const EnsPGvvariationfeature gvvf) |
| 7125 | { |
| 7126 | return (gvvf) ? gvvf->Adaptor : NULL; |
| 7127 | } |
| 7128 | |
| 7129 | |
| 7130 | |
| 7131 | |
| 7132 | /* @func ensGvvariationfeatureGetAllele *************************************** |
| 7133 | ** |
| 7134 | ** Get the allele member of an Ensembl Genetic Variation Variation Feature. |
| 7135 | ** |
| 7136 | ** @param [r] gvvf [const EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7137 | ** Variation Feature |
| 7138 | ** |
| 7139 | ** @return [AjPStr] Allele or NULL |
| 7140 | ** |
| 7141 | ** @release 6.4.0 |
| 7142 | ** @@ |
| 7143 | ******************************************************************************/ |
| 7144 | |
| 7145 | AjPStr ensGvvariationfeatureGetAllele( |
| 7146 | const EnsPGvvariationfeature gvvf) |
| 7147 | { |
| 7148 | return (gvvf) ? gvvf->Allele : NULL; |
| 7149 | } |
| 7150 | |
| 7151 | |
| 7152 | |
| 7153 | |
| 7154 | /* @func ensGvvariationfeatureGetConsequencetype ****************************** |
| 7155 | ** |
| 7156 | ** Get the consequence type member of an |
| 7157 | ** Ensembl Genetic Variation Variation Feature. |
| 7158 | ** |
| 7159 | ** @param [r] gvvf [const EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7160 | ** Variation Feature |
| 7161 | ** |
| 7162 | ** @return [AjPStr] Consequence type or NULL |
| 7163 | ** |
| 7164 | ** @release 6.4.0 |
| 7165 | ** @@ |
| 7166 | ******************************************************************************/ |
| 7167 | |
| 7168 | AjPStr ensGvvariationfeatureGetConsequencetype( |
| 7169 | const EnsPGvvariationfeature gvvf) |
| 7170 | { |
| 7171 | return (gvvf) ? gvvf->Consequencetype : NULL; |
| 7172 | } |
| 7173 | |
| 7174 | |
| 7175 | |
| 7176 | |
| 7177 | /* @func ensGvvariationfeatureGetFeature ************************************** |
| 7178 | ** |
| 7179 | ** Get the Ensembl Feature member of an |
| 7180 | ** Ensembl Genetic Variation Variation Feature. |
| 7181 | ** |
| 7182 | ** @param [r] gvvf [const EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7183 | ** Variation Feature |
| 7184 | ** |
| 7185 | ** @return [EnsPFeature] Ensembl Feature or NULL |
| 7186 | ** |
| 7187 | ** @release 6.2.0 |
| 7188 | ** @@ |
| 7189 | ******************************************************************************/ |
| 7190 | |
| 7191 | EnsPFeature ensGvvariationfeatureGetFeature( |
| 7192 | const EnsPGvvariationfeature gvvf) |
| 7193 | { |
| 7194 | return (gvvf) ? gvvf->Feature : NULL; |
| 7195 | } |
| 7196 | |
| 7197 | |
| 7198 | |
| 7199 | |
| 7200 | /* @func ensGvvariationfeatureGetGvsource ************************************* |
| 7201 | ** |
| 7202 | ** Get the Ensembl Genetic Variation Source member of an |
| 7203 | ** Ensembl Genetic Variation Variation Feature. |
| 7204 | ** |
| 7205 | ** @param [r] gvvf [const EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7206 | ** Variation Feature |
| 7207 | ** |
| 7208 | ** @return [EnsPGvsource] Ensembl Genetic Variation Source or NULL |
| 7209 | ** |
| 7210 | ** @release 6.4.0 |
| 7211 | ** @@ |
| 7212 | ******************************************************************************/ |
| 7213 | |
| 7214 | EnsPGvsource ensGvvariationfeatureGetGvsource( |
| 7215 | const EnsPGvvariationfeature gvvf) |
| 7216 | { |
| 7217 | return (gvvf) ? gvvf->Gvsource : NULL; |
| 7218 | } |
| 7219 | |
| 7220 | |
| 7221 | |
| 7222 | |
| 7223 | /* @func ensGvvariationfeatureGetGvvariationclass ***************************** |
| 7224 | ** |
| 7225 | ** Get the Ensembl Genetic Variation Variation Class enumeration member of an |
| 7226 | ** Ensembl Genetic Variation Variation Feature. |
| 7227 | ** |
| 7228 | ** @param [r] gvvf [const EnsPGvvariationfeature] |
| 7229 | ** Ensembl Genetic Variation Variation Feature |
| 7230 | ** |
| 7231 | ** @return [EnsEGvvariationClass] |
| 7232 | ** Ensembl Genetic Variation Variation Class enumeration or |
| 7233 | ** ensEGvvariationClassNULL |
| 7234 | ** |
| 7235 | ** @release 6.4.0 |
| 7236 | ** @@ |
| 7237 | ******************************************************************************/ |
| 7238 | |
| 7239 | EnsEGvvariationClass ensGvvariationfeatureGetGvvariationclass( |
| 7240 | const EnsPGvvariationfeature gvvf) |
| 7241 | { |
| 7242 | return (gvvf) ? gvvf->GvvariationClass : ensEGvvariationClassNULL; |
| 7243 | } |
| 7244 | |
| 7245 | |
| 7246 | |
| 7247 | |
| 7248 | /* @func ensGvvariationfeatureGetIdentifier *********************************** |
| 7249 | ** |
| 7250 | ** Get the SQL database-internal identifier member of an |
| 7251 | ** Ensembl Genetic Variation Variation Feature. |
| 7252 | ** |
| 7253 | ** @param [r] gvvf [const EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7254 | ** Variation Feature |
| 7255 | ** |
| 7256 | ** @return [ajuint] SQL database-internal identifier or 0U |
| 7257 | ** |
| 7258 | ** @release 6.2.0 |
| 7259 | ** @@ |
| 7260 | ******************************************************************************/ |
| 7261 | |
| 7262 | ajuint ensGvvariationfeatureGetIdentifier( |
| 7263 | const EnsPGvvariationfeature gvvf) |
| 7264 | { |
| 7265 | return (gvvf) ? gvvf->Identifier : 0U; |
| 7266 | } |
| 7267 | |
| 7268 | |
| 7269 | |
| 7270 | |
| 7271 | /* @func ensGvvariationfeatureGetMapweight ************************************ |
| 7272 | ** |
| 7273 | ** Get the map weight member of an |
| 7274 | ** Ensembl Genetic Variation Variation Feature. |
| 7275 | ** |
| 7276 | ** @param [r] gvvf [const EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7277 | ** Variation Feature |
| 7278 | ** |
| 7279 | ** @return [ajuint] Map weight or 0U |
| 7280 | ** |
| 7281 | ** @release 6.4.0 |
| 7282 | ** @@ |
| 7283 | ******************************************************************************/ |
| 7284 | |
| 7285 | ajuint ensGvvariationfeatureGetMapweight( |
| 7286 | const EnsPGvvariationfeature gvvf) |
| 7287 | { |
| 7288 | return (gvvf) ? gvvf->Mapweight : 0U; |
| 7289 | } |
| 7290 | |
| 7291 | |
| 7292 | |
| 7293 | |
| 7294 | /* @func ensGvvariationfeatureGetName ***************************************** |
| 7295 | ** |
| 7296 | ** Get the name member of an Ensembl Genetic Variation Variation Feature. |
| 7297 | ** |
| 7298 | ** @param [r] gvvf [const EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7299 | ** Variation Feature |
| 7300 | ** |
| 7301 | ** @return [AjPStr] Name or NULL |
| 7302 | ** |
| 7303 | ** @release 6.2.0 |
| 7304 | ** @@ |
| 7305 | ******************************************************************************/ |
| 7306 | |
| 7307 | AjPStr ensGvvariationfeatureGetName( |
| 7308 | const EnsPGvvariationfeature gvvf) |
| 7309 | { |
| 7310 | return (gvvf) ? gvvf->Name : NULL; |
| 7311 | } |
| 7312 | |
| 7313 | |
| 7314 | |
| 7315 | |
| 7316 | /* @func ensGvvariationfeatureGetValidationcode ******************************* |
| 7317 | ** |
| 7318 | ** Get the validation code member of an |
| 7319 | ** Ensembl Genetic Variation Variation Feature. |
| 7320 | ** |
| 7321 | ** @param [r] gvvf [const EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7322 | ** Variation Feature |
| 7323 | ** |
| 7324 | ** @return [AjPStr] Validation code or NULL |
| 7325 | ** |
| 7326 | ** @release 6.4.0 |
| 7327 | ** @@ |
| 7328 | ******************************************************************************/ |
| 7329 | |
| 7330 | AjPStr ensGvvariationfeatureGetValidationcode( |
| 7331 | const EnsPGvvariationfeature gvvf) |
| 7332 | { |
| 7333 | return (gvvf) ? gvvf->Validationcode : NULL; |
| 7334 | } |
| 7335 | |
| 7336 | |
| 7337 | |
| 7338 | |
| 7339 | /* @section load on demand **************************************************** |
| 7340 | ** |
| 7341 | ** Functions for returning members of an Ensembl Genetic Variation Variation |
| 7342 | ** Feature object, which may need loading from an Ensembl SQL database on |
| 7343 | ** demand. |
| 7344 | ** |
| 7345 | ** @fdata [EnsPGvvariationfeature] |
| 7346 | ** |
| 7347 | ** @nam3rule Load Return Ensembl Genetic Variation Variation Feature |
| 7348 | ** attribute(s) loaded on demand |
| 7349 | ** @nam4rule Gvvariation Return The Ensembl Genetic Variation Variation |
| 7350 | ** |
| 7351 | ** @argrule * gvvf [EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7352 | ** Variation Feature |
| 7353 | ** |
| 7354 | ** @valrule Gvvariation [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 7355 | ** or NULL |
| 7356 | ** |
| 7357 | ** @fcategory use |
| 7358 | ******************************************************************************/ |
| 7359 | |
| 7360 | |
| 7361 | |
| 7362 | |
| 7363 | /* @func ensGvvariationfeatureLoadGvvariation ********************************* |
| 7364 | ** |
| 7365 | ** Get the Ensembl Genetic Variation Variation member of an |
| 7366 | ** Ensembl Genetic Variation Variation Feature. |
| 7367 | ** |
| 7368 | ** This is not a simple accessor function, it will fetch the Ensembl Genetic |
| 7369 | ** Variation Variation from the Ensembl Genetic Variation database in case it |
| 7370 | ** is not defined. |
| 7371 | ** |
| 7372 | ** @param [u] gvvf [EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7373 | ** Variation Feature |
| 7374 | ** |
| 7375 | ** @return [EnsPGvvariation] Ensembl Genetic Variation Variation or NULL |
| 7376 | ** |
| 7377 | ** @release 6.4.0 |
| 7378 | ** @@ |
| 7379 | ******************************************************************************/ |
| 7380 | |
| 7381 | EnsPGvvariation ensGvvariationfeatureLoadGvvariation( |
| 7382 | EnsPGvvariationfeature gvvf) |
| 7383 | { |
| 7384 | if (!gvvf) |
| 7385 | return NULL; |
| 7386 | |
| 7387 | if (gvvf->Gvvariation) |
| 7388 | return gvvf->Gvvariation; |
| 7389 | |
| 7390 | if (!gvvf->Adaptor) |
| 7391 | return NULL; |
| 7392 | |
| 7393 | ensGvvariationadaptorFetchByIdentifier( |
| 7394 | ensRegistryGetGvvariationadaptor( |
| 7395 | ensGvvariationfeatureadaptorGetDatabaseadaptor(gvvf->Adaptor)), |
| 7396 | gvvf->Gvvariationidentifier, |
| 7397 | &gvvf->Gvvariation); |
| 7398 | |
| 7399 | return gvvf->Gvvariation; |
| 7400 | } |
| 7401 | |
| 7402 | |
| 7403 | |
| 7404 | |
| 7405 | /* @section member assignment ************************************************* |
| 7406 | ** |
| 7407 | ** Functions for assigning members of an |
| 7408 | ** Ensembl Genetic Variation Variation Feature object. |
| 7409 | ** |
| 7410 | ** @fdata [EnsPGvvariationfeature] |
| 7411 | ** |
| 7412 | ** @nam3rule Set Set one member of a Genetic Variation Variation Feature |
| 7413 | ** @nam4rule Adaptor |
| 7414 | ** Set the Ensembl Genetic Variation Variation Feature Adaptor |
| 7415 | ** @nam4rule Allele Set the allele |
| 7416 | ** @nam4rule Consequencetype Set the consequence type |
| 7417 | ** @nam4rule Feature Set the Ensembl Feature |
| 7418 | ** @nam4rule Gvsource Set the Ensembl Genetic Variation Source |
| 7419 | ** @nam4rule Gvvariation Set the Ensembl Genetic Variation Variation |
| 7420 | ** @nam4rule Gvvariationclass |
| 7421 | ** Set the Ensembl Genetic Variation Variation Class enumeration |
| 7422 | ** @nam4rule Identifier Set the SQL database-internal identifier |
| 7423 | ** @nam4rule Mapweight Set the map weight |
| 7424 | ** @nam4rule Name Set the name |
| 7425 | ** @nam4rule Validationcode Set the validation code |
| 7426 | ** |
| 7427 | ** @argrule * gvvf [EnsPGvvariationfeature] |
| 7428 | ** Ensembl Genetic Variation Variation Feature object |
| 7429 | ** @argrule Adaptor gvvfa [EnsPGvvariationfeatureadaptor] |
| 7430 | ** Ensembl Genetic Variation Variation Feature Adaptor |
| 7431 | ** @argrule Allele allele [AjPStr] Allele |
| 7432 | ** @argrule Consequencetype consequencetype [AjPStr] Consequence type |
| 7433 | ** @argrule Feature feature [EnsPFeature] Ensembl Feature |
| 7434 | ** @argrule Gvsource gvsource [EnsPGvsource] Ensembl Genetic Variation Source |
| 7435 | ** @argrule Gvvariation gvv [EnsPGvvariation] |
| 7436 | ** Ensembl Genetic Variation Variation |
| 7437 | ** @argrule Gvvariationclass gvvc [EnsEGvvariationClass] |
| 7438 | ** Ensembl Genetic Variation Variation Class enumeration |
| 7439 | ** @argrule Identifier identifier [ajuint] SQL database-internal identifier |
| 7440 | ** @argrule Mapweight mapweight [ajuint] Map weight |
| 7441 | ** @argrule Name name [AjPStr] Name |
| 7442 | ** @argrule Validationcode validationcode [AjPStr] Validation code |
| 7443 | ** |
| 7444 | ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise |
| 7445 | ** |
| 7446 | ** @fcategory modify |
| 7447 | ******************************************************************************/ |
| 7448 | |
| 7449 | |
| 7450 | |
| 7451 | |
| 7452 | /* @func ensGvvariationfeatureSetAdaptor ************************************** |
| 7453 | ** |
| 7454 | ** Set the Ensembl Genetic Variation Variation Feature Adaptor member of an |
| 7455 | ** Ensembl Genetic Variation Variation Feature. |
| 7456 | ** |
| 7457 | ** @param [u] gvvf [EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7458 | ** Variation Feature |
| 7459 | ** @param [u] gvvfa [EnsPGvvariationfeatureadaptor] Ensembl Genetic Variation |
| 7460 | ** Variation Feature Adaptor |
| 7461 | ** |
| 7462 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 7463 | ** |
| 7464 | ** @release 6.2.0 |
| 7465 | ** @@ |
| 7466 | ******************************************************************************/ |
| 7467 | |
| 7468 | AjBool ensGvvariationfeatureSetAdaptor(EnsPGvvariationfeature gvvf, |
| 7469 | EnsPGvvariationfeatureadaptor gvvfa) |
| 7470 | { |
| 7471 | if (!gvvf) |
| 7472 | return ajFalse; |
| 7473 | |
| 7474 | gvvf->Adaptor = gvvfa; |
| 7475 | |
| 7476 | return ajTrue; |
| 7477 | } |
| 7478 | |
| 7479 | |
| 7480 | |
| 7481 | |
| 7482 | /* @func ensGvvariationfeatureSetAllele *************************************** |
| 7483 | ** |
| 7484 | ** Set the allele member of an Ensembl Genetic Variation Variation Feature. |
| 7485 | ** |
| 7486 | ** @param [u] gvvf [EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7487 | ** Variation Feature |
| 7488 | ** @param [u] allele [AjPStr] Allele |
| 7489 | ** |
| 7490 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 7491 | ** |
| 7492 | ** @release 6.4.0 |
| 7493 | ** @@ |
| 7494 | ******************************************************************************/ |
| 7495 | |
| 7496 | AjBool ensGvvariationfeatureSetAllele(EnsPGvvariationfeature gvvf, |
| 7497 | AjPStr allele) |
| 7498 | { |
| 7499 | if (!gvvf) |
| 7500 | return ajFalse; |
| 7501 | |
| 7502 | ajStrDel(&gvvf->Allele); |
| 7503 | |
| 7504 | if (allele) |
| 7505 | gvvf->Allele = ajStrNewRef(allele); |
| 7506 | |
| 7507 | return ajTrue; |
| 7508 | } |
| 7509 | |
| 7510 | |
| 7511 | |
| 7512 | |
| 7513 | /* @func ensGvvariationfeatureSetConsequencetype ****************************** |
| 7514 | ** |
| 7515 | ** Set the consequence type member of an |
| 7516 | ** Ensembl Genetic Variation Variation Feature. |
| 7517 | ** |
| 7518 | ** @param [u] gvvf [EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7519 | ** Variation Feature |
| 7520 | ** @param [u] consequencetype [AjPStr] Consequence type |
| 7521 | ** |
| 7522 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 7523 | ** |
| 7524 | ** @release 6.4.0 |
| 7525 | ** @@ |
| 7526 | ******************************************************************************/ |
| 7527 | |
| 7528 | AjBool ensGvvariationfeatureSetConsequencetype(EnsPGvvariationfeature gvvf, |
| 7529 | AjPStr consequencetype) |
| 7530 | { |
| 7531 | if (!gvvf) |
| 7532 | return ajFalse; |
| 7533 | |
| 7534 | ajStrDel(&gvvf->Consequencetype); |
| 7535 | |
| 7536 | if (consequencetype) |
| 7537 | gvvf->Consequencetype = ajStrNewRef(consequencetype); |
| 7538 | |
| 7539 | return ajTrue; |
| 7540 | } |
| 7541 | |
| 7542 | |
| 7543 | |
| 7544 | |
| 7545 | /* @func ensGvvariationfeatureSetFeature ************************************** |
| 7546 | ** |
| 7547 | ** Set the Ensembl Feature member of an |
| 7548 | ** Ensembl Genetic Variation Variation Feature. |
| 7549 | ** |
| 7550 | ** @param [u] gvvf [EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7551 | ** Variation Feature |
| 7552 | ** @param [u] feature [EnsPFeature] Ensembl Feature |
| 7553 | ** |
| 7554 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 7555 | ** |
| 7556 | ** @release 6.2.0 |
| 7557 | ** @@ |
| 7558 | ******************************************************************************/ |
| 7559 | |
| 7560 | AjBool ensGvvariationfeatureSetFeature(EnsPGvvariationfeature gvvf, |
| 7561 | EnsPFeature feature) |
| 7562 | { |
| 7563 | if (!gvvf) |
| 7564 | return ajFalse; |
| 7565 | |
| 7566 | ensFeatureDel(&gvvf->Feature); |
| 7567 | |
| 7568 | gvvf->Feature = ensFeatureNewRef(feature); |
| 7569 | |
| 7570 | return ajTrue; |
| 7571 | } |
| 7572 | |
| 7573 | |
| 7574 | |
| 7575 | |
| 7576 | /* @func ensGvvariationfeatureSetGvsource ************************************* |
| 7577 | ** |
| 7578 | ** Set the Ensembl Genetic Variation Source member of an |
| 7579 | ** Ensembl Genetic Variation Variation Feature. |
| 7580 | ** |
| 7581 | ** @param [u] gvvf [EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7582 | ** Variation Feature |
| 7583 | ** @param [u] gvsource [EnsPGvsource] Ensembl Genetic Variation Source |
| 7584 | ** |
| 7585 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 7586 | ** |
| 7587 | ** @release 6.4.0 |
| 7588 | ** @@ |
| 7589 | ******************************************************************************/ |
| 7590 | |
| 7591 | AjBool ensGvvariationfeatureSetGvsource(EnsPGvvariationfeature gvvf, |
| 7592 | EnsPGvsource gvsource) |
| 7593 | { |
| 7594 | if (!gvvf) |
| 7595 | return ajFalse; |
| 7596 | |
| 7597 | ensGvsourceDel(&gvvf->Gvsource); |
| 7598 | |
| 7599 | gvvf->Gvsource = ensGvsourceNewRef(gvsource); |
| 7600 | |
| 7601 | return ajTrue; |
| 7602 | } |
| 7603 | |
| 7604 | |
| 7605 | |
| 7606 | |
| 7607 | /* @func ensGvvariationfeatureSetGvvariation ********************************** |
| 7608 | ** |
| 7609 | ** Set the Ensembl Genetic Variation Variation member of an |
| 7610 | ** Ensembl Genetic Variation Variation Feature. |
| 7611 | ** |
| 7612 | ** @param [u] gvvf [EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7613 | ** Variation Feature |
| 7614 | ** @param [u] gvv [EnsPGvvariation] Ensembl Genetic Variation Variation |
| 7615 | ** |
| 7616 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 7617 | ** |
| 7618 | ** @release 6.2.0 |
| 7619 | ** @@ |
| 7620 | ******************************************************************************/ |
| 7621 | |
| 7622 | AjBool ensGvvariationfeatureSetGvvariation(EnsPGvvariationfeature gvvf, |
| 7623 | EnsPGvvariation gvv) |
| 7624 | { |
| 7625 | if (!gvvf) |
| 7626 | return ajFalse; |
| 7627 | |
| 7628 | ensGvvariationDel(&gvvf->Gvvariation); |
| 7629 | |
| 7630 | gvvf->Gvvariation = ensGvvariationNewRef(gvv); |
| 7631 | |
| 7632 | return ajTrue; |
| 7633 | } |
| 7634 | |
| 7635 | |
| 7636 | |
| 7637 | |
| 7638 | /* @func ensGvvariationfeatureSetGvvariationclass ***************************** |
| 7639 | ** |
| 7640 | ** Set the Ensembl Genetic Variation Variation Class enumeration member of an |
| 7641 | ** Ensembl Genetic Variation Variation Feature. |
| 7642 | ** |
| 7643 | ** @param [u] gvvf [EnsPGvvariationfeature] |
| 7644 | ** Ensembl Genetic Variation Variation Feature |
| 7645 | ** @param [u] gvvc [EnsEGvvariationClass] |
| 7646 | ** Ensembl Genetic Variation Variation Class enumeration |
| 7647 | ** |
| 7648 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 7649 | ** |
| 7650 | ** @release 6.4.0 |
| 7651 | ** @@ |
| 7652 | ******************************************************************************/ |
| 7653 | |
| 7654 | AjBool ensGvvariationfeatureSetGvvariationclass(EnsPGvvariationfeature gvvf, |
| 7655 | EnsEGvvariationClass gvvc) |
| 7656 | { |
| 7657 | if (!gvvf) |
| 7658 | return ajFalse; |
| 7659 | |
| 7660 | gvvf->GvvariationClass = gvvc; |
| 7661 | |
| 7662 | return ajTrue; |
| 7663 | } |
| 7664 | |
| 7665 | |
| 7666 | |
| 7667 | |
| 7668 | /* @func ensGvvariationfeatureSetIdentifier *********************************** |
| 7669 | ** |
| 7670 | ** Set the SQL database-internal identifier member of an |
| 7671 | ** Ensembl Genetic Variation Variation Feature. |
| 7672 | ** |
| 7673 | ** @param [u] gvvf [EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7674 | ** Variation Feature |
| 7675 | ** @param [r] identifier [ajuint] SQL database-internal identifier |
| 7676 | ** |
| 7677 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 7678 | ** |
| 7679 | ** @release 6.3.0 |
| 7680 | ** @@ |
| 7681 | ******************************************************************************/ |
| 7682 | |
| 7683 | AjBool ensGvvariationfeatureSetIdentifier(EnsPGvvariationfeature gvvf, |
| 7684 | ajuint identifier) |
| 7685 | { |
| 7686 | if (!gvvf) |
| 7687 | return ajFalse; |
| 7688 | |
| 7689 | gvvf->Identifier = identifier; |
| 7690 | |
| 7691 | return ajTrue; |
| 7692 | } |
| 7693 | |
| 7694 | |
| 7695 | |
| 7696 | |
| 7697 | /* @func ensGvvariationfeatureSetMapweight ************************************ |
| 7698 | ** |
| 7699 | ** Set the map weight member of an |
| 7700 | ** Ensembl Genetic Variation Variation Feature. |
| 7701 | ** |
| 7702 | ** @param [u] gvvf [EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7703 | ** Variation Feature |
| 7704 | ** @param [r] mapweight [ajuint] Map weight |
| 7705 | ** |
| 7706 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 7707 | ** |
| 7708 | ** @release 6.4.0 |
| 7709 | ** @@ |
| 7710 | ******************************************************************************/ |
| 7711 | |
| 7712 | AjBool ensGvvariationfeatureSetMapweight(EnsPGvvariationfeature gvvf, |
| 7713 | ajuint mapweight) |
| 7714 | { |
| 7715 | if (!gvvf) |
| 7716 | return ajFalse; |
| 7717 | |
| 7718 | gvvf->Mapweight = mapweight; |
| 7719 | |
| 7720 | return ajTrue; |
| 7721 | } |
| 7722 | |
| 7723 | |
| 7724 | |
| 7725 | |
| 7726 | /* @func ensGvvariationfeatureSetName ***************************************** |
| 7727 | ** |
| 7728 | ** Set the name member of an Ensembl Genetic Variation Variation Feature. |
| 7729 | ** |
| 7730 | ** @param [u] gvvf [EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7731 | ** Variation Feature |
| 7732 | ** @param [u] name [AjPStr] Name |
| 7733 | ** |
| 7734 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 7735 | ** |
| 7736 | ** @release 6.2.0 |
| 7737 | ** @@ |
| 7738 | ******************************************************************************/ |
| 7739 | |
| 7740 | AjBool ensGvvariationfeatureSetName(EnsPGvvariationfeature gvvf, |
| 7741 | AjPStr name) |
| 7742 | { |
| 7743 | if (!gvvf) |
| 7744 | return ajFalse; |
| 7745 | |
| 7746 | ajStrDel(&gvvf->Name); |
| 7747 | |
| 7748 | if (name) |
| 7749 | gvvf->Name = ajStrNewRef(name); |
| 7750 | |
| 7751 | return ajTrue; |
| 7752 | } |
| 7753 | |
| 7754 | |
| 7755 | |
| 7756 | |
| 7757 | /* @func ensGvvariationfeatureSetValidationcode ******************************* |
| 7758 | ** |
| 7759 | ** Set the validation code member of an |
| 7760 | ** Ensembl Genetic Variation Variation Feature. |
| 7761 | ** |
| 7762 | ** @param [u] gvvf [EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7763 | ** Variation Feature |
| 7764 | ** @param [u] validationcode [AjPStr] Validation code |
| 7765 | ** |
| 7766 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 7767 | ** |
| 7768 | ** @release 6.4.0 |
| 7769 | ** @@ |
| 7770 | ******************************************************************************/ |
| 7771 | |
| 7772 | AjBool ensGvvariationfeatureSetValidationcode(EnsPGvvariationfeature gvvf, |
| 7773 | AjPStr validationcode) |
| 7774 | { |
| 7775 | if (!gvvf) |
| 7776 | return ajFalse; |
| 7777 | |
| 7778 | ajStrDel(&gvvf->Validationcode); |
| 7779 | |
| 7780 | if (validationcode) |
| 7781 | gvvf->Validationcode = ajStrNewRef(validationcode); |
| 7782 | |
| 7783 | return ajTrue; |
| 7784 | } |
| 7785 | |
| 7786 | |
| 7787 | |
| 7788 | |
| 7789 | /* @section debugging ********************************************************* |
| 7790 | ** |
| 7791 | ** Functions for reporting of an |
| 7792 | ** Ensembl Genetic Variation Variation Feature object. |
| 7793 | ** |
| 7794 | ** @fdata [EnsPGvvariationfeature] |
| 7795 | ** |
| 7796 | ** @nam3rule Trace Report Ensembl Genetic Variation Variation Feature members |
| 7797 | ** to debug file |
| 7798 | ** |
| 7799 | ** @argrule Trace gvvf [const EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7800 | ** Variation Feature |
| 7801 | ** @argrule Trace level [ajuint] Indentation level |
| 7802 | ** |
| 7803 | ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise |
| 7804 | ** |
| 7805 | ** @fcategory misc |
| 7806 | ******************************************************************************/ |
| 7807 | |
| 7808 | |
| 7809 | |
| 7810 | |
| 7811 | /* @func ensGvvariationfeatureTrace ******************************************* |
| 7812 | ** |
| 7813 | ** Trace an Ensembl Genetic Variation Variation Feature. |
| 7814 | ** |
| 7815 | ** @param [r] gvvf [const EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7816 | ** Variation Feature |
| 7817 | ** @param [r] level [ajuint] Indentation level |
| 7818 | ** |
| 7819 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 7820 | ** |
| 7821 | ** @release 6.2.0 |
| 7822 | ** @@ |
| 7823 | ******************************************************************************/ |
| 7824 | |
| 7825 | AjBool ensGvvariationfeatureTrace(const EnsPGvvariationfeature gvvf, |
| 7826 | ajuint level) |
| 7827 | { |
| 7828 | AjPStr indent = NULL; |
| 7829 | |
| 7830 | if (!gvvf) |
| 7831 | return ajFalse; |
| 7832 | |
| 7833 | indent = ajStrNew(); |
| 7834 | |
| 7835 | ajStrAppendCountK(&indent, ' ', level * 2); |
| 7836 | |
| 7837 | ajDebug("%SensGvvariationfeatureTrace %p\n" |
| 7838 | "%S Use %u\n" |
| 7839 | "%S Identifier %u\n" |
| 7840 | "%S Adaptor %p\n" |
| 7841 | "%S Feature %p\n" |
| 7842 | "%S Gvsource %p\n" |
| 7843 | "%S Gvvariation %p\n" |
| 7844 | "%S Allele '%S'\n" |
| 7845 | "%S Name '%S'\n" |
| 7846 | "%S Validationcode '%S'\n" |
| 7847 | "%S Consequencetype '%S'\n" |
| 7848 | "%S Mapweight %u\n" |
| 7849 | "%S GvvariationClass '%s'\n", |
| 7850 | indent, gvvf, |
| 7851 | indent, gvvf->Use, |
| 7852 | indent, gvvf->Identifier, |
| 7853 | indent, gvvf->Adaptor, |
| 7854 | indent, gvvf->Feature, |
| 7855 | indent, gvvf->Gvsource, |
| 7856 | indent, gvvf->Gvvariation, |
| 7857 | indent, gvvf->Allele, |
| 7858 | indent, gvvf->Name, |
| 7859 | indent, gvvf->Validationcode, |
| 7860 | indent, gvvf->Consequencetype, |
| 7861 | indent, gvvf->Mapweight, |
| 7862 | indent, ensGvvariationClassToChar(gvvf->GvvariationClass)); |
| 7863 | |
| 7864 | ajStrDel(&indent); |
| 7865 | |
| 7866 | ensFeatureTrace(gvvf->Feature, level + 1); |
| 7867 | |
| 7868 | ensGvsourceTrace(gvvf->Gvsource, level + 1); |
| 7869 | |
| 7870 | ensGvvariationTrace(gvvf->Gvvariation, level + 1); |
| 7871 | |
| 7872 | return ajTrue; |
| 7873 | } |
| 7874 | |
| 7875 | |
| 7876 | |
| 7877 | |
| 7878 | /* @section calculate ********************************************************* |
| 7879 | ** |
| 7880 | ** Functions for calculating information from an |
| 7881 | ** Ensembl Genetic Variation Variation Feature object. |
| 7882 | ** |
| 7883 | ** @fdata [EnsPGvvariationfeature] |
| 7884 | ** |
| 7885 | ** @nam3rule Calculate |
| 7886 | **Calculate Ensembl Genetic Variation Variation Feature information |
| 7887 | ** @nam4rule Length Calculate the length |
| 7888 | ** @nam4rule Memsize Calculate the memory size in bytes |
| 7889 | ** |
| 7890 | ** @argrule * gvvf [const EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7891 | ** Variation Feature |
| 7892 | ** |
| 7893 | ** @valrule Length [ajuint] Length or 0U |
| 7894 | ** @valrule Memsize [size_t] Memory size in bytes or 0 |
| 7895 | ** |
| 7896 | ** @fcategory misc |
| 7897 | ******************************************************************************/ |
| 7898 | |
| 7899 | |
| 7900 | |
| 7901 | |
| 7902 | /* @func ensGvvariationfeatureCalculateLength ********************************* |
| 7903 | ** |
| 7904 | ** Calculate the length of an |
| 7905 | ** Ensembl Genetic Variation Variation Feature. |
| 7906 | ** |
| 7907 | ** @param [r] gvvf [const EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7908 | ** Variation Feature |
| 7909 | ** |
| 7910 | ** @return [ajuint] Length or 0U |
| 7911 | ** |
| 7912 | ** @release 6.4.0 |
| 7913 | ** @@ |
| 7914 | ******************************************************************************/ |
| 7915 | |
| 7916 | ajuint ensGvvariationfeatureCalculateLength( |
| 7917 | const EnsPGvvariationfeature gvvf) |
| 7918 | { |
| 7919 | if (!gvvf) |
| 7920 | return 0U; |
| 7921 | |
| 7922 | return ensFeatureGetEnd(gvvf->Feature) |
| 7923 | - ensFeatureGetStart(gvvf->Feature) |
| 7924 | + 1U; |
| 7925 | } |
| 7926 | |
| 7927 | |
| 7928 | |
| 7929 | |
| 7930 | /* @func ensGvvariationfeatureCalculateMemsize ******************************** |
| 7931 | ** |
| 7932 | ** Calculate the memory size in bytes of an |
| 7933 | ** Ensembl Genetic Variation Variation Feature. |
| 7934 | ** |
| 7935 | ** @param [r] gvvf [const EnsPGvvariationfeature] Ensembl Genetic Variation |
| 7936 | ** Variation Feature |
| 7937 | ** |
| 7938 | ** @return [size_t] Memory size in bytes or 0 |
| 7939 | ** |
| 7940 | ** @release 6.4.0 |
| 7941 | ** @@ |
| 7942 | ******************************************************************************/ |
| 7943 | |
| 7944 | size_t ensGvvariationfeatureCalculateMemsize( |
| 7945 | const EnsPGvvariationfeature gvvf) |
| 7946 | { |
| 7947 | size_t size = 0; |
| 7948 | |
| 7949 | if (!gvvf) |
| 7950 | return 0; |
| 7951 | |
| 7952 | size += sizeof (EnsOGvvariationfeature); |
| 7953 | |
| 7954 | size += ensFeatureCalculateMemsize(gvvf->Feature); |
| 7955 | |
| 7956 | size += ensGvsourceCalculateMemsize(gvvf->Gvsource); |
| 7957 | |
| 7958 | size += ensGvvariationCalculateMemsize(gvvf->Gvvariation); |
| 7959 | |
| 7960 | if (gvvf->Allele) |
| 7961 | { |
| 7962 | size += sizeof (AjOStr); |
| 7963 | |
| 7964 | size += ajStrGetRes(gvvf->Allele); |
| 7965 | } |
| 7966 | |
| 7967 | if (gvvf->Name) |
| 7968 | { |
| 7969 | size += sizeof (AjOStr); |
| 7970 | |
| 7971 | size += ajStrGetRes(gvvf->Name); |
| 7972 | } |
| 7973 | |
| 7974 | if (gvvf->Validationcode) |
| 7975 | { |
| 7976 | size += sizeof (AjOStr); |
| 7977 | |
| 7978 | size += ajStrGetRes(gvvf->Validationcode); |
| 7979 | } |
| 7980 | |
| 7981 | if (gvvf->Consequencetype) |
| 7982 | { |
| 7983 | size += sizeof (AjOStr); |
| 7984 | |
| 7985 | size += ajStrGetRes(gvvf->Consequencetype); |
| 7986 | } |
| 7987 | |
| 7988 | return size; |
| 7989 | } |
| 7990 | |
| 7991 | |
| 7992 | |
| 7993 | |
| 7994 | /* @section convenience functions ********************************************* |
| 7995 | ** |
| 7996 | ** Ensembl Genetic Variation Variation Feature convenience functions |
| 7997 | ** |
| 7998 | ** @fdata [EnsPGvvariationfeature] |
| 7999 | ** |
| 8000 | ** @nam3rule Get Get member(s) of associated objects |
| 8001 | ** @nam4rule Somatic Return the somatic or germline attribute of the |
| 8002 | ** Ensembl Genetic Variation Source |
| 8003 | ** @nam4rule Sourcename Return the Ensembl Genetic Variation Source name |
| 8004 | ** |
| 8005 | ** @argrule * gvvf [const EnsPGvvariationfeature] |
| 8006 | ** Ensembl Genetic Variation Variation Feature |
| 8007 | ** |
| 8008 | ** @valrule Somatic [AjBool] Somatic or germline attribute or ajFalse |
| 8009 | ** @valrule Sourcename [AjPStr] Ensembl Genetic Variation Source name or NULL |
| 8010 | ** |
| 8011 | ** @fcategory use |
| 8012 | ******************************************************************************/ |
| 8013 | |
| 8014 | |
| 8015 | |
| 8016 | |
| 8017 | /* @func ensGvvariationfeatureGetSomatic ************************************** |
| 8018 | ** |
| 8019 | ** Get the somatic member of an |
| 8020 | ** Ensembl Genetic Variation Variation Feature. |
| 8021 | ** |
| 8022 | ** @cc Bio::EnsEMBL::Variation::VariationFeature::somatic |
| 8023 | ** @param [r] gvvf [const EnsPGvvariationfeature] Ensembl Genetic Variation |
| 8024 | ** Variation Feature |
| 8025 | ** |
| 8026 | ** @return [AjBool] Somatic attribute or ajFalse |
| 8027 | ** |
| 8028 | ** @release 6.4.0 |
| 8029 | ** @@ |
| 8030 | ******************************************************************************/ |
| 8031 | |
| 8032 | AjBool ensGvvariationfeatureGetSomatic( |
| 8033 | const EnsPGvvariationfeature gvvf) |
| 8034 | { |
| 8035 | return (gvvf) ? ensGvsourceGetSomatic(gvvf->Gvsource) : ajFalse; |
| 8036 | } |
| 8037 | |
| 8038 | |
| 8039 | |
| 8040 | |
| 8041 | /* @func ensGvvariationfeatureGetSourcename *********************************** |
| 8042 | ** |
| 8043 | ** Get the name member of an Ensembl Genetic Variation Source associated |
| 8044 | ** with an Ensembl Genetic Variation Variation Feature. |
| 8045 | ** |
| 8046 | ** @cc Bio::EnsEMBL::Variation::VariationFeature::source |
| 8047 | ** @param [r] gvvf [const EnsPGvvariationfeature] Ensembl Genetic Variation |
| 8048 | ** Variation Feature |
| 8049 | ** |
| 8050 | ** @return [AjPStr] Ensembl Genetic Variation Source name or NULL |
| 8051 | ** |
| 8052 | ** @release 6.4.0 |
| 8053 | ** @@ |
| 8054 | ******************************************************************************/ |
| 8055 | |
| 8056 | AjPStr ensGvvariationfeatureGetSourcename( |
| 8057 | const EnsPGvvariationfeature gvvf) |
| 8058 | { |
| 8059 | return (gvvf) ? ensGvsourceGetName(gvvf->Gvsource) : NULL; |
| 8060 | } |
| 8061 | |
| 8062 | |
| 8063 | |
| 8064 | |
| 8065 | /* @section query ************************************************************* |
| 8066 | ** |
| 8067 | ** Functions for querying the properties of an Ensembl Slice. |
| 8068 | ** |
| 8069 | ** @fdata [EnsPGvvariationfeature] |
| 8070 | ** |
| 8071 | ** @nam3rule Is Check whether an Ensembl Genetic Variation Variation Feature |
| 8072 | ** represents a certain property |
| 8073 | ** @nam4rule Reference Check for annotation on a reference Ensembl Slice |
| 8074 | ** |
| 8075 | ** @argrule * gvvf [EnsPGvvariationfeature] Ensembl Genetic Variation |
| 8076 | ** Variation Feature |
| 8077 | ** @argrule * Presult [AjBool*] Boolean result |
| 8078 | ** |
| 8079 | ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise |
| 8080 | ** |
| 8081 | ** @fcategory use |
| 8082 | ******************************************************************************/ |
| 8083 | |
| 8084 | |
| 8085 | |
| 8086 | |
| 8087 | /* @func ensGvvariationfeatureIsReference ************************************* |
| 8088 | ** |
| 8089 | ** Check whether an Ensembl Genetic Variation Variation Feature is annotated |
| 8090 | ** on an Ensembl Slice based on an Ensembl Sequence Region, which |
| 8091 | ** has an Ensembl Attribute of code "non_ref" set. |
| 8092 | ** |
| 8093 | ** @cc Bio::EnsEMBL::Variation::VariationFeature::is_reference |
| 8094 | ** @param [u] gvvf [EnsPGvvariationfeature] Ensembl Genetic Variation |
| 8095 | ** Variation Feature |
| 8096 | ** @param [u] Presult [AjBool*] ajTrue if the Ensembl Sequence Region has the |
| 8097 | ** Ensembl Attribute of code "non_ref" not set |
| 8098 | ** |
| 8099 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 8100 | ** |
| 8101 | ** @release 6.4.0 |
| 8102 | ** @@ |
| 8103 | ******************************************************************************/ |
| 8104 | |
| 8105 | AjBool ensGvvariationfeatureIsReference(EnsPGvvariationfeature gvvf, |
| 8106 | AjBool *Presult) |
| 8107 | { |
| 8108 | AjBool nonreference = AJFALSE; |
| 8109 | AjBool result = AJFALSE; |
| 8110 | |
| 8111 | EnsPSlice slice = NULL; |
| 8112 | |
| 8113 | if (!gvvf) |
| 8114 | return ajFalse; |
| 8115 | |
| 8116 | if (!Presult) |
| 8117 | return ajFalse; |
| 8118 | |
| 8119 | slice = ensFeatureGetSlice(gvvf->Feature); |
| 8120 | |
| 8121 | result = ensSliceIsNonreference(slice, &nonreference); |
| 8122 | |
| 8123 | if (nonreference == ajTrue) |
| 8124 | *Presult = ajFalse; |
| 8125 | else |
| 8126 | *Presult = ajTrue; |
| 8127 | |
| 8128 | return result; |
| 8129 | } |
| 8130 | |
| 8131 | |
| 8132 | |
| 8133 | |
| 8134 | /* @datasection [AjPList] AJAX List ******************************************* |
| 8135 | ** |
| 8136 | ** @nam2rule List Functions for manipulating AJAX List objects |
| 8137 | ** |
| 8138 | ******************************************************************************/ |
| 8139 | |
| 8140 | |
| 8141 | |
| 8142 | |
| 8143 | /* @funcstatic listGvvariationfeatureCompareEndAscending ********************** |
| 8144 | ** |
| 8145 | ** AJAX List of Ensembl Genetic Variation Variation Feature objects comparison |
| 8146 | ** function to sort by Ensembl Feature end member in ascending order. |
| 8147 | ** |
| 8148 | ** @param [r] item1 [const void*] |
| 8149 | ** Ensembl Genetic VariationVariation Feature address 1 |
| 8150 | ** @param [r] item2 [const void*] |
| 8151 | ** Ensembl Genetic Variation Variation Feature address 2 |
| 8152 | ** @see ajListSort |
| 8153 | ** |
| 8154 | ** @return [int] The comparison function returns an integer less than, |
| 8155 | ** equal to, or greater than zero if the first argument is |
| 8156 | ** considered to be respectively less than, equal to, or |
| 8157 | ** greater than the second. |
| 8158 | ** |
| 8159 | ** @release 6.4.0 |
| 8160 | ** @@ |
| 8161 | ******************************************************************************/ |
| 8162 | |
| 8163 | static int listGvvariationfeatureCompareEndAscending( |
| 8164 | const void *item1, |
| 8165 | const void *item2) |
| 8166 | { |
| 8167 | EnsPGvvariationfeature gvvf1 = *(EnsOGvvariationfeature *const *) item1; |
| 8168 | EnsPGvvariationfeature gvvf2 = *(EnsOGvvariationfeature *const *) item2; |
| 8169 | |
| 8170 | #if defined(AJ_DEBUG) && AJ_DEBUG >= 2 |
| 8171 | if (ajDebugTest("listGvvariationfeatureCompareEndAscending")) |
| 8172 | ajDebug("listGvvariationfeatureCompareEndAscending\n" |
| 8173 | " gvvf1 %p\n" |
| 8174 | " gvvf2 %p\n", |
| 8175 | gvvf1, |
| 8176 | gvvf2); |
| 8177 | #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 2 */ |
| 8178 | |
| 8179 | /* Sort empty values towards the end of the AJAX List. */ |
| 8180 | |
| 8181 | if (gvvf1 && (!gvvf2)) |
| 8182 | return -1; |
| 8183 | |
| 8184 | if ((!gvvf1) && (!gvvf2)) |
| 8185 | return 0; |
| 8186 | |
| 8187 | if ((!gvvf1) && gvvf2) |
| 8188 | return +1; |
| 8189 | |
| 8190 | return ensFeatureCompareEndAscending(gvvf1->Feature, gvvf2->Feature); |
| 8191 | } |
| 8192 | |
| 8193 | |
| 8194 | |
| 8195 | |
| 8196 | /* @funcstatic listGvvariationfeatureCompareEndDescending ********************* |
| 8197 | ** |
| 8198 | ** AJAX List of Ensembl Genetic Variation Variation Feature objects comparison |
| 8199 | ** function to sort by Ensembl Feature end member in descending order. |
| 8200 | ** |
| 8201 | ** @param [r] item1 [const void*] |
| 8202 | ** Ensembl Genetic Variation Variation Feature address 1 |
| 8203 | ** @param [r] item2 [const void*] |
| 8204 | ** Ensembl Genetic Variation Variation Feature address 2 |
| 8205 | ** @see ajListSort |
| 8206 | ** |
| 8207 | ** @return [int] The comparison function returns an integer less than, |
| 8208 | ** equal to, or greater than zero if the first argument is |
| 8209 | ** considered to be respectively less than, equal to, or |
| 8210 | ** greater than the second. |
| 8211 | ** |
| 8212 | ** @release 6.4.0 |
| 8213 | ** @@ |
| 8214 | ******************************************************************************/ |
| 8215 | |
| 8216 | static int listGvvariationfeatureCompareEndDescending( |
| 8217 | const void *item1, |
| 8218 | const void *item2) |
| 8219 | { |
| 8220 | EnsPGvvariationfeature gvvf1 = *(EnsOGvvariationfeature *const *) item1; |
| 8221 | EnsPGvvariationfeature gvvf2 = *(EnsOGvvariationfeature *const *) item2; |
| 8222 | |
| 8223 | #if defined(AJ_DEBUG) && AJ_DEBUG >= 2 |
| 8224 | if (ajDebugTest("listGvvariationfeatureCompareEndDescending")) |
| 8225 | ajDebug("listGvvariationfeatureCompareEndDescending\n" |
| 8226 | " gvvf1 %p\n" |
| 8227 | " gvvf2 %p\n", |
| 8228 | gvvf1, |
| 8229 | gvvf2); |
| 8230 | #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 2 */ |
| 8231 | |
| 8232 | /* Sort empty values towards the end of the AJAX List. */ |
| 8233 | |
| 8234 | if (gvvf1 && (!gvvf2)) |
| 8235 | return -1; |
| 8236 | |
| 8237 | if ((!gvvf1) && (!gvvf2)) |
| 8238 | return 0; |
| 8239 | |
| 8240 | if ((!gvvf1) && gvvf2) |
| 8241 | return +1; |
| 8242 | |
| 8243 | return ensFeatureCompareEndDescending(gvvf1->Feature, gvvf2->Feature); |
| 8244 | } |
| 8245 | |
| 8246 | |
| 8247 | |
| 8248 | |
| 8249 | /* @funcstatic listGvvariationfeatureCompareIdentifierAscending *************** |
| 8250 | ** |
| 8251 | ** AJAX List of Ensembl Genetic Variation Variation Feature objects comparison |
| 8252 | ** function to sort by identifier member in ascending order. |
| 8253 | ** |
| 8254 | ** @param [r] item1 [const void*] |
| 8255 | ** Ensembl Genetic VariationVariation Feature address 1 |
| 8256 | ** @param [r] item2 [const void*] |
| 8257 | ** Ensembl Genetic Variation Variation Feature address 2 |
| 8258 | ** @see ajListSort |
| 8259 | ** |
| 8260 | ** @return [int] The comparison function returns an integer less than, |
| 8261 | ** equal to, or greater than zero if the first argument is |
| 8262 | ** considered to be respectively less than, equal to, or |
| 8263 | ** greater than the second. |
| 8264 | ** |
| 8265 | ** @release 6.4.0 |
| 8266 | ** @@ |
| 8267 | ******************************************************************************/ |
| 8268 | |
| 8269 | static int listGvvariationfeatureCompareIdentifierAscending( |
| 8270 | const void *item1, |
| 8271 | const void *item2) |
| 8272 | { |
| 8273 | EnsPGvvariationfeature gvvf1 = *(EnsOGvvariationfeature *const *) item1; |
| 8274 | EnsPGvvariationfeature gvvf2 = *(EnsOGvvariationfeature *const *) item2; |
| 8275 | |
| 8276 | #if defined(AJ_DEBUG) && AJ_DEBUG >= 2 |
| 8277 | if (ajDebugTest("listGvvariationfeatureCompareIdentifierAscending")) |
| 8278 | ajDebug("listGvvariationfeatureCompareIdentifierAscending\n" |
| 8279 | " gvvf1 %p\n" |
| 8280 | " gvvf2 %p\n", |
| 8281 | gvvf1, |
| 8282 | gvvf2); |
| 8283 | #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 2 */ |
| 8284 | |
| 8285 | /* Sort empty values towards the end of the AJAX List. */ |
| 8286 | |
| 8287 | if (gvvf1 && (!gvvf2)) |
| 8288 | return -1; |
| 8289 | |
| 8290 | if ((!gvvf1) && (!gvvf2)) |
| 8291 | return 0; |
| 8292 | |
| 8293 | if ((!gvvf1) && gvvf2) |
| 8294 | return +1; |
| 8295 | |
| 8296 | if (gvvf1->Identifier < gvvf2->Identifier) |
| 8297 | return -1; |
| 8298 | |
| 8299 | if (gvvf1->Identifier > gvvf2->Identifier) |
| 8300 | return +1; |
| 8301 | |
| 8302 | return 0; |
| 8303 | } |
| 8304 | |
| 8305 | |
| 8306 | |
| 8307 | |
| 8308 | /* @funcstatic listGvvariationfeatureCompareStartAscending ******************** |
| 8309 | ** |
| 8310 | ** AJAX List of Ensembl Genetic Variation Variation Feature objects comparison |
| 8311 | ** function to sort by Ensembl Feature start member in ascending order. |
| 8312 | ** |
| 8313 | ** @param [r] item1 [const void*] |
| 8314 | ** Ensembl Genetic VariationVariation Feature address 1 |
| 8315 | ** @param [r] item2 [const void*] |
| 8316 | ** Ensembl Genetic Variation Variation Feature address 2 |
| 8317 | ** @see ajListSort |
| 8318 | ** |
| 8319 | ** @return [int] The comparison function returns an integer less than, |
| 8320 | ** equal to, or greater than zero if the first argument is |
| 8321 | ** considered to be respectively less than, equal to, or |
| 8322 | ** greater than the second. |
| 8323 | ** |
| 8324 | ** @release 6.4.0 |
| 8325 | ** @@ |
| 8326 | ******************************************************************************/ |
| 8327 | |
| 8328 | static int listGvvariationfeatureCompareStartAscending( |
| 8329 | const void *item1, |
| 8330 | const void *item2) |
| 8331 | { |
| 8332 | EnsPGvvariationfeature gvvf1 = *(EnsOGvvariationfeature *const *) item1; |
| 8333 | EnsPGvvariationfeature gvvf2 = *(EnsOGvvariationfeature *const *) item2; |
| 8334 | |
| 8335 | #if defined(AJ_DEBUG) && AJ_DEBUG >= 2 |
| 8336 | if (ajDebugTest("listGvvariationfeatureCompareStartAscending")) |
| 8337 | ajDebug("listGvvariationfeatureCompareStartAscending\n" |
| 8338 | " gvvf1 %p\n" |
| 8339 | " gvvf2 %p\n", |
| 8340 | gvvf1, |
| 8341 | gvvf2); |
| 8342 | #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 2 */ |
| 8343 | |
| 8344 | /* Sort empty values towards the end of the AJAX List. */ |
| 8345 | |
| 8346 | if (gvvf1 && (!gvvf2)) |
| 8347 | return -1; |
| 8348 | |
| 8349 | if ((!gvvf1) && (!gvvf2)) |
| 8350 | return 0; |
| 8351 | |
| 8352 | if ((!gvvf1) && gvvf2) |
| 8353 | return +1; |
| 8354 | |
| 8355 | return ensFeatureCompareStartAscending(gvvf1->Feature, gvvf2->Feature); |
| 8356 | } |
| 8357 | |
| 8358 | |
| 8359 | |
| 8360 | |
| 8361 | /* @funcstatic listGvvariationfeatureCompareStartDescending ******************* |
| 8362 | ** |
| 8363 | ** AJAX List of Ensembl Genetic Variation Variation Feature objects comparison |
| 8364 | ** function to sort by Ensembl Feature start member in descending order. |
| 8365 | ** |
| 8366 | ** @param [r] item1 [const void*] |
| 8367 | ** Ensembl Genetic Variation Variation Feature address 1 |
| 8368 | ** @param [r] item2 [const void*] |
| 8369 | ** Ensembl Genetic Variation Variation Feature address 2 |
| 8370 | ** @see ajListSort |
| 8371 | ** |
| 8372 | ** @return [int] The comparison function returns an integer less than, |
| 8373 | ** equal to, or greater than zero if the first argument is |
| 8374 | ** considered to be respectively less than, equal to, or |
| 8375 | ** greater than the second. |
| 8376 | ** |
| 8377 | ** @release 6.4.0 |
| 8378 | ** @@ |
| 8379 | ******************************************************************************/ |
| 8380 | |
| 8381 | static int listGvvariationfeatureCompareStartDescending( |
| 8382 | const void *item1, |
| 8383 | const void *item2) |
| 8384 | { |
| 8385 | EnsPGvvariationfeature gvvf1 = *(EnsOGvvariationfeature *const *) item1; |
| 8386 | EnsPGvvariationfeature gvvf2 = *(EnsOGvvariationfeature *const *) item2; |
| 8387 | |
| 8388 | #if defined(AJ_DEBUG) && AJ_DEBUG >= 2 |
| 8389 | if (ajDebugTest("listGvvariationfeatureCompareStartDescending")) |
| 8390 | ajDebug("listGvvariationfeatureCompareStartDescending\n" |
| 8391 | " gvvf1 %p\n" |
| 8392 | " gvvf2 %p\n", |
| 8393 | gvvf1, |
| 8394 | gvvf2); |
| 8395 | #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 2 */ |
| 8396 | |
| 8397 | /* Sort empty values towards the end of the AJAX List. */ |
| 8398 | |
| 8399 | if (gvvf1 && (!gvvf2)) |
| 8400 | return -1; |
| 8401 | |
| 8402 | if ((!gvvf1) && (!gvvf2)) |
| 8403 | return 0; |
| 8404 | |
| 8405 | if ((!gvvf1) && gvvf2) |
| 8406 | return +1; |
| 8407 | |
| 8408 | return ensFeatureCompareStartDescending(gvvf1->Feature, gvvf2->Feature); |
| 8409 | } |
| 8410 | |
| 8411 | |
| 8412 | |
| 8413 | |
| 8414 | /* @section list ************************************************************** |
| 8415 | ** |
| 8416 | ** Functions for manipulating AJAX List objects. |
| 8417 | ** |
| 8418 | ** @fdata [AjPList] |
| 8419 | ** |
| 8420 | ** @nam3rule Gvvariationfeature Functions for manipulating AJAX List objects |
| 8421 | ** of Ensembl Genetic Variation Variation Feature objects |
| 8422 | ** @nam4rule Sort Sort functions |
| 8423 | ** @nam5rule End Sort by Ensembl Feature end member |
| 8424 | ** @nam5rule Identifier Sort by identifier member |
| 8425 | ** @nam5rule Start Sort by Ensembl Feature start member |
| 8426 | ** @nam6rule Ascending Sort in ascending order |
| 8427 | ** @nam6rule Descending Sort in descending order |
| 8428 | ** |
| 8429 | ** @argrule * gvvfs [AjPList] |
| 8430 | ** AJAX List of Ensembl Genetic Variation Variation Feature objects |
| 8431 | ** |
| 8432 | ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise |
| 8433 | ** |
| 8434 | ** @fcategory misc |
| 8435 | ******************************************************************************/ |
| 8436 | |
| 8437 | |
| 8438 | |
| 8439 | |
| 8440 | /* @func ensListGvvariationfeatureSortEndAscending **************************** |
| 8441 | ** |
| 8442 | ** Sort Ensembl Genetic Variation Variation Feature by their |
| 8443 | ** Ensembl Feature end coordinate in ascending order. |
| 8444 | ** |
| 8445 | ** @param [u] gvvfs [AjPList] |
| 8446 | ** AJAX List of Ensembl Genetic Variation Variation Feature objects |
| 8447 | ** |
| 8448 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 8449 | ** |
| 8450 | ** @release 6.4.0 |
| 8451 | ** @@ |
| 8452 | ******************************************************************************/ |
| 8453 | |
| 8454 | AjBool ensListGvvariationfeatureSortEndAscending(AjPList gvvfs) |
| 8455 | { |
| 8456 | if (!gvvfs) |
| 8457 | return ajFalse; |
| 8458 | |
| 8459 | ajListSortTwoThree(gvvfs, |
| 8460 | &listGvvariationfeatureCompareEndAscending, |
| 8461 | &listGvvariationfeatureCompareStartAscending, |
| 8462 | &listGvvariationfeatureCompareIdentifierAscending); |
| 8463 | |
| 8464 | return ajTrue; |
| 8465 | } |
| 8466 | |
| 8467 | |
| 8468 | |
| 8469 | |
| 8470 | /* @func ensListGvvariationfeatureSortEndDescending *************************** |
| 8471 | ** |
| 8472 | ** Sort Ensembl Genetic Variation Variation Feature by their |
| 8473 | ** Ensembl Feature end coordinate in descending order. |
| 8474 | ** |
| 8475 | ** @param [u] gvvfs [AjPList] |
| 8476 | ** AJAX List of Ensembl Genetic Variation Variation Feature objects |
| 8477 | ** |
| 8478 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 8479 | ** |
| 8480 | ** @release 6.4.0 |
| 8481 | ** @@ |
| 8482 | ******************************************************************************/ |
| 8483 | |
| 8484 | AjBool ensListGvvariationfeatureSortEndDescending(AjPList gvvfs) |
| 8485 | { |
| 8486 | if (!gvvfs) |
| 8487 | return ajFalse; |
| 8488 | |
| 8489 | ajListSortTwoThree(gvvfs, |
| 8490 | &listGvvariationfeatureCompareEndDescending, |
| 8491 | &listGvvariationfeatureCompareStartDescending, |
| 8492 | &listGvvariationfeatureCompareIdentifierAscending); |
| 8493 | |
| 8494 | return ajTrue; |
| 8495 | } |
| 8496 | |
| 8497 | |
| 8498 | |
| 8499 | |
| 8500 | /* @func ensListGvvariationfeatureSortIdentifierAscending ********************* |
| 8501 | ** |
| 8502 | ** Sort Ensembl Genetic Variation Variation Feature by their |
| 8503 | ** identifier member in ascending order. |
| 8504 | ** |
| 8505 | ** @param [u] gvvfs [AjPList] AJAX List of Ensembl Genetic Variation |
| 8506 | ** Variation Feature objects |
| 8507 | ** |
| 8508 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 8509 | ** |
| 8510 | ** @release 6.4.0 |
| 8511 | ** @@ |
| 8512 | ******************************************************************************/ |
| 8513 | |
| 8514 | AjBool ensListGvvariationfeatureSortIdentifierAscending(AjPList gvvfs) |
| 8515 | { |
| 8516 | if (!gvvfs) |
| 8517 | return ajFalse; |
| 8518 | |
| 8519 | ajListSort(gvvfs, &listGvvariationfeatureCompareIdentifierAscending); |
| 8520 | |
| 8521 | return ajTrue; |
| 8522 | } |
| 8523 | |
| 8524 | |
| 8525 | |
| 8526 | |
| 8527 | /* @func ensListGvvariationfeatureSortStartAscending ************************** |
| 8528 | ** |
| 8529 | ** Sort Ensembl Genetic Variation Variation Feature by their |
| 8530 | ** Ensembl Feature start coordinate in ascending order. |
| 8531 | ** |
| 8532 | ** @param [u] gvvfs [AjPList] AJAX List of Ensembl Genetic Variation |
| 8533 | ** Variation Feature objects |
| 8534 | ** |
| 8535 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 8536 | ** |
| 8537 | ** @release 6.4.0 |
| 8538 | ** @@ |
| 8539 | ******************************************************************************/ |
| 8540 | |
| 8541 | AjBool ensListGvvariationfeatureSortStartAscending(AjPList gvvfs) |
| 8542 | { |
| 8543 | if (!gvvfs) |
| 8544 | return ajFalse; |
| 8545 | |
| 8546 | ajListSortTwoThree(gvvfs, |
| 8547 | &listGvvariationfeatureCompareStartAscending, |
| 8548 | &listGvvariationfeatureCompareEndAscending, |
| 8549 | &listGvvariationfeatureCompareIdentifierAscending); |
| 8550 | |
| 8551 | return ajTrue; |
| 8552 | } |
| 8553 | |
| 8554 | |
| 8555 | |
| 8556 | |
| 8557 | /* @func ensListGvvariationfeatureSortStartDescending ************************* |
| 8558 | ** |
| 8559 | ** Sort Ensembl Genetic Variation Variation Feature by their |
| 8560 | ** Ensembl Feature start coordinate in descending order. |
| 8561 | ** |
| 8562 | ** @param [u] gvvfs [AjPList] AJAX List of Ensembl Genetic Variation |
| 8563 | ** Variation Feature objects |
| 8564 | ** |
| 8565 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 8566 | ** |
| 8567 | ** @release 6.4.0 |
| 8568 | ** @@ |
| 8569 | ******************************************************************************/ |
| 8570 | |
| 8571 | AjBool ensListGvvariationfeatureSortStartDescending(AjPList gvvfs) |
| 8572 | { |
| 8573 | if (!gvvfs) |
| 8574 | return ajFalse; |
| 8575 | |
| 8576 | ajListSortTwoThree(gvvfs, |
| 8577 | &listGvvariationfeatureCompareStartDescending, |
| 8578 | &listGvvariationfeatureCompareEndDescending, |
| 8579 | &listGvvariationfeatureCompareIdentifierAscending); |
| 8580 | |
| 8581 | return ajTrue; |
| 8582 | } |
| 8583 | |
| 8584 | |
| 8585 | |
| 8586 | |
| 8587 | /* |
| 8588 | ** TODO: The following methods are not implemented: |
| 8589 | ** get_all_TranscriptVariations |
| 8590 | ** add_TranscriptVariation |
| 8591 | ** display_consequence |
| 8592 | ** add_consequence_type |
| 8593 | */ |
| 8594 | |
| 8595 | |
| 8596 | |
| 8597 | |
| 8598 | /* @datasection [EnsPGvvariationfeatureadaptor] Ensembl Genetic Variation |
| 8599 | ** Variation Feature Adaptor |
| 8600 | ** |
| 8601 | ** @nam2rule Gvvariationfeatureadaptor Functions for manipulating |
| 8602 | ** Ensembl Genetic Variation Variation Feature Adaptor objects |
| 8603 | ** |
| 8604 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationFeatureAdaptor |
| 8605 | ** @cc CVS Revision: 1.46 |
| 8606 | ** @cc CVS Tag: branch-ensembl-61 |
| 8607 | ** |
| 8608 | ** NOTE: Since the "source" SQL table contains only a small number of records |
| 8609 | ** linked to a potentially large number of records in other SQL tables, the |
| 8610 | ** contents have been modelled as independent objects. The EnsPGvsourceadaptor |
| 8611 | ** caches all EnsPGvsource entries, which should help reduce memory |
| 8612 | ** requirements. Consequently, neither the "variation" nor "variation_synonym" |
| 8613 | ** SQL tables need joining to the "source" table. |
| 8614 | ** |
| 8615 | ******************************************************************************/ |
| 8616 | |
| 8617 | |
| 8618 | |
| 8619 | |
| 8620 | /* @funcstatic gvvariationfeatureadaptorFetchAllbyStatement ******************* |
| 8621 | ** |
| 8622 | ** Fetch all Ensembl Genetic Variation Variation Feature objects |
| 8623 | ** via an SQL statement. |
| 8624 | ** |
| 8625 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationFeatureAdaptor::_objs_from_sth |
| 8626 | ** @param [u] ba [EnsPBaseadaptor] Ensembl Base Adaptor |
| 8627 | ** @param [r] statement [const AjPStr] SQL statement |
| 8628 | ** @param [uN] am [EnsPAssemblymapper] Ensembl Assembly Mapper |
| 8629 | ** @param [uN] slice [EnsPSlice] Ensembl Slice |
| 8630 | ** @param [u] gvvfs [AjPList] AJAX List of Ensembl Genetic Variation |
| 8631 | ** Variation Feature objects |
| 8632 | ** |
| 8633 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 8634 | ** |
| 8635 | ** @release 6.4.0 |
| 8636 | ** @@ |
| 8637 | ******************************************************************************/ |
| 8638 | |
| 8639 | static AjBool gvvariationfeatureadaptorFetchAllbyStatement( |
| 8640 | EnsPBaseadaptor ba, |
| 8641 | const AjPStr statement, |
| 8642 | EnsPAssemblymapper am, |
| 8643 | EnsPSlice slice, |
| 8644 | AjPList gvvfs) |
| 8645 | { |
| 8646 | ajint mapweight = 0; |
| 8647 | |
| 8648 | ajuint lastgvvfid = 0U; |
| 8649 | ajuint identifier = 0U; |
| 8650 | ajuint gvvidentifier = 0U; |
| 8651 | ajuint sourceid = 0U; |
| 8652 | |
| 8653 | ajuint srid = 0U; |
| 8654 | ajuint srstart = 0U; |
| 8655 | ajuint srend = 0U; |
| 8656 | ajint srstrand = 0; |
| 8657 | |
| 8658 | AjPSqlstatement sqls = NULL; |
| 8659 | AjISqlrow sqli = NULL; |
| 8660 | AjPSqlrow sqlr = NULL; |
| 8661 | |
| 8662 | AjPStr allele = NULL; |
| 8663 | AjPStr name = NULL; |
| 8664 | AjPStr validation = NULL; |
| 8665 | AjPStr consequence = NULL; |
| 8666 | AjPStr class = NULL; |
| 8667 | |
| 8668 | EnsEGvvariationClass gvvc = ensEGvvariationClassNULL; |
| 8669 | |
| 8670 | EnsPDatabaseadaptor dba = NULL; |
| 8671 | |
| 8672 | EnsPGvsource gvsource = NULL; |
| 8673 | EnsPGvsourceadaptor gvsourcea = NULL; |
| 8674 | |
| 8675 | EnsPGvvariationfeature gvvf = NULL; |
| 8676 | EnsPGvvariationfeatureadaptor gvvfa = NULL; |
| 8677 | |
| 8678 | EnsPFeature feature = NULL; |
| 8679 | |
| 8680 | if (ajDebugTest("gvvariationfeatureadaptorFetchAllbyStatement")) |
| 8681 | ajDebug("gvvariationfeatureadaptorFetchAllbyStatement\n" |
| 8682 | " ba %p\n" |
| 8683 | " statement %p\n" |
| 8684 | " am %p\n" |
| 8685 | " slice %p\n" |
| 8686 | " gvvfs %p\n", |
| 8687 | ba, |
| 8688 | statement, |
| 8689 | am, |
| 8690 | slice, |
| 8691 | gvvfs); |
| 8692 | |
| 8693 | if (!ba) |
| 8694 | return ajFalse; |
| 8695 | |
| 8696 | if (!statement) |
| 8697 | return ajFalse; |
| 8698 | |
| 8699 | if (!gvvfs) |
| 8700 | return ajFalse; |
| 8701 | |
| 8702 | dba = ensBaseadaptorGetDatabaseadaptor(ba); |
| 8703 | |
| 8704 | gvvfa = ensRegistryGetGvvariationfeatureadaptor(dba); |
| 8705 | gvsourcea = ensRegistryGetGvsourceadaptor(dba); |
| 8706 | |
| 8707 | sqls = ensDatabaseadaptorSqlstatementNew(dba, statement); |
| 8708 | |
| 8709 | sqli = ajSqlrowiterNew(sqls); |
| 8710 | |
| 8711 | while (!ajSqlrowiterDone(sqli)) |
| 8712 | { |
| 8713 | identifier = 0; |
| 8714 | srid = 0; |
| 8715 | srstart = 0; |
| 8716 | srend = 0; |
| 8717 | srstrand = 0; |
| 8718 | gvvidentifier = 0; |
| 8719 | allele = ajStrNew(); |
| 8720 | name = ajStrNew(); |
| 8721 | mapweight = 0; |
| 8722 | sourceid = 0; |
| 8723 | validation = ajStrNew(); |
| 8724 | consequence = ajStrNew(); |
| 8725 | class = ajStrNew(); |
| 8726 | gvvc = ensEGvvariationClassNULL; |
| 8727 | |
| 8728 | sqlr = ajSqlrowiterGet(sqli); |
| 8729 | |
| 8730 | ajSqlcolumnToUint(sqlr, &identifier); |
| 8731 | ajSqlcolumnToUint(sqlr, &srid); |
| 8732 | ajSqlcolumnToUint(sqlr, &srstart); |
| 8733 | ajSqlcolumnToUint(sqlr, &srend); |
| 8734 | ajSqlcolumnToInt(sqlr, &srstrand); |
| 8735 | ajSqlcolumnToUint(sqlr, &gvvidentifier); |
| 8736 | ajSqlcolumnToStr(sqlr, &allele); |
| 8737 | ajSqlcolumnToStr(sqlr, &name); |
| 8738 | ajSqlcolumnToInt(sqlr, &mapweight); |
| 8739 | ajSqlcolumnToUint(sqlr, &sourceid); |
| 8740 | ajSqlcolumnToStr(sqlr, &validation); |
| 8741 | ajSqlcolumnToStr(sqlr, &consequence); |
| 8742 | ajSqlcolumnToStr(sqlr, &class); |
| 8743 | |
| 8744 | /* |
| 8745 | ** Skip multiple rows, because of the LEFT JOIN condition to the |
| 8746 | ** "failed_variation" SQL table. |
| 8747 | */ |
| 8748 | |
| 8749 | if (lastgvvfid == identifier) |
| 8750 | { |
| 8751 | ajStrDel(&allele); |
| 8752 | ajStrDel(&name); |
| 8753 | ajStrDel(&validation); |
| 8754 | ajStrDel(&consequence); |
| 8755 | ajStrDel(&class); |
| 8756 | |
| 8757 | continue; |
| 8758 | } |
| 8759 | else |
| 8760 | lastgvvfid = identifier; |
| 8761 | |
| 8762 | ensBaseadaptorRetrieveFeature(ba, |
| 8763 | 0U, |
| 8764 | srid, |
| 8765 | srstart, |
| 8766 | srend, |
| 8767 | srstrand, |
| 8768 | am, |
| 8769 | slice, |
| 8770 | &feature); |
| 8771 | |
| 8772 | if (!feature) |
| 8773 | { |
| 8774 | ajStrDel(&allele); |
| 8775 | ajStrDel(&name); |
| 8776 | ajStrDel(&validation); |
| 8777 | ajStrDel(&consequence); |
| 8778 | ajStrDel(&class); |
| 8779 | |
| 8780 | continue; |
| 8781 | } |
| 8782 | |
| 8783 | /* |
| 8784 | ** Finally, create a new |
| 8785 | ** Ensembl Genetic Variation Variation Feature. |
| 8786 | */ |
| 8787 | |
| 8788 | ensGvsourceadaptorFetchByIdentifier(gvsourcea, sourceid, &gvsource); |
| 8789 | |
| 8790 | /* Set the Ensembl Genetic Variation Variation Class. */ |
| 8791 | |
| 8792 | gvvc = ensGvvariationClassFromStr(class); |
| 8793 | |
| 8794 | if (!gvvc) |
| 8795 | ajFatal("gvvariationfeatureadaptorFetchAllbyStatement encountered " |
| 8796 | "unexpected string '%S' in the " |
| 8797 | "'variation_feature.class_so_id' field.\n", class); |
| 8798 | |
| 8799 | gvvf = ensGvvariationfeatureNewIdentifier(gvvfa, |
| 8800 | identifier, |
| 8801 | feature, |
| 8802 | gvsource, |
| 8803 | gvvc, |
| 8804 | gvvidentifier, |
| 8805 | allele, |
| 8806 | name, |
| 8807 | validation, |
| 8808 | consequence, |
| 8809 | mapweight); |
| 8810 | |
| 8811 | ajListPushAppend(gvvfs, (void *) gvvf); |
| 8812 | |
| 8813 | ensGvsourceDel(&gvsource); |
| 8814 | |
| 8815 | ensFeatureDel(&feature); |
| 8816 | |
| 8817 | ajStrDel(&allele); |
| 8818 | ajStrDel(&name); |
| 8819 | ajStrDel(&validation); |
| 8820 | ajStrDel(&consequence); |
| 8821 | ajStrDel(&class); |
| 8822 | } |
| 8823 | |
| 8824 | ajSqlrowiterDel(&sqli); |
| 8825 | |
| 8826 | ensDatabaseadaptorSqlstatementDel(dba, &sqls); |
| 8827 | |
| 8828 | return ajTrue; |
| 8829 | } |
| 8830 | |
| 8831 | |
| 8832 | |
| 8833 | |
| 8834 | /* @section constructors ****************************************************** |
| 8835 | ** |
| 8836 | ** All constructors return a new Ensembl Genetic Variation Variation Feature |
| 8837 | ** Adaptor by pointer. |
| 8838 | ** It is the responsibility of the user to first destroy any previous |
| 8839 | ** Genetic Variation Variation Feature Adaptor. |
| 8840 | ** The target pointer does not need to be initialised to NULL, |
| 8841 | ** but it is good programming practice to do so anyway. |
| 8842 | ** |
| 8843 | ** @fdata [EnsPGvvariationfeatureadaptor] |
| 8844 | ** |
| 8845 | ** @nam3rule New Constructor |
| 8846 | ** |
| 8847 | ** @argrule New dba [EnsPDatabaseadaptor] Ensembl Database Adaptor |
| 8848 | ** |
| 8849 | ** @valrule * [EnsPGvvariationfeatureadaptor] |
| 8850 | ** Ensembl Genetic Variation Variation Feature Adaptor or NULL |
| 8851 | ** |
| 8852 | ** @fcategory new |
| 8853 | ******************************************************************************/ |
| 8854 | |
| 8855 | |
| 8856 | |
| 8857 | |
| 8858 | /* @func ensGvvariationfeatureadaptorNew ************************************** |
| 8859 | ** |
| 8860 | ** Default constructor for an |
| 8861 | ** Ensembl Genetic Variation Variation Feature Adaptor. |
| 8862 | ** |
| 8863 | ** Ensembl Object Adaptors are singleton objects in the sense that a single |
| 8864 | ** instance of an Ensembl Object Adaptor connected to a particular database is |
| 8865 | ** sufficient to instantiate any number of Ensembl Objects from the database. |
| 8866 | ** Each Ensembl Object will have a weak reference to the Object Adaptor that |
| 8867 | ** instantiated it. Therefore, Ensembl Object Adaptors should not be |
| 8868 | ** instantiated directly, but rather obtained from the Ensembl Registry, |
| 8869 | ** which will in turn call this function if neccessary. |
| 8870 | ** |
| 8871 | ** @see ensRegistryGetDatabaseadaptor |
| 8872 | ** @see ensRegistryGetGvvariationfeatureadaptor |
| 8873 | ** |
| 8874 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationFeatureAdaptor::new |
| 8875 | ** @param [u] dba [EnsPDatabaseadaptor] Ensembl Database Adaptor |
| 8876 | ** |
| 8877 | ** @return [EnsPGvvariationfeatureadaptor] |
| 8878 | ** Ensembl Genetic Variation Variation Feature Adaptor or NULL |
| 8879 | ** |
| 8880 | ** @release 6.4.0 |
| 8881 | ** @@ |
| 8882 | ******************************************************************************/ |
| 8883 | |
| 8884 | EnsPGvvariationfeatureadaptor ensGvvariationfeatureadaptorNew( |
| 8885 | EnsPDatabaseadaptor dba) |
| 8886 | { |
| 8887 | EnsPFeatureadaptor fa = NULL; |
| 8888 | |
| 8889 | EnsPGvvariationfeatureadaptor gvvfa = NULL; |
| 8890 | |
| 8891 | if (!dba) |
| 8892 | return NULL; |
| 8893 | |
| 8894 | fa = ensFeatureadaptorNew( |
| 8895 | dba, |
| 8896 | gvvariationfeatureadaptorKTablenames, |
| 8897 | gvvariationfeatureadaptorKColumnnames, |
| 8898 | gvvariationfeatureadaptorKLeftjoins, |
| 8899 | gvvariationfeatureadaptorKDefaultcondition, |
| 8900 | (const char *) NULL, |
| 8901 | &gvvariationfeatureadaptorFetchAllbyStatement, |
| 8902 | (void *(*)(const void *)) NULL, |
| 8903 | (void *(*)(void *)) &ensGvvariationfeatureNewRef, |
| 8904 | (AjBool (*)(const void *)) NULL, |
| 8905 | (void (*)(void **)) &ensGvvariationfeatureDel, |
| 8906 | (size_t (*)(const void *)) &ensGvvariationfeatureCalculateMemsize, |
| 8907 | (EnsPFeature (*)(const void *)) &ensGvvariationfeatureGetFeature, |
| 8908 | "Ensembl Genetic Variation Variation Feature"); |
| 8909 | |
| 8910 | if (!fa) |
| 8911 | return NULL; |
| 8912 | |
| 8913 | AJNEW0(gvvfa); |
| 8914 | |
| 8915 | gvvfa->Adaptor = ensRegistryGetGvdatabaseadaptor(dba); |
| 8916 | gvvfa->Featureadaptor = fa; |
| 8917 | |
| 8918 | return gvvfa; |
| 8919 | } |
| 8920 | |
| 8921 | |
| 8922 | |
| 8923 | |
| 8924 | /* @section destructors ******************************************************* |
| 8925 | ** |
| 8926 | ** Destruction destroys all internal data structures and frees the memory |
| 8927 | ** allocated for an Ensembl Genetic Variation Variation Feature Adaptor object. |
| 8928 | ** |
| 8929 | ** @fdata [EnsPGvvariationfeatureadaptor] |
| 8930 | ** |
| 8931 | ** @nam3rule Del Destroy (free) an |
| 8932 | ** Ensembl Genetic Variation Variation Feature Adaptor |
| 8933 | ** |
| 8934 | ** @argrule * Pgvvfa [EnsPGvvariationfeatureadaptor*] |
| 8935 | ** Ensembl Genetic Variation Variation Feature Adaptor address |
| 8936 | ** |
| 8937 | ** @valrule * [void] |
| 8938 | ** |
| 8939 | ** @fcategory delete |
| 8940 | ******************************************************************************/ |
| 8941 | |
| 8942 | |
| 8943 | |
| 8944 | |
| 8945 | /* @func ensGvvariationfeatureadaptorDel ************************************** |
| 8946 | ** |
| 8947 | ** Default destructor for an |
| 8948 | ** Ensembl Genetic Variation Variation Feature Adaptor. |
| 8949 | ** |
| 8950 | ** Ensembl Object Adaptors are singleton objects that are registered in the |
| 8951 | ** Ensembl Registry and weakly referenced by Ensembl Objects that have been |
| 8952 | ** instantiated by it. Therefore, Ensembl Object Adaptors should never be |
| 8953 | ** destroyed directly. Upon exit, the Ensembl Registry will call this function |
| 8954 | ** if required. |
| 8955 | ** |
| 8956 | ** @param [d] Pgvvfa [EnsPGvvariationfeatureadaptor*] |
| 8957 | ** Ensembl Genetic Variation Variation Feature Adaptor address |
| 8958 | ** |
| 8959 | ** @return [void] |
| 8960 | ** |
| 8961 | ** @release 6.4.0 |
| 8962 | ** @@ |
| 8963 | ******************************************************************************/ |
| 8964 | |
| 8965 | void ensGvvariationfeatureadaptorDel(EnsPGvvariationfeatureadaptor *Pgvvfa) |
| 8966 | { |
| 8967 | EnsPGvvariationfeatureadaptor pthis = NULL; |
| 8968 | |
| 8969 | if (!Pgvvfa) |
| 8970 | return; |
| 8971 | |
| 8972 | #if defined(AJ_DEBUG) && AJ_DEBUG >= 1 |
| 8973 | if (ajDebugTest("ensGvvariationfeatureadaptorDel")) |
| 8974 | ajDebug("ensGvvariationfeatureadaptorDel\n" |
| 8975 | " *Pgvvfa %p\n", |
| 8976 | *Pgvvfa); |
| 8977 | #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 1 */ |
| 8978 | |
| 8979 | if (!(pthis = *Pgvvfa)) |
| 8980 | return; |
| 8981 | |
| 8982 | ensFeatureadaptorDel(&pthis->Featureadaptor); |
| 8983 | |
| 8984 | ajMemFree((void **) Pgvvfa); |
| 8985 | |
| 8986 | return; |
| 8987 | } |
| 8988 | |
| 8989 | |
| 8990 | |
| 8991 | |
| 8992 | /* @section member retrieval ************************************************** |
| 8993 | ** |
| 8994 | ** Functions for returning members of an |
| 8995 | ** Ensembl Genetic Variation Variation Feature Adaptor object. |
| 8996 | ** |
| 8997 | ** @fdata [EnsPGvvariationfeatureadaptor] |
| 8998 | ** |
| 8999 | ** @nam3rule Get Return Ensembl Genetic Variation Variation Feature Adaptor |
| 9000 | ** attribute(s) |
| 9001 | ** @nam4rule Baseadaptor Return the Ensembl Base Adaptor |
| 9002 | ** @nam4rule Databaseadaptor Return the Ensembl Database Adaptor |
| 9003 | ** @nam4rule Featureadaptor Return the Ensembl Feature Adaptor |
| 9004 | ** @nam4rule Gvdatabaseadaptor |
| 9005 | ** Return the Ensembl Genetic Variation Database Adaptor |
| 9006 | ** |
| 9007 | ** @argrule * gvvfa [const EnsPGvvariationfeatureadaptor] |
| 9008 | ** Ensembl Genetic Variation Variation Feature Adaptor |
| 9009 | ** |
| 9010 | ** @valrule Baseadaptor [EnsPBaseadaptor] |
| 9011 | ** Ensembl Base Adaptor or NULL |
| 9012 | ** @valrule Databaseadaptor [EnsPDatabaseadaptor] |
| 9013 | ** Ensembl Database Adaptor or NULL |
| 9014 | ** @valrule Featureadaptor [EnsPFeatureadaptor] |
| 9015 | ** Ensembl Feature Adaptor or NULL |
| 9016 | ** @valrule Gvdatabaseadaptor [EnsPGvdatabaseadaptor] |
| 9017 | ** Ensembl Genetic Variation Database Adaptor or NULL |
| 9018 | ** |
| 9019 | ** @fcategory use |
| 9020 | ******************************************************************************/ |
| 9021 | |
| 9022 | |
| 9023 | |
| 9024 | |
| 9025 | /* @func ensGvvariationfeatureadaptorGetBaseadaptor *************************** |
| 9026 | ** |
| 9027 | ** Get the Ensembl Base Adaptor member of an |
| 9028 | ** Ensembl Genetic Variation Variation Feature Adaptor. |
| 9029 | ** |
| 9030 | ** @param [r] gvvfa [const EnsPGvvariationfeatureadaptor] |
| 9031 | ** Ensembl Genetic Variation Variation Feature Adaptor |
| 9032 | ** |
| 9033 | ** @return [EnsPBaseadaptor] Ensembl Base Adaptor or NULL |
| 9034 | ** |
| 9035 | ** @release 6.4.0 |
| 9036 | ** @@ |
| 9037 | ******************************************************************************/ |
| 9038 | |
| 9039 | EnsPBaseadaptor ensGvvariationfeatureadaptorGetBaseadaptor( |
| 9040 | const EnsPGvvariationfeatureadaptor gvvfa) |
| 9041 | { |
| 9042 | return ensFeatureadaptorGetBaseadaptor( |
| 9043 | ensGvvariationfeatureadaptorGetFeatureadaptor(gvvfa)); |
| 9044 | } |
| 9045 | |
| 9046 | |
| 9047 | |
| 9048 | |
| 9049 | /* @func ensGvvariationfeatureadaptorGetDatabaseadaptor *********************** |
| 9050 | ** |
| 9051 | ** Get the Ensembl Database Adaptor member of an |
| 9052 | ** Ensembl Genetic Variation Variation Feature Adaptor. |
| 9053 | ** |
| 9054 | ** @param [r] gvvfa [const EnsPGvvariationfeatureadaptor] |
| 9055 | ** Ensembl Genetic Variation Variation Feature Adaptor |
| 9056 | ** |
| 9057 | ** @return [EnsPDatabaseadaptor] Ensembl Database Adaptor or NULL |
| 9058 | ** |
| 9059 | ** @release 6.4.0 |
| 9060 | ** @@ |
| 9061 | ******************************************************************************/ |
| 9062 | |
| 9063 | EnsPDatabaseadaptor ensGvvariationfeatureadaptorGetDatabaseadaptor( |
| 9064 | const EnsPGvvariationfeatureadaptor gvvfa) |
| 9065 | { |
| 9066 | return ensGvdatabaseadaptorGetDatabaseadaptor( |
| 9067 | ensGvvariationfeatureadaptorGetGvdatabaseadaptor(gvvfa)); |
| 9068 | } |
| 9069 | |
| 9070 | |
| 9071 | |
| 9072 | |
| 9073 | /* @func ensGvvariationfeatureadaptorGetFeatureadaptor ************************ |
| 9074 | ** |
| 9075 | ** Get the Ensembl Feature Adaptor member of an |
| 9076 | ** Ensembl Genetic Variation Variation Feature Adaptor. |
| 9077 | ** |
| 9078 | ** @param [r] gvvfa [const EnsPGvvariationfeatureadaptor] |
| 9079 | ** Ensembl Genetic Variation Variation Feature Adaptor |
| 9080 | ** |
| 9081 | ** @return [EnsPFeatureadaptor] Ensembl Feature Adaptor or NULL |
| 9082 | ** |
| 9083 | ** @release 6.4.0 |
| 9084 | ** @@ |
| 9085 | ******************************************************************************/ |
| 9086 | |
| 9087 | EnsPFeatureadaptor ensGvvariationfeatureadaptorGetFeatureadaptor( |
| 9088 | const EnsPGvvariationfeatureadaptor gvvfa) |
| 9089 | { |
| 9090 | return (gvvfa) ? gvvfa->Featureadaptor : NULL; |
| 9091 | } |
| 9092 | |
| 9093 | |
| 9094 | |
| 9095 | |
| 9096 | /* @func ensGvvariationfeatureadaptorGetGvdatabaseadaptor ********************* |
| 9097 | ** |
| 9098 | ** Get the Ensembl Genetic Variation Database Adaptor member of an |
| 9099 | ** Ensembl Genetic Variation Variation Feature Adaptor. |
| 9100 | ** |
| 9101 | ** @param [r] gvvfa [const EnsPGvvariationfeatureadaptor] |
| 9102 | ** Ensembl Genetic Variation Variation Feature Adaptor |
| 9103 | ** |
| 9104 | ** @return [EnsPGvdatabaseadaptor] |
| 9105 | ** Ensembl Genetic Variation Database Adaptor or NULL |
| 9106 | ** |
| 9107 | ** @release 6.4.0 |
| 9108 | ** @@ |
| 9109 | ******************************************************************************/ |
| 9110 | |
| 9111 | EnsPGvdatabaseadaptor ensGvvariationfeatureadaptorGetGvdatabaseadaptor( |
| 9112 | const EnsPGvvariationfeatureadaptor gvvfa) |
| 9113 | { |
| 9114 | return (gvvfa) ? gvvfa->Adaptor : NULL; |
| 9115 | } |
| 9116 | |
| 9117 | |
| 9118 | |
| 9119 | |
| 9120 | /* @section object retrieval ************************************************** |
| 9121 | ** |
| 9122 | ** Functions for fetching Ensembl Genetic Variation Variation Feature objects |
| 9123 | ** from an Ensembl SQL database. |
| 9124 | ** |
| 9125 | ** @fdata [EnsPGvvariationfeatureadaptor] |
| 9126 | ** |
| 9127 | ** @nam3rule Fetch Fetch Ensembl Genetic Variation Variation Feature object(s) |
| 9128 | ** @nam4rule All Fetch all Ensembl Genetic Variation Variation Feature |
| 9129 | ** objects |
| 9130 | ** @nam4rule Allby Fetch all Ensembl Genetic Variation Variation Feature |
| 9131 | ** objects matching a criterion |
| 9132 | ** @nam5rule Frequency Fetch all by an Ensembl Genetic Variation Population |
| 9133 | ** and minor allele frequency |
| 9134 | ** @nam5rule Gvpopulation Fetch all by an Ensembl Genetic Variation Population |
| 9135 | ** @nam5rule Gvvariation Fetch all by an Ensembl Genetic Variation Variation |
| 9136 | ** @nam5rule Slice Fetch all by an Ensembl Slice |
| 9137 | ** @nam6rule Annotated Fetch all associated with annotations |
| 9138 | ** @nam6rule Constraint Fetch all by an SQL constraint |
| 9139 | ** @nam6rule Genotyped Fetch all genotyped |
| 9140 | ** @nam4rule By Fetch one Ensembl Genetic Variation Variation Feature object |
| 9141 | ** matching a criterion |
| 9142 | ** @nam5rule Identifier Fetch by an SQL database-internal identifier |
| 9143 | ** |
| 9144 | ** @argrule * gvvfa [EnsPGvvariationfeatureadaptor] Ensembl Genetic Variation |
| 9145 | ** Variation Feature Adaptor |
| 9146 | ** @argrule AllbyFrequency gvp [const EnsPGvpopulation] Ensembl Genetic |
| 9147 | ** Variation Population |
| 9148 | ** @argrule AllbyFrequency frequency [float] Minor allele frequency |
| 9149 | ** @argrule AllbyFrequency slice [EnsPSlice] Ensembl Slice |
| 9150 | ** @argrule AllbyFrequency gvvfs [AjPList] AJAX List of Ensembl Genetic |
| 9151 | ** Variation Variation Feature objects |
| 9152 | ** @argrule AllbyGvpopulation gvp [const EnsPGvpopulation] Ensembl Genetic |
| 9153 | ** Variation Population |
| 9154 | ** @argrule AllbyGvpopulation slice [EnsPSlice] Ensembl Slice |
| 9155 | ** @argrule AllbyGvpopulation gvvfs [AjPList] AJAX List of Ensembl Genetic |
| 9156 | ** Variation Variation Feature objects |
| 9157 | ** @argrule AllbyGvvariation gvv [const EnsPGvvariation] Ensembl Genetic |
| 9158 | ** Variation Variation |
| 9159 | ** @argrule AllbyGvvariation gvvfs [AjPList] AJAX List of Ensembl Genetic |
| 9160 | ** Variation Variation Feature objects |
| 9161 | ** @argrule AllbySliceAnnotated vsource [const AjPStr] variation_feature source |
| 9162 | ** @argrule AllbySliceAnnotated psource [const AjPStr] annotation_source |
| 9163 | ** @argrule AllbySliceAnnotated annotation [const AjPStr] annotation_name |
| 9164 | ** @argrule AllbySliceAnnotated somatic [AjBool] Somatic (ajTrue) or |
| 9165 | ** germline (ajFalse) |
| 9166 | ** @argrule AllbySliceAnnotated slice [EnsPSlice] Ensembl Slice |
| 9167 | ** @argrule AllbySliceAnnotated gvvfs [AjPList] AJAX List of Ensembl Genetic |
| 9168 | ** Variation Variation Feature objects |
| 9169 | ** @argrule AllbySliceConstraint slice [EnsPSlice] Ensembl Slice |
| 9170 | ** @argrule AllbySliceConstraint constraint [const AjPStr] SQL constraint |
| 9171 | ** @argrule AllbySliceConstraint somatic [AjBool] Somatic (ajTrue) or |
| 9172 | ** germline (ajFalse) |
| 9173 | ** @argrule AllbySliceConstraint gvvfs [AjPList] AJAX List of Ensembl Genetic |
| 9174 | ** Variation Variation Feature objects |
| 9175 | ** @argrule AllbySliceGenotyped slice [EnsPSlice] Ensembl Slice |
| 9176 | ** @argrule AllbySliceGenotyped gvvfs [AjPList] AJAX List of Ensembl Genetic |
| 9177 | ** Variation Variation Feature objects |
| 9178 | ** @argrule ByIdentifier identifier [ajuint] SQL database-internal identifier |
| 9179 | ** @argrule By Pgvvf [EnsPGvvariationfeature*] |
| 9180 | ** Ensembl Genetic Variation Variation Feature address |
| 9181 | ** |
| 9182 | ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise |
| 9183 | ** |
| 9184 | ** @fcategory use |
| 9185 | ******************************************************************************/ |
| 9186 | |
| 9187 | |
| 9188 | |
| 9189 | |
| 9190 | /* @func ensGvvariationfeatureadaptorFetchAllbyFrequency ********************** |
| 9191 | ** |
| 9192 | ** Fetch all Ensembl Genetic Variation Variation Feature objects associated |
| 9193 | ** with an Ensembl Genetic Variation Population and minor allele frequency on |
| 9194 | ** an Ensembl Slice. |
| 9195 | ** |
| 9196 | ** The caller is responsible for deleting the Ensembl Genetic Variation |
| 9197 | ** Variation Feature objects before deleting the AJAX List. |
| 9198 | ** |
| 9199 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationFeatureAdaptor:: |
| 9200 | ** fetch_all_by_Slice_Population |
| 9201 | ** @param [u] gvvfa [EnsPGvvariationfeatureadaptor] Ensembl Genetic |
| 9202 | ** Variation Variation Feature Adaptor |
| 9203 | ** @param [r] gvp [const EnsPGvpopulation] Ensembl Genetic Variation Population |
| 9204 | ** @param [r] frequency [float] Minor allele frequency |
| 9205 | ** @param [u] slice [EnsPSlice] Ensembl Slice |
| 9206 | ** @param [u] gvvfs [AjPList] AJAX List of Ensembl Genetic Variation |
| 9207 | ** Variation Feature objects |
| 9208 | ** |
| 9209 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 9210 | ** |
| 9211 | ** @release 6.4.0 |
| 9212 | ** @@ |
| 9213 | ******************************************************************************/ |
| 9214 | |
| 9215 | AjBool ensGvvariationfeatureadaptorFetchAllbyFrequency( |
| 9216 | EnsPGvvariationfeatureadaptor gvvfa, |
| 9217 | const EnsPGvpopulation gvp, |
| 9218 | float frequency, |
| 9219 | EnsPSlice slice, |
| 9220 | AjPList gvvfs) |
| 9221 | { |
| 9222 | const char *const *txtcolumns = NULL; |
| 9223 | |
| 9224 | register ajuint i = 0U; |
| 9225 | |
| 9226 | AjBool result = AJFALSE; |
| 9227 | |
| 9228 | AjPStr columns = NULL; |
| 9229 | AjPStr fvsconstraint = NULL; |
| 9230 | AjPStr statement = NULL; |
| 9231 | |
| 9232 | EnsPBaseadaptor ba = NULL; |
| 9233 | |
| 9234 | if (!gvvfa) |
| 9235 | return ajFalse; |
| 9236 | |
| 9237 | if (!gvp) |
| 9238 | return ajFalse; |
| 9239 | |
| 9240 | if (!slice) |
| 9241 | return ajFalse; |
| 9242 | |
| 9243 | if (!gvvfs) |
| 9244 | return ajFalse; |
| 9245 | |
| 9246 | /* Adjust frequency if given a percentage. */ |
| 9247 | |
| 9248 | if (frequency > 1.0F) |
| 9249 | frequency /= 100.0F; |
| 9250 | |
| 9251 | /* Build the column expression. */ |
| 9252 | |
| 9253 | ba = ensGvvariationfeatureadaptorGetBaseadaptor(gvvfa); |
| 9254 | |
| 9255 | txtcolumns = ensBaseadaptorGetColumnnames(ba); |
| 9256 | |
| 9257 | columns = ajStrNew(); |
| 9258 | |
| 9259 | for (i = 0U; txtcolumns[i]; i++) |
| 9260 | ajFmtPrintAppS(&columns, "%s, ", txtcolumns[i]); |
| 9261 | |
| 9262 | /* Remove last comma and space from the column expression. */ |
| 9263 | |
| 9264 | ajStrCutEnd(&columns, 2); |
| 9265 | |
| 9266 | /* Build the final SQL statement. */ |
| 9267 | |
| 9268 | ensGvdatabaseadaptorFailedvariationsconstraint( |
| 9269 | ensGvvariationfeatureadaptorGetGvdatabaseadaptor(gvvfa), |
| 9270 | (const AjPStr) NULL, |
| 9271 | &fvsconstraint); |
| 9272 | |
| 9273 | statement = ajFmtStr( |
| 9274 | "SELECT " |
| 9275 | "%S " |
| 9276 | "FROM " |
| 9277 | "(" |
| 9278 | "variation_feature vf, " |
| 9279 | "source, " |
| 9280 | "allele a" |
| 9281 | ") " |
| 9282 | "LEFT JOIN " |
| 9283 | "failed_variation " |
| 9284 | "ON " |
| 9285 | "(variation_feature.variation_id = failed_variation.variation_id) " |
| 9286 | "WHERE " |
| 9287 | "variation_feature.source_id = source.source_id " |
| 9288 | "AND " |
| 9289 | "variation_feature.variation_id = allele.variation_id " |
| 9290 | "AND " |
| 9291 | "allele.sample_id = %u " |
| 9292 | "AND " |
| 9293 | "(" |
| 9294 | "IF(allele.frequency > 0.5, 1 - allele.frequency, allele.frequency) > " |
| 9295 | "%f" |
| 9296 | ") " |
| 9297 | "AND " |
| 9298 | "variation_feature.seq_region_id = %u " |
| 9299 | "AND " |
| 9300 | "variation_feature.seq_region_end > %d " |
| 9301 | "AND " |
| 9302 | "variation_feature.seq_region_start < %d " |
| 9303 | "AND " |
| 9304 | "%S " |
| 9305 | "GROUP BY " |
| 9306 | "allele.variation_id", |
| 9307 | columns, |
| 9308 | ensGvpopulationGetIdentifier(gvp), |
| 9309 | frequency, |
| 9310 | ensSliceGetSeqregionIdentifier(slice), |
| 9311 | ensSliceGetStart(slice), |
| 9312 | ensSliceGetEnd(slice), |
| 9313 | fvsconstraint); |
| 9314 | |
| 9315 | ajStrDel(&fvsconstraint); |
| 9316 | |
| 9317 | result = gvvariationfeatureadaptorFetchAllbyStatement( |
| 9318 | ba, |
| 9319 | statement, |
| 9320 | (EnsPAssemblymapper) NULL, |
| 9321 | (EnsPSlice) NULL, |
| 9322 | gvvfs); |
| 9323 | |
| 9324 | ajStrDel(&columns); |
| 9325 | ajStrDel(&statement); |
| 9326 | |
| 9327 | return result; |
| 9328 | } |
| 9329 | |
| 9330 | |
| 9331 | |
| 9332 | |
| 9333 | /* @func ensGvvariationfeatureadaptorFetchAllbyGvpopulation ******************* |
| 9334 | ** |
| 9335 | ** Fetch all Ensembl Genetic Variation Variation Feature objects associated |
| 9336 | ** with an Ensembl Genetic Variation Population on an Ensembl Slice. |
| 9337 | ** |
| 9338 | ** The caller is responsible for deleting the Ensembl Genetic Variation |
| 9339 | ** Variation Feature objects before deleting the AJAX List. |
| 9340 | ** |
| 9341 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationFeatureAdaptor:: |
| 9342 | ** fetch_all_by_Slice_Population |
| 9343 | ** @param [u] gvvfa [EnsPGvvariationfeatureadaptor] Ensembl Genetic |
| 9344 | ** Variation Variation Feature Adaptor |
| 9345 | ** @param [r] gvp [const EnsPGvpopulation] Ensembl Genetic Variation Population |
| 9346 | ** @param [u] slice [EnsPSlice] Ensembl Slice |
| 9347 | ** @param [u] gvvfs [AjPList] AJAX List of Ensembl Genetic Variation |
| 9348 | ** Variation Feature objects |
| 9349 | ** |
| 9350 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 9351 | ** |
| 9352 | ** @release 6.4.0 |
| 9353 | ** @@ |
| 9354 | ******************************************************************************/ |
| 9355 | |
| 9356 | AjBool ensGvvariationfeatureadaptorFetchAllbyGvpopulation( |
| 9357 | EnsPGvvariationfeatureadaptor gvvfa, |
| 9358 | const EnsPGvpopulation gvp, |
| 9359 | EnsPSlice slice, |
| 9360 | AjPList gvvfs) |
| 9361 | { |
| 9362 | const char *const *txtcolumns = NULL; |
| 9363 | |
| 9364 | register ajuint i = 0U; |
| 9365 | |
| 9366 | AjBool result = AJFALSE; |
| 9367 | |
| 9368 | AjPStr columns = NULL; |
| 9369 | AjPStr statement = NULL; |
| 9370 | |
| 9371 | EnsPBaseadaptor ba = NULL; |
| 9372 | |
| 9373 | if (!gvvfa) |
| 9374 | return ajFalse; |
| 9375 | |
| 9376 | if (!gvp) |
| 9377 | return ajFalse; |
| 9378 | |
| 9379 | if (!slice) |
| 9380 | return ajFalse; |
| 9381 | |
| 9382 | if (!gvvfs) |
| 9383 | return ajFalse; |
| 9384 | |
| 9385 | /* Build the column expression. */ |
| 9386 | |
| 9387 | ba = ensGvvariationfeatureadaptorGetBaseadaptor(gvvfa); |
| 9388 | |
| 9389 | txtcolumns = ensBaseadaptorGetColumnnames(ba); |
| 9390 | |
| 9391 | columns = ajStrNew(); |
| 9392 | |
| 9393 | for (i = 0U; txtcolumns[i]; i++) |
| 9394 | ajFmtPrintAppS(&columns, "%s, ", txtcolumns[i]); |
| 9395 | |
| 9396 | /* Remove last comma and space from the column expression. */ |
| 9397 | |
| 9398 | ajStrCutEnd(&columns, 2); |
| 9399 | |
| 9400 | /* Build the final SQL statement. */ |
| 9401 | |
| 9402 | statement = ajFmtStr( |
| 9403 | "SELECT " |
| 9404 | "%S " |
| 9405 | "FROM " |
| 9406 | "variation_feature vf, " |
| 9407 | "source, " |
| 9408 | "allele " |
| 9409 | "WHERE " |
| 9410 | "variation_feature.source_id = source.source_id " |
| 9411 | "AND " |
| 9412 | "variation_feature.variation_id = allele.variation_id " |
| 9413 | "AND " |
| 9414 | "allele.sample_id = %u " |
| 9415 | "AND " |
| 9416 | "variation_feature.seq_region_id = %u " |
| 9417 | "AND " |
| 9418 | "variation_feature.seq_region_end > %d " |
| 9419 | "AND " |
| 9420 | "variation_feature.seq_region_start < %d " |
| 9421 | "GROUP BY " |
| 9422 | "allele.variation_id", |
| 9423 | columns, |
| 9424 | ensGvpopulationGetIdentifier(gvp), |
| 9425 | ensSliceGetSeqregionIdentifier(slice), |
| 9426 | ensSliceGetStart(slice), |
| 9427 | ensSliceGetEnd(slice)); |
| 9428 | |
| 9429 | result = gvvariationfeatureadaptorFetchAllbyStatement( |
| 9430 | ba, |
| 9431 | statement, |
| 9432 | (EnsPAssemblymapper) NULL, |
| 9433 | (EnsPSlice) NULL, |
| 9434 | gvvfs); |
| 9435 | |
| 9436 | ajStrDel(&columns); |
| 9437 | ajStrDel(&statement); |
| 9438 | |
| 9439 | return result; |
| 9440 | } |
| 9441 | |
| 9442 | |
| 9443 | |
| 9444 | |
| 9445 | /* @func ensGvvariationfeatureadaptorFetchAllbyGvvariation ******************** |
| 9446 | ** |
| 9447 | ** Fetch all Ensembl Genetic Variation Variation Feature objects by an |
| 9448 | ** Ensembl Genetic Variation Variation. |
| 9449 | ** |
| 9450 | ** The caller is responsible for deleting the Ensembl Genetic Variation |
| 9451 | ** Variation Feature objects before deleting the AJAX List. |
| 9452 | ** |
| 9453 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationFeatureAdaptor:: |
| 9454 | ** fetch_all_by_Variation |
| 9455 | ** @param [u] gvvfa [EnsPGvvariationfeatureadaptor] Ensembl Genetic |
| 9456 | ** Variation Variation Feature Adaptor |
| 9457 | ** @param [r] gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 9458 | ** @param [u] gvvfs [AjPList] AJAX List of Ensembl Genetic Variation |
| 9459 | ** Variation Feature objects |
| 9460 | ** |
| 9461 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 9462 | ** |
| 9463 | ** @release 6.4.0 |
| 9464 | ** @@ |
| 9465 | ******************************************************************************/ |
| 9466 | |
| 9467 | AjBool ensGvvariationfeatureadaptorFetchAllbyGvvariation( |
| 9468 | EnsPGvvariationfeatureadaptor gvvfa, |
| 9469 | const EnsPGvvariation gvv, |
| 9470 | AjPList gvvfs) |
| 9471 | { |
| 9472 | AjBool result = AJFALSE; |
| 9473 | |
| 9474 | AjPStr constraint = NULL; |
| 9475 | |
| 9476 | if (!gvvfa) |
| 9477 | return ajFalse; |
| 9478 | |
| 9479 | if (!gvv) |
| 9480 | return ajFalse; |
| 9481 | |
| 9482 | if (!gvvfs) |
| 9483 | return ajFalse; |
| 9484 | |
| 9485 | constraint = ajFmtStr("variation_feature.variation_id = %u", |
| 9486 | ensGvvariationGetIdentifier(gvv)); |
| 9487 | |
| 9488 | result = ensBaseadaptorFetchAllbyConstraint( |
| 9489 | ensGvvariationfeatureadaptorGetBaseadaptor(gvvfa), |
| 9490 | constraint, |
| 9491 | (EnsPAssemblymapper) NULL, |
| 9492 | (EnsPSlice) NULL, |
| 9493 | gvvfs); |
| 9494 | |
| 9495 | ajStrDel(&constraint); |
| 9496 | |
| 9497 | return result; |
| 9498 | } |
| 9499 | |
| 9500 | |
| 9501 | |
| 9502 | |
| 9503 | /* @func ensGvvariationfeatureadaptorFetchAllbySliceAnnotated ***************** |
| 9504 | ** |
| 9505 | ** Fetch all Ensembl Genetic Variation Variation Feature objects associated |
| 9506 | ** with annotations on an Ensembl Slice. |
| 9507 | ** |
| 9508 | ** The caller is responsible for deleting the Ensembl Genetic Variation |
| 9509 | ** Variation Feature objects before deleting the AJAX List. |
| 9510 | ** |
| 9511 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationFeatureAdaptor:: |
| 9512 | ** _internal_fetch_all_with_annotation_by_Slice |
| 9513 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationFeatureAdaptor:: |
| 9514 | ** fetch_all_with_annotation_by_Slice |
| 9515 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationFeatureAdaptor:: |
| 9516 | ** fetch_all_somatic_with_annotation_by_Slice |
| 9517 | ** @param [u] gvvfa [EnsPGvvariationfeatureadaptor] Ensembl Genetic |
| 9518 | ** Variation Variation Feature Adaptor |
| 9519 | ** @param [r] vsource [const AjPStr] variation_feature source |
| 9520 | ** @param [r] psource [const AjPStr] annotation_source |
| 9521 | ** @param [r] annotation [const AjPStr] annotation_name |
| 9522 | ** @param [r] somatic [AjBool] Somatic (ajTrue) or germline (ajFalse) |
| 9523 | ** @param [u] slice [EnsPSlice] Ensembl Slice |
| 9524 | ** @param [u] gvvfs [AjPList] AJAX List of Ensembl Genetic Variation |
| 9525 | ** Variation Feature objects |
| 9526 | ** |
| 9527 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 9528 | ** |
| 9529 | ** @release 6.4.0 |
| 9530 | ** @@ |
| 9531 | ******************************************************************************/ |
| 9532 | |
| 9533 | AjBool ensGvvariationfeatureadaptorFetchAllbySliceAnnotated( |
| 9534 | EnsPGvvariationfeatureadaptor gvvfa, |
| 9535 | const AjPStr vsource, |
| 9536 | const AjPStr psource, |
| 9537 | const AjPStr annotation, |
| 9538 | AjBool somatic, |
| 9539 | EnsPSlice slice, |
| 9540 | AjPList gvvfs) |
| 9541 | { |
| 9542 | const char *const *txtcolumns = NULL; |
| 9543 | |
| 9544 | char *txtstring = NULL; |
| 9545 | |
| 9546 | register ajuint i = 0U; |
| 9547 | |
| 9548 | AjBool result = AJFALSE; |
| 9549 | |
| 9550 | AjPStr columns = NULL; |
| 9551 | AjPStr constraint = NULL; |
| 9552 | AjPStr fvsconstraint = NULL; |
| 9553 | AjPStr statement = NULL; |
| 9554 | |
| 9555 | EnsPBaseadaptor ba = NULL; |
| 9556 | |
| 9557 | ensGvdatabaseadaptorFailedvariationsconstraint( |
| 9558 | ensGvvariationfeatureadaptorGetGvdatabaseadaptor(gvvfa), |
| 9559 | (const AjPStr) NULL, |
| 9560 | &fvsconstraint); |
| 9561 | |
| 9562 | constraint = ajFmtStr( |
| 9563 | "vsource.somatic = %d AND %S", |
| 9564 | somatic, |
| 9565 | fvsconstraint); |
| 9566 | |
| 9567 | ajStrDel(&fvsconstraint); |
| 9568 | |
| 9569 | if (vsource && ajStrGetLen(vsource)) |
| 9570 | { |
| 9571 | ensFeatureadaptorEscapeC(gvvfa->Featureadaptor, &txtstring, vsource); |
| 9572 | |
| 9573 | ajFmtPrintAppS(&constraint, " AND vsource.name = '%s'", txtstring); |
| 9574 | |
| 9575 | ajCharDel(&txtstring); |
| 9576 | } |
| 9577 | |
| 9578 | if (psource && ajStrGetLen(psource)) |
| 9579 | { |
| 9580 | ensFeatureadaptorEscapeC(gvvfa->Featureadaptor, |
| 9581 | &txtstring, |
| 9582 | psource); |
| 9583 | |
| 9584 | ajFmtPrintAppS(&constraint, " AND psource.name = '%s'", txtstring); |
| 9585 | |
| 9586 | ajCharDel(&txtstring); |
| 9587 | } |
| 9588 | |
| 9589 | if (annotation && ajStrGetLen(annotation)) |
| 9590 | { |
| 9591 | ensFeatureadaptorEscapeC(gvvfa->Featureadaptor, |
| 9592 | &txtstring, |
| 9593 | annotation); |
| 9594 | |
| 9595 | if (ajStrIsNum(annotation)) |
| 9596 | ajFmtPrintAppS(&constraint, |
| 9597 | " AND phenotype.phenotype_id = %s", |
| 9598 | txtstring); |
| 9599 | else |
| 9600 | ajFmtPrintAppS(&constraint, |
| 9601 | " AND " |
| 9602 | "(" |
| 9603 | "phenotype.name = '%s' " |
| 9604 | "OR " |
| 9605 | "phenotype.description LIKE '%%%s%%'" |
| 9606 | ")", |
| 9607 | txtstring, |
| 9608 | txtstring); |
| 9609 | |
| 9610 | ajCharDel(&txtstring); |
| 9611 | } |
| 9612 | |
| 9613 | /* Build the column expression. */ |
| 9614 | |
| 9615 | ba = ensGvvariationfeatureadaptorGetBaseadaptor(gvvfa); |
| 9616 | |
| 9617 | txtcolumns = ensBaseadaptorGetColumnnames(ba); |
| 9618 | |
| 9619 | columns = ajStrNew(); |
| 9620 | |
| 9621 | for (i = 0U; txtcolumns[i]; i++) |
| 9622 | ajFmtPrintAppS(&columns, "%s, ", txtcolumns[i]); |
| 9623 | |
| 9624 | /* Remove last comma and space from the column expression. */ |
| 9625 | |
| 9626 | ajStrCutEnd(&columns, 2); |
| 9627 | |
| 9628 | /* Build the final SQL statement. */ |
| 9629 | |
| 9630 | statement = ajFmtStr( |
| 9631 | "SELECT " |
| 9632 | "%S " |
| 9633 | "FROM " |
| 9634 | "(" |
| 9635 | "variation_feature, " |
| 9636 | "variation_annotation, " |
| 9637 | "phenotype, " |
| 9638 | "source vsource, " |
| 9639 | "source psource" |
| 9640 | ")" |
| 9641 | "LEFT JOIN " |
| 9642 | "failed_variation " |
| 9643 | "ON " |
| 9644 | "(variation_feature.variation_id = failed_variation.variation_id) " |
| 9645 | "WHERE " |
| 9646 | "variation_annotation.source_id = psource.source_id " |
| 9647 | "AND " |
| 9648 | "variation_feature.source_id = vsource.source_id " |
| 9649 | "AND " |
| 9650 | "variation_feature.variation_id = variation_annotation.variation_id " |
| 9651 | "AND " |
| 9652 | "variation_annotation.phenotype_id = phenotype.phenotype_id " |
| 9653 | "%S " |
| 9654 | "AND " |
| 9655 | "variation_feature.seq_region_id = %u " |
| 9656 | "AND " |
| 9657 | "variation_feature.seq_region_end > %d " |
| 9658 | "AND " |
| 9659 | "variation_feature.seq_region_start < %d " |
| 9660 | "GROUP BY " |
| 9661 | "variation_feature.variation_feature_id", |
| 9662 | columns, |
| 9663 | constraint, |
| 9664 | ensSliceGetSeqregionIdentifier(slice), |
| 9665 | ensSliceGetStart(slice), |
| 9666 | ensSliceGetEnd(slice)); |
| 9667 | |
| 9668 | result = gvvariationfeatureadaptorFetchAllbyStatement( |
| 9669 | ba, |
| 9670 | statement, |
| 9671 | (EnsPAssemblymapper) NULL, |
| 9672 | (EnsPSlice) NULL, |
| 9673 | gvvfs); |
| 9674 | |
| 9675 | ajStrDel(&columns); |
| 9676 | ajStrDel(&constraint); |
| 9677 | ajStrDel(&statement); |
| 9678 | |
| 9679 | return result; |
| 9680 | } |
| 9681 | |
| 9682 | |
| 9683 | |
| 9684 | |
| 9685 | /* @func ensGvvariationfeatureadaptorFetchAllbySliceConstraint **************** |
| 9686 | ** |
| 9687 | ** Fetch all Ensembl Genetic Variation Variation Feature objects matching a |
| 9688 | ** SQL constraint on an Ensembl Slice. |
| 9689 | ** |
| 9690 | ** The caller is responsible for deleting the Ensembl Genetic Variation |
| 9691 | ** Variation Feature objects before deleting the AJAX List. |
| 9692 | ** |
| 9693 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationFeatureAdaptor:: |
| 9694 | ** fetch_all_by_Slice |
| 9695 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationFeatureAdaptor:: |
| 9696 | ** fetch_all_by_Slice_constraint |
| 9697 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationFeatureAdaptor:: |
| 9698 | ** fetch_all_somatic_by_Slice |
| 9699 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationFeatureAdaptor:: |
| 9700 | ** fetch_all_somatic_by_Slice_constraint |
| 9701 | ** @param [u] gvvfa [EnsPGvvariationfeatureadaptor] Ensembl Genetic Variation |
| 9702 | ** Variation Feature Adaptor |
| 9703 | ** @param [u] slice [EnsPSlice] Ensembl Slice |
| 9704 | ** @param [rN] constraint [const AjPStr] SQL constraint |
| 9705 | ** @param [r] somatic [AjBool] Somatic (ajTrue) or germline (ajFalse) |
| 9706 | ** @param [u] gvvfs [AjPList] AJAX List of Ensembl Genetic Variation |
| 9707 | ** Variation Feature objects |
| 9708 | ** |
| 9709 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 9710 | ** |
| 9711 | ** @release 6.4.0 |
| 9712 | ** @@ |
| 9713 | ******************************************************************************/ |
| 9714 | |
| 9715 | AjBool ensGvvariationfeatureadaptorFetchAllbySliceConstraint( |
| 9716 | EnsPGvvariationfeatureadaptor gvvfa, |
| 9717 | EnsPSlice slice, |
| 9718 | const AjPStr constraint, |
| 9719 | AjBool somatic, |
| 9720 | AjPList gvvfs) |
| 9721 | { |
| 9722 | AjBool result = AJFALSE; |
| 9723 | |
| 9724 | AjPStr fvsconstraint = NULL; |
| 9725 | AjPStr newconstraint = NULL; |
| 9726 | |
| 9727 | if (!gvvfa) |
| 9728 | return ajFalse; |
| 9729 | |
| 9730 | if (!slice) |
| 9731 | return ajFalse; |
| 9732 | |
| 9733 | if (!gvvfs) |
| 9734 | return ajFalse; |
| 9735 | |
| 9736 | ensGvdatabaseadaptorFailedvariationsconstraint( |
| 9737 | ensGvvariationfeatureadaptorGetGvdatabaseadaptor(gvvfa), |
| 9738 | (const AjPStr) NULL, |
| 9739 | &fvsconstraint); |
| 9740 | |
| 9741 | /* By default, filter out somatic mutations. */ |
| 9742 | |
| 9743 | if (constraint && ajStrGetLen(constraint)) |
| 9744 | newconstraint = ajFmtStr("%S AND source.somatic = %d AND %S", |
| 9745 | constraint, |
| 9746 | somatic, |
| 9747 | fvsconstraint); |
| 9748 | else |
| 9749 | newconstraint = ajFmtStr("source.somatic = %d AND %S", |
| 9750 | somatic, |
| 9751 | fvsconstraint); |
| 9752 | |
| 9753 | result = ensFeatureadaptorFetchAllbySlice( |
| 9754 | ensGvvariationfeatureadaptorGetFeatureadaptor(gvvfa), |
| 9755 | slice, |
| 9756 | newconstraint, |
| 9757 | (AjPStr) NULL, |
| 9758 | gvvfs); |
| 9759 | |
| 9760 | ajStrDel(&fvsconstraint); |
| 9761 | ajStrDel(&newconstraint); |
| 9762 | |
| 9763 | return result; |
| 9764 | } |
| 9765 | |
| 9766 | |
| 9767 | |
| 9768 | |
| 9769 | /* @func ensGvvariationfeatureadaptorFetchAllbySliceGenotyped ***************** |
| 9770 | ** |
| 9771 | ** Fetch all genotyped Ensembl Genetic Variation Variation Feature objects on |
| 9772 | ** an Ensembl Slice. |
| 9773 | ** |
| 9774 | ** The caller is responsible for deleting the Ensembl Genetic Variation |
| 9775 | ** Variation Feature objects before deleting the AJAX List. |
| 9776 | ** |
| 9777 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationFeatureAdaptor:: |
| 9778 | ** fetch_all_genotyped_by_Slice |
| 9779 | ** @param [u] gvvfa [EnsPGvvariationfeatureadaptor] Ensembl Genetic |
| 9780 | ** Variation Variation Feature Adaptor |
| 9781 | ** @param [u] slice [EnsPSlice] Ensembl Slice |
| 9782 | ** @param [u] gvvfs [AjPList] AJAX List of Ensembl Genetic Variation |
| 9783 | ** Variation Feature objects |
| 9784 | ** |
| 9785 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 9786 | ** |
| 9787 | ** @release 6.4.0 |
| 9788 | ** @@ |
| 9789 | ******************************************************************************/ |
| 9790 | |
| 9791 | AjBool ensGvvariationfeatureadaptorFetchAllbySliceGenotyped( |
| 9792 | EnsPGvvariationfeatureadaptor gvvfa, |
| 9793 | EnsPSlice slice, |
| 9794 | AjPList gvvfs) |
| 9795 | { |
| 9796 | AjBool result = AJFALSE; |
| 9797 | |
| 9798 | AjPStr constraint = NULL; |
| 9799 | |
| 9800 | if (!gvvfa) |
| 9801 | return ajFalse; |
| 9802 | |
| 9803 | if (!slice) |
| 9804 | return ajFalse; |
| 9805 | |
| 9806 | if (!gvvfs) |
| 9807 | return ajFalse; |
| 9808 | |
| 9809 | constraint = ajStrNewC("variation_feature.flags & 1"); |
| 9810 | |
| 9811 | result = ensGvvariationfeatureadaptorFetchAllbySliceConstraint( |
| 9812 | gvvfa, |
| 9813 | slice, |
| 9814 | constraint, |
| 9815 | ajTrue, |
| 9816 | gvvfs); |
| 9817 | |
| 9818 | ajStrDel(&constraint); |
| 9819 | |
| 9820 | return result; |
| 9821 | } |
| 9822 | |
| 9823 | |
| 9824 | |
| 9825 | |
| 9826 | /* @func ensGvvariationfeatureadaptorFetchByIdentifier ************************ |
| 9827 | ** |
| 9828 | ** Fetch an Ensembl Genetic Variation Variation Feature via its |
| 9829 | ** SQL database-internal identifier. |
| 9830 | ** |
| 9831 | ** The caller is responsible for deleting the Ensembl Exon. |
| 9832 | ** |
| 9833 | ** @cc Bio::EnsEMBL::DBSQL::BaseAdaptor::fetch_by_dbID |
| 9834 | ** @param [u] gvvfa [EnsPGvvariationfeatureadaptor] |
| 9835 | ** Ensembl Genetic Variation Variation Feature Adaptor |
| 9836 | ** @param [r] identifier [ajuint] SQL database-internal identifier |
| 9837 | ** @param [wP] Pgvvf [EnsPGvvariationfeature*] |
| 9838 | ** Ensembl Genetic Variation Variation Feature address |
| 9839 | ** |
| 9840 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 9841 | ** |
| 9842 | ** @release 6.4.0 |
| 9843 | ** @@ |
| 9844 | ******************************************************************************/ |
| 9845 | |
| 9846 | AjBool ensGvvariationfeatureadaptorFetchByIdentifier( |
| 9847 | EnsPGvvariationfeatureadaptor gvvfa, |
| 9848 | ajuint identifier, |
| 9849 | EnsPGvvariationfeature *Pgvvf) |
| 9850 | { |
| 9851 | return ensBaseadaptorFetchByIdentifier( |
| 9852 | ensGvvariationfeatureadaptorGetBaseadaptor(gvvfa), |
| 9853 | identifier, |
| 9854 | (void **) Pgvvf); |
| 9855 | } |
| 9856 | |
| 9857 | |
| 9858 | |
| 9859 | |
| 9860 | /* @section object retrieval ************************************************** |
| 9861 | ** |
| 9862 | ** Functions for retrieving Ensembl Genetic Variation Variation Feature- |
| 9863 | ** releated objects from an Ensembl SQL database. |
| 9864 | ** |
| 9865 | ** @fdata [EnsPGvvariationfeatureadaptor] |
| 9866 | ** |
| 9867 | ** @nam3rule Retrieve Retrieve Ensembl Genetic Variation Variation Feature- |
| 9868 | ** related object(s) |
| 9869 | ** @nam4rule All Retrieve all releated objects |
| 9870 | ** @nam5rule Identifiers Retrieve all SQL database-internal identifier objects |
| 9871 | ** |
| 9872 | ** @argrule * gvvfa [EnsPGvvariationfeatureadaptor] |
| 9873 | ** Ensembl Genetic Variation Variation Feature Adaptor |
| 9874 | ** @argrule AllIdentifiers identifiers [AjPList] |
| 9875 | ** AJAX List of AJAX unsigned integer |
| 9876 | ** (Ensembl Genetic Variation Variation Feature identifier) objects |
| 9877 | ** |
| 9878 | ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise |
| 9879 | ** |
| 9880 | ** @fcategory use |
| 9881 | ******************************************************************************/ |
| 9882 | |
| 9883 | |
| 9884 | |
| 9885 | |
| 9886 | /* @func ensGvvariationfeatureadaptorRetrieveAllIdentifiers ******************* |
| 9887 | ** |
| 9888 | ** Retrieve all SQL database-internal identifier objects of |
| 9889 | ** Ensembl Genetic Variation Variation Feature objects. |
| 9890 | ** |
| 9891 | ** The caller is responsible for deleting the AJAX unsigned integers before |
| 9892 | ** deleting the AJAX List. |
| 9893 | ** |
| 9894 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationFeatureAdaptor::list_dbIDs |
| 9895 | ** @param [u] gvvfa [EnsPGvvariationfeatureadaptor] |
| 9896 | ** Ensembl Genetic Variation Variation Feature Adaptor |
| 9897 | ** @param [u] identifiers [AjPList] |
| 9898 | ** AJAX List of AJAX unsigned integer |
| 9899 | ** (Ensembl Genetic Variation Variation Feature identifier) objects |
| 9900 | ** |
| 9901 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 9902 | ** |
| 9903 | ** @release 6.4.0 |
| 9904 | ** @@ |
| 9905 | ******************************************************************************/ |
| 9906 | |
| 9907 | AjBool ensGvvariationfeatureadaptorRetrieveAllIdentifiers( |
| 9908 | EnsPGvvariationfeatureadaptor gvvfa, |
| 9909 | AjPList identifiers) |
| 9910 | { |
| 9911 | AjBool result = AJFALSE; |
| 9912 | |
| 9913 | AjPStr table = NULL; |
| 9914 | |
| 9915 | if (!gvvfa) |
| 9916 | return ajFalse; |
| 9917 | |
| 9918 | if (!identifiers) |
| 9919 | return ajFalse; |
| 9920 | |
| 9921 | table = ajStrNewC("variation_feature"); |
| 9922 | |
| 9923 | result = ensBaseadaptorRetrieveAllIdentifiers( |
| 9924 | ensGvvariationfeatureadaptorGetBaseadaptor(gvvfa), |
| 9925 | table, |
| 9926 | (AjPStr) NULL, |
| 9927 | identifiers); |
| 9928 | |
| 9929 | ajStrDel(&table); |
| 9930 | |
| 9931 | return result; |
| 9932 | } |
| 9933 | |
| 9934 | |
| 9935 | |
| 9936 | |
| 9937 | /* @datasection [EnsPGvvariationset] Ensembl Genetic Variation Variation Set ** |
| 9938 | ** |
| 9939 | ** @nam2rule Gvvariationset Functions for manipulating |
| 9940 | ** Ensembl Genetic Variation Variation Set objects |
| 9941 | ** |
| 9942 | ** @cc Bio::EnsEMBL::Variation::VariationSet |
| 9943 | ** @cc CVS Revision: 1.10 |
| 9944 | ** @cc CVS Tag: branch-ensembl-68 |
| 9945 | ** |
| 9946 | ******************************************************************************/ |
| 9947 | |
| 9948 | |
| 9949 | |
| 9950 | |
| 9951 | /* @section constructors ****************************************************** |
| 9952 | ** |
| 9953 | ** All constructors return a new Ensembl Genetic Variation Variation Set |
| 9954 | ** by pointer. |
| 9955 | ** It is the responsibility of the user to first destroy any previous |
| 9956 | ** Genetic Variation Variation Set. The target pointer does not need to be |
| 9957 | ** initialised to NULL, but it is good programming practice to do so anyway. |
| 9958 | ** |
| 9959 | ** @fdata [EnsPGvvariationset] |
| 9960 | ** |
| 9961 | ** @nam3rule New Constructor |
| 9962 | ** @nam4rule Cpy Constructor with existing object |
| 9963 | ** @nam4rule Ini Constructor with initial values |
| 9964 | ** @nam4rule Ref Constructor by incrementing the reference counter |
| 9965 | ** |
| 9966 | ** @argrule Cpy gvvs [const EnsPGvvariationset] Ensembl Genetic Variation |
| 9967 | ** Variation Set |
| 9968 | ** @argrule Ini gvvsa [EnsPGvvariationsetadaptor] Ensembl Genetic Variation |
| 9969 | ** Variation Set Adaptor |
| 9970 | ** @argrule Ini identifier [ajuint] SQL database-internal identifier |
| 9971 | ** @argrule Ini name [AjPStr] Name |
| 9972 | ** @argrule Ini description [AjPStr] Description |
| 9973 | ** @argrule Ini shortname [AjPStr] Short name |
| 9974 | ** @argrule Ref gvvs [EnsPGvvariationset] |
| 9975 | ** Ensembl Genetic Variation Variation Set |
| 9976 | ** |
| 9977 | ** @valrule * [EnsPGvvariationset] |
| 9978 | ** Ensembl Genetic Variation Variation Set or NULL |
| 9979 | ** |
| 9980 | ** @fcategory new |
| 9981 | ******************************************************************************/ |
| 9982 | |
| 9983 | |
| 9984 | |
| 9985 | |
| 9986 | /* @func ensGvvariationsetNewCpy ********************************************** |
| 9987 | ** |
| 9988 | ** Object-based constructor function, which returns an independent object. |
| 9989 | ** |
| 9990 | ** @param [r] gvvs [const EnsPGvvariationset] |
| 9991 | ** Ensembl Genetic Variation Variation Set |
| 9992 | ** |
| 9993 | ** @return [EnsPGvvariationset] Ensembl Genetic Variation Variation Set or NULL |
| 9994 | ** |
| 9995 | ** @release 6.4.0 |
| 9996 | ** @@ |
| 9997 | ******************************************************************************/ |
| 9998 | |
| 9999 | EnsPGvvariationset ensGvvariationsetNewCpy(const EnsPGvvariationset gvvs) |
| 10000 | { |
| 10001 | EnsPGvvariationset pthis = NULL; |
| 10002 | |
| 10003 | if (!gvvs) |
| 10004 | return NULL; |
| 10005 | |
| 10006 | AJNEW0(pthis); |
| 10007 | |
| 10008 | pthis->Use = 1U; |
| 10009 | pthis->Identifier = gvvs->Identifier; |
| 10010 | pthis->Adaptor = gvvs->Adaptor; |
| 10011 | |
| 10012 | if (gvvs->Name) |
| 10013 | pthis->Name = ajStrNewRef(gvvs->Name); |
| 10014 | |
| 10015 | if (gvvs->Description) |
| 10016 | pthis->Description = ajStrNewRef(gvvs->Description); |
| 10017 | |
| 10018 | if (gvvs->Shortname) |
| 10019 | pthis->Shortname = ajStrNewRef(gvvs->Shortname); |
| 10020 | |
| 10021 | return pthis; |
| 10022 | } |
| 10023 | |
| 10024 | |
| 10025 | |
| 10026 | |
| 10027 | /* @func ensGvvariationsetNewIni ********************************************** |
| 10028 | ** |
| 10029 | ** Constructor for an Ensembl Genetic Variation Variation Set with initial |
| 10030 | ** values. |
| 10031 | ** |
| 10032 | ** @cc Bio::EnsEMBL::Storable::new |
| 10033 | ** @param [uN] gvvsa [EnsPGvvariationsetadaptor] |
| 10034 | ** Ensembl Genetic Variation Variation Set Adaptor |
| 10035 | ** @param [r] identifier [ajuint] SQL database-internal identifier |
| 10036 | ** @cc Bio::EnsEMBL::Variation::VariationSet::new |
| 10037 | ** @param [u] name [AjPStr] Name |
| 10038 | ** @param [u] description [AjPStr] Description |
| 10039 | ** @param [u] shortname [AjPStr] Short name |
| 10040 | ** |
| 10041 | ** @return [EnsPGvvariationset] Ensembl Genetic Variation Variation Set or NULL |
| 10042 | ** |
| 10043 | ** @release 6.4.0 |
| 10044 | ** @@ |
| 10045 | ******************************************************************************/ |
| 10046 | |
| 10047 | EnsPGvvariationset ensGvvariationsetNewIni(EnsPGvvariationsetadaptor gvvsa, |
| 10048 | ajuint identifier, |
| 10049 | AjPStr name, |
| 10050 | AjPStr description, |
| 10051 | AjPStr shortname) |
| 10052 | { |
| 10053 | EnsPGvvariationset gvvs = NULL; |
| 10054 | |
| 10055 | if (!name) |
| 10056 | return NULL; |
| 10057 | |
| 10058 | if (!description) |
| 10059 | return NULL; |
| 10060 | |
| 10061 | AJNEW0(gvvs); |
| 10062 | |
| 10063 | gvvs->Use = 1U; |
| 10064 | gvvs->Identifier = identifier; |
| 10065 | gvvs->Adaptor = gvvsa; |
| 10066 | |
| 10067 | if (name) |
| 10068 | gvvs->Name = ajStrNewS(name); |
| 10069 | |
| 10070 | if (description) |
| 10071 | gvvs->Description = ajStrNewS(description); |
| 10072 | |
| 10073 | if (shortname) |
| 10074 | gvvs->Shortname = ajStrNewS(shortname); |
| 10075 | |
| 10076 | return gvvs; |
| 10077 | } |
| 10078 | |
| 10079 | |
| 10080 | |
| 10081 | |
| 10082 | /* @func ensGvvariationsetNewRef ********************************************** |
| 10083 | ** |
| 10084 | ** Ensembl Object referencing function, which returns a pointer to the |
| 10085 | ** Ensembl Object passed in and increases its reference count. |
| 10086 | ** |
| 10087 | ** @param [u] gvvs [EnsPGvvariationset] Ensembl Genetic Variation Variation Set |
| 10088 | ** |
| 10089 | ** @return [EnsPGvvariationset] Ensembl Genetic Variation Variation Set or NULL |
| 10090 | ** |
| 10091 | ** @release 6.4.0 |
| 10092 | ** @@ |
| 10093 | ******************************************************************************/ |
| 10094 | |
| 10095 | EnsPGvvariationset ensGvvariationsetNewRef(EnsPGvvariationset gvvs) |
| 10096 | { |
| 10097 | if (!gvvs) |
| 10098 | return NULL; |
| 10099 | |
| 10100 | gvvs->Use++; |
| 10101 | |
| 10102 | return gvvs; |
| 10103 | } |
| 10104 | |
| 10105 | |
| 10106 | |
| 10107 | |
| 10108 | /* @section destructors ******************************************************* |
| 10109 | ** |
| 10110 | ** Destruction destroys all internal data structures and frees the memory |
| 10111 | ** allocated for an Ensembl Genetic Variation Variation Set object. |
| 10112 | ** |
| 10113 | ** @fdata [EnsPGvvariationset] |
| 10114 | ** |
| 10115 | ** @nam3rule Del Destroy (free) an |
| 10116 | ** Ensembl Genetic Variation Variation Set |
| 10117 | ** |
| 10118 | ** @argrule * Pgvvs [EnsPGvvariationset*] |
| 10119 | ** Ensembl Genetic Variation Variation Set address |
| 10120 | ** |
| 10121 | ** @valrule * [void] |
| 10122 | ** |
| 10123 | ** @fcategory delete |
| 10124 | ******************************************************************************/ |
| 10125 | |
| 10126 | |
| 10127 | |
| 10128 | |
| 10129 | /* @func ensGvvariationsetDel ************************************************* |
| 10130 | ** |
| 10131 | ** Default destructor for an Ensembl Genetic Variation Variation Set. |
| 10132 | ** |
| 10133 | ** @param [d] Pgvvs [EnsPGvvariationset*] |
| 10134 | ** Ensembl Genetic Variation Variation Set address |
| 10135 | ** |
| 10136 | ** @return [void] |
| 10137 | ** |
| 10138 | ** @release 6.4.0 |
| 10139 | ** @@ |
| 10140 | ******************************************************************************/ |
| 10141 | |
| 10142 | void ensGvvariationsetDel(EnsPGvvariationset *Pgvvs) |
| 10143 | { |
| 10144 | EnsPGvvariationset pthis = NULL; |
| 10145 | |
| 10146 | if (!Pgvvs) |
| 10147 | return; |
| 10148 | |
| 10149 | #if defined(AJ_DEBUG) && AJ_DEBUG >= 1 |
| 10150 | if (ajDebugTest("ensGvvariationsetDel")) |
| 10151 | { |
| 10152 | ajDebug("ensGvvariationsetDel\n" |
| 10153 | " *Pgvvs %p\n", |
| 10154 | *Pgvvs); |
| 10155 | |
| 10156 | ensGvvariationsetTrace(*Pgvvs, 1); |
| 10157 | } |
| 10158 | #endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 1 */ |
| 10159 | |
| 10160 | if (!(pthis = *Pgvvs) || --pthis->Use) |
| 10161 | { |
| 10162 | *Pgvvs = NULL; |
| 10163 | |
| 10164 | return; |
| 10165 | } |
| 10166 | |
| 10167 | ajStrDel(&pthis->Name); |
| 10168 | ajStrDel(&pthis->Description); |
| 10169 | ajStrDel(&pthis->Shortname); |
| 10170 | |
| 10171 | ajMemFree((void **) Pgvvs); |
| 10172 | |
| 10173 | return; |
| 10174 | } |
| 10175 | |
| 10176 | |
| 10177 | |
| 10178 | |
| 10179 | /* @section member retrieval ************************************************** |
| 10180 | ** |
| 10181 | ** Functions for returning members of an |
| 10182 | ** Ensembl Genetic Variation Set object. |
| 10183 | ** |
| 10184 | ** @fdata [EnsPGvvariationset] |
| 10185 | ** |
| 10186 | ** @nam3rule Get Return Genetic Variation Variation Set attribute(s) |
| 10187 | ** @nam4rule Adaptor |
| 10188 | ** Return the Ensembl Genetic Variation Variation Set Adaptor |
| 10189 | ** @nam4rule Identifier Return the SQL database-internal identifier |
| 10190 | ** @nam4rule Name Return the name |
| 10191 | ** @nam4rule Description Return the description |
| 10192 | ** @nam4rule Shortname Return the short name |
| 10193 | ** |
| 10194 | ** @argrule * gvvs [const EnsPGvvariationset] |
| 10195 | ** Ensembl Genetic Variation Variation Set |
| 10196 | ** |
| 10197 | ** @valrule Adaptor [EnsPGvvariationsetadaptor] |
| 10198 | ** Ensembl Genetic Variation Variation Set Adaptor or NULL |
| 10199 | ** @valrule Description [AjPStr] Description or NULL |
| 10200 | ** @valrule Identifier [ajuint] SQL database-internal identifier or 0U |
| 10201 | ** @valrule Name [AjPStr] Name or NULL |
| 10202 | ** @valrule Shortname [AjPStr] Short name or NULL |
| 10203 | ** |
| 10204 | ** @fcategory use |
| 10205 | ******************************************************************************/ |
| 10206 | |
| 10207 | |
| 10208 | |
| 10209 | |
| 10210 | /* @func ensGvvariationsetGetAdaptor ****************************************** |
| 10211 | ** |
| 10212 | ** Get the Ensembl Genetic Variation Variation Set Adaptor member of an |
| 10213 | ** Ensembl Genetic Variation Variation Set. |
| 10214 | ** |
| 10215 | ** @cc Bio::EnsEMBL::Storable::adaptor |
| 10216 | ** @param [r] gvvs [const EnsPGvvariationset] |
| 10217 | ** Ensembl Genetic Variation Variation Set |
| 10218 | ** |
| 10219 | ** @return [EnsPGvvariationsetadaptor] |
| 10220 | ** Ensembl Genetic Variation Variation Set Adaptor or NULL |
| 10221 | ** |
| 10222 | ** @release 6.4.0 |
| 10223 | ** @@ |
| 10224 | ******************************************************************************/ |
| 10225 | |
| 10226 | EnsPGvvariationsetadaptor ensGvvariationsetGetAdaptor( |
| 10227 | const EnsPGvvariationset gvvs) |
| 10228 | { |
| 10229 | return (gvvs) ? gvvs->Adaptor : NULL; |
| 10230 | } |
| 10231 | |
| 10232 | |
| 10233 | |
| 10234 | |
| 10235 | /* @func ensGvvariationsetGetDescription ************************************** |
| 10236 | ** |
| 10237 | ** Get the description member of an Ensembl Genetic Variation Variation Set. |
| 10238 | ** |
| 10239 | ** @param [r] gvvs [const EnsPGvvariationset] |
| 10240 | ** Ensembl Genetic Variation Variation Set |
| 10241 | ** |
| 10242 | ** @return [AjPStr] Description or NULL |
| 10243 | ** |
| 10244 | ** @release 6.4.0 |
| 10245 | ** @@ |
| 10246 | ******************************************************************************/ |
| 10247 | |
| 10248 | AjPStr ensGvvariationsetGetDescription( |
| 10249 | const EnsPGvvariationset gvvs) |
| 10250 | { |
| 10251 | return (gvvs) ? gvvs->Description : NULL; |
| 10252 | } |
| 10253 | |
| 10254 | |
| 10255 | |
| 10256 | |
| 10257 | /* @func ensGvvariationsetGetIdentifier *************************************** |
| 10258 | ** |
| 10259 | ** Get the SQL database-internal identifier member of an |
| 10260 | ** Ensembl Genetic Variation Variation Set. |
| 10261 | ** |
| 10262 | ** @cc Bio::EnsEMBL::Storable::dbID |
| 10263 | ** @param [r] gvvs [const EnsPGvvariationset] |
| 10264 | ** Ensembl Genetic Variation Variation Set |
| 10265 | ** |
| 10266 | ** @return [ajuint] SQL database-internal identifier or 0U |
| 10267 | ** |
| 10268 | ** @release 6.4.0 |
| 10269 | ** @@ |
| 10270 | ******************************************************************************/ |
| 10271 | |
| 10272 | ajuint ensGvvariationsetGetIdentifier( |
| 10273 | const EnsPGvvariationset gvvs) |
| 10274 | { |
| 10275 | return (gvvs) ? gvvs->Identifier : 0U; |
| 10276 | } |
| 10277 | |
| 10278 | |
| 10279 | |
| 10280 | |
| 10281 | /* @func ensGvvariationsetGetName ********************************************* |
| 10282 | ** |
| 10283 | ** Get the name member of an Ensembl Genetic Variation Variation Set. |
| 10284 | ** |
| 10285 | ** @param [r] gvvs [const EnsPGvvariationset] |
| 10286 | ** Ensembl Genetic Variation Variation Set |
| 10287 | ** |
| 10288 | ** @return [AjPStr] Name or NULL |
| 10289 | ** |
| 10290 | ** @release 6.4.0 |
| 10291 | ** @@ |
| 10292 | ******************************************************************************/ |
| 10293 | |
| 10294 | AjPStr ensGvvariationsetGetName( |
| 10295 | const EnsPGvvariationset gvvs) |
| 10296 | { |
| 10297 | return (gvvs) ? gvvs->Name : NULL; |
| 10298 | } |
| 10299 | |
| 10300 | |
| 10301 | |
| 10302 | |
| 10303 | /* @func ensGvvariationsetGetShortname **************************************** |
| 10304 | ** |
| 10305 | ** Get the short name member of an Ensembl Genetic Variation Variation Set. |
| 10306 | ** |
| 10307 | ** @param [r] gvvs [const EnsPGvvariationset] |
| 10308 | ** Ensembl Genetic Variation Variation Set |
| 10309 | ** |
| 10310 | ** @return [AjPStr] Short name or NULL |
| 10311 | ** |
| 10312 | ** @release 6.4.0 |
| 10313 | ** @@ |
| 10314 | ******************************************************************************/ |
| 10315 | |
| 10316 | AjPStr ensGvvariationsetGetShortname( |
| 10317 | const EnsPGvvariationset gvvs) |
| 10318 | { |
| 10319 | return (gvvs) ? gvvs->Shortname : NULL; |
| 10320 | } |
| 10321 | |
| 10322 | |
| 10323 | |
| 10324 | |
| 10325 | /* @section member assignment ************************************************* |
| 10326 | ** |
| 10327 | ** Functions for assigning members of an |
| 10328 | ** Ensembl Genetic Variation Variation Set object. |
| 10329 | ** |
| 10330 | ** @fdata [EnsPGvvariationset] |
| 10331 | ** |
| 10332 | ** @nam3rule Set Set one member of a Genetic Variation Variation Set |
| 10333 | ** @nam4rule Adaptor |
| 10334 | ** Set the Ensembl Genetic Variation Variation Set Adaptor |
| 10335 | ** @nam4rule Description Set the description |
| 10336 | ** @nam4rule Identifier Set the SQL database-internal identifier |
| 10337 | ** @nam4rule Name Set the name |
| 10338 | ** @nam4rule Shortname Set the short name |
| 10339 | ** |
| 10340 | ** @argrule * gvvs [EnsPGvvariationset] |
| 10341 | ** Ensembl Genetic Variation Variation Set object |
| 10342 | ** @argrule Adaptor gvvsa [EnsPGvvariationsetadaptor] |
| 10343 | ** Ensembl Genetic Variation Variation Set Adaptor |
| 10344 | ** @argrule Description description [AjPStr] Description |
| 10345 | ** @argrule Identifier identifier [ajuint] SQL database-internal identifier |
| 10346 | ** @argrule Name name [AjPStr] Name |
| 10347 | ** @argrule Shortname shortname [AjPStr] Short name |
| 10348 | ** |
| 10349 | ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise |
| 10350 | ** |
| 10351 | ** @fcategory modify |
| 10352 | ******************************************************************************/ |
| 10353 | |
| 10354 | |
| 10355 | |
| 10356 | |
| 10357 | /* @func ensGvvariationsetSetAdaptor ****************************************** |
| 10358 | ** |
| 10359 | ** Set the Ensembl Genetic Variation Variation Set Adaptor member of an |
| 10360 | ** Ensembl Genetic Variation Variation Set. |
| 10361 | ** |
| 10362 | ** @param [u] gvvs [EnsPGvvariationset] |
| 10363 | ** Ensembl Genetic Variation Variation Set |
| 10364 | ** @param [u] gvvsa [EnsPGvvariationsetadaptor] |
| 10365 | ** Ensembl Genetic Variation Variation Set Adaptor |
| 10366 | ** |
| 10367 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 10368 | ** |
| 10369 | ** @release 6.4.0 |
| 10370 | ** @@ |
| 10371 | ******************************************************************************/ |
| 10372 | |
| 10373 | AjBool ensGvvariationsetSetAdaptor(EnsPGvvariationset gvvs, |
| 10374 | EnsPGvvariationsetadaptor gvvsa) |
| 10375 | { |
| 10376 | if (!gvvs) |
| 10377 | return ajFalse; |
| 10378 | |
| 10379 | gvvs->Adaptor = gvvsa; |
| 10380 | |
| 10381 | return ajTrue; |
| 10382 | } |
| 10383 | |
| 10384 | |
| 10385 | |
| 10386 | |
| 10387 | /* @func ensGvvariationsetSetDescription ************************************** |
| 10388 | ** |
| 10389 | ** Set the description member of an |
| 10390 | ** Ensembl Genetic Variation Variation Set. |
| 10391 | ** |
| 10392 | ** @param [u] gvvs [EnsPGvvariationset] |
| 10393 | ** Ensembl Genetic Variation Variation Set |
| 10394 | ** @param [u] description [AjPStr] Description |
| 10395 | ** |
| 10396 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 10397 | ** |
| 10398 | ** @release 6.4.0 |
| 10399 | ** @@ |
| 10400 | ******************************************************************************/ |
| 10401 | |
| 10402 | AjBool ensGvvariationsetSetDescription(EnsPGvvariationset gvvs, |
| 10403 | AjPStr description) |
| 10404 | { |
| 10405 | if (!gvvs) |
| 10406 | return ajFalse; |
| 10407 | |
| 10408 | ajStrDel(&gvvs->Description); |
| 10409 | |
| 10410 | if (description) |
| 10411 | gvvs->Description = ajStrNewRef(description); |
| 10412 | |
| 10413 | return ajTrue; |
| 10414 | } |
| 10415 | |
| 10416 | |
| 10417 | |
| 10418 | |
| 10419 | /* @func ensGvvariationsetSetIdentifier *************************************** |
| 10420 | ** |
| 10421 | ** Set the SQL database-internal identifier member of an |
| 10422 | ** Ensembl Genetic Variation Variation Set. |
| 10423 | ** |
| 10424 | ** @param [u] gvvs [EnsPGvvariationset] |
| 10425 | ** Ensembl Genetic Variation Variation Set |
| 10426 | ** @param [r] identifier [ajuint] SQL database-internal identifier |
| 10427 | ** |
| 10428 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 10429 | ** |
| 10430 | ** @release 6.4.0 |
| 10431 | ** @@ |
| 10432 | ******************************************************************************/ |
| 10433 | |
| 10434 | AjBool ensGvvariationsetSetIdentifier(EnsPGvvariationset gvvs, |
| 10435 | ajuint identifier) |
| 10436 | { |
| 10437 | if (!gvvs) |
| 10438 | return ajFalse; |
| 10439 | |
| 10440 | gvvs->Identifier = identifier; |
| 10441 | |
| 10442 | return ajTrue; |
| 10443 | } |
| 10444 | |
| 10445 | |
| 10446 | |
| 10447 | |
| 10448 | /* @func ensGvvariationsetSetName ********************************************* |
| 10449 | ** |
| 10450 | ** Set the name member of an |
| 10451 | ** Ensembl Genetic Variation Variation Set. |
| 10452 | ** |
| 10453 | ** @param [u] gvvs [EnsPGvvariationset] |
| 10454 | ** Ensembl Genetic Variation Variation Set |
| 10455 | ** @param [u] name [AjPStr] Name |
| 10456 | ** |
| 10457 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 10458 | ** |
| 10459 | ** @release 6.4.0 |
| 10460 | ** @@ |
| 10461 | ******************************************************************************/ |
| 10462 | |
| 10463 | AjBool ensGvvariationsetSetName(EnsPGvvariationset gvvs, |
| 10464 | AjPStr name) |
| 10465 | { |
| 10466 | if (!gvvs) |
| 10467 | return ajFalse; |
| 10468 | |
| 10469 | ajStrDel(&gvvs->Name); |
| 10470 | |
| 10471 | if (name) |
| 10472 | gvvs->Name = ajStrNewRef(name); |
| 10473 | |
| 10474 | return ajTrue; |
| 10475 | } |
| 10476 | |
| 10477 | |
| 10478 | |
| 10479 | |
| 10480 | /* @func ensGvvariationsetSetShortname **************************************** |
| 10481 | ** |
| 10482 | ** Set the short name member of an |
| 10483 | ** Ensembl Genetic Variation Variation Set. |
| 10484 | ** |
| 10485 | ** @param [u] gvvs [EnsPGvvariationset] |
| 10486 | ** Ensembl Genetic Variation Variation Set |
| 10487 | ** @param [u] shortname [AjPStr] Short name |
| 10488 | ** |
| 10489 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 10490 | ** |
| 10491 | ** @release 6.4.0 |
| 10492 | ** @@ |
| 10493 | ******************************************************************************/ |
| 10494 | |
| 10495 | AjBool ensGvvariationsetSetShortname(EnsPGvvariationset gvvs, |
| 10496 | AjPStr shortname) |
| 10497 | { |
| 10498 | if (!gvvs) |
| 10499 | return ajFalse; |
| 10500 | |
| 10501 | ajStrDel(&gvvs->Shortname); |
| 10502 | |
| 10503 | if (shortname) |
| 10504 | gvvs->Shortname = ajStrNewRef(shortname); |
| 10505 | |
| 10506 | return ajTrue; |
| 10507 | } |
| 10508 | |
| 10509 | |
| 10510 | |
| 10511 | |
| 10512 | /* @section debugging ********************************************************* |
| 10513 | ** |
| 10514 | ** Functions for reporting of an |
| 10515 | ** Ensembl Genetic Variation Variation Set object. |
| 10516 | ** |
| 10517 | ** @fdata [EnsPGvvariationset] |
| 10518 | ** |
| 10519 | ** @nam3rule Trace Report Ensembl Genetic Variation Variation Set members |
| 10520 | ** to debug file |
| 10521 | ** |
| 10522 | ** @argrule Trace gvvs [const EnsPGvvariationset] |
| 10523 | ** Ensembl Genetic Variation Variation Set |
| 10524 | ** @argrule Trace level [ajuint] Indentation level |
| 10525 | ** |
| 10526 | ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise |
| 10527 | ** |
| 10528 | ** @fcategory misc |
| 10529 | ******************************************************************************/ |
| 10530 | |
| 10531 | |
| 10532 | |
| 10533 | |
| 10534 | /* @func ensGvvariationsetTrace *********************************************** |
| 10535 | ** |
| 10536 | ** Trace an Ensembl Genetic Variation Variation Set. |
| 10537 | ** |
| 10538 | ** @param [r] gvvs [const EnsPGvvariationset] |
| 10539 | ** Ensembl Genetic Variation Variation Set |
| 10540 | ** @param [r] level [ajuint] Indentation level |
| 10541 | ** |
| 10542 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 10543 | ** |
| 10544 | ** @release 6.4.0 |
| 10545 | ** @@ |
| 10546 | ******************************************************************************/ |
| 10547 | |
| 10548 | AjBool ensGvvariationsetTrace(const EnsPGvvariationset gvvs, |
| 10549 | ajuint level) |
| 10550 | { |
| 10551 | AjPStr indent = NULL; |
| 10552 | |
| 10553 | if (!gvvs) |
| 10554 | return ajFalse; |
| 10555 | |
| 10556 | indent = ajStrNew(); |
| 10557 | |
| 10558 | ajStrAppendCountK(&indent, ' ', level * 2); |
| 10559 | |
| 10560 | ajDebug("%SensGvvariationsetTrace %p\n" |
| 10561 | "%S Use %u\n" |
| 10562 | "%S Identifier %u\n" |
| 10563 | "%S Adaptor %p\n" |
| 10564 | "%S Name '%S'\n" |
| 10565 | "%S Description '%S'\n" |
| 10566 | "%S Shortname '%S'\n", |
| 10567 | indent, gvvs, |
| 10568 | indent, gvvs->Use, |
| 10569 | indent, gvvs->Identifier, |
| 10570 | indent, gvvs->Adaptor, |
| 10571 | indent, gvvs->Name, |
| 10572 | indent, gvvs->Description, |
| 10573 | indent, gvvs->Shortname); |
| 10574 | |
| 10575 | ajStrDel(&indent); |
| 10576 | |
| 10577 | return ajTrue; |
| 10578 | } |
| 10579 | |
| 10580 | |
| 10581 | |
| 10582 | |
| 10583 | /* @section calculate ********************************************************* |
| 10584 | ** |
| 10585 | ** Functions for calculating information from an |
| 10586 | ** Ensembl Genetic Variation Variation Set object. |
| 10587 | ** |
| 10588 | ** @fdata [EnsPGvvariationset] |
| 10589 | ** |
| 10590 | ** @nam3rule Calculate |
| 10591 | ** Calculate Ensembl Genetic Variation Variation Set information |
| 10592 | ** @nam4rule Memsize Calculate the memory size in bytes |
| 10593 | ** |
| 10594 | ** @argrule * gvvs [const EnsPGvvariationset] |
| 10595 | ** Ensembl Genetic Variation Variation Set |
| 10596 | ** |
| 10597 | ** @valrule Memsize [size_t] Memory size in bytes or 0 |
| 10598 | ** |
| 10599 | ** @fcategory misc |
| 10600 | ******************************************************************************/ |
| 10601 | |
| 10602 | |
| 10603 | |
| 10604 | |
| 10605 | /* @func ensGvvariationsetCalculateMemsize ************************************ |
| 10606 | ** |
| 10607 | ** Calculate the memory size in bytes of an |
| 10608 | ** Ensembl Genetic Variation Variation Set. |
| 10609 | ** |
| 10610 | ** @param [r] gvvs [const EnsPGvvariationset] |
| 10611 | ** Ensembl Genetic Variation Variation Set |
| 10612 | ** |
| 10613 | ** @return [size_t] Memory size in bytes or 0 |
| 10614 | ** |
| 10615 | ** @release 6.4.0 |
| 10616 | ** @@ |
| 10617 | ******************************************************************************/ |
| 10618 | |
| 10619 | size_t ensGvvariationsetCalculateMemsize(const EnsPGvvariationset gvvs) |
| 10620 | { |
| 10621 | size_t size = 0; |
| 10622 | |
| 10623 | if (!gvvs) |
| 10624 | return 0; |
| 10625 | |
| 10626 | size += sizeof (EnsOGvvariationset); |
| 10627 | |
| 10628 | if (gvvs->Name) |
| 10629 | { |
| 10630 | size += sizeof (AjOStr); |
| 10631 | |
| 10632 | size += ajStrGetRes(gvvs->Name); |
| 10633 | } |
| 10634 | |
| 10635 | if (gvvs->Description) |
| 10636 | { |
| 10637 | size += sizeof (AjOStr); |
| 10638 | |
| 10639 | size += ajStrGetRes(gvvs->Description); |
| 10640 | } |
| 10641 | |
| 10642 | if (gvvs->Shortname) |
| 10643 | { |
| 10644 | size += sizeof (AjOStr); |
| 10645 | |
| 10646 | size += ajStrGetRes(gvvs->Shortname); |
| 10647 | } |
| 10648 | |
| 10649 | return size; |
| 10650 | } |
| 10651 | |
| 10652 | |
| 10653 | |
| 10654 | |
| 10655 | /* @section fetch ************************************************************* |
| 10656 | ** |
| 10657 | ** Functions for fetching information from an |
| 10658 | ** Ensembl Genetic Variation Variation Set object. |
| 10659 | ** |
| 10660 | ** @fdata [EnsPGvvariationset] |
| 10661 | ** |
| 10662 | ** @nam3rule Fetch Fetch Ensembl Genetic Variation Variation Set information |
| 10663 | ** @nam4rule All Fetch all objects |
| 10664 | ** @nam5rule Gvvariations Fetch all Ensembl Genetic Variation Variation objects |
| 10665 | ** @nam5rule Sub Fetch sub-Ensembl Genetic Variation Variation Set objects |
| 10666 | ** @nam5rule Super Fetch super-Ensembl Genetic Variation Variation Set objects |
| 10667 | ** |
| 10668 | ** @argrule * gvvs [EnsPGvvariationset] |
| 10669 | ** Ensembl Genetic Variation Variation Set |
| 10670 | ** @argrule Sub immediate [AjBool] Only immediate |
| 10671 | ** @argrule Super immediate [AjBool] Only immediate |
| 10672 | ** @argrule * gvvss [AjPList] |
| 10673 | ** AJAX List of Ensembl Genetic Variation Variation Set objects |
| 10674 | ** |
| 10675 | ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise |
| 10676 | ** |
| 10677 | ** @fcategory misc |
| 10678 | ******************************************************************************/ |
| 10679 | |
| 10680 | |
| 10681 | |
| 10682 | |
| 10683 | /* @func ensGvvariationsetFetchAllGvvariations ******************************** |
| 10684 | ** |
| 10685 | ** Recursively fetch all Ensembl Genetic Variation Variation Set objects, which |
| 10686 | ** belong to this Ensembl Genetic Variation Variation Set and all subsets. |
| 10687 | ** |
| 10688 | ** The caller is responsible for deleting the |
| 10689 | ** Ensembl Genetic Variation Variation objects before deleting the AJAX List. |
| 10690 | ** |
| 10691 | ** @cc Bio::EnsEMBL::Variation::VariationSet::get_all_Variations |
| 10692 | ** @param [u] gvvs [EnsPGvvariationset] |
| 10693 | ** Ensembl Genetic Variation Variation Set |
| 10694 | ** @param [u] gvvss [AjPList] |
| 10695 | ** AJAX List of Ensembl Genetic Variation Variation objects |
| 10696 | ** |
| 10697 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 10698 | ** |
| 10699 | ** @release 6.4.0 |
| 10700 | ** @@ |
| 10701 | ******************************************************************************/ |
| 10702 | |
| 10703 | AjBool ensGvvariationsetFetchAllGvvariations( |
| 10704 | EnsPGvvariationset gvvs, |
| 10705 | AjPList gvvss) |
| 10706 | { |
| 10707 | if (!gvvs) |
| 10708 | return ajFalse; |
| 10709 | |
| 10710 | if (!gvvss) |
| 10711 | return ajFalse; |
| 10712 | |
| 10713 | return ensGvvariationadaptorFetchAllbyGvvariationset( |
| 10714 | ensRegistryGetGvvariationadaptor( |
| 10715 | ensGvvariationsetadaptorGetDatabaseadaptor(gvvs->Adaptor)), |
| 10716 | gvvs, |
| 10717 | gvvss); |
| 10718 | } |
| 10719 | |
| 10720 | |
| 10721 | |
| 10722 | |
| 10723 | /* @func ensGvvariationsetFetchAllSub ***************************************** |
| 10724 | ** |
| 10725 | ** Recursively fetch all Ensembl Genetic Variation Variation Set objects, which |
| 10726 | ** are subsets of this Ensembl Genetic Variation Variation Set. |
| 10727 | ** |
| 10728 | ** The caller is responsible for deleting the |
| 10729 | ** Ensembl Genetic Variation Variation Set objects before deleting the |
| 10730 | ** AJAX List. |
| 10731 | ** |
| 10732 | ** @cc Bio::EnsEMBL::Variation::VariationSet::get_all_sub_VariationSets |
| 10733 | ** @param [u] gvvs [EnsPGvvariationset] Ensembl Genetic Variation Variation Set |
| 10734 | ** @param [r] immediate [AjBool] ajTrue: only the direct subsets of this |
| 10735 | ** variation set will be fetched |
| 10736 | ** ajFalse: recursively fetch all subsets |
| 10737 | ** @param [u] gvvss [AjPList] |
| 10738 | ** AJAX List of Ensembl Genetic Variation Variation Set objects |
| 10739 | ** |
| 10740 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 10741 | ** |
| 10742 | ** @release 6.4.0 |
| 10743 | ** @@ |
| 10744 | ******************************************************************************/ |
| 10745 | |
| 10746 | AjBool ensGvvariationsetFetchAllSub(EnsPGvvariationset gvvs, |
| 10747 | AjBool immediate, |
| 10748 | AjPList gvvss) |
| 10749 | { |
| 10750 | if (!gvvs) |
| 10751 | return ajFalse; |
| 10752 | |
| 10753 | if (!gvvss) |
| 10754 | return ajFalse; |
| 10755 | |
| 10756 | return ensGvvariationsetadaptorFetchAllbySuper( |
| 10757 | gvvs->Adaptor, |
| 10758 | gvvs, |
| 10759 | immediate, |
| 10760 | gvvss); |
| 10761 | } |
| 10762 | |
| 10763 | |
| 10764 | |
| 10765 | |
| 10766 | /* @func ensGvvariationsetFetchAllSuper *************************************** |
| 10767 | ** |
| 10768 | ** Recursively fetch all Ensembl Genetic Variation Variation Set objects, which |
| 10769 | ** are supersets of this Ensembl Genetic Variation Variation Set. |
| 10770 | ** |
| 10771 | ** The caller is responsible for deleting the |
| 10772 | ** Ensembl Genetic Variation Variation Set objects before deleting the |
| 10773 | ** AJAX List. |
| 10774 | ** |
| 10775 | ** @cc Bio::EnsEMBL::Variation::VariationSet::get_all_sub_VariationSets |
| 10776 | ** @param [u] gvvs [EnsPGvvariationset] Ensembl Genetic Variation Variation Set |
| 10777 | ** @param [r] immediate [AjBool] ajTrue: only the direct supersets of this |
| 10778 | ** variation set will be fetched |
| 10779 | ** ajFalse: recursively fetch all supersets |
| 10780 | ** @param [u] gvvss [AjPList] AJAX List of Ensembl Genetic Variation |
| 10781 | ** Variation Set objects |
| 10782 | ** |
| 10783 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 10784 | ** |
| 10785 | ** @release 6.4.0 |
| 10786 | ** @@ |
| 10787 | ******************************************************************************/ |
| 10788 | |
| 10789 | AjBool ensGvvariationsetFetchAllSuper(EnsPGvvariationset gvvs, |
| 10790 | AjBool immediate, |
| 10791 | AjPList gvvss) |
| 10792 | { |
| 10793 | if (!gvvs) |
| 10794 | return ajFalse; |
| 10795 | |
| 10796 | if (!gvvss) |
| 10797 | return ajFalse; |
| 10798 | |
| 10799 | return ensGvvariationsetadaptorFetchAllbySub( |
| 10800 | gvvs->Adaptor, |
| 10801 | gvvs, |
| 10802 | immediate, |
| 10803 | gvvss); |
| 10804 | } |
| 10805 | |
| 10806 | |
| 10807 | |
| 10808 | |
| 10809 | /* @datasection [EnsPGvvariationsetadaptor] Ensembl Genetic Variation Variation |
| 10810 | ** Set Adaptor |
| 10811 | ** |
| 10812 | ** @nam2rule Gvvariationsetadaptor Functions for manipulating |
| 10813 | ** Ensembl Genetic Variation Variation Set Adaptor objects |
| 10814 | ** |
| 10815 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationSetAdaptor |
| 10816 | ** @cc CVS Revision: 1.10 |
| 10817 | ** @cc CVS Tag: branch-ensembl-68 |
| 10818 | ** |
| 10819 | ******************************************************************************/ |
| 10820 | |
| 10821 | |
| 10822 | |
| 10823 | |
| 10824 | /* @funcstatic gvvariationsetadaptorFetchAllbyStatement *********************** |
| 10825 | ** |
| 10826 | ** Run a SQL statement against an Ensembl Database Adaptor and consolidate the |
| 10827 | ** results into an AJAX List of Ensembl Genetic Variation Variation Set |
| 10828 | ** objects. |
| 10829 | ** |
| 10830 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationSetAdaptor::_objs_from_sth |
| 10831 | ** @param [u] ba [EnsPBaseadaptor] Ensembl Base Adaptor |
| 10832 | ** @param [r] statement [const AjPStr] SQL statement |
| 10833 | ** @param [uN] am [EnsPAssemblymapper] Ensembl Assembly Mapper |
| 10834 | ** @param [uN] slice [EnsPSlice] Ensembl Slice |
| 10835 | ** @param [u] gvvss [AjPList] |
| 10836 | ** AJAX List of Ensembl Genetic Variation Variation Set objects |
| 10837 | ** |
| 10838 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 10839 | ** |
| 10840 | ** @release 6.4.0 |
| 10841 | ** @@ |
| 10842 | ******************************************************************************/ |
| 10843 | |
| 10844 | static AjBool gvvariationsetadaptorFetchAllbyStatement( |
| 10845 | EnsPBaseadaptor ba, |
| 10846 | const AjPStr statement, |
| 10847 | EnsPAssemblymapper am, |
| 10848 | EnsPSlice slice, |
| 10849 | AjPList gvvss) |
| 10850 | { |
| 10851 | ajuint identifier = 0U; |
| 10852 | ajuint attributeid = 0U; |
| 10853 | |
| 10854 | AjPSqlstatement sqls = NULL; |
| 10855 | AjISqlrow sqli = NULL; |
| 10856 | AjPSqlrow sqlr = NULL; |
| 10857 | |
| 10858 | AjPStr name = NULL; |
| 10859 | AjPStr description = NULL; |
| 10860 | |
| 10861 | EnsPDatabaseadaptor dba = NULL; |
| 10862 | |
| 10863 | EnsPGvattribute gva = NULL; |
| 10864 | EnsPGvattributeadaptor gvaa = NULL; |
| 10865 | |
| 10866 | EnsPGvvariationset gvvs = NULL; |
| 10867 | EnsPGvvariationsetadaptor gvvsa = NULL; |
| 10868 | |
| 10869 | if (ajDebugTest("gvvariationsetadaptorFetchAllbyStatement")) |
| 10870 | ajDebug("gvvariationsetadaptorFetchAllbyStatement\n" |
| 10871 | " ba %p\n" |
| 10872 | " statement %p\n" |
| 10873 | " am %p\n" |
| 10874 | " slice %p\n" |
| 10875 | " gvvss %p\n", |
| 10876 | ba, |
| 10877 | statement, |
| 10878 | am, |
| 10879 | slice, |
| 10880 | gvvss); |
| 10881 | |
| 10882 | if (!ba) |
| 10883 | return ajFalse; |
| 10884 | |
| 10885 | if (!statement) |
| 10886 | return ajFalse; |
| 10887 | |
| 10888 | if (!gvvss) |
| 10889 | return ajFalse; |
| 10890 | |
| 10891 | dba = ensBaseadaptorGetDatabaseadaptor(ba); |
| 10892 | |
| 10893 | gvaa = ensRegistryGetGvattributeadaptor(dba); |
| 10894 | gvvsa = ensRegistryGetGvvariationsetadaptor(dba); |
| 10895 | |
| 10896 | sqls = ensDatabaseadaptorSqlstatementNew(dba, statement); |
| 10897 | |
| 10898 | sqli = ajSqlrowiterNew(sqls); |
| 10899 | |
| 10900 | while (!ajSqlrowiterDone(sqli)) |
| 10901 | { |
| 10902 | identifier = 0U; |
| 10903 | name = ajStrNew(); |
| 10904 | description = ajStrNew(); |
| 10905 | attributeid = 0U; |
| 10906 | |
| 10907 | sqlr = ajSqlrowiterGet(sqli); |
| 10908 | |
| 10909 | ajSqlcolumnToUint(sqlr, &identifier); |
| 10910 | ajSqlcolumnToStr(sqlr, &name); |
| 10911 | ajSqlcolumnToStr(sqlr, &description); |
| 10912 | ajSqlcolumnToUint(sqlr, &attributeid); |
| 10913 | |
| 10914 | ensGvattributeadaptorFetchByIdentifier(gvaa, attributeid, &gva); |
| 10915 | |
| 10916 | gvvs = ensGvvariationsetNewIni(gvvsa, |
| 10917 | identifier, |
| 10918 | name, |
| 10919 | description, |
| 10920 | ensGvattributeGetValue(gva)); |
| 10921 | |
| 10922 | ajListPushAppend(gvvss, (void *) gvvs); |
| 10923 | |
| 10924 | ensGvattributeDel(&gva); |
| 10925 | |
| 10926 | ajStrDel(&name); |
| 10927 | ajStrDel(&description); |
| 10928 | } |
| 10929 | |
| 10930 | ajSqlrowiterDel(&sqli); |
| 10931 | |
| 10932 | ensDatabaseadaptorSqlstatementDel(dba, &sqls); |
| 10933 | |
| 10934 | return ajTrue; |
| 10935 | } |
| 10936 | |
| 10937 | |
| 10938 | |
| 10939 | |
| 10940 | /* @section constructors ****************************************************** |
| 10941 | ** |
| 10942 | ** All constructors return a new Ensembl Genetic Variation Variation Set |
| 10943 | ** Adaptor by pointer. |
| 10944 | ** It is the responsibility of the user to first destroy any previous |
| 10945 | ** Genetic Variation Variation Set Adaptor. |
| 10946 | ** The target pointer does not need to be initialised to NULL, |
| 10947 | ** but it is good programming practice to do so anyway. |
| 10948 | ** |
| 10949 | ** @fdata [EnsPGvvariationsetadaptor] |
| 10950 | ** |
| 10951 | ** @nam3rule New Constructor |
| 10952 | ** |
| 10953 | ** @argrule New dba [EnsPDatabaseadaptor] Ensembl Database Adaptor |
| 10954 | ** |
| 10955 | ** @valrule * [EnsPGvvariationsetadaptor] |
| 10956 | ** Ensembl Genetic Variation Variation Set Adaptor or NULL |
| 10957 | ** |
| 10958 | ** @fcategory new |
| 10959 | ******************************************************************************/ |
| 10960 | |
| 10961 | |
| 10962 | |
| 10963 | |
| 10964 | /* @func ensGvvariationsetadaptorNew ****************************************** |
| 10965 | ** |
| 10966 | ** Default constructor for an Ensembl Genetic Variation Variation Set Adaptor. |
| 10967 | ** |
| 10968 | ** Ensembl Object Adaptors are singleton objects in the sense that a single |
| 10969 | ** instance of an Ensembl Object Adaptor connected to a particular database is |
| 10970 | ** sufficient to instantiate any number of Ensembl Objects from the database. |
| 10971 | ** Each Ensembl Object will have a weak reference to the Object Adaptor that |
| 10972 | ** instantiated it. Therefore, Ensembl Object Adaptors should not be |
| 10973 | ** instantiated directly, but rather obtained from the Ensembl Registry, |
| 10974 | ** which will in turn call this function if neccessary. |
| 10975 | ** |
| 10976 | ** @see ensRegistryGetDatabaseadaptor |
| 10977 | ** @see ensRegistryGetGvvariationsetadaptor |
| 10978 | ** |
| 10979 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationSetAdaptor::new |
| 10980 | ** @param [u] dba [EnsPDatabaseadaptor] Ensembl Database Adaptor |
| 10981 | ** |
| 10982 | ** @return [EnsPGvvariationsetadaptor] |
| 10983 | ** Ensembl Genetic Variation Variation Set Adaptor or NULL |
| 10984 | ** |
| 10985 | ** @release 6.4.0 |
| 10986 | ** @@ |
| 10987 | ******************************************************************************/ |
| 10988 | |
| 10989 | EnsPGvvariationsetadaptor ensGvvariationsetadaptorNew( |
| 10990 | EnsPDatabaseadaptor dba) |
| 10991 | { |
| 10992 | return ensBaseadaptorNew( |
| 10993 | dba, |
| 10994 | gvvariationsetadaptorKTablenames, |
| 10995 | gvvariationsetadaptorKColumnnames, |
| 10996 | (const EnsPBaseadaptorLeftjoin) NULL, |
| 10997 | (const char *) NULL, |
| 10998 | (const char *) NULL, |
| 10999 | &gvvariationsetadaptorFetchAllbyStatement); |
| 11000 | } |
| 11001 | |
| 11002 | |
| 11003 | |
| 11004 | |
| 11005 | /* @section destructors ******************************************************* |
| 11006 | ** |
| 11007 | ** Destruction destroys all internal data structures and frees the memory |
| 11008 | ** allocated for an Ensembl Genetic Variation Variation Set Adaptor object. |
| 11009 | ** |
| 11010 | ** @fdata [EnsPGvvariationsetadaptor] |
| 11011 | ** |
| 11012 | ** @nam3rule Del Destroy (free) an |
| 11013 | ** Ensembl Genetic Variation Variation Set Adaptor |
| 11014 | ** |
| 11015 | ** @argrule * Pgvvsa [EnsPGvvariationsetadaptor*] |
| 11016 | ** Ensembl Genetic Variation Variation Set Adaptor address |
| 11017 | ** |
| 11018 | ** @valrule * [void] |
| 11019 | ** |
| 11020 | ** @fcategory delete |
| 11021 | ******************************************************************************/ |
| 11022 | |
| 11023 | |
| 11024 | |
| 11025 | |
| 11026 | /* @func ensGvvariationsetadaptorDel ****************************************** |
| 11027 | ** |
| 11028 | ** Default destructor for an Ensembl Genetic Variation Variation Set Adaptor. |
| 11029 | ** |
| 11030 | ** Ensembl Object Adaptors are singleton objects that are registered in the |
| 11031 | ** Ensembl Registry and weakly referenced by Ensembl Objects that have been |
| 11032 | ** instantiated by it. Therefore, Ensembl Object Adaptors should never be |
| 11033 | ** destroyed directly. Upon exit, the Ensembl Registry will call this function |
| 11034 | ** if required. |
| 11035 | ** |
| 11036 | ** @param [d] Pgvvsa [EnsPGvvariationsetadaptor*] |
| 11037 | ** Ensembl Genetic Variation Variation Set Adaptor address |
| 11038 | ** |
| 11039 | ** @return [void] |
| 11040 | ** |
| 11041 | ** @release 6.4.0 |
| 11042 | ** @@ |
| 11043 | ******************************************************************************/ |
| 11044 | |
| 11045 | void ensGvvariationsetadaptorDel(EnsPGvvariationsetadaptor *Pgvvsa) |
| 11046 | { |
| 11047 | ensBaseadaptorDel(Pgvvsa); |
| 11048 | |
| 11049 | return; |
| 11050 | } |
| 11051 | |
| 11052 | |
| 11053 | |
| 11054 | |
| 11055 | /* @section member retrieval ************************************************** |
| 11056 | ** |
| 11057 | ** Functions for returning members of an |
| 11058 | ** Ensembl Genetic Variation Variation Set Adaptor object. |
| 11059 | ** |
| 11060 | ** @fdata [EnsPGvvariationsetadaptor] |
| 11061 | ** |
| 11062 | ** @nam3rule Get |
| 11063 | ** Return Ensembl Genetic Variation Variation Set Adaptor attribute(s) |
| 11064 | ** @nam4rule Baseadaptor Return the Ensembl Base Adaptor |
| 11065 | ** @nam4rule Databaseadaptor Return the Ensembl Database Adaptor |
| 11066 | ** |
| 11067 | ** @argrule * gvvsa [EnsPGvvariationsetadaptor] |
| 11068 | ** Ensembl Genetic Variation Variation Set Adaptor |
| 11069 | ** |
| 11070 | ** @valrule Baseadaptor [EnsPBaseadaptor] |
| 11071 | ** Ensembl Base Adaptor or NULL |
| 11072 | ** @valrule Databaseadaptor [EnsPDatabaseadaptor] |
| 11073 | ** Ensembl Database Adaptor or NULL |
| 11074 | ** |
| 11075 | ** @fcategory use |
| 11076 | ******************************************************************************/ |
| 11077 | |
| 11078 | |
| 11079 | |
| 11080 | |
| 11081 | /* @func ensGvvariationsetadaptorGetBaseadaptor ******************************* |
| 11082 | ** |
| 11083 | ** Get the Ensembl Base Adaptor member of an |
| 11084 | ** Ensembl Genetic Variation Variation Set Adaptor. |
| 11085 | ** |
| 11086 | ** @param [u] gvvsa [EnsPGvvariationsetadaptor] |
| 11087 | ** Ensembl Genetic Variation Variation Set Adaptor |
| 11088 | ** |
| 11089 | ** @return [EnsPBaseadaptor] Ensembl Base Adaptor or NULL |
| 11090 | ** |
| 11091 | ** @release 6.5.0 |
| 11092 | ** @@ |
| 11093 | ******************************************************************************/ |
| 11094 | |
| 11095 | EnsPBaseadaptor ensGvvariationsetadaptorGetBaseadaptor( |
| 11096 | EnsPGvvariationsetadaptor gvvsa) |
| 11097 | { |
| 11098 | return gvvsa; |
| 11099 | } |
| 11100 | |
| 11101 | |
| 11102 | |
| 11103 | |
| 11104 | /* @func ensGvvariationsetadaptorGetDatabaseadaptor *************************** |
| 11105 | ** |
| 11106 | ** Get the Ensembl Database Adaptor member of an |
| 11107 | ** Ensembl Genetic Variation Variation Set Adaptor. |
| 11108 | ** |
| 11109 | ** @param [u] gvvsa [EnsPGvvariationsetadaptor] |
| 11110 | ** Ensembl Genetic Variation Variation Set Adaptor |
| 11111 | ** |
| 11112 | ** @return [EnsPDatabaseadaptor] Ensembl Database Adaptor or NULL |
| 11113 | ** |
| 11114 | ** @release 6.5.0 |
| 11115 | ** @@ |
| 11116 | ******************************************************************************/ |
| 11117 | |
| 11118 | EnsPDatabaseadaptor ensGvvariationsetadaptorGetDatabaseadaptor( |
| 11119 | EnsPGvvariationsetadaptor gvvsa) |
| 11120 | { |
| 11121 | return ensBaseadaptorGetDatabaseadaptor( |
| 11122 | ensGvvariationsetadaptorGetBaseadaptor(gvvsa)); |
| 11123 | } |
| 11124 | |
| 11125 | |
| 11126 | |
| 11127 | |
| 11128 | /* @section object retrieval ************************************************** |
| 11129 | ** |
| 11130 | ** Functions for fetching Ensembl Genetic Variation Variation Set objects |
| 11131 | ** from an Ensembl SQL database. |
| 11132 | ** |
| 11133 | ** @fdata [EnsPGvvariationsetadaptor] |
| 11134 | ** |
| 11135 | ** @nam3rule Fetch Fetch Ensembl Genetic Variation Variation Set object(s) |
| 11136 | ** @nam4rule All Fetch all Ensembl Genetic Variation Variation Set objects |
| 11137 | ** @nam5rule Toplevel Fetch all top-level Ensembl Genetic Variation Variation |
| 11138 | ** Set objects |
| 11139 | ** @nam4rule Allby Fetch all Ensembl Genetic Variation Variation Set objects |
| 11140 | ** matching a criterion |
| 11141 | ** @nam5rule Gvvariation Fetch all by an Ensembl Genetic Variation Variation |
| 11142 | ** @nam5rule Sub Fetch all by a sub-Ensembl Genetic Variation Variation Set |
| 11143 | ** @nam5rule Super Fetch all by a super-Ensembl Genetic Variation Variation Set |
| 11144 | ** @nam4rule By Fetch one Ensembl Genetic Variation Variation Set object |
| 11145 | ** matching a criterion |
| 11146 | ** @nam5rule Identifier Fetch by an SQL database-internal identifier |
| 11147 | ** @nam5rule Name Fetch by a name |
| 11148 | ** @nam5rule Shortname Fetch by a short name |
| 11149 | ** |
| 11150 | ** @argrule * gvvsa [EnsPGvvariationsetadaptor] |
| 11151 | ** Ensembl Genetic Variation Variation Set Adaptor |
| 11152 | ** @argrule All gvvss [AjPList] |
| 11153 | ** AJAX List of Ensembl Genetic Variation Variation Set objects |
| 11154 | ** @argrule Gvvariation gvv [const EnsPGvvariation] |
| 11155 | ** Ensembl Genetic Variation Variation |
| 11156 | ** @argrule AllbySub gvvs [const EnsPGvvariationset] |
| 11157 | ** Ensembl Genetic Variation Variation Set |
| 11158 | ** @argrule AllbySub immediate [AjBool] only direct sub-sets |
| 11159 | ** @argrule AllbySuper gvvs [const EnsPGvvariationset] |
| 11160 | ** Ensembl Genetic Variation Variation Set |
| 11161 | ** @argrule AllbySuper immediate [AjBool] only direct super-sets |
| 11162 | ** @argrule Allby gvvss [AjPList] |
| 11163 | ** AJAX List of Ensembl Genetic Variation Variation Set objects |
| 11164 | ** @argrule Identifier identifier [ajuint] SQL database-internal identifier |
| 11165 | ** @argrule Name name [const AjPStr] Name |
| 11166 | ** @argrule Shortname shortname [const AjPStr] Short name |
| 11167 | ** @argrule By Pgvvs [EnsPGvvariationset*] |
| 11168 | ** Ensembl Genetic Variation Variation Set address |
| 11169 | ** |
| 11170 | ** @valrule * [AjBool] ajTrue upon success, ajFalse otherwise |
| 11171 | ** |
| 11172 | ** @fcategory use |
| 11173 | ******************************************************************************/ |
| 11174 | |
| 11175 | |
| 11176 | |
| 11177 | |
| 11178 | /* @func ensGvvariationsetadaptorFetchAllToplevel ***************************** |
| 11179 | ** |
| 11180 | ** Fetch all top-level Ensembl Genetic Variation Variation Set objects, which |
| 11181 | ** are not sub-sets of any other Ensembl Genetic Variation Variation Set. |
| 11182 | ** |
| 11183 | ** The caller is responsible for deleting the |
| 11184 | ** Ensembl Genetic Variation Variation Set objects before deleting the |
| 11185 | ** AJAX List. |
| 11186 | ** |
| 11187 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationSetAdaptor:: |
| 11188 | ** fetch_all_top_VariationSets |
| 11189 | ** @param [u] gvvsa [EnsPGvvariationsetadaptor] Ensembl Genetic Variation |
| 11190 | ** Variation Set Adaptor |
| 11191 | ** @param [u] gvvss [AjPList] AJAX List of Ensembl Genetic Variation |
| 11192 | ** Variation Set objects |
| 11193 | ** |
| 11194 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 11195 | ** |
| 11196 | ** @release 6.4.0 |
| 11197 | ** @@ |
| 11198 | ******************************************************************************/ |
| 11199 | |
| 11200 | AjBool ensGvvariationsetadaptorFetchAllToplevel( |
| 11201 | EnsPGvvariationsetadaptor gvvsa, |
| 11202 | AjPList gvvss) |
| 11203 | { |
| 11204 | AjBool result = AJFALSE; |
| 11205 | |
| 11206 | AjPStr constraint = NULL; |
| 11207 | |
| 11208 | if (!gvvss) |
| 11209 | return ajFalse; |
| 11210 | |
| 11211 | if (!gvvss) |
| 11212 | return ajFalse; |
| 11213 | |
| 11214 | constraint = ajStrNewC( |
| 11215 | "NOT EXISTS " |
| 11216 | "(" |
| 11217 | "SELECT " |
| 11218 | "* " |
| 11219 | "FROM " |
| 11220 | "variation_set_structure " |
| 11221 | "WHERE " |
| 11222 | "variation_set_structure.variation_set_sub = " |
| 11223 | "variation_set.variation_set_id " |
| 11224 | ")"); |
| 11225 | |
| 11226 | result = ensBaseadaptorFetchAllbyConstraint( |
| 11227 | ensGvvariationsetadaptorGetBaseadaptor(gvvsa), |
| 11228 | constraint, |
| 11229 | (EnsPAssemblymapper) NULL, |
| 11230 | (EnsPSlice) NULL, |
| 11231 | gvvss); |
| 11232 | |
| 11233 | ajStrDel(&constraint); |
| 11234 | |
| 11235 | return result; |
| 11236 | } |
| 11237 | |
| 11238 | |
| 11239 | |
| 11240 | |
| 11241 | /* @funcstatic listGvvariationsetCompareIdentifierAscending ******************* |
| 11242 | ** |
| 11243 | ** AJAX List comparison function to sort Ensembl Genetic Variation Variation |
| 11244 | ** Set objects by identifier in ascending order. |
| 11245 | ** |
| 11246 | ** @param [r] item1 [const void*] Ensembl Genetic Variation Variation Set 1 |
| 11247 | ** @param [r] item2 [const void*] Ensembl Genetic Variation Variation Set 2 |
| 11248 | ** @see ajListSort |
| 11249 | ** @see ajListSortUnique |
| 11250 | ** |
| 11251 | ** @return [int] The comparison function returns an integer less than, |
| 11252 | ** equal to, or greater than zero if the first argument is |
| 11253 | ** considered to be respectively less than, equal to, or |
| 11254 | ** greater than the second. |
| 11255 | ** |
| 11256 | ** @release 6.4.0 |
| 11257 | ** @@ |
| 11258 | ******************************************************************************/ |
| 11259 | |
| 11260 | static int listGvvariationsetCompareIdentifierAscending( |
| 11261 | const void *item1, |
| 11262 | const void *item2) |
| 11263 | { |
| 11264 | int result = 0; |
| 11265 | |
| 11266 | EnsPGvvariationset gvvs1 = *(EnsOGvvariationset *const *) item1; |
| 11267 | EnsPGvvariationset gvvs2 = *(EnsOGvvariationset *const *) item2; |
| 11268 | |
| 11269 | if (ajDebugTest("gvvariationsetlistCompare")) |
| 11270 | ajDebug("gvvariationsetlistCompare\n" |
| 11271 | " gvvs1 %p\n" |
| 11272 | " gvvs2 %p\n", |
| 11273 | gvvs1, |
| 11274 | gvvs2); |
| 11275 | |
| 11276 | if (gvvs1->Identifier < gvvs2->Identifier) |
| 11277 | result = -1; |
| 11278 | |
| 11279 | if (gvvs1->Identifier > gvvs2->Identifier) |
| 11280 | result = +1; |
| 11281 | |
| 11282 | return result; |
| 11283 | } |
| 11284 | |
| 11285 | |
| 11286 | |
| 11287 | |
| 11288 | /* @funcstatic listGvvariationsetDelete *************************************** |
| 11289 | ** |
| 11290 | ** ajListSortUnique "itemdel" function to delete Ensembl Genetic Variation |
| 11291 | ** Variation Set objects that are redundant. |
| 11292 | ** |
| 11293 | ** @param [r] Pitem [void**] Ensembl Genetic Variation Variation Set address |
| 11294 | ** @param [r] cl [void*] Standard, passed in from ajListSortUnique |
| 11295 | ** @see ajListSortUnique |
| 11296 | ** |
| 11297 | ** @return [void] |
| 11298 | ** |
| 11299 | ** @release 6.4.0 |
| 11300 | ** @@ |
| 11301 | ******************************************************************************/ |
| 11302 | |
| 11303 | static void listGvvariationsetDelete(void **Pitem, void *cl) |
| 11304 | { |
| 11305 | if (!Pitem) |
| 11306 | return; |
| 11307 | |
| 11308 | (void) cl; |
| 11309 | |
| 11310 | ensGvvariationsetDel((EnsPGvvariationset *) Pitem); |
| 11311 | |
| 11312 | return; |
| 11313 | } |
| 11314 | |
| 11315 | |
| 11316 | |
| 11317 | |
| 11318 | /* @func ensGvvariationsetadaptorFetchAllbyGvvariation ************************ |
| 11319 | ** |
| 11320 | ** Fetch an Ensembl Genetic Variation Variation Set via an |
| 11321 | ** Ensembl Genetic Variation Variation. |
| 11322 | ** |
| 11323 | ** The caller is responsible for deleting the |
| 11324 | ** Ensembl Genetic Variation Variation Set objects before deleting the |
| 11325 | ** AJAX List. |
| 11326 | ** |
| 11327 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationSetAdaptor::fetch_by_Variation |
| 11328 | ** @param [u] gvvsa [EnsPGvvariationsetadaptor] |
| 11329 | ** Ensembl Genetic Variation Variation Set Adaptor |
| 11330 | ** @param [r] gvv [const EnsPGvvariation] Ensembl Genetic Variation Variation |
| 11331 | ** @param [u] gvvss [AjPList] |
| 11332 | ** AJAX List of Ensembl Genetic Variation Variation Set objects |
| 11333 | ** |
| 11334 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 11335 | ** |
| 11336 | ** @release 6.4.0 |
| 11337 | ** @@ |
| 11338 | ******************************************************************************/ |
| 11339 | |
| 11340 | AjBool ensGvvariationsetadaptorFetchAllbyGvvariation( |
| 11341 | EnsPGvvariationsetadaptor gvvsa, |
| 11342 | const EnsPGvvariation gvv, |
| 11343 | AjPList gvvss) |
| 11344 | { |
| 11345 | const char *const *txtcolumns = NULL; |
| 11346 | |
| 11347 | register ajuint i = 0U; |
| 11348 | |
| 11349 | AjBool result = AJFALSE; |
| 11350 | |
| 11351 | AjPList variationsets = NULL; |
| 11352 | |
| 11353 | AjPStr columns = NULL; |
| 11354 | AjPStr statement = NULL; |
| 11355 | |
| 11356 | EnsPBaseadaptor ba = NULL; |
| 11357 | |
| 11358 | EnsPGvvariationset gvvs = NULL; |
| 11359 | |
| 11360 | if (!gvvsa) |
| 11361 | return ajFalse; |
| 11362 | |
| 11363 | if (!gvv) |
| 11364 | return ajFalse; |
| 11365 | |
| 11366 | if (!gvvss) |
| 11367 | return ajFalse; |
| 11368 | |
| 11369 | ba = ensGvvariationsetadaptorGetBaseadaptor(gvvsa); |
| 11370 | |
| 11371 | txtcolumns = ensBaseadaptorGetColumnnames(ba); |
| 11372 | |
| 11373 | columns = ajStrNew(); |
| 11374 | |
| 11375 | for (i = 0U; txtcolumns[i]; i++) |
| 11376 | ajFmtPrintAppS(&columns, "%s, ", txtcolumns[i]); |
| 11377 | |
| 11378 | /* Remove last comma and space from the column expression. */ |
| 11379 | |
| 11380 | ajStrCutEnd(&columns, 2); |
| 11381 | |
| 11382 | statement = ajFmtStr( |
| 11383 | "SELECT " |
| 11384 | "%S " |
| 11385 | "FROM " |
| 11386 | "variation_set, " |
| 11387 | "variation_set_variation " |
| 11388 | "WHERE " |
| 11389 | "variation_set.variation_set_id = " |
| 11390 | "variation_set_variation.variation_set_id " |
| 11391 | "AND " |
| 11392 | "variation_set_variation.variation_id = %u", |
| 11393 | columns, |
| 11394 | ensGvvariationGetIdentifier(gvv)); |
| 11395 | |
| 11396 | ajStrDel(&columns); |
| 11397 | |
| 11398 | variationsets = ajListNew(); |
| 11399 | |
| 11400 | result = ensBaseadaptorFetchAllbyConstraint( |
| 11401 | ba, |
| 11402 | statement, |
| 11403 | (EnsPAssemblymapper) NULL, |
| 11404 | (EnsPSlice) NULL, |
| 11405 | variationsets); |
| 11406 | |
| 11407 | ajStrDel(&statement); |
| 11408 | |
| 11409 | /* |
| 11410 | ** Fetch all supersets of the returned Ensembl Genetic Variation |
| 11411 | ** Variation Set objects as well. Since an Ensembl Genetic Variation |
| 11412 | ** Variation may occur at several places in a hierarchy, which will cause |
| 11413 | ** duplicated data sort the AJAX List uniquely. |
| 11414 | */ |
| 11415 | |
| 11416 | while (ajListPop(variationsets, (void **) &gvvs)) |
| 11417 | { |
| 11418 | ensGvvariationsetadaptorFetchAllbySub(gvvsa, |
| 11419 | gvvs, |
| 11420 | ajFalse, |
| 11421 | gvvss); |
| 11422 | |
| 11423 | /* |
| 11424 | ** Move the current Ensembl Genetic Variation Variation Set onto the |
| 11425 | ** AJAX List of subsets, too. |
| 11426 | */ |
| 11427 | |
| 11428 | ajListPushAppend(gvvss, (void *) gvvs); |
| 11429 | } |
| 11430 | |
| 11431 | ajListFree(&variationsets); |
| 11432 | |
| 11433 | ajListSortUnique(gvvss, |
| 11434 | &listGvvariationsetCompareIdentifierAscending, |
| 11435 | &listGvvariationsetDelete); |
| 11436 | |
| 11437 | return result; |
| 11438 | } |
| 11439 | |
| 11440 | |
| 11441 | |
| 11442 | |
| 11443 | /* @func ensGvvariationsetadaptorFetchAllbySub ******************************** |
| 11444 | ** |
| 11445 | ** Fetch all Ensembl Genetic Variation Variation Set objects, by a subset of an |
| 11446 | ** Ensembl Genetic Variation Variation Set. |
| 11447 | ** |
| 11448 | ** The caller is responsible for deleting the |
| 11449 | ** Ensembl Genetic Variation Variation Set objects before deleting the |
| 11450 | ** AJAX List. |
| 11451 | ** |
| 11452 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationSetAdaptor:: |
| 11453 | ** fetch_all_by_sub_VariationSet |
| 11454 | ** @param [u] gvvsa [EnsPGvvariationsetadaptor] |
| 11455 | ** Ensembl Genetic Variation Variation Set Adaptor |
| 11456 | ** @param [r] gvvs [const EnsPGvvariationset] |
| 11457 | ** Ensembl Genetic Variation Variation Set |
| 11458 | ** @param [r] immediate [AjBool] ajTrue: only the direct supersets of this |
| 11459 | ** variation set will be fetched |
| 11460 | ** ajFalse: recursively fetch all supersets |
| 11461 | ** @param [u] gvvss [AjPList] |
| 11462 | ** AJAX List of Ensembl Genetic Variation Variation Set objects |
| 11463 | ** |
| 11464 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 11465 | ** |
| 11466 | ** @release 6.4.0 |
| 11467 | ** @@ |
| 11468 | ******************************************************************************/ |
| 11469 | |
| 11470 | AjBool ensGvvariationsetadaptorFetchAllbySub( |
| 11471 | EnsPGvvariationsetadaptor gvvsa, |
| 11472 | const EnsPGvvariationset gvvs, |
| 11473 | AjBool immediate, |
| 11474 | AjPList gvvss) |
| 11475 | { |
| 11476 | ajuint *Pidentifier = NULL; |
| 11477 | |
| 11478 | ajuint vssid = 0U; |
| 11479 | |
| 11480 | AjPList variationsets = NULL; |
| 11481 | |
| 11482 | AjPSqlstatement sqls = NULL; |
| 11483 | AjISqlrow sqli = NULL; |
| 11484 | AjPSqlrow sqlr = NULL; |
| 11485 | |
| 11486 | AjPStr statement = NULL; |
| 11487 | |
| 11488 | AjPTable gvvstable = NULL; |
| 11489 | |
| 11490 | EnsPDatabaseadaptor dba = NULL; |
| 11491 | |
| 11492 | EnsPGvvariationset variationset = NULL; |
| 11493 | |
| 11494 | if (!gvvsa) |
| 11495 | return ajFalse; |
| 11496 | |
| 11497 | if (!gvvs) |
| 11498 | return ajFalse; |
| 11499 | |
| 11500 | if (!gvvss) |
| 11501 | return ajFalse; |
| 11502 | |
| 11503 | variationsets = ajListNew(); |
| 11504 | |
| 11505 | /* |
| 11506 | ** Initialise an AJAX Table of AJAX unsigned integer key and |
| 11507 | ** Ensembl Genetic Variation Variation Set value data. |
| 11508 | ** The AJAX Table is cleared by moving Ensembl Genetic Variation |
| 11509 | ** Variation Set objects onto an AJAX List. |
| 11510 | */ |
| 11511 | |
| 11512 | gvvstable = ajTableuintNew(0U); |
| 11513 | |
| 11514 | dba = ensGvvariationsetadaptorGetDatabaseadaptor(gvvsa); |
| 11515 | |
| 11516 | /* |
| 11517 | ** First, get all Ensembl Genetic Variation Variation Set objects that are |
| 11518 | ** direct supersets of this one. |
| 11519 | */ |
| 11520 | |
| 11521 | statement = ajFmtStr( |
| 11522 | "SELECT " |
| 11523 | "variation_set_structure.variation_set_super " |
| 11524 | "FROM " |
| 11525 | "variation_set_structure " |
| 11526 | "WHERE " |
| 11527 | "variation_set_structure.variation_set_sub = %u", |
| 11528 | gvvs->Identifier); |
| 11529 | |
| 11530 | sqls = ensDatabaseadaptorSqlstatementNew(dba, statement); |
| 11531 | |
| 11532 | sqli = ajSqlrowiterNew(sqls); |
| 11533 | |
| 11534 | while (!ajSqlrowiterDone(sqli)) |
| 11535 | { |
| 11536 | vssid = 0; |
| 11537 | |
| 11538 | sqlr = ajSqlrowiterGet(sqli); |
| 11539 | |
| 11540 | ajSqlcolumnToUint(sqlr, &vssid); |
| 11541 | |
| 11542 | if (!ajTableFetchmodV(gvvstable, (const void *) &vssid)) |
| 11543 | { |
| 11544 | ensGvvariationsetadaptorFetchByIdentifier(gvvsa, |
| 11545 | vssid, |
| 11546 | &variationset); |
| 11547 | |
| 11548 | if (!variationset) |
| 11549 | continue; |
| 11550 | |
| 11551 | AJNEW0(Pidentifier); |
| 11552 | |
| 11553 | *Pidentifier = vssid; |
| 11554 | |
| 11555 | ajTablePut(gvvstable, (void *) Pidentifier, (void *) variationset); |
| 11556 | |
| 11557 | if (immediate) |
| 11558 | continue; |
| 11559 | |
| 11560 | ensGvvariationsetadaptorFetchAllbySub(gvvsa, |
| 11561 | variationset, |
| 11562 | immediate, |
| 11563 | variationsets); |
| 11564 | |
| 11565 | while (ajListPop(variationsets, (void **) &variationset)) |
| 11566 | { |
| 11567 | if (!variationset) |
| 11568 | continue; |
| 11569 | |
| 11570 | vssid = ensGvvariationsetGetIdentifier(variationset); |
| 11571 | |
| 11572 | if (!ajTableFetchmodV(gvvstable, (const void *) &vssid)) |
| 11573 | { |
| 11574 | AJNEW0(Pidentifier); |
| 11575 | |
| 11576 | *Pidentifier = ensGvvariationsetGetIdentifier( |
| 11577 | variationset); |
| 11578 | |
| 11579 | ajTablePut(gvvstable, |
| 11580 | (void *) Pidentifier, |
| 11581 | (void *) ensGvvariationsetNewRef(variationset)); |
| 11582 | } |
| 11583 | |
| 11584 | ensGvvariationsetDel(&variationset); |
| 11585 | } |
| 11586 | } |
| 11587 | } |
| 11588 | |
| 11589 | ajSqlrowiterDel(&sqli); |
| 11590 | |
| 11591 | ensDatabaseadaptorSqlstatementDel(dba, &sqls); |
| 11592 | |
| 11593 | ajStrDel(&statement); |
| 11594 | |
| 11595 | ajListFree(&variationsets); |
| 11596 | |
| 11597 | /* |
| 11598 | ** Move all Ensembl Genetic Variation Variation Set objects from the |
| 11599 | ** AJAX Table onto the AJAX List. |
| 11600 | */ |
| 11601 | |
| 11602 | ensTableuintToList(gvvstable, gvvss); |
| 11603 | |
| 11604 | ajTableFree(&gvvstable); |
| 11605 | |
| 11606 | return ajTrue; |
| 11607 | } |
| 11608 | |
| 11609 | |
| 11610 | |
| 11611 | |
| 11612 | /* @func ensGvvariationsetadaptorFetchAllbySuper ****************************** |
| 11613 | ** |
| 11614 | ** Fetch all Ensembl Genetic Variation Variation Set objects, by a superset of |
| 11615 | ** an Ensembl Genetic Variation Variation Set. |
| 11616 | ** The caller is responsible for deleting the |
| 11617 | ** Ensembl Genetic Variation Variation Set objects before deleting the |
| 11618 | ** AJAX List. |
| 11619 | ** |
| 11620 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationSetAdaptor:: |
| 11621 | ** fetch_all_by_super_VariationSet |
| 11622 | ** @param [u] gvvsa [EnsPGvvariationsetadaptor] |
| 11623 | ** Ensembl Genetic Variation Variation Set Adaptor |
| 11624 | ** @param [r] gvvs [const EnsPGvvariationset] |
| 11625 | ** Ensembl Genetic Variation Variation Set |
| 11626 | ** @param [r] immediate [AjBool] ajTrue: only the direct subsets of this |
| 11627 | ** variation set will be fetched |
| 11628 | ** ajFalse: recursively fetch all supersets |
| 11629 | ** @param [u] gvvss [AjPList] |
| 11630 | ** AJAX List of Ensembl Genetic Variation Variation Set objects |
| 11631 | ** |
| 11632 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 11633 | ** |
| 11634 | ** @release 6.4.0 |
| 11635 | ** @@ |
| 11636 | ******************************************************************************/ |
| 11637 | |
| 11638 | AjBool ensGvvariationsetadaptorFetchAllbySuper( |
| 11639 | EnsPGvvariationsetadaptor gvvsa, |
| 11640 | const EnsPGvvariationset gvvs, |
| 11641 | AjBool immediate, |
| 11642 | AjPList gvvss) |
| 11643 | { |
| 11644 | ajuint *Pidentifier = NULL; |
| 11645 | |
| 11646 | ajuint vssid = 0U; |
| 11647 | |
| 11648 | AjPList variationsets = NULL; |
| 11649 | |
| 11650 | AjPSqlstatement sqls = NULL; |
| 11651 | AjISqlrow sqli = NULL; |
| 11652 | AjPSqlrow sqlr = NULL; |
| 11653 | |
| 11654 | AjPStr statement = NULL; |
| 11655 | |
| 11656 | AjPTable gvvstable = NULL; |
| 11657 | |
| 11658 | EnsPDatabaseadaptor dba = NULL; |
| 11659 | |
| 11660 | EnsPGvvariationset variationset = NULL; |
| 11661 | |
| 11662 | if (!gvvsa) |
| 11663 | return ajFalse; |
| 11664 | |
| 11665 | if (!gvvs) |
| 11666 | return ajFalse; |
| 11667 | |
| 11668 | if (!gvvss) |
| 11669 | return ajFalse; |
| 11670 | |
| 11671 | variationsets = ajListNew(); |
| 11672 | |
| 11673 | /* |
| 11674 | ** Initialise an AJAX Table of AJAX unsigned integer key and |
| 11675 | ** Ensembl Genetic Variation Variation Set value data. |
| 11676 | ** The AJAX Table is cleared by moving Ensembl Genetic Variation |
| 11677 | ** Variation Set objects onto an AJAX List. |
| 11678 | */ |
| 11679 | |
| 11680 | gvvstable = ajTableuintNew(0U); |
| 11681 | |
| 11682 | dba = ensGvvariationsetadaptorGetDatabaseadaptor(gvvsa); |
| 11683 | |
| 11684 | /* |
| 11685 | ** First, get all Ensembl Genetic Variation Variation Set objects that are |
| 11686 | ** direct supersets of this one. |
| 11687 | */ |
| 11688 | |
| 11689 | statement = ajFmtStr( |
| 11690 | "SELECT " |
| 11691 | "variation_set_structure.variation_set_sub " |
| 11692 | "FROM " |
| 11693 | "variation_set_structure " |
| 11694 | "WHERE " |
| 11695 | "variation_set_structure.variation_set_super = %u", |
| 11696 | gvvs->Identifier); |
| 11697 | |
| 11698 | sqls = ensDatabaseadaptorSqlstatementNew(dba, statement); |
| 11699 | |
| 11700 | sqli = ajSqlrowiterNew(sqls); |
| 11701 | |
| 11702 | while (!ajSqlrowiterDone(sqli)) |
| 11703 | { |
| 11704 | vssid = 0; |
| 11705 | |
| 11706 | sqlr = ajSqlrowiterGet(sqli); |
| 11707 | |
| 11708 | ajSqlcolumnToUint(sqlr, &vssid); |
| 11709 | |
| 11710 | if (!ajTableFetchmodV(gvvstable, (const void *) &vssid)) |
| 11711 | { |
| 11712 | ensGvvariationsetadaptorFetchByIdentifier(gvvsa, |
| 11713 | vssid, |
| 11714 | &variationset); |
| 11715 | |
| 11716 | if (!variationset) |
| 11717 | continue; |
| 11718 | |
| 11719 | AJNEW0(Pidentifier); |
| 11720 | |
| 11721 | *Pidentifier = vssid; |
| 11722 | |
| 11723 | ajTablePut(gvvstable, (void *) Pidentifier, (void *) variationset); |
| 11724 | |
| 11725 | if (immediate) |
| 11726 | continue; |
| 11727 | |
| 11728 | ensGvvariationsetadaptorFetchAllbySub(gvvsa, |
| 11729 | variationset, |
| 11730 | immediate, |
| 11731 | variationsets); |
| 11732 | |
| 11733 | while (ajListPop(variationsets, (void **) &variationset)) |
| 11734 | { |
| 11735 | if (!variationset) |
| 11736 | continue; |
| 11737 | |
| 11738 | vssid = ensGvvariationsetGetIdentifier(variationset); |
| 11739 | |
| 11740 | if (!ajTableFetchmodV(gvvstable, (const void *) &vssid)) |
| 11741 | { |
| 11742 | AJNEW0(Pidentifier); |
| 11743 | |
| 11744 | *Pidentifier = ensGvvariationsetGetIdentifier( |
| 11745 | variationset); |
| 11746 | |
| 11747 | ajTablePut(gvvstable, |
| 11748 | (void *) Pidentifier, |
| 11749 | (void *) ensGvvariationsetNewRef(variationset)); |
| 11750 | } |
| 11751 | |
| 11752 | ensGvvariationsetDel(&variationset); |
| 11753 | } |
| 11754 | } |
| 11755 | } |
| 11756 | |
| 11757 | ajSqlrowiterDel(&sqli); |
| 11758 | |
| 11759 | ensDatabaseadaptorSqlstatementDel(dba, &sqls); |
| 11760 | |
| 11761 | ajStrDel(&statement); |
| 11762 | |
| 11763 | ajListFree(&variationsets); |
| 11764 | |
| 11765 | /* |
| 11766 | ** Move all Ensembl Genetic Variation Variation Set objects from the |
| 11767 | ** AJAX Table onto the AJAX List. |
| 11768 | */ |
| 11769 | |
| 11770 | ensTableuintToList(gvvstable, gvvss); |
| 11771 | |
| 11772 | ajTableFree(&gvvstable); |
| 11773 | |
| 11774 | return ajTrue; |
| 11775 | } |
| 11776 | |
| 11777 | |
| 11778 | |
| 11779 | |
| 11780 | /* @func ensGvvariationsetadaptorFetchByIdentifier **************************** |
| 11781 | ** |
| 11782 | ** Fetch an Ensembl Genetic Variation Variation Set via its |
| 11783 | ** SQL database-internal identifier. |
| 11784 | ** The caller is responsible for deleting the |
| 11785 | ** Ensembl Genetic Variation Variation Set. |
| 11786 | ** |
| 11787 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationSetAdaptor::fetch_by_dbID |
| 11788 | ** @param [u] gvvsa [EnsPGvvariationsetadaptor] |
| 11789 | ** Ensembl Genetic Variation Variation Set Adaptor |
| 11790 | ** @param [r] identifier [ajuint] SQL database-internal identifier |
| 11791 | ** @param [wP] Pgvvs [EnsPGvvariationset*] |
| 11792 | ** Ensembl Genetic Variation Variation Set address |
| 11793 | ** |
| 11794 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 11795 | ** |
| 11796 | ** @release 6.4.0 |
| 11797 | ** @@ |
| 11798 | ******************************************************************************/ |
| 11799 | |
| 11800 | AjBool ensGvvariationsetadaptorFetchByIdentifier( |
| 11801 | EnsPGvvariationsetadaptor gvvsa, |
| 11802 | ajuint identifier, |
| 11803 | EnsPGvvariationset *Pgvvs) |
| 11804 | { |
| 11805 | return ensBaseadaptorFetchByIdentifier( |
| 11806 | ensGvvariationsetadaptorGetBaseadaptor(gvvsa), |
| 11807 | identifier, |
| 11808 | (void **) Pgvvs); |
| 11809 | } |
| 11810 | |
| 11811 | |
| 11812 | |
| 11813 | |
| 11814 | /* @func ensGvvariationsetadaptorFetchByName ********************************** |
| 11815 | ** |
| 11816 | ** Fetch an Ensembl Genetic Variation Variation Set via its name. |
| 11817 | ** The caller is responsible for deleting the |
| 11818 | ** Ensembl Genetic Variation Variation Set. |
| 11819 | ** |
| 11820 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationSetAdaptor::fetch_by_name |
| 11821 | ** @param [u] gvvsa [EnsPGvvariationsetadaptor] |
| 11822 | ** Ensembl Genetic Variation Variation Set Adaptor |
| 11823 | ** @param [r] name [const AjPStr] Name |
| 11824 | ** @param [wP] Pgvvs [EnsPGvvariationset*] |
| 11825 | ** Ensembl Genetic Variation Variation Set address |
| 11826 | ** |
| 11827 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 11828 | ** |
| 11829 | ** @release 6.4.0 |
| 11830 | ** @@ |
| 11831 | ******************************************************************************/ |
| 11832 | |
| 11833 | AjBool ensGvvariationsetadaptorFetchByName( |
| 11834 | EnsPGvvariationsetadaptor gvvsa, |
| 11835 | const AjPStr name, |
| 11836 | EnsPGvvariationset *Pgvvs) |
| 11837 | { |
| 11838 | char *txtname = NULL; |
| 11839 | |
| 11840 | AjBool result = AJFALSE; |
| 11841 | |
| 11842 | AjPList gvvss = NULL; |
| 11843 | |
| 11844 | AjPStr constraint = NULL; |
| 11845 | |
| 11846 | EnsPBaseadaptor ba = NULL; |
| 11847 | |
| 11848 | EnsPGvvariationset gvvs = NULL; |
| 11849 | |
| 11850 | if (!gvvsa) |
| 11851 | return ajFalse; |
| 11852 | |
| 11853 | if (!(name && ajStrGetLen(name))) |
| 11854 | return ajFalse; |
| 11855 | |
| 11856 | if (!Pgvvs) |
| 11857 | return ajFalse; |
| 11858 | |
| 11859 | *Pgvvs = NULL; |
| 11860 | |
| 11861 | ba = ensGvvariationsetadaptorGetBaseadaptor(gvvsa); |
| 11862 | |
| 11863 | ensBaseadaptorEscapeC(ba, &txtname, name); |
| 11864 | |
| 11865 | constraint = ajFmtStr("variation_set.name = '%s'", txtname); |
| 11866 | |
| 11867 | ajCharDel(&txtname); |
| 11868 | |
| 11869 | gvvss = ajListNew(); |
| 11870 | |
| 11871 | result = ensBaseadaptorFetchAllbyConstraint( |
| 11872 | ba, |
| 11873 | constraint, |
| 11874 | (EnsPAssemblymapper) NULL, |
| 11875 | (EnsPSlice) NULL, |
| 11876 | gvvss); |
| 11877 | |
| 11878 | if (ajListGetLength(gvvss) > 1) |
| 11879 | ajWarn("ensGvvariationsetadaptorFetchByName got more " |
| 11880 | "than one Ensembl Genetic Variation Variation Set for " |
| 11881 | "name '%S'.\n", name); |
| 11882 | |
| 11883 | ajListPop(gvvss, (void **) Pgvvs); |
| 11884 | |
| 11885 | while (ajListPop(gvvss, (void **) &gvvs)) |
| 11886 | ensGvvariationsetDel(&gvvs); |
| 11887 | |
| 11888 | ajListFree(&gvvss); |
| 11889 | |
| 11890 | ajStrDel(&constraint); |
| 11891 | |
| 11892 | return result; |
| 11893 | } |
| 11894 | |
| 11895 | |
| 11896 | |
| 11897 | |
| 11898 | /* @func ensGvvariationsetadaptorFetchByShortname ***************************** |
| 11899 | ** |
| 11900 | ** Fetch an Ensembl Genetic Variation Variation Set via its short name. |
| 11901 | ** The caller is responsible for deleting the |
| 11902 | ** Ensembl Genetic Variation Variation Set. |
| 11903 | ** |
| 11904 | ** @cc Bio::EnsEMBL::Variation::DBSQL::VariationSetAdaptor::fetch_by_short_name |
| 11905 | ** @param [u] gvvsa [EnsPGvvariationsetadaptor] |
| 11906 | ** Ensembl Genetic Variation Variation Set Adaptor |
| 11907 | ** @param [r] shortname [const AjPStr] Short name |
| 11908 | ** @param [wP] Pgvvs [EnsPGvvariationset*] |
| 11909 | ** Ensembl Genetic Variation Variation Set address |
| 11910 | ** |
| 11911 | ** @return [AjBool] ajTrue upon success, ajFalse otherwise |
| 11912 | ** |
| 11913 | ** @release 6.4.0 |
| 11914 | ** @@ |
| 11915 | ******************************************************************************/ |
| 11916 | |
| 11917 | AjBool ensGvvariationsetadaptorFetchByShortname( |
| 11918 | EnsPGvvariationsetadaptor gvvsa, |
| 11919 | const AjPStr shortname, |
| 11920 | EnsPGvvariationset *Pgvvs) |
| 11921 | { |
| 11922 | AjBool result = AJFALSE; |
| 11923 | |
| 11924 | AjPList list = NULL; |
| 11925 | |
| 11926 | AjPStr gvattcode = NULL; |
| 11927 | AjPStr constraint = NULL; |
| 11928 | |
| 11929 | EnsPGvattribute gva = NULL; |
| 11930 | |
| 11931 | EnsPGvvariationset gvvs = NULL; |
| 11932 | |
| 11933 | if (!gvvsa) |
| 11934 | return ajFalse; |
| 11935 | |
| 11936 | if (!(shortname && ajStrGetLen(shortname))) |
| 11937 | return ajFalse; |
| 11938 | |
| 11939 | if (!Pgvvs) |
| 11940 | return ajFalse; |
| 11941 | |
| 11942 | *Pgvvs = NULL; |
| 11943 | |
| 11944 | list = ajListNew(); |
| 11945 | |
| 11946 | /* NOTE: _short_name_attrib_type_code has not been implmented. */ |
| 11947 | gvattcode = ajStrNewC("short_name"); |
| 11948 | |
| 11949 | ensGvattributeadaptorFetchAllbyCode( |
| 11950 | ensRegistryGetGvattributeadaptor( |
| 11951 | ensGvvariationsetadaptorGetDatabaseadaptor(gvvsa)), |
| 11952 | gvattcode, |
| 11953 | shortname, |
| 11954 | list); |
| 11955 | |
| 11956 | ajStrDel(&gvattcode); |
| 11957 | |
| 11958 | ajListPeekFirst(list, (void **) &gva); |
| 11959 | |
| 11960 | if (!gva) |
| 11961 | { |
| 11962 | while (ajListPop(list, (void **) &gva)) |
| 11963 | ensGvattributeDel(&gva); |
| 11964 | |
| 11965 | ajListFree(&list); |
| 11966 | |
| 11967 | return ajTrue; |
| 11968 | } |
| 11969 | |
| 11970 | constraint = ajFmtStr("variation_set.short_name_attrib_id = %u", |
| 11971 | ensGvattributeGetIdentifier(gva)); |
| 11972 | |
| 11973 | while (ajListPop(list, (void **) &gva)) |
| 11974 | ensGvattributeDel(&gva); |
| 11975 | |
| 11976 | result = ensBaseadaptorFetchAllbyConstraint( |
| 11977 | ensGvvariationsetadaptorGetBaseadaptor(gvvsa), |
| 11978 | constraint, |
| 11979 | (EnsPAssemblymapper) NULL, |
| 11980 | (EnsPSlice) NULL, |
| 11981 | list); |
| 11982 | |
| 11983 | if (ajListGetLength(list) > 1) |
| 11984 | ajWarn("ensGvvariationsetadaptorFetchByName got more " |
| 11985 | "than one Ensembl Genetic Variation Variation Set for " |
| 11986 | "shortname '%S'.\n", shortname); |
| 11987 | |
| 11988 | ajListPop(list, (void **) Pgvvs); |
| 11989 | |
| 11990 | while (ajListPop(list, (void **) &gvvs)) |
| 11991 | ensGvvariationsetDel(&gvvs); |
| 11992 | |
| 11993 | ajListFree(&list); |
| 11994 | |
| 11995 | ajStrDel(&constraint); |
| 11996 | |
| 11997 | return result; |
| 11998 | } |
| 11999 | |
| 12000 | |
| 12001 | |
| 12002 | |
| 12003 | #if AJFALSE |
| 12004 | /* FIXME: Remove? */ |
| 12005 | AjBool ensGvvariationsetadaptorRetrieveAllGvvariationidentifiers( |
| 12006 | EnsPGvvariationsetadaptor gvvsa, |
| 12007 | EnsPGvvariationset gvvs) |
| 12008 | { |
| 12009 | AjPList gvvss = NULL; |
| 12010 | |
| 12011 | AjPStr csv = NULL; |
| 12012 | AjPStr constraint = NULL; |
| 12013 | AjPStr fvconstraint = NULL; |
| 12014 | |
| 12015 | EnsPDatabaseadaptor dba = NULL; |
| 12016 | |
| 12017 | EnsPGvdatabaseadaptor gvdba = NULL; |
| 12018 | |
| 12019 | EnsPGvvariationset lgvvs = NULL; |
| 12020 | EnsPGvvariationsetadaptor gvvsa = NULL; |
| 12021 | |
| 12022 | if (!gvvsa) |
| 12023 | return ajFalse; |
| 12024 | |
| 12025 | if (!gvvs) |
| 12026 | return ajFalse; |
| 12027 | |
| 12028 | dba = ensGvvariationsetadaptorGetDatabaseadaptor(gvvsa); |
| 12029 | |
| 12030 | gvdba = ensRegistryGetGvdatabaseadaptor(dba); |
| 12031 | gvvsa = ensRegistryGetGvvariationsetadaptor(dba); |
| 12032 | |
| 12033 | gvvss = ajListNew(); |
| 12034 | |
| 12035 | csv = ajStrNew(); |
| 12036 | |
| 12037 | ensGvvariationsetadaptorFetchAllbySuper(gvvsa, gvvs, ajFalse, gvvss); |
| 12038 | |
| 12039 | while (ajListPop(gvvss, (void **) &lgvvs)) |
| 12040 | { |
| 12041 | ajFmtPrintAppS(csv, "%u, ", ensGvvariationsetGetIdentifier(lgvvs)); |
| 12042 | |
| 12043 | ensGvvariationsetDel(&lgvvs); |
| 12044 | } |
| 12045 | /* FIXME: Get variation set identifier objects. */ |
| 12046 | |
| 12047 | ensGvdatabaseadaptorFailedvariationsconstraint(gvdba, |
| 12048 | (const AjPStr) NULL, |
| 12049 | &fvconstraint); |
| 12050 | |
| 12051 | statement = ajFmtStr( |
| 12052 | "SELECT DISTINCT " |
| 12053 | "variation_set_variation.variation_id " |
| 12054 | "FROM " |
| 12055 | "variation_set_variation vsv " |
| 12056 | "LEFT JOIN " |
| 12057 | "failed_variation fv " |
| 12058 | "ON " |
| 12059 | "(" |
| 12060 | "failed_variation.variation_id = " |
| 12061 | "variation_set_variation.variation_id" |
| 12062 | ")" |
| 12063 | "WHERE " |
| 12064 | "variation_set_variation.variation_set_id IN (%S) " |
| 12065 | "AND %S", |
| 12066 | csv, |
| 12067 | fvconstraint); |
| 12068 | |
| 12069 | ajStrDel(&csv); |
| 12070 | ajStrDel(&fvconstraint); |
| 12071 | |
| 12072 | return ajTrue; |
| 12073 | } |
| 12074 | #endif /* AJFALSE */ |