$aFields = array('id', 'name', 'chromosome', 'chrom_band', 'imprinting', 'refseq_genomic', 'refseq_UD', 'reference', 'url_homepage', 'url_external', 'allow_download', 'allow_index_wiki', 'id_hgnc', 'id_entrez', 'id_omim', 'show_hgmd', 'show_genecards', 'show_genetests', 'note_index', 'note_listing', 'refseq', 'refseq_url', 'disclaimer', 'disclaimer_text', 'header', 'header_align', 'footer', 'footer_align', 'created_by', 'created_date'); // Prepare values. $_POST['created_by'] = $_AUTH['id']; if (empty($_POST['created_date']) || @strtotime($_POST['created_date']) > time()) { $_POST['created_date'] = date('Y-m-d H:i:s'); } $_POST['id'] = $zData['id']; $_POST['name'] = $zData['name']; $_POST['refseq_UD'] = $zData['refseq_UD']; $_POST['chromosome'] = $zData['chromosome']; $_POST['id_hgnc'] = $zData['id_hgnc']; $_POST['id_entrez'] = $zData['id_entrez'] ? $zData['id_entrez'] : ''; $_POST['id_omim'] = $zData['id_omim'] ? $zData['id_omim'] : ''; $_DATA['Genes']->insertEntry($_POST, $aFields); // Add the default custom columns to this gene. lovd_addAllDefaultCustomColumns('gene', $_POST['id']); // Write to log... lovd_writeLog('Event', LOG_EVENT, 'Created gene information entry ' . $_POST['id'] . ' (' . $_POST['name'] . ')'); // Make current user curator of this gene. $_DB->query('INSERT INTO ' . TABLE_CURATES . ' VALUES (?, ?, ?, ?)', array($_AUTH['id'], $_POST['id'], 1, 1)); // Add diseases. $aSuccessDiseases = array(); if (!empty($_POST['active_diseases']) && is_array($_POST['active_diseases'])) { foreach ($_POST['active_diseases'] as $nDisease) { // Add disease to gene. if ($nDisease) { $q = $_DB->query('INSERT INTO ' . TABLE_GEN2DIS . ' VALUES (?, ?)', array($_POST['id'], $nDisease), false); if (!$q) { // Silent error. lovd_writeLog('Error', LOG_EVENT, 'Disease information entry ' . $nDisease . ' - could not be added to gene ' . $_POST['id']); } else {
require ROOT_PATH . 'inc-lib-actions.php'; require ROOT_PATH . 'class/object_diseases.php'; $_DATA = new LOVD_Disease(); require ROOT_PATH . 'inc-lib-form.php'; if (!empty($_POST)) { lovd_errorClean(); $_DATA->checkFields($_POST); if (!lovd_error()) { // Fields to be used. $aFields = array('symbol', 'name', 'id_omim', 'tissues', 'features', 'remarks', 'created_by', 'created_date'); // Prepare values. $_POST['created_by'] = $_AUTH['id']; $_POST['created_date'] = date('Y-m-d H:i:s'); $nID = $_DATA->insertEntry($_POST, $aFields); // Add all standard custom columns to this new disease. lovd_addAllDefaultCustomColumns('disease', $nID); // Write to log... lovd_writeLog('Event', LOG_EVENT, 'Created disease information entry ' . $nID . ' - ' . $_POST['symbol'] . ' (' . $_POST['name'] . ')'); // Add genes. $aSuccess = array(); if (!empty($_POST['genes'])) { foreach ($_POST['genes'] as $sGene) { // Add gene to disease. // FIXME; Nu dat PDO beschikbaar is, doe dit in een prepared statement met multiple executes. $q = $_DB->query('INSERT INTO ' . TABLE_GEN2DIS . ' VALUES (?, ?)', array($sGene, $nID), false); if (!$q) { // Silent error. lovd_writeLog('Error', LOG_EVENT, 'Disease information entry ' . $nID . ' - ' . $_POST['symbol'] . ' - could not be added to gene ' . $sGene); } else { $aSuccess[] = $sGene; }
if (!empty($aFieldsTranscript)) { // Mapping is going to succeed! Let's add this gene and transcript. $aVariantOnTranscriptSQL = $aVariantOnTranscriptSQL[$aFieldsTranscript['id_ncbi']]; // But first check if the gene was already there without transcripts. if (!$_DB->query('SELECT COUNT(*) FROM ' . TABLE_GENES . ' WHERE id = ?', array($sSymbol))->fetchColumn()) { $aFields = array('id' => $sSymbol, 'name' => $sGeneName, 'chromosome' => $sChromosome, 'chrom_band' => $sChromBand, 'refseq_genomic' => $sRefseqGenomic, 'refseq_UD' => $sRefseqUD, 'reference' => '', 'url_homepage' => '', 'url_external' => '', 'allow_download' => 0, 'allow_index_wiki' => 0, 'id_hgnc' => $sHgncID, 'id_entrez' => $sEntrez, 'id_omim' => $sOmim, 'show_hgmd' => 1, 'show_genecards' => 1, 'show_genetests' => 1, 'note_index' => '', 'note_listing' => '', 'refseq' => '', 'refseq_url' => '', 'disclaimer' => 1, 'disclaimer_text' => '', 'header' => '', 'header_align' => -1, 'footer' => '', 'footer_align' => -1, 'created_by' => 0, 'created_date' => date('Y-m-d H:i:s'), 'updated_by' => 0, 'updated_date' => date('Y-m-d H:i:s')); $_DB->query('INSERT INTO ' . TABLE_GENES . ' (' . implode(', ', array_keys($aFields)) . ') VALUES (?' . str_repeat(', ?', count($aFields) - 1) . ')', array_values($aFields)); // Only assign newly inserted genes to managers. If the creator of the variant is not a manager, make the database admin the curator for this gene. if (empty($aManagerList)) { // Building the list of managers only once. $aManagerList = $_DB->query('SELECT id FROM ' . TABLE_USERS . ' WHERE level >= ' . LEVEL_MANAGER . ' ORDER BY level DESC')->fetchAllColumn(); } $nCurator = array_search($aVariant['created_by'], $aManagerList) !== false ? $aVariant['created_by'] : $aManagerList[0]; $_DB->query('INSERT INTO ' . TABLE_CURATES . ' VALUES (?, ?, ?, ?)', array($nCurator, $sSymbol, 1, 1)); // Also activate default custom columns for this gene. lovd_addAllDefaultCustomColumns('gene', $sSymbol, 0); } // Now insert the transcript. $q = $_DB->query('INSERT IGNORE INTO ' . TABLE_TRANSCRIPTS . ' (' . implode(', ', array_keys($aFieldsTranscript)) . ') VALUES (?' . str_repeat(', ?', count($aFieldsTranscript) - 1) . ')', array_values($aFieldsTranscript)); if ($q->rowCount()) { // Get the ID of the newly inserted transcript. $nID = $_DB->lastInsertId(); } else { // This transcript was just added by a concurrent call to the mapping script. Get its ID and map on. $nID = $_DB->query('SELECT id FROM ' . TABLE_TRANSCRIPTS . ' WHERE id_ncbi = ?', array($aFieldsTranscript['id_ncbi']))->fetchColumn(); } // Get the p. description too. $aPrediction = lovd_getRNAProteinPrediction($sRefseqUD, $sSymbol, $aFieldsTranscript['id_ncbi'], $aVariantOnTranscriptSQL[1][7]); $aVariantOnTranscriptSQL[1][8] = empty($aPrediction['predict']['RNA']) ? '' : $aPrediction['predict']['RNA']; $aVariantOnTranscriptSQL[1][9] = empty($aPrediction['predict']['protein']) ? '' : $aPrediction['predict']['protein']; // Map the variant to the newly inserted transcript.