12 $accession = trim($accession);
13 if($accession ==
"") {
14 throw new Exception(
'Accession must be valid, empty accession was provided');
16 $job->logMessage(
'[INFO] Performing removal of markers and genotypes on study: ' . $accession);
19 $transaction = db_transaction();
21 $job->logMessage(
'[INFO] Removing records from chado.genotype table...');
23 $sql .=
"delete from chado.genotype where genotype_id in ";
24 $sql .=
" (select distinct genotype_id from chado.genotype_call where project_id = (";
25 $sql .=
" select project_id from chado.project_dbxref where dbxref_id = (";
26 $sql .=
" select dbxref_id from chado.dbxref where accession = '" . $accession .
"'";
30 chado_query($sql, []);
31 $job->logMessage(
'[INFO] Done.');
33 $job->logMessage(
'[INFO] Removing records from chado.feature table...');
35 $sql .=
"delete from chado.feature where feature_id in (";
36 $sql .=
" select distinct marker_id from chado.genotype_call where project_id = (";
37 $sql .=
" select project_id from chado.project_dbxref where dbxref_id = (";
38 $sql .=
" select dbxref_id from chado.dbxref where accession = '" . $accession .
"'";
42 $sql .=
"or feature_id in (";
43 $sql .=
" select distinct variant_id from chado.genotype_call where project_id = (";
44 $sql .=
" select project_id from chado.project_dbxref where dbxref_id = (";
45 $sql .=
" select dbxref_id from chado.dbxref where accession = '" . $accession .
"'";
49 chado_query($sql, []);
50 $job->logMessage(
'[INFO] Done.');
52 $job->logMessage(
'[INFO] Removing records from chado.genotype_call table...');
54 $sql .=
"delete from chado.genotype_call where project_id = (";
55 $sql .=
" select project_id from chado.project_dbxref where dbxref_id = (";
56 $sql .=
" select dbxref_id from chado.dbxref where accession = '" . $accession .
"'";
59 chado_query($sql, []);
60 $job->logMessage(
'[INFO] Done.');
61 $job->logMessage(
'[STATUS] Job has been completed successfully without errors.');
63 catch (Exception $e) {
64 $transaction->rollback();
65 $job->logMessage(
'[ERROR] Job failed', array(), TRIPAL_ERROR);
66 $job->logMessage(
'[ERROR] Error message: @msg', array(
'@msg' => $e->getMessage()), TRIPAL_ERROR);
67 $job->logMessage(
"[ERROR] Trace: \n@trace", array(
'@trace' => $e->getTraceAsString()), TRIPAL_ERROR);
68 watchdog_exception(
'tpps', $e);
tpps_remove_all_markers_genotypes($accession, TripalJob $job=NULL)