Esempio n. 1
0
 function prepareData($zData = '', $sView = 'list')
 {
     // Prepares the data by "enriching" the variable received with links, pictures, etc.
     global $_AUTH, $_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 == 'entry') {
         $zData['individualid_'] = '<A href="individuals/' . $zData['individualid'] . '">' . $zData['individualid'] . '</A>';
         if ($_AUTH['level'] >= LEVEL_COLLABORATOR) {
             $zData['individualid_'] .= ' <SPAN style="color : #' . $this->getStatusColor($zData['individual_statusid']) . '">(' . $_SETT['data_status'][$zData['individual_statusid']] . ')</SPAN>';
         }
         $zData['disease_'] = '<A href="diseases/' . $zData['diseaseid'] . '">' . $zData['disease'] . '</A>';
         if (!empty($zData['Phenotype/Age']) && preg_match('/^([<>])?(\\d+y)(\\d+m)?(\\d+d)?(\\?)?$/', htmlspecialchars_decode($zData['Phenotype/Age']), $aMatches)) {
             $aMatches = $aMatches + array_fill(0, 5, '');
             // Fill $aMatches with enough values.
             $nYears = (int) $aMatches[2];
             $nMonths = (int) $aMatches[3];
             $nDays = (int) $aMatches[4];
             $sAge = !$nYears ? '' : $nYears . ' year' . ($nYears == 1 ? '' : 's');
             $sAge .= !$nMonths ? '' : ($sAge ? ', ' : '') . $nMonths . ' month' . ($nMonths == 1 ? '' : 's');
             $sAge .= !$nDays ? '' : ($sAge ? ', ' : '') . $nDays . ' day' . ($nDays == 1 ? '' : 's');
             $zData['Phenotype/Age'] .= ' (' . (!$aMatches[1] ? '' : ($aMatches[1] == '>' ? 'later than' : 'before') . ' ') . (empty($aMatches[5]) ? '' : 'approximately ') . $sAge . ')';
         }
     }
     return $zData;
 }
Esempio n. 2
0
 function prepareData($zData = '', $sView = 'list')
 {
     // Prepares the data by "enriching" the variable received with links, pictures, etc.
     global $_AUTH, $_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 == 'entry') {
         $zData['individualid_'] = '<A href="individuals/' . $zData['individualid'] . '">' . $zData['individualid'] . '</A>';
         if ($_AUTH['level'] >= LEVEL_COLLABORATOR) {
             $zData['individualid_'] .= ' <SPAN style="color : #' . $this->getStatusColor($zData['individual_statusid']) . '">(' . $_SETT['data_status'][$zData['individual_statusid']] . ')</SPAN>';
         }
     }
     $zData['variants_found_'] = $zData['variants_found_'] == -1 ? 'Not yet submitted' : $zData['variants_found_'];
     return $zData;
 }
Esempio n. 3
0
 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 == 'entry') {
         if (!empty($zData['Individual/Age_of_death']) && preg_match('/^([<>])?(\\d+y)(\\d+m)?(\\d+d)?(\\?)?$/', htmlspecialchars_decode($zData['Individual/Age_of_death']), $aMatches)) {
             $aMatches = $aMatches + array_fill(0, 5, '');
             // Fill $aMatches with enough values.
             $nYears = (int) $aMatches[2];
             $nMonths = (int) $aMatches[3];
             $nDays = (int) $aMatches[4];
             $sAge = !$nYears ? '' : $nYears . ' year' . ($nYears == 1 ? '' : 's');
             $sAge .= !$nMonths ? '' : ($sAge ? ', ' : '') . $nMonths . ' month' . ($nMonths == 1 ? '' : 's');
             $sAge .= !$nDays ? '' : ($sAge ? ', ' : '') . $nDays . ' day' . ($nDays == 1 ? '' : 's');
             $zData['Individual/Age_of_death'] .= ' (' . (!$aMatches[1] ? '' : ($aMatches[1] == '>' ? 'later than' : 'before') . ' ') . (empty($aMatches[5]) ? '' : 'approximately ') . $sAge . ')';
         }
         // Hide Panel ID if not applicable.
         if (empty($zData['panelid'])) {
             unset($this->aColumnsViewEntry['panelid_']);
         } else {
             $zData['panelid_'] = '<A href="individuals/' . $zData['panelid'] . '">' . $zData['panelid'] . '</A>';
         }
         // Associated with diseases...
         $zData['diseases_'] = '';
         foreach ($zData['diseases'] as $aDisease) {
             list($nID, $sSymbol, $sName) = $aDisease;
             $zData['diseases_'] .= (!$zData['diseases_'] ? '' : ', ') . '<A href="diseases/' . $nID . '" title="' . $sName . '">' . $sSymbol . '</A>';
         }
         // Parents...
         if (empty($zData['fatherid']) && empty($zData['motherid'])) {
             unset($this->aColumnsViewEntry['parents_']);
         } else {
             if ($zData['fatherid']) {
                 $zData['parents_'] = '<A href="individuals/' . $zData['fatherid'] . '">Father</A>';
             }
             if ($zData['motherid']) {
                 $zData['parents_'] .= (empty($zData['parents_']) ? '' : ', ') . '<A href="individuals/' . $zData['motherid'] . '">Mother</A>';
             }
         }
     }
     return $zData;
 }
