コード例 #1
0
ファイル: object_diseases.php プロジェクト: LOVDnl/LOVD3
 function prepareData($zData = '', $sView = 'list')
 {
     // Prepares the data by "enriching" the variable received with links, pictures, etc.
     if (!in_array($sView, array('list', 'entry'))) {
         $sView = 'list';
     }
     // Makes sure it's an array and htmlspecialchars() all the values.
     $zData = parent::prepareData($zData, $sView);
     if ($sView == 'list') {
         $zData['row_id'] = $zData['id'];
         $zData['symbol'] = '<A href="' . $zData['row_link'] . '" class="hide">' . $zData['symbol'] . '</A>';
         $zData['genes_'] = '';
         $i = 0;
         if (count($zData['genes']) > 22) {
             // Don't show all genes.
             foreach ($zData['genes'] as $key => $sID) {
                 $zData['genes_'] .= (!$key ? '' : ', ') . $sID;
                 $i++;
                 if ($i >= 20) {
                     break;
                 }
             }
             $zData['genes_'] .= ', ' . ($zData['gene_count'] - $i) . ' more';
         } else {
             $zData['genes_'] = implode(', ', $zData['genes']);
         }
     } else {
         if (!empty($zData['id_omim'])) {
             $zData['id_omim'] = '<A href="' . lovd_getExternalSource('omim', $zData['id_omim'], true) . '" target="_blank">' . $zData['id_omim'] . '</A>';
         }
         $zData['phenotypes_'] = $zData['phenotypes'];
         if ($zData['phenotypes']) {
             $zData['phenotypes_'] = '<A href="phenotypes/disease/' . $zData['id'] . '">' . $zData['phenotypes'] . '</A>';
         }
         // Provide links to gene symbols this disease is associated with.
         $this->aColumnsViewEntry['genes_'] .= ' ' . count($zData['genes']) . ' gene' . (count($zData['genes']) == 1 ? '' : 's');
         $zData['genes_'] = '';
         $zData['genes_short_'] = '';
         $i = 0;
         foreach ($zData['genes'] as $key => $sID) {
             $zData['genes_'] .= (!$key ? '' : ', ') . '<A href="genes/' . $sID . '">' . $sID . '</A>';
             if ($i < 20) {
                 $zData['genes_short_'] .= (!$key ? '' : ', ') . '<A href="genes/' . $sID . '">' . $sID . '</A>';
                 $i++;
             }
         }
         if (count($zData['genes']) > 22) {
             // Replace long gene list by shorter one, allowing expand.
             $zData['genes_'] = '<SPAN>' . $zData['genes_short_'] . ', <A href="#" onclick="$(this).parent().hide(); $(this).parent().next().show(); return false;">' . (count($zData['genes']) - $i) . ' more...</A></SPAN><SPAN style="display : none;">' . $zData['genes_'] . '</SPAN>';
         }
     }
     return $zData;
 }
