| 1 | # GenPerl module | ||
| 2 | # | ||
| 3 | |||
| 4 | # POD documentation - main docs before the code | ||
| 5 | |||
| 6 | =head1 NAME | ||
| 7 | |||
| 8 | Genetics::API::DB::Delete | ||
| 9 | |||
| 10 | =head1 SYNOPSIS | ||
| 11 | |||
| 12 | use Genetics::API ; | ||
| 13 | |||
| 14 | $api = new Genetics::API(DSN => {driver => "mysql", | ||
| 15 | host => $Host, | ||
| 16 | database => $Database}, | ||
| 17 | user => $UserName, | ||
| 18 | password => $Password) ; | ||
| 19 | |||
| 20 | foreach $id (@badGenotypeIDs ) { | ||
| 21 | $rv = $api->deleteGenotype($id) ; | ||
| 22 | defined $rv or print "Error deleting Genotype w/ ID $id\n" ; | ||
| 23 | } | ||
| 24 | |||
| 25 | =head1 DESCRIPTION | ||
| 26 | |||
| 27 | The Genetics::API::DB packages provide an interface for the manipulation of | ||
| 28 | GenPerl objects in a relational database. This package contains the methods | ||
| 29 | for deleting objects from the database. | ||
| 30 | |||
| 31 | =head1 LICENSE | ||
| 32 | |||
| 33 | This program is free software; you can redistribute it and/or modify | ||
| 34 | it under the terms of the GNU General Public License as published by | ||
| 35 | the Free Software Foundation; either version 2 of the License, or | ||
| 36 | (at your option) any later version. | ||
| 37 | |||
| 38 | This program is distributed in the hope that it will be useful, | ||
| 39 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 40 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 41 | GNU General Public License for more details. | ||
| 42 | |||
| 43 | You should have received a copy of the GNU General Public License | ||
| 44 | along with this program; if not, write to the Free Software | ||
| 45 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 46 | |||
| 47 | =head1 FEEDBACK | ||
| 48 | |||
| 49 | Currently, all feedback should be sent directly to the author. | ||
| 50 | |||
| 51 | =head1 AUTHOR - Steve Mathias | ||
| 52 | |||
| 53 | Email: mathias@genomica.com | ||
| 54 | |||
| 55 | Phone: (720) 565-4029 | ||
| 56 | |||
| 57 | Address: Genomica Corporation | ||
| 58 | 1745 38th Street | ||
| 59 | Boulder, CO 80301 | ||
| 60 | |||
| 61 | =head1 DETAILS | ||
| 62 | |||
| 63 | The rest of the documentation describes each of the object variables and | ||
| 64 | methods. The names of internal variables and methods are preceded with an | ||
| 65 | underscore (_). | ||
| 66 | |||
| 67 | =cut | ||
| 68 | |||
| 69 | ################## | ||
| 70 | # # | ||
| 71 | # Begin the code # | ||
| 72 | # # | ||
| 73 | ################## | ||
| 74 | |||
| 75 | package Genetics::API::DB::Delete ; | ||
| 76 | |||
| 77 | BEGIN { | ||
| 78 | $ID = "Genetics::API::DB::Delete" ; | ||
| 79 | #$DEBUG = $main::DEBUG ; | ||
| 80 | $DEBUG = 0 ; | ||
| 81 | $DEBUG and warn "Debugging in $ID is on" ; | ||
| 82 | } | ||
| 83 | |||
| 84 | =head1 Imported Packages | ||
| 85 | |||
| 86 | strict Just to be anal | ||
| 87 | vars Global variables | ||
| 88 | Carp Error reporting | ||
| 89 | |||
| 90 | =cut | ||
| 91 | |||
| 92 | use strict ; | ||
| 93 | use vars qw(@ISA @EXPORT @EXPORT_OK $ID $VERSION $DEBUG) ; | ||
| 94 | use Carp ; | ||
| 95 | use Exporter ; | ||
| 96 | |||
| 97 | =head1 Inheritance | ||
| 98 | |||
| 99 | Exporter Make methods available to importing packages | ||
| 100 | |||
| 101 | =cut | ||
| 102 | |||
| 103 | @ISA = qw(Exporter) ; | ||
| 104 | |||
| 105 | @EXPORT = qw(deleteCluster deleteSubject deleteKindred deleteMarker deleteSNP | ||
| 106 | deleteGenotype deleteStudyVariable deletePhenotype deleteFrequencySource | ||
| 107 | deleteHtMarkerCollection deleteHaplotype deleteDNASample deleteTissueSample | ||
| 108 | deleteMap _deleteObjectData _deleteAssayAttrs) ; | ||
| 109 | @EXPORT_OK = qw(); | ||
| 110 | |||
| 111 | =head1 Public Methods | ||
| 112 | |||
| 113 | =head2 deleteCluster | ||
| 114 | |||
| 115 | Function : Delete a Genetics::Object::Cluster object from the database. | ||
| 116 | Argument : The id of the object to be deleted. | ||
| 117 | Returns : 1 on success, undef otherwise. | ||
| 118 | Scope : Public | ||
| 119 | Comments : | ||
| 120 | |||
| 121 | =cut | ||
| 122 | |||
| 123 | sub deleteCluster { | ||
| 124 | my($self, $id) = @_ ; | ||
| 125 | my($actualType) ; | ||
| 126 | my $dbh = $self->{dbh} ; | ||
| 127 | |||
| 128 | $DEBUG and carp " ->[deleteCluster] $id." ; | ||
| 129 | |||
| 130 | ( $actualType ) = $dbh->selectrow_array("select objType from Object | ||
| 131 | where id = $id") ; | ||
| 132 | if ( $actualType ne "Cluster") { | ||
| 133 | carp " ->[deleteCluster] Object with ID = $id is not a Cluster!" ; | ||
| 134 | return(undef) ; | ||
| 135 | } | ||
| 136 | |||
| 137 | # Object data | ||
| 138 | $self->_deleteObjectData($id) ; | ||
| 139 | # Cluster fields | ||
| 140 | $dbh->do( "delete from Cluster | ||
| 141 | where clusterID = $id" ) ; | ||
| 142 | # ClusterContents fields | ||
| 143 | $dbh->do( "delete from ClusterContents | ||
| 144 | where clusterID = $id" ) ; | ||
| 145 | |||
| 146 | $DEBUG and carp " ->[deleteCluster] End." ; | ||
| 147 | |||
| 148 | return(1) ; | ||
| 149 | } | ||
| 150 | |||
| 151 | =head2 deleteSubject | ||
| 152 | |||
| 153 | Function : Delete a Genetics::Object::Subject object from the database. | ||
| 154 | Argument : The id of the object to be deleted. | ||
| 155 | Returns : 1 on success, undef otherwise. | ||
| 156 | Scope : Public | ||
| 157 | |||
| 158 | =cut | ||
| 159 | |||
| 160 | sub deleteSubject { | ||
| 161 | my($self, $id) = @_ ; | ||
| 162 | my($actualType) ; | ||
| 163 | my $dbh = $self->{dbh} ; | ||
| 164 | |||
| 165 | $DEBUG and carp " ->[deleteSubject] $id." ; | ||
| 166 | |||
| 167 | ( $actualType ) = $dbh->selectrow_array("select objType from Object | ||
| 168 | where id = $id") ; | ||
| 169 | if ( $actualType ne "Subject") { | ||
| 170 | carp " ->[deleteSubject] Object with ID = $id is not a Subject!" ; | ||
| 171 | return(undef) ; | ||
| 172 | } | ||
| 173 | |||
| 174 | # Object | ||
| 175 | $self->_deleteObjectData($id) ; | ||
| 176 | # Subject | ||
| 177 | $dbh->do( "delete from Subject | ||
| 178 | where subjectID = $id" ) ; | ||
| 179 | # KindredSubject | ||
| 180 | $dbh->do( "delete from KindredSubject | ||
| 181 | where subjectID = $id" ) ; | ||
| 182 | |||
| 183 | $DEBUG and carp " ->[deleteSubject] End." ; | ||
| 184 | |||
| 185 | return(1) ; | ||
| 186 | } | ||
| 187 | |||
| 188 | =head2 deleteKindred | ||
| 189 | |||
| 190 | Function : Delete a Genetics::Object::Kindred object from the database. | ||
| 191 | Argument : The id of the object to be deleted. | ||
| 192 | Returns : 1 on success, undef otherwise. | ||
| 193 | Scope : Public | ||
| 194 | Comments : | ||
| 195 | |||
| 196 | =cut | ||
| 197 | |||
| 198 | sub deleteKindred { | ||
| 199 | my($self, $id) = @_ ; | ||
| 200 | my($actualType) ; | ||
| 201 | my $dbh = $self->{dbh} ; | ||
| 202 | |||
| 203 | $DEBUG and carp " ->[deleteKindred] $id." ; | ||
| 204 | |||
| 205 | ( $actualType ) = $dbh->selectrow_array("select objType from Object | ||
| 206 | where id = $id") ; | ||
| 207 | if ( $actualType ne "Kindred") { | ||
| 208 | carp " ->[deleteKindred] Object with ID = $id is not a Kindred!" ; | ||
| 209 | return(undef) ; | ||
| 210 | } | ||
| 211 | |||
| 212 | # Object | ||
| 213 | $self->_deleteObjectData($id) ; | ||
| 214 | # Kindred | ||
| 215 | $dbh->do( "delete from Kindred | ||
| 216 | where kindredID = $id" ) ; | ||
| 217 | # KindredSubject | ||
| 218 | $dbh->do( "delete from KindredSubject | ||
| 219 | where subjectID = $id" ) ; | ||
| 220 | |||
| 221 | $DEBUG and carp " ->[deleteKindred] End." ; | ||
| 222 | |||
| 223 | return(1) ; | ||
| 224 | } | ||
| 225 | |||
| 226 | =head2 deleteMarker | ||
| 227 | |||
| 228 | Function : Delete a Genetics::Object::Marker object from the database. | ||
| 229 | Argument : The id of the object to be deleted. | ||
| 230 | Returns : 1 on success, undef otherwise. | ||
| 231 | Scope : Public | ||
| 232 | Comments : | ||
| 233 | |||
| 234 | =cut | ||
| 235 | |||
| 236 | sub deleteMarker { | ||
| 237 | my($self, $id) = @_ ; | ||
| 238 | my($actualType, $seqID, $sth, $arrRef) ; | ||
| 239 | my $dbh = $self->{dbh} ; | ||
| 240 | |||
| 241 | $DEBUG and carp " ->[deleteMarker] $id." ; | ||
| 242 | |||
| 243 | ( $actualType ) = $dbh->selectrow_array("select objType from Object | ||
| 244 | where id = $id") ; | ||
| 245 | if ( $actualType ne "Marker") { | ||
| 246 | carp " ->[deleteMarker] Object with ID = $id is not a Marker!" ; | ||
| 247 | return(undef) ; | ||
| 248 | } | ||
| 249 | |||
| 250 | # Object | ||
| 251 | $self->_deleteObjectData($id) ; | ||
| 252 | # Sequence | ||
| 253 | ( $seqID ) = $dbh->selectrow_array( "select sequenceID from SequenceObject | ||
| 254 | where seqObjectID = $id" ) ; | ||
| 255 | if ( defined $seqID ) { | ||
| 256 | $dbh->do( "delete from Sequence | ||
| 257 | where sequenceID = $seqID" ) ; | ||
| 258 | } | ||
| 259 | # SequenceObject | ||
| 260 | $dbh->do( "delete from SequenceObject | ||
| 261 | where seqObjectID = $id" ) ; | ||
| 262 | # ISCNMapLocation data | ||
| 263 | $sth = $dbh->prepare( "select iscnMapLocID from SeqObjISCN | ||
| 264 | where seqObjectID = $id" ) ; | ||
| 265 | $sth->execute() ; | ||
| 266 | while ($arrRef = $sth->fetchrow_arrayref()) { | ||
| 267 | $dbh->do( "delete from ISCNMapLocation | ||
| 268 | where iscnMapLocID = $$arrRef[0]" ) ; | ||
| 269 | } | ||
| 270 | $dbh->do( "delete from SeqObjISCN | ||
| 271 | where seqObjectID = $id" ) ; | ||
| 272 | # Marker | ||
| 273 | $dbh->do( "delete from Marker | ||
| 274 | where markerID = $id" ) ; | ||
| 275 | # Allele | ||
| 276 | $dbh->do( "delete from Allele | ||
| 277 | where poID = $id" ) ; | ||
| 278 | |||
| 279 | $DEBUG and carp " ->[deleteMarker] End." ; | ||
| 280 | |||
| 281 | return(1) ; | ||
| 282 | } | ||
| 283 | |||
| 284 | =head2 deleteSNP | ||
| 285 | |||
| 286 | Function : Delete a Genetics::Object::SNP object from the database. | ||
| 287 | Argument : The id of the object to be deleted. | ||
| 288 | Returns : 1 on success, undef otherwise. | ||
| 289 | Scope : Public | ||
| 290 | Comments : | ||
| 291 | |||
| 292 | =cut | ||
| 293 | |||
| 294 | sub deleteSNP { | ||
| 295 | my($self, $id) = @_ ; | ||
| 296 | my($actualType, $seqID, $sth, $arrRef) ; | ||
| 297 | my $dbh = $self->{dbh} ; | ||
| 298 | |||
| 299 | $DEBUG and carp " ->[deleteSNP] $id." ; | ||
| 300 | |||
| 301 | ( $actualType ) = $dbh->selectrow_array("select objType from Object | ||
| 302 | where id = $id") ; | ||
| 303 | if ( $actualType ne "SNP") { | ||
| 304 | carp " ->[deleteMarker] Object with ID = $id is not a SNP!" ; | ||
| 305 | return(undef) ; | ||
| 306 | } | ||
| 307 | |||
| 308 | # Object | ||
| 309 | $self->_deleteObjectData($id) ; | ||
| 310 | # Sequence | ||
| 311 | ( $seqID ) = $dbh->selectrow_array( "select sequenceID from SequenceObject | ||
| 312 | where seqObjectID = $id" ) ; | ||
| 313 | if ( defined $seqID ) { | ||
| 314 | $dbh->do( "delete from Sequence | ||
| 315 | where sequenceID = $seqID" ) ; | ||
| 316 | } | ||
| 317 | # SequenceObject | ||
| 318 | $dbh->do( "delete from SequenceObject | ||
| 319 | where seqObjectID = $id" ) ; | ||
| 320 | # ISCNMapLocation data | ||
| 321 | $sth = $dbh->prepare( "select iscnMapLocID from SeqObjISCN | ||
| 322 | where seqObjectID = $id" ) ; | ||
| 323 | $sth->execute() ; | ||
| 324 | while ($arrRef = $sth->fetchrow_arrayref()) { | ||
| 325 | $dbh->do( "delete from ISCNMapLocation | ||
| 326 | where iscnMapLocID = $$arrRef[0]" ) ; | ||
| 327 | } | ||
| 328 | $dbh->do( "delete from SeqObjISCN | ||
| 329 | where seqObjectID = $id" ) ; | ||
| 330 | # SNP fields | ||
| 331 | $dbh->do( "delete from SNP | ||
| 332 | where snpID = $id" ) ; | ||
| 333 | # Allele | ||
| 334 | $dbh->do( "delete from Allele | ||
| 335 | where poID = $id" ) ; | ||
| 336 | |||
| 337 | $DEBUG and carp " ->[deleteSNP] End." ; | ||
| 338 | |||
| 339 | return(1) ; | ||
| 340 | } | ||
| 341 | |||
| 342 | =head2 deleteGenotype | ||
| 343 | |||
| 344 | Function : Delete a Genetics::Object::Genotype object from the database. | ||
| 345 | Argument : The id of the object to be deleted. | ||
| 346 | Returns : 1 on success, undef otherwise. | ||
| 347 | Scope : Public | ||
| 348 | Comments : | ||
| 349 | |||
| 350 | =cut | ||
| 351 | |||
| 352 | sub deleteGenotype { | ||
| 353 | my($self, $id) = @_ ; | ||
| 354 | my($actualType, $sth, $arrRef) ; | ||
| 355 | my $dbh = $self->{dbh} ; | ||
| 356 | |||
| 357 | $DEBUG and carp " ->[deleteGenotype] $id." ; | ||
| 358 | |||
| 359 | ( $actualType ) = $dbh->selectrow_array("select objType from Object | ||
| 360 | where id = $id") ; | ||
| 361 | if ( $actualType ne "Genotype") { | ||
| 362 | carp " ->[deleteGenotype] Object with ID = $id is not a Genotype!" ; | ||
| 363 | return(undef) ; | ||
| 364 | } | ||
| 365 | |||
| 366 | # Object | ||
| 367 | $self->_deleteObjectData($id) ; | ||
| 368 | # Genotype | ||
| 369 | $dbh->do( "delete from Genotype | ||
| 370 | where gtID = $id" ) ; | ||
| 371 | # Genotype AssayAttributes | ||
| 372 | $dbh->do( "delete from AttributeValue | ||
| 373 | where objID = $id" ) ; | ||
| 374 | # AlleleCall and AlleleCall AssayAttributes | ||
| 375 | $sth = $dbh->prepare( "select alleleCallID from AlleleCall | ||
| 376 | where gtID = $id" ) ; | ||
| 377 | $sth->execute() ; | ||
| 378 | while ($arrRef = $sth->fetchrow_arrayref()) { | ||
| 379 | $dbh->do( "delete from AttributeValue | ||
| 380 | where alleleCallID = $$arrRef[0]" ) ; | ||
| 381 | } | ||
| 382 | $dbh->do( "delete from AlleleCall | ||
| 383 | where gtID = $id" ) ; | ||
| 384 | |||
| 385 | $DEBUG and carp " ->[deleteGenotype] End." ; | ||
| 386 | |||
| 387 | return(1) ; | ||
| 388 | } | ||
| 389 | |||
| 390 | =head2 deleteStudyVariable | ||
| 391 | |||
| 392 | Function : Delete a Genetics::Object::StudyVariable object from the database. | ||
| 393 | Argument : The id of the object to be deleted. | ||
| 394 | Returns : 1 on success, undef otherwise. | ||
| 395 | Scope : Public | ||
| 396 | Comments : | ||
| 397 | |||
| 398 | =cut | ||
| 399 | |||
| 400 | sub deleteStudyVariable { | ||
| 401 | my($self, $id) = @_ ; | ||
| 402 | my($actualType, $sth, $arrRef) ; | ||
| 403 | my $dbh = $self->{dbh} ; | ||
| 404 | |||
| 405 | $DEBUG and carp " ->[deleteStudyVariable] $id." ; | ||
| 406 | |||
| 407 | ( $actualType ) = $dbh->selectrow_array("select objType from Object | ||
| 408 | where id = $id") ; | ||
| 409 | if ( $actualType ne "StudyVariable") { | ||
| 410 | carp " ->[deleteStudyVariable] Object with ID = $id is not a StudyVariable!" ; | ||
| 411 | return(undef) ; | ||
| 412 | } | ||
| 413 | |||
| 414 | # Object | ||
| 415 | $self->_deleteObjectData($id) ; | ||
| 416 | # StudyVariable | ||
| 417 | $dbh->do( "delete from StudyVariable | ||
| 418 | where studyVariableID = $id" ) ; | ||
| 419 | # CodeDerivation and StaticLCPenetrance data | ||
| 420 | $sth = $dbh->prepare(" select codeDerivationID from CodeDerivation | ||
| 421 | where studyVariableID = $id" ) ; | ||
| 422 | $sth->execute() ; | ||
| 423 | while ($arrRef = $sth->fetchrow_arrayref()) { | ||
| 424 | $dbh->do( "delete from StaticLCPenetrance | ||
| 425 | where cdID = $$arrRef[0]" ) ; | ||
| 426 | } | ||
| 427 | $dbh->do( "delete from CodeDerivation | ||
| 428 | where studyVariableID = $id" ) ; | ||
| 429 | # AffectionStatus data | ||
| 430 | $sth = $dbh->prepare(" select asDefID from AffectionStatusDefinition | ||
| 431 | where studyVariableID = $id" ) ; | ||
| 432 | $sth->execute() ; | ||
| 433 | while ($arrRef = $sth->fetchrow_arrayref()) { | ||
| 434 | $dbh->do( "delete from AffectionStatusElement | ||
| 435 | where asDefID = $$arrRef[0]" ) ; | ||
| 436 | } | ||
| 437 | $dbh->do( "delete from AffectionStatusDefinition | ||
| 438 | where studyVariableID = $id" ) ; | ||
| 439 | # LiabilityClass data | ||
| 440 | $sth = $dbh->prepare( "select lcDefID from LiabilityClassDefinition | ||
| 441 | where studyVariableID = $id" ) ; | ||
| 442 | $sth->execute() ; | ||
| 443 | while ($arrRef = $sth->fetchrow_arrayref()) { | ||
| 444 | $dbh->do( "delete from LiabilityClass | ||
| 445 | where lcDefID = $$arrRef[0]" ) ; | ||
| 446 | } | ||
| 447 | $dbh->do( "delete from LiabilityClassDefinition | ||
| 448 | where studyVariableID = $id" ) ; | ||
| 449 | |||
| 450 | $DEBUG and carp " ->[deleteStudyVariable] End." ; | ||
| 451 | |||
| 452 | return(1) ; | ||
| 453 | } | ||
| 454 | |||
| 455 | =head2 deletePhenotype | ||
| 456 | |||
| 457 | Function : Delete a Genetics::Object::Phenotype object from the database. | ||
| 458 | Argument : The id of the object to be deleted. | ||
| 459 | Returns : 1 on success, undef otherwise. | ||
| 460 | Scope : Public | ||
| 461 | Comments : | ||
| 462 | |||
| 463 | =cut | ||
| 464 | |||
| 465 | sub deletePhenotype { | ||
| 466 | my($self, $id) = @_ ; | ||
| 467 | my($actualType) ; | ||
| 468 | my $dbh = $self->{dbh} ; | ||
| 469 | |||
| 470 | $DEBUG and carp " ->[deletePhenotype] $id." ; | ||
| 471 | |||
| 472 | ( $actualType ) = $dbh->selectrow_array("select objType from Object | ||
| 473 | where id = $id") ; | ||
| 474 | if ( $actualType ne "Phenotype") { | ||
| 475 | carp " ->[deletePhenotype] Object with ID = $id is not a Phenotype!" ; | ||
| 476 | return(undef) ; | ||
| 477 | } | ||
| 478 | |||
| 479 | # Object | ||
| 480 | $self->_deleteObjectData($id) ; | ||
| 481 | # Phenotype | ||
| 482 | $dbh->do( "delete from Phenotype | ||
| 483 | where ptID = $id" ) ; | ||
| 484 | # Phenotype AssayAttributes | ||
| 485 | $dbh->do( "delete from AttributeValue | ||
| 486 | where objID = $id" ) ; | ||
| 487 | |||
| 488 | $DEBUG and carp " ->[deletePhenotype] End." ; | ||
| 489 | |||
| 490 | return(1) ; | ||
| 491 | } | ||
| 492 | |||
| 493 | =head2 deleteFrequencySource | ||
| 494 | |||
| 495 | Function : Delete a Genetics::Object::FrequencySource object from the database. | ||
| 496 | Argument : The id of the object to be deleted. | ||
| 497 | Returns : 1 on success, undef otherwise. | ||
| 498 | Scope : Public | ||
| 499 | Comments : | ||
| 500 | |||
| 501 | =cut | ||
| 502 | |||
| 503 | sub deleteFrequencySource { | ||
| 504 | my($self, $id) = @_ ; | ||
| 505 | my($actualType, $sth, $arrRef) ; | ||
| 506 | my $dbh = $self->{dbh} ; | ||
| 507 | |||
| 508 | $DEBUG and carp " ->[deleteFrequencySource] $id." ; | ||
| 509 | |||
| 510 | ( $actualType ) = $dbh->selectrow_array("select objType from Object | ||
| 511 | where id = $id") ; | ||
| 512 | if ( $actualType ne "FrequencySource") { | ||
| 513 | carp " ->[deleteFrequencySource] Object with ID = $id is not a FrequencySource!" ; | ||
| 514 | return(undef) ; | ||
| 515 | } | ||
| 516 | |||
| 517 | # Object | ||
| 518 | $self->_deleteObjectData($id) ; | ||
| 519 | # ObsFrequency data | ||
| 520 | $sth = $dbh->prepare( "select obsFreqID from FreqSourceObsFrequency | ||
| 521 | where freqSourceID = $id" ) ; | ||
| 522 | $sth->execute() ; | ||
| 523 | while ($arrRef = $sth->fetchrow_arrayref()) { | ||
| 524 | $dbh->do( "delete from ObsFrequency | ||
| 525 | where obsFreqID = $$arrRef[0]" ) ; | ||
| 526 | } | ||
| 527 | $dbh->do( "delete from FreqSourceObsFrequency | ||
| 528 | where freqSourceID = $id" ) ; | ||
| 529 | |||
| 530 | $DEBUG and carp " ->[deleteFrequencySource] End." ; | ||
| 531 | |||
| 532 | return(1) ; | ||
| 533 | } | ||
| 534 | |||
| 535 | =head2 deleteHtMarkerCollection | ||
| 536 | |||
| 537 | Function : Delete a Genetics::Object::HtMarkerCollection object from the database. | ||
| 538 | Argument : The id of the object to be deleted. | ||
| 539 | Returns : 1 on success, undef otherwise. | ||
| 540 | Scope : Public | ||
| 541 | Comments : | ||
| 542 | |||
| 543 | =cut | ||
| 544 | |||
| 545 | sub deleteHtMarkerCollection { | ||
| 546 | my($self, $id) = @_ ; | ||
| 547 | my($actualType) ; | ||
| 548 | my $dbh = $self->{dbh} ; | ||
| 549 | |||
| 550 | $DEBUG and carp " ->[deleteHtMarkerCollection] $id." ; | ||
| 551 | |||
| 552 | ( $actualType ) = $dbh->selectrow_array("select objType from Object | ||
| 553 | where id = $id") ; | ||
| 554 | if ( $actualType ne "HtMarkerCollection") { | ||
| 555 | carp " ->[deleteHtMarkerCollection] Object with ID = $id is not a HtMarkerCollection!" ; | ||
| 556 | return(undef) ; | ||
| 557 | } | ||
| 558 | |||
| 559 | # Object | ||
| 560 | $self->_deleteObjectData($id) ; | ||
| 561 | # HtMarkerCollection | ||
| 562 | $dbh->do( "delete from HtMarkerCollection | ||
| 563 | where hmcID = $id" ) ; | ||
| 564 | # HMCPolyObj | ||
| 565 | $dbh->do( "delete from HMCPolyObj | ||
| 566 | where hmcID = $id" ) ; | ||
| 567 | |||
| 568 | $DEBUG and carp " ->[deleteHtMarkerCollection] End." ; | ||
| 569 | |||
| 570 | return(1) ; | ||
| 571 | } | ||
| 572 | |||
| 573 | =head2 deleteHaplotype | ||
| 574 | |||
| 575 | Function : Delete a Genetics::Object::Haplotype object from the database. | ||
| 576 | Argument : The id of the object to be deleted. | ||
| 577 | Returns : 1 on success, undef otherwise. | ||
| 578 | Scope : Public | ||
| 579 | Comments : | ||
| 580 | |||
| 581 | =cut | ||
| 582 | |||
| 583 | sub deleteHaplotype { | ||
| 584 | my($self, $id) = @_ ; | ||
| 585 | my($actualType) ; | ||
| 586 | my $dbh = $self->{dbh} ; | ||
| 587 | |||
| 588 | $DEBUG and carp " ->[deleteHaplotype] $id." ; | ||
| 589 | |||
| 590 | ( $actualType ) = $dbh->selectrow_array("select objType from Object | ||
| 591 | where id = $id") ; | ||
| 592 | if ( $actualType ne "Haplotype") { | ||
| 593 | carp " ->[deleteHaplotype] Object with ID = $id is not a Haplotype!" ; | ||
| 594 | return(undef) ; | ||
| 595 | } | ||
| 596 | |||
| 597 | # Object | ||
| 598 | $self->_deleteObjectData($id) ; | ||
| 599 | # Haplotype | ||
| 600 | $dbh->do( "delete from Haplotype | ||
| 601 | where haplotypeID = $id" ) ; | ||
| 602 | # HaplotypeAllele | ||
| 603 | $dbh->do( "delete from HaplotypeAllele | ||
| 604 | where haplotypeID = $id" ) ; | ||
| 605 | |||
| 606 | $DEBUG and carp " ->[deleteHaplotype] End." ; | ||
| 607 | |||
| 608 | return(1) ; | ||
| 609 | } | ||
| 610 | |||
| 611 | =head2 deleteDNASample | ||
| 612 | |||
| 613 | Function : Delete a Genetics::Object::DNASample object from the database. | ||
| 614 | Argument : The id of the object to be deleted. | ||
| 615 | Returns : 1 on success, undef otherwise. | ||
| 616 | Scope : Public | ||
| 617 | Comments : | ||
| 618 | |||
| 619 | =cut | ||
| 620 | |||
| 621 | sub deleteDNASample { | ||
| 622 | my($self, $id) = @_ ; | ||
| 623 | my($actualType) ; | ||
| 624 | my $dbh = $self->{dbh} ; | ||
| 625 | |||
| 626 | $DEBUG and carp " ->[deleteDNASample] $id." ; | ||
| 627 | |||
| 628 | ( $actualType ) = $dbh->selectrow_array("select objType from Object | ||
| 629 | where id = $id") ; | ||
| 630 | if ( $actualType ne "DNASample") { | ||
| 631 | carp " ->[deleteDNASample] Object with ID = $id is not a DNASample!" ; | ||
| 632 | return(undef) ; | ||
| 633 | } | ||
| 634 | |||
| 635 | # Object | ||
| 636 | $self->_deleteObjectData($id) ; | ||
| 637 | # Sample | ||
| 638 | $dbh->do( "delete from Sample | ||
| 639 | where sampleID = $id" ) ; | ||
| 640 | # DNASample | ||
| 641 | $dbh->do( "delete from DNASample | ||
| 642 | where dnaSampleID = $id" ) ; | ||
| 643 | # SubjectSample | ||
| 644 | $dbh->do( "delete from SubjectSample | ||
| 645 | where sampleID = $id" ) ; | ||
| 646 | # SampleGenotype data | ||
| 647 | $dbh->do( "delete from SampleGenotype | ||
| 648 | where sampleID = $id" ) ; | ||
| 649 | # TissueDNASample | ||
| 650 | $dbh->do( "delete from TissueDNASample | ||
| 651 | where dnaSampleID = $id" ) ; | ||
| 652 | |||
| 653 | $DEBUG and carp " ->[deleteDNASample] End." ; | ||
| 654 | |||
| 655 | return(1) ; | ||
| 656 | } | ||
| 657 | |||
| 658 | =head2 deleteTissueSample | ||
| 659 | |||
| 660 | Function : Delete a Genetics::Object::TissueSample object from the database. | ||
| 661 | Argument : The id of the object to be deleted. | ||
| 662 | Returns : 1 on success, undef otherwise. | ||
| 663 | Scope : Public | ||
| 664 | Comments : | ||
| 665 | |||
| 666 | =cut | ||
| 667 | |||
| 668 | sub deleteTissueSample { | ||
| 669 | my($self, $id) = @_ ; | ||
| 670 | my($actualType) ; | ||
| 671 | my $dbh = $self->{dbh} ; | ||
| 672 | |||
| 673 | $DEBUG and carp " ->[deleteTissueSample] $id." ; | ||
| 674 | |||
| 675 | ( $actualType ) = $dbh->selectrow_array("select objType from Object | ||
| 676 | where id = $id") ; | ||
| 677 | if ( $actualType ne "TissueSample") { | ||
| 678 | carp " ->[deleteTissueSample] Object with ID = $id is not a TissueSample!" ; | ||
| 679 | return(undef) ; | ||
| 680 | } | ||
| 681 | |||
| 682 | # Object | ||
| 683 | $self->_deleteObjectData($id) ; | ||
| 684 | # Sample | ||
| 685 | $dbh->do( "delete from Sample | ||
| 686 | where sampleID = $id" ) ; | ||
| 687 | # TissueSample | ||
| 688 | $dbh->do( "delete from TissueSample | ||
| 689 | where tissueSampleID = $id" ) ; | ||
| 690 | # SampleSubject | ||
| 691 | $dbh->do( "delete from SampleSubject | ||
| 692 | where sampleID = $id" ) ; | ||
| 693 | # SampleGenotype | ||
| 694 | $dbh->do( "delete from SampleGenotype | ||
| 695 | where sampleID = $id" ) ; | ||
| 696 | # TissueDNASample | ||
| 697 | $dbh->do( "delete from TissueDNASample | ||
| 698 | where tissueSampleID = $id" ) ; | ||
| 699 | |||
| 700 | $DEBUG and carp " ->[deleteTissueSample] End." ; | ||
| 701 | |||
| 702 | return(1) ; | ||
| 703 | } | ||
| 704 | |||
| 705 | =head2 deleteMap | ||
| 706 | |||
| 707 | Function : Delete a Genetics::Object::Map object from the database. | ||
| 708 | Argument : The id of the object to be deleted. | ||
| 709 | Returns : 1 on success, undef otherwise. | ||
| 710 | Scope : Public | ||
| 711 | Comments : | ||
| 712 | |||
| 713 | =cut | ||
| 714 | |||
| 715 | sub deleteMap { | ||
| 716 | my($self, $id) = @_ ; | ||
| 717 | my($actualType) ; | ||
| 718 | my $dbh = $self->{dbh} ; | ||
| 719 | |||
| 720 | $DEBUG and carp " ->[deleteMap] $id." ; | ||
| 721 | |||
| 722 | ( $actualType ) = $dbh->selectrow_array("select objType from Object | ||
| 723 | where id = $id") ; | ||
| 724 | if ( $actualType ne "Map") { | ||
| 725 | carp " ->[deleteMap] Object with ID = $id is not a Map!" ; | ||
| 726 | return(undef) ; | ||
| 727 | } | ||
| 728 | |||
| 729 | # Object | ||
| 730 | $self->_deleteObjectData($id) ; | ||
| 731 | # Map | ||
| 732 | $dbh->do( "delete from Map | ||
| 733 | where mapID = $id" ) ; | ||
| 734 | # OrderedMapElement | ||
| 735 | $dbh->do( "delete from OrderedMapElement | ||
| 736 | where mapID = $id" ) ; | ||
| 737 | |||
| 738 | $DEBUG and carp " ->[deleteMap] End." ; | ||
| 739 | |||
| 740 | return(1) ; | ||
| 741 | } | ||
| 742 | |||
| 743 | =head1 Private methods | ||
| 744 | |||
| 745 | =head2 _deleteObjectData | ||
| 746 | |||
| 747 | Function : Delete data common to all Genetics::Object objects to the database. | ||
| 748 | Argument : A Genetics::Object ID. | ||
| 749 | Returns : 1 on success, undef otherwise. | ||
| 750 | Scope : Private | ||
| 751 | Called by : The various deleteObjectSubClass methods. | ||
| 752 | |||
| 753 | =cut | ||
| 754 | |||
| 755 | sub _deleteObjectData { | ||
| 756 | my($self, $id) = @_ ; | ||
| 757 | my($rv) ; | ||
| 758 | my $dbh = $self->{dbh} ; | ||
| 759 | |||
| 760 | $DEBUG and carp " ->[_deleteObjectData] $id" ; | ||
| 761 | |||
| 762 | # Delete from Object | ||
| 763 | $rv = $dbh->do( "delete from Object | ||
| 764 | where id = $id" ) ; | ||
| 765 | if ( ! defined $rv ) { | ||
| 766 | carp " ->[_deleteObjectData] Delete from Object failed for ID $id" ; | ||
| 767 | return(undef) ; | ||
| 768 | } | ||
| 769 | # Delete from NameAlias | ||
| 770 | $dbh->do( "delete from NameAlias | ||
| 771 | where objID = $id" ) ; | ||
| 772 | # Delete from DBXReference | ||
| 773 | $dbh->do( "delete from DBXReference | ||
| 774 | where objID = $id" ) ; | ||
| 775 | # Delete from Keyword | ||
| 776 | $dbh->do( "delete from Keyword | ||
| 777 | where objID = $id" ) ; | ||
| 778 | |||
| 779 | $DEBUG and carp " ->[_deleteObjectData] End" ; | ||
| 780 | |||
| 781 | return(1) ; | ||
| 782 | } | ||
| 783 | |||
| 784 | 1; | ||
| 785 |