Esempio n. 4
0
 function prepareData($zData = '', $sView = 'list')
 {
     // Prepares the data by "enriching" the variable received with links, pictures, etc.
     global $_AUTH, $_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 == 'entry') {
         $zData['individualid_'] = '';
         // While in principle a variant should only be connected to one patient, due to database model limitations, through several screenings, one could link a variant to more individuals.
         foreach ($zData['individuals'] as $aIndividual) {
             list($nID, $nStatusID) = $aIndividual;
             $zData['individualid_'] .= ($zData['individualid_'] ? ', ' : '') . '<A href="individuals/' . $nID . '">' . $nID . '</A>';
             if ($_AUTH['level'] >= LEVEL_COLLABORATOR) {
                 $zData['individualid_'] .= ' <SPAN style="color : #' . $this->getStatusColor($nStatusID) . '">(' . $_SETT['data_status'][$nStatusID] . ')</SPAN>';
             }
         }
         if (empty($zData['individualid_'])) {
             unset($this->aColumnsViewEntry['individualid_']);
         }
         $zData['effect_reported'] = $_SETT['var_effect'][$zData['effectid'][0]];
         $zData['effect_concluded'] = $_SETT['var_effect'][$zData['effectid'][1]];
         if (!empty($zData['VariantOnGenome/DBID'])) {
             // Allow linking to view of all these variants.
             $sQ = 'SELECT COUNT(*) FROM ' . TABLE_VARIANTS . ' WHERE chromosome = ? AND `VariantOnGenome/DBID` = ?';
             $aArgs = array($zData['chromosome'], $zData['VariantOnGenome/DBID']);
             if ($_AUTH['level'] < LEVEL_CURATOR) {
                 $sQ .= ' AND statusid >= ?';
                 $aArgs[] = STATUS_MARKED;
             }
             $n = $_DB->query($sQ, $aArgs)->fetchColumn();
             if ($n > 1) {
                 list($sPrefix, ) = explode('_', $zData['VariantOnGenome/DBID'], 2);
                 $sLink = '<A href="' . (substr($sPrefix, 0, 3) == 'chr' ? 'variants' : 'view/' . $sPrefix) . '?search_VariantOnGenome%2FDBID=%3D%22' . $zData['VariantOnGenome/DBID'] . '%22">See all ' . $n . ' reported entries</A>';
                 // This is against our coding policy of never modifying actual contents of values (we always create a copy with _ appended), but now I simply can't without
                 // modifying the column list manually. If only array_splice() would work on associative arrays... I'm not going to create a workaround here.
                 $zData['VariantOnGenome/DBID'] .= ' <SPAN style="float:right">' . $sLink . '</SPAN>';
             }
         }
         if ($zData['mapping_flags'] & MAPPING_ALLOW) {
             $sMappingLinkText = '';
             $sMappingLinkTitle = '';
             if ($zData['mapping_flags'] & MAPPING_NOT_RECOGNIZED) {
                 $zData['mapping_flags_'] = 'Variant not recognized';
                 if ($zData['mapping_flags'] & MAPPING_ALLOW_CREATE_GENES) {
                     $zData['mapping_flags_'] .= ' (would have created genes as needed)';
                 }
                 $sMappingLinkText = 'Retry';
             } elseif ($zData['mapping_flags'] & MAPPING_DONE) {
                 $zData['mapping_flags_'] = 'Done';
                 if ($zData['mapping_flags'] & MAPPING_ALLOW_CREATE_GENES) {
                     $zData['mapping_flags_'] .= ' (created genes as needed)';
                 }
                 $sMappingLinkText = 'Map again';
                 $sMappingLinkTitle = 'If new transcripts have been added to LOVD, this will try to map this variant to them.';
             } else {
                 $zData['mapping_flags_'] = 'Scheduled';
                 if ($zData['mapping_flags'] & MAPPING_ALLOW_CREATE_GENES) {
                     $zData['mapping_flags_'] .= ', creating genes as needed';
                 }
                 if ($zData['mapping_flags'] & MAPPING_ERROR) {
                     $zData['mapping_flags_'] .= ' (encountered a problem on the last attempt)';
                 }
                 $sMappingLinkText = 'Map now';
             }
             if ($_AUTH['level'] >= LEVEL_OWNER) {
                 $zData['mapping_flags_'] .= ' <SPAN style="float: right" id="mapOnRequest"><A href="#" onclick="return lovd_mapOnRequest();"' . (!$sMappingLinkTitle ? '' : ' title="' . $sMappingLinkTitle . '"') . '>' . $sMappingLinkText . '</A></SPAN>';
             }
         } else {
             $zData['mapping_flags_'] = 'Off';
         }
         // 2013-09-27; 3.0-08; Frequences retrieved from the LOVD WGS install.
         if (!$zData['chromosome'] || !$zData['position_g_start'] || !$zData['position_g_end']) {
             $zData['average_frequency_'] = 'Genomic location of variant could not be determined';
         } elseif ($zData['average_frequency'] === '') {
             $zData['average_frequency_'] = '<A href="#" onclick="lovd_openWindow(\'' . ROOT_PATH . 'scripts/fetch_frequencies.php\', \'FetchFrequencies\', \'500\', \'150\'); return false;">Retrieve</A>';
         } elseif ($zData['average_frequency'] === '0') {
             $zData['average_frequency_'] = 'Variant not found in online data sets';
         } else {
             $zData['average_frequency_'] = round($zData['average_frequency'], 5) . ' <SPAN style="float: right"><A href="http://databases.lovd.nl/whole_genome/variants/chr' . $zData['chromosome'] . '?search_VariantOnGenome/DNA=' . $zData['VariantOnGenome/DNA'] . '" title="" target="_blank">View details</A></SPAN>';
         }
     }
     // Replace rs numbers with dbSNP links.
     if (!empty($zData['VariantOnGenome/dbSNP'])) {
         $zData['VariantOnGenome/dbSNP'] = preg_replace('/(rs\\d+)/', '<SPAN' . ($sView != 'list' ? '' : ' onclick="cancelParentEvent(event);"') . '><A href="http://www.ncbi.nlm.nih.gov/SNP/snp_ref.cgi?rs=' . "\$1" . '" target="_blank">' . "\$1" . '</A></SPAN>', $zData['VariantOnGenome/dbSNP']);
     }
     return $zData;
 }
 function viewEntry($nID = false)
 {
     global $_DB;
     list($nID, $nTranscriptID) = explode(',', $nID);
     $this->aSQLViewEntry['WHERE'] .= (empty($this->aSQLViewEntry['WHERE']) ? '' : ' AND ') . 'vot.transcriptid = \'' . $nTranscriptID . '\'';
     // Before passing this on to parent::viewEntry(), perform a standard getCount() check on the transcript ID,
     // to make sure that we won't get a query error when the combination of VariantID/TranscriptID does not yield
     // any results. Easiest is then to fake a wrong $nID such that parent::viewEntry() will complain.
     if (!$_DB->query('SELECT COUNT(*) FROM ' . TABLE_VARIANTS_ON_TRANSCRIPTS . ' WHERE id = ? AND transcriptid = ?', array($nID, $nTranscriptID))->fetchColumn()) {
         $nID = -1;
     }
     parent::viewEntry($nID);
 }