コード例 #2
0
ファイル: object_genes.php プロジェクト: LOVDnl/LOVD3
 function prepareData($zData = '', $sView = 'list')
 {
     // Prepares the data by "enriching" the variable received with links, pictures, etc.
     global $_AUTH, $_CONF, $_DB, $_SETT;
     if (!in_array($sView, array('list', 'entry'))) {
         $sView = 'list';
     }
     // Makes sure it's an array and htmlspecialchars() all the values.
     $zData = parent::prepareData($zData, $sView);
     if ($sView == 'list') {
         $zData['updated_date_'] = substr($zData['updated_date'], 0, 10);
     } else {
         $zData['imprinting_'] = $_SETT['gene_imprinting'][$zData['imprinting']];
         // FIXME; zou dit een external source moeten zijn?
         $zData['refseq_genomic_'] = '<A href="' . (substr($zData['refseq_genomic'], 0, 3) == 'LRG' ? 'ftp://ftp.ebi.ac.uk/pub/databases/lrgex/' . $zData['refseq_genomic'] . '.xml' : 'http://www.ncbi.nlm.nih.gov/nuccore/' . $zData['refseq_genomic']) . '" target="_blank">' . $zData['refseq_genomic'] . '</A>';
         $zData['refseq_UD_'] = '<A href="' . str_replace('services', 'Reference/', $_CONF['mutalyzer_soap_url']) . $zData['refseq_UD'] . '.gb" target="_blank">' . $zData['refseq_UD'] . '</A>';
         // Transcript links and exon/intron info table. Check if files exist, and build link. Otherwise, remove field.
         $zData['refseq_transcript_'] = '';
         $zData['exon_tables'] = '';
         foreach ($zData['transcripts'] as $aTranscript) {
             list($nTranscriptID, $sNCBI) = $aTranscript;
             $zData['refseq_transcript_'] .= (!$zData['refseq_transcript_'] ? '' : ', ') . '<A href="transcripts/' . $nTranscriptID . '">' . $sNCBI . '</A>';
             $sExonTableFile = ROOT_PATH . 'refseq/' . $zData['id'] . '_' . $sNCBI . '_table.html';
             if (is_readable($sExonTableFile)) {
                 $zData['exon_tables'] .= (!$zData['exon_tables'] ? '' : ', ') . '<A href="' . $sExonTableFile . '" target="_blank">' . $sNCBI . '</A>';
             }
         }
         if (!$zData['refseq_transcript_']) {
             unset($this->aColumnsViewEntry['refseq_transcript_']);
         }
         if (!$zData['exon_tables']) {
             unset($this->aColumnsViewEntry['exon_tables']);
         }
         // Associated with diseases...
         $zData['diseases_'] = '';
         $zData['disease_omim_'] = '';
         foreach ($zData['diseases'] as $aDisease) {
             list($nID, $nOMIMID, $sSymbol, $sName) = $aDisease;
             // Link to disease entry in LOVD.
             $zData['diseases_'] .= (!$zData['diseases_'] ? '' : ', ') . '<A href="diseases/' . $nID . '">' . $sSymbol . '</A>';
             if ($nOMIMID) {
                 // Add link to OMIM for each disease that has an OMIM ID.
                 $zData['disease_omim_'] .= (!$zData['disease_omim_'] ? '' : '<BR>') . '<A href="' . lovd_getExternalSource('omim', $nOMIMID, true) . '" target="_blank">' . $sSymbol . ($sSymbol == $sName ? '' : ' (' . $sName . ')') . '</A>';
             }
         }
         if (isset($zData['reference'])) {
             // FIXME; is 't niet beter de PubMed custom link data uit de database te halen? Als ie ooit wordt aangepast, gaat dit fout.
             $zData['reference'] = preg_replace('/\\{PMID:(.*):(.*)\\}/U', '<A href="http://www.ncbi.nlm.nih.gov/pubmed/$2" target="_blank">$1</A>', $zData['reference']);
         }
         $zData['allow_download_'] = '<IMG src="gfx/mark_' . $zData['allow_download'] . '.png" alt="" width="11" height="11">';
         $zData['allow_index_wiki_'] = '<IMG src="gfx/mark_' . $zData['allow_index_wiki'] . '.png" alt="" width="11" height="11">';
         // Human readable RefSeq link.
         if ($zData['refseq_url']) {
             $zData['refseq_url_'] = '<A href="' . $zData['refseq_url'] . '" target="_blank">' . ($zData['refseq'] == 'c' ? 'Coding DNA' : 'Genomic') . ' reference sequence</A>';
         }
         // Curators and collaborators.
         $zData['curators_'] = $zData['collaborators_'] = '';
         $aCurators = $aCollaborators = array();
         foreach ($zData['curators'] as $aVal) {
             if ($aVal) {
                 // Should always be true, since genes should always have a curator!
                 list($nUserID, $sName, $bAllowEdit, $nOrder) = $aVal;
                 if ($bAllowEdit) {
                     $aCurators[$nUserID] = array($sName, $nOrder);
                 } else {
                     $aCollaborators[$nUserID] = $sName;
                 }
             }
         }
         asort($aCollaborators);
         // Sort collaborators by name.
         $nCurators = count($aCurators);
         $nCollaborators = count($aCollaborators);
         // Curator string.
         $i = 0;
         foreach ($aCurators as $nUserID => $aUser) {
             $i++;
             list($sName, $nOrder) = $aUser;
             // 2013-06-05; 3.0-06; There should be no link for users not logged in; they can't access these anyways.
             if ($_AUTH) {
                 // Use links, hidden curators possibly in the list (depends on exact user level).
                 $zData['curators_'] .= ($i == 1 ? '' : ($i == $nCurators ? ' and ' : ', ')) . ($nOrder ? '<B><A href="users/' . $nUserID . '">' . $sName . '</A></B>' : '<I><A href="users/' . $nUserID . '">' . $sName . '</A> (hidden)</I>');
             } else {
                 // Don't use links, and we never see hidden users anyways.
                 $zData['curators_'] .= ($i == 1 ? '' : ($i == $nCurators ? ' and ' : ', ')) . '<B>' . $sName . '</B>';
             }
         }
         $this->aColumnsViewEntry['curators_'] .= ' (' . $nCurators . ')';
         if ($_AUTH['level'] >= LEVEL_COLLABORATOR) {
             // Collaborator string.
             $i = 0;
             foreach ($aCollaborators as $nUserID => $sName) {
                 $i++;
                 $zData['collaborators_'] .= ($i == 1 ? '' : ($i == $nCollaborators ? ' and ' : ', ')) . '<A href="users/' . $nUserID . '">' . $sName . '</A>';
             }
             $this->aColumnsViewEntry['collaborators_'][0] .= ' (' . $nCollaborators . ')';
         }
         // Links on the stats numbers that lead to their views.
         $zData['variants_'] = 0;
         if ($zData['variants']) {
             $zData['variants_'] = '<A href="variants/' . $zData['id'] . '?search_var_status=%3D%22Marked%22%7C%3D%22Public%22">' . $zData['variants'] . '</A>';
         }
         $zData['uniq_variants_'] = 0;
         if ($zData['uniq_variants']) {
             $zData['uniq_variants_'] = '<A href="variants/' . $zData['id'] . '/unique?search_var_status=%3D%22Marked%22%7C%3D%22Public%22">' . $zData['uniq_variants'] . '</A>';
         }
         //'count_individuals' => 'Individuals with public variants',
         $zData['hidden_variants_'] = $zData['hidden_variants'];
         if ($zData['hidden_variants'] && $_AUTH['level'] >= LEVEL_CURATOR) {
             $zData['hidden_variants_'] = '<A href="variants/' . $zData['id'] . '?search_var_status=%3D%22Pending%22%7C%3D%22Non%20public%22">' . $zData['hidden_variants'] . '</A>';
         }
         $zData['note_index'] = html_entity_decode($zData['note_index']);
         // The individual count can only be found by adding up all distinct individual's panel_size.
         // 2013-10-11; 3.0-08; This query was first done using GROUP_CONCAT incorporated in the ViewEntry query. However, since the results were sometimes too long for MySQL, resulting in incorrect numbers and notices, this query is better represented as a separate query.
         $zData['count_individuals'] = (int) $_DB->query('SELECT SUM(panel_size) FROM (SELECT DISTINCT i.id, i.panel_size FROM ' . TABLE_INDIVIDUALS . ' AS i INNER JOIN ' . TABLE_SCREENINGS . ' AS s ON (i.id = s.individualid) INNER JOIN ' . TABLE_SCR2VAR . ' AS s2v ON (s.id = s2v.screeningid) INNER JOIN ' . TABLE_VARIANTS . ' AS vog ON (s2v.variantid = vog.id) INNER JOIN ' . TABLE_VARIANTS_ON_TRANSCRIPTS . ' AS vot ON (vog.id = vot.id) INNER JOIN ' . TABLE_TRANSCRIPTS . ' AS t ON (vot.transcriptid = t.id) WHERE i.panelid IS NULL AND vog.statusid >= ' . STATUS_MARKED . ' AND t.geneid = ?)i', array($zData['id']))->fetchColumn();
         $zData['created_date_'] = str_replace(' 00:00:00', '', $zData['created_date_']);
         if ($zData['updated_date']) {
             $zData['version_'] = '<B>' . $zData['id'] . date(':ymd', strtotime($zData['updated_date_'])) . '</B>';
         } else {
             unset($this->aColumnsViewEntry['version_']);
             if ($_AUTH['level'] < LEVEL_COLLABORATOR) {
                 // Also unset the empty updated_date field; users lower than collaborator don't see the updated_by field, either.
                 unset($this->aColumnsViewEntry['updated_date_']);
             }
         }
         if ($_AUTH['level'] < LEVEL_COLLABORATOR) {
             // Public, change date timestamps to human readable format.
             $zData['created_date_'] = date('F d, Y', strtotime($zData['created_date_']));
             $zData['updated_date_'] = date('F d, Y', strtotime($zData['updated_date_']));
         }
         // Graphs & utilities.
         if ($zData['variants']) {
             $zData['graphs'] = '<A href="' . CURRENT_PATH . '/graphs" class="hide">Graphs displaying summary information of all variants in the database</A> &raquo;';
             $sURLBedFile = rawurlencode(str_replace('https://', 'http://', $_CONF['location_url'] ? $_CONF['location_url'] : lovd_getInstallURL()) . 'api/rest/variants/' . $zData['id'] . '?format=text/bed');
             $sURLUCSC = 'http://genome.ucsc.edu/cgi-bin/hgTracks?clade=mammal&amp;org=Human&amp;db=' . $_CONF['refseq_build'] . '&amp;position=chr' . $zData['chromosome'] . ':' . ($zData['position_g_mrna_start'] - 50) . '-' . ($zData['position_g_mrna_end'] + 50) . ($zData['sense'] ? '' : '&amp;complement_hg19=1') . '&amp;hgt.customText=' . $sURLBedFile;
             $zData['ucsc'] = 'Show variants in the UCSC Genome Browser (<A href="' . $sURLUCSC . '" target="_blank">full view</A>, <A href="' . $sURLUCSC . rawurlencode('&visibility=4') . '" target="_blank">compact view</A>)';
             if ($_CONF['refseq_build'] == 'hg18') {
                 $sURLEnsembl = 'http://may2009.archive.ensembl.org/Homo_sapiens/Location/View?r=' . $zData['chromosome'] . ':' . ($zData['position_g_mrna_start'] - 50) . '-' . ($zData['position_g_mrna_end'] + 50) . ';data_URL=';
             } elseif ($_CONF['refseq_build'] == 'hg19') {
                 $sURLEnsembl = 'http://grch37.ensembl.org/Homo_sapiens/Location/View?r=' . $zData['chromosome'] . ':' . ($zData['position_g_mrna_start'] - 50) . '-' . ($zData['position_g_mrna_end'] + 50) . ';contigviewbottom=url:';
             } else {
                 $sURLEnsembl = 'http://www.ensembl.org/Homo_sapiens/Location/View?r=' . $zData['chromosome'] . ':' . ($zData['position_g_mrna_start'] - 50) . '-' . ($zData['position_g_mrna_end'] + 50) . ';contigviewbottom=url:';
             }
             // The weird addition in the end is to fake a proper name in Ensembl.
             $sURLEnsembl .= $sURLBedFile . rawurlencode('&name=/' . $zData['id'] . ' variants');
             $zData['ensembl'] = 'Show variants in the Ensembl Genome Browser (<A href="' . $sURLEnsembl . '=labels" target="_blank">full view</A>, <A href="' . $sURLEnsembl . '=normal" target="_blank">compact view</A>)';
             $zData['ncbi'] = 'Show distribution histogram of variants in the <A href="http://www.ncbi.nlm.nih.gov/projects/sviewer/?id=' . $_SETT['human_builds'][$_CONF['refseq_build']]['ncbi_sequences'][$zData['chromosome']] . '&amp;v=' . ($zData['position_g_mrna_start'] - 100) . ':' . ($zData['position_g_mrna_end'] + 100) . '&amp;content=7&amp;url=' . $sURLBedFile . '" target="_blank">NCBI Sequence Viewer</A>';
         } else {
             unset($this->aColumnsViewEntry['TableStart_Graphs'], $this->aColumnsViewEntry['TableHeader_Graphs'], $this->aColumnsViewEntry['graphs'], $this->aColumnsViewEntry['ucsc'], $this->aColumnsViewEntry['ensembl'], $this->aColumnsViewEntry['ncbi'], $this->aColumnsViewEntry['TableEnd_Graphs'], $this->aColumnsViewEntry['HR_2']);
         }
         // URLs for "Links to other resources".
         $zData['url_homepage_'] = $zData['url_homepage'] ? '<A href="' . $zData['url_homepage'] . '" target="_blank">' . $zData['url_homepage'] . '</A>' : '';
         $zData['url_external_'] = '';
         if ($zData['url_external']) {
             $aLinks = explode("\r\n", $zData['url_external']);
             foreach ($aLinks as $sLink) {
                 if (preg_match('/^(.+) &lt;(.+)&gt;$/', $sLink, $aRegs)) {
                     $zData['url_external_'] .= ($zData['url_external_'] ? '<BR>' : '') . '<A href="' . $aRegs[2] . '" target="_blank">' . $aRegs[1] . '</A>';
                 } else {
                     $zData['url_external_'] .= ($zData['url_external_'] ? '<BR>' : '') . '<A href="' . $sLink . '" target="_blank">' . $sLink . '</A>';
                 }
             }
         }
         $aExternal = array('id_omim', 'id_hgnc', 'id_entrez', 'id_pubmed_gene', 'show_hgmd', 'show_genecards', 'show_genetests');
         foreach ($aExternal as $sColID) {
             list($sType, $sSource) = explode('_', $sColID, 2);
             if (!empty($zData[$sColID])) {
                 $zData[$sColID . '_'] = '<A href="' . lovd_getExternalSource($sSource, $sType == 'id' ? $zData[$sColID] : rawurlencode($zData['id']), true) . '" target="_blank">' . ($sType == 'id' ? $zData[$sColID] : rawurlencode($zData['id'])) . '</A>';
             } else {
                 $zData[$sColID . '_'] = '';
             }
         }
         // Link to PubMed articles now shows Entrez Gene ID, which might be misinterpreted as a number of articles. Replace by Gene Symbol.
         $zData['id_pubmed_gene_'] = str_replace($zData['id_entrez'] . '</A>', $zData['id'] . '</A>', $zData['id_pubmed_gene_']);
         // Disclaimer.
         $sYear = substr($zData['created_date'], 0, 4);
         $sYear = (int) $sYear && $sYear < date('Y') ? $sYear . '-' . date('Y') : date('Y');
         $aDisclaimer = array(0 => 'No', 1 => 'Standard LOVD disclaimer', 2 => 'Own disclaimer');
         $zData['disclaimer_'] = $aDisclaimer[$zData['disclaimer']];
         $zData['disclaimer_text_'] = !$zData['disclaimer'] ? '' : ($zData['disclaimer'] == 2 ? html_entity_decode($zData['disclaimer_text']) : 'The contents of this LOVD database are the intellectual property of the respective curator(s). Any unauthorised use, copying, storage or distribution of this material without written permission from the curator(s) will lead to copyright infringement with possible ensuing litigation. Copyright &copy; ' . $sYear . '. All Rights Reserved. For further details, refer to Directive 96/9/EC of the European Parliament and the Council of March 11 (1996) on the legal protection of databases.<BR><BR>We have used all reasonable efforts to ensure that the information displayed on these pages and contained in the databases is of high quality. We make no warranty, express or implied, as to its accuracy or that the information is fit for a particular purpose, and will not be held responsible for any consequences arising out of any inaccuracies or omissions. Individuals, organisations and companies which use this database do so on the understanding that no liability whatsoever either direct or indirect shall rest upon the curator(s) or any of their employees or agents for the effects of any product, process or method that may be produced or adopted by any part, notwithstanding that the formulation of such product, process or method may be based upon information here provided.');
         // Unset fields that will not be shown if they're empty.
         foreach (array('note_index', 'refseq_url_', 'url_homepage_', 'url_external_', 'id_entrez_', 'id_pubmed_gene_', 'id_omim_', 'disease_omim_', 'show_hgmd_', 'show_genecards_', 'show_genetests_') as $key) {
             if (empty($zData[$key])) {
                 unset($this->aColumnsViewEntry[$key]);
             }
         }
     }
     return $zData;
 }