Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve/api variants #594

Open
wants to merge 125 commits into
base: release/3.5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
475c3ee
Add 'relative to' message to both DNA fields
loeswerkman Oct 6, 2021
998fd1b
Allow element data to be added into HTML via viewForm
loeswerkman Oct 7, 2021
eb3b9ea
Add genome build as element data into viewForm
loeswerkman Oct 7, 2021
1d121fd
Redo code to add source to variants using element data
loeswerkman Oct 7, 2021
2fc7097
Add map button to all DNA fields in variant data entry form
loeswerkman Oct 7, 2021
1d3dad7
Remove disabled method.
ifokkema Oct 8, 2021
e607423
When adding to the DNA field description, don't overwrite anything.
ifokkema Oct 8, 2021
77a3e86
Improved efficiency of variables a bit, shortening the code.
ifokkema Oct 8, 2021
68f4ff4
Clean up the code a bit, and simply selecting VOG/DNA fields in JS.
ifokkema Oct 8, 2021
a9dbc6d
Add IsHGVS function and Unit test
loeswerkman Oct 15, 2021
4e83069
Open checkHGVS dialogue in variant creation form
loeswerkman Jan 21, 2022
8949e05
Create and implement the isHGVS wrapper function
loeswerkman Jan 27, 2022
5ef4aeb
Merge branch 'release/3.5' into improve/variantCreationForm
loeswerkman Feb 10, 2022
d94faee
Add an '@' before the ob_end_flush()
loeswerkman Feb 10, 2022
2d9c9c7
Add 'supported_by_VV' to GBs in
loeswerkman Feb 10, 2022
b1ccf66
Fix spelling
loeswerkman Feb 10, 2022
e0b4d90
WIP: Redoing the mapping and validation through VV
loeswerkman Feb 10, 2022
63e05e5
Simplify and clean up code; shorten the output
loeswerkman Feb 21, 2022
fce7fb8
Document the fact that flush() does not work here
loeswerkman Feb 21, 2022
d7d5282
Replaced flush() calls with recursive calls
loeswerkman Feb 23, 2022
4f3e8e5
Allow variants which VV cannot validate into the DB
loeswerkman Feb 24, 2022
5227038
Clean up the output and accredit VariantValidator
loeswerkman Feb 24, 2022
723cd57
Remove redundant VV call for multiple transcripts
loeswerkman Feb 24, 2022
32cbf30
Change line separators from CRLF to LF
loeswerkman Feb 24, 2022
9915eda
Reset the output if the variant is an empty string
loeswerkman Feb 24, 2022
6e4e443
Handle exit as a statement instead of a function
loeswerkman Feb 24, 2022
ea1e4bd
Clean up bits of the code
loeswerkman Feb 25, 2022
4f57803
WIP: Save md5 translation of validated variants
loeswerkman Feb 26, 2022
4562560
WIP: Save md5 translation of validated variants
loeswerkman Feb 26, 2022
0ba1f0c
Fix bug when no transcripts are given
loeswerkman Mar 1, 2022
b0ffbbe
Fix issue causing blocked fields to not reach POST
loeswerkman Mar 1, 2022
a8afce5
Fix issue when setting the md5 key after validation
loeswerkman Mar 1, 2022
aa272d0
Merge branch 'improve/variantCreationForm' of github.com:LOVDnl/LOVD3…
loeswerkman Mar 1, 2022
07b52e6
Update documentation to better fit the code
loeswerkman Mar 1, 2022
7e75c35
Fix indentation
loeswerkman Mar 1, 2022
cc0dcda
Merge branch 'release/3.5' into gb/mapNewVariants
loeswerkman Mar 1, 2022
82abf86
Merge branch 'gb/mapNewVariants' into improve/variantCreationForm
loeswerkman Mar 1, 2022
fc90491
Fetch GB IDs using the data element and not SQL
loeswerkman Mar 2, 2022
afda306
Clean up code that checks refSeqs in description
loeswerkman Mar 2, 2022
20ea1e3
Stop blocking the 'Ignore this transcript' button
loeswerkman Mar 2, 2022
d9bf913
Fix bug and add comment to code which resets values
loeswerkman Mar 2, 2022
0a82e7f
Reset all values when the dialogue is called
loeswerkman Mar 3, 2022
a9f8773
Add the source of the variant when it is mapped
loeswerkman Mar 3, 2022
daee268
Trigger HGVS check when the chromosome is updated
loeswerkman Mar 3, 2022
ee315bb
Stop expiring the cache for inc-js-variants.php
loeswerkman Mar 3, 2022
3e3b691
Add css classes to the input fields to show status
loeswerkman Mar 3, 2022
fb3ce67
Fix bug when resetting the script
loeswerkman Mar 3, 2022
534d05f
Simplify code and add class to RNA&Protein fields
loeswerkman Mar 3, 2022
bc8b39c
Disable the Enter for all DNA fields
loeswerkman Mar 3, 2022
83b07f0
Fix all code that has to do with URL encoding
loeswerkman Mar 3, 2022
4fa5279
Reset all values based on whether mapping status
loeswerkman Mar 3, 2022
bb648a1
Make sure the dialog is closed if an error occurs
loeswerkman Mar 3, 2022
3ea60b2
Remove md5 key; Use checkFields to check input
loeswerkman Mar 3, 2022
186176b
Add documentation to the checkFields addition
loeswerkman Mar 3, 2022
c9cbda4
Get rid of the $_GET['chromosome'] usage
loeswerkman Mar 3, 2022
b4abbe2
Remove MD5 key function that is no longer used
loeswerkman Mar 4, 2022
6f154b2
Remove hidden codedVariants field (md5 key)
loeswerkman Mar 4, 2022
be5f3e6
Removing flush()
loeswerkman Mar 4, 2022
ca7a8e4
Take string, not int in update_images_per_step()
loeswerkman Mar 4, 2022
34b397e
Clean up code around update_dialogue() calls
loeswerkman Mar 4, 2022
e691e0e
Add documentation to the possible reset
loeswerkman Mar 4, 2022
4f976d6
Fix old typing in documentation
loeswerkman Mar 4, 2022
58e2165
Add and update documentation
loeswerkman Mar 4, 2022
0e983f3
Add addslashes() for safe keeping
loeswerkman Mar 4, 2022
88e9ba7
Remove old code related to the md5 key
loeswerkman Mar 4, 2022
3f9d7e3
Fix strange line separation
loeswerkman Mar 4, 2022
7a63d5e
Restore cache header
loeswerkman Mar 4, 2022
08cbb5f
Add documentation to lovd_checkHGVS()
loeswerkman Mar 4, 2022
bfd314e
Rewrite hardcoded code to view variants on all GBs
loeswerkman Mar 23, 2022
4362e90
Update header
loeswerkman Mar 25, 2022
e9eea63
Clear up class name 'acc' to 'accept
loeswerkman Mar 25, 2022
b11ff02
Stop resetting values if an empty string is passed
loeswerkman Mar 25, 2022
f436950
Remove use of variables for buttons and images
loeswerkman Mar 25, 2022
aa1c715
Remove display:none and .show() for all imgs
loeswerkman Mar 25, 2022
9e450dc
Fix issue regarding oChromosome variable
loeswerkman Mar 25, 2022
e783dc0
Clean up the selection of an object by its data
loeswerkman Mar 25, 2022
ff584cf
Fill in fields that remained empty after mapping
loeswerkman Mar 25, 2022
752fd19
Use strpos instead of regex to find DNA fields
loeswerkman Mar 25, 2022
f626d4e
Fix and clean code that checks the variant format
loeswerkman Mar 25, 2022
ac3de94
Use 'https' instead of 'http' for the HGVS link
loeswerkman Mar 25, 2022
9436ec7
Fill and deactivate empty fields after mapping
loeswerkman Mar 25, 2022
2d443ac
Clarify message when VV threw a syntax/build
loeswerkman Mar 25, 2022
121a300
Remove RefSeq from description in OKCouldBeValid
loeswerkman Mar 25, 2022
6f9bef4
Fix concatenations of strings and strings
loeswerkman Mar 31, 2022
66f7a76
Get rid of negative selection to fill empty fields
loeswerkman Mar 31, 2022
5c3cc75
Fix code around strpos that finds 'DNA'
loeswerkman Mar 31, 2022
a96825a
Fix dates
loeswerkman Mar 31, 2022
ffb0258
WIP: Remove hardcoded GB handling; redo code aliases
loeswerkman Mar 31, 2022
40b23a4
Update header
loeswerkman Mar 31, 2022
29ffdca
Clean up convertAliasesToVML()
loeswerkman Mar 31, 2022
05d4ad6
WIP: Remove hardcoded GB handling; redo code aliases
loeswerkman Apr 1, 2022
57985a2
Merge branch 'improve/variantCreationForm' into improve/APIVariants
loeswerkman Apr 4, 2022
000ffda
Cleanup layout
loeswerkman Apr 4, 2022
c7104d3
Fix retrieval of active genome builds
loeswerkman Apr 4, 2022
2a91a9a
Fix GB parts of the SQL query
loeswerkman Apr 4, 2022
d2936bf
Use key() instead of array_keys()[0]
loeswerkman Apr 4, 2022
cf603bf
Use isset() instead of in_array()
loeswerkman Apr 4, 2022
498593d
Change name to
loeswerkman Apr 4, 2022
15763e1
Use array_diff() instead of array_filter()
loeswerkman Apr 4, 2022
34c1515
Fix issue in SQL query
loeswerkman Apr 4, 2022
34fc50a
Fix code that builds the DNA query per GB
loeswerkman Apr 5, 2022
614ef30
Add documentation and move code
loeswerkman Apr 5, 2022
4e0e93f
Use the specified GB instead of the primary one
loeswerkman Apr 5, 2022
4c0d162
Fix typo in SQL query
loeswerkman Apr 7, 2022
d86ecd4
Reset keys of aliases using array_values()
loeswerkman Apr 7, 2022
1a052f7
Remove suffix of position fields of the chosen build
loeswerkman Apr 7, 2022
f25129c
Fix issue in GROUP and ORDER BY of position fields
loeswerkman Apr 7, 2022
56473b8
Fix issue when VariantOnGenome/DNA is null
loeswerkman Apr 7, 2022
13f34ee
Clean up how the possible GBs are shown
loeswerkman Apr 12, 2022
68e54f0
Add IFNULL to vog-retrieving query
loeswerkman Apr 12, 2022
d01f6cb
Update dates
loeswerkman Apr 12, 2022
f80670a
Use key() instead of array_keys()[0]
loeswerkman Apr 12, 2022
1f2a3ec
Move global request to top of function
loeswerkman Apr 12, 2022
3e59f38
Update dates in api.php
loeswerkman Apr 12, 2022
3008015
Retrieve GB more efficiently using strstr()
loeswerkman Apr 12, 2022
c85b917
Prepare column suffixes in SQL query in main api
loeswerkman Apr 13, 2022
8b8b886
Prepare column suffixes in SQL query in GA4GH api
loeswerkman Apr 13, 2022
4c6ceb8
Remove part of SQL query that should have been gone
loeswerkman Apr 13, 2022
43c442a
Use ->quote() around
loeswerkman Apr 13, 2022
05632c5
Use ...[$sBuild] instead of current(...)
loeswerkman Apr 13, 2022
7f8dcb0
Separate different aliases of the same build
loeswerkman Apr 13, 2022
7574bad
View panel-specific aliases per panel
loeswerkman May 20, 2022
4466609
Use $sGBColumns instead of outdated $sGBSuffix
loeswerkman May 20, 2022
61a0af6
Update dates
loeswerkman May 20, 2022
664a006
Fixing newlines back to Linux standard (LF)
loeswerkman May 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
614 changes: 614 additions & 0 deletions src/ajax/check_hgvs_dialogue.php

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/ajax/mobidetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,14 @@
$_SESSION['csrf_tokens']['mobidetails_confirm'] = md5(uniqid());
$sFormConfirmation = str_replace('{{CSRF_TOKEN}}', $_SESSION['csrf_tokens']['mobidetails_confirm'], $sFormConfirmation);

// This print statement and flush do not work.
// It seems that flush successfully forces the output
// to the browser, but the browser does not seem to
// execute the JS until the page has finished loading. (Chrome)
print('
$("#mobidetails_dialog").html("<IMG src=\'gfx/ajax_loading.gif\' alt=\'Please wait...\' width=\'100\' height=\'100\'>");
');
ob_end_flush();
@ob_end_flush();
flush();

// Now check with MobiDetails.
Expand Down
137 changes: 89 additions & 48 deletions src/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* LEIDEN OPEN VARIATION DATABASE (LOVD)
*
* Created : 2012-11-08
* Modified : 2021-09-17
* Modified : 2022-04-12
* For LOVD : 3.0-28
*
* Supported URIs:
Expand All @@ -14,8 +14,8 @@
* 3.0-beta-10 /api/rest.php/variants/{{ GENE }}/unique
* 3.0-beta-10 /api/rest.php/variants/{{ GENE }}?search_position=c.1234
* 3.0-beta-10 /api/rest.php/variants/{{ GENE }}?search_position=c.1234+56_2345-67 (c.1234%2B56_2345-67)
* 3.0-beta-10 /api/rest.php/variants/{{ GENE }}?search_position=g.12345678
* 3.0-beta-10 /api/rest.php/variants/{{ GENE }}?search_position=g.1234_5678&position_match=exact|exclusive|partial
* 3.0-beta-10 /api/rest.php/variants/{{ GENE }}?search_position=hg19:g.12345678
* 3.0-beta-10 /api/rest.php/variants/{{ GENE }}?search_position=hg19:g.1234_5678&position_match=exact|exclusive|partial
* 3.0-beta-10 /api/rest.php/variants/{{ GENE }}?search_Variant%2FDNA=c.1234C>G (c.1234C%3EG)
* 3.0-beta-10 /api/rest.php/variants/{{ GENE }}?search_Variant%2FDBID=DMD_01234
* 3.0-19 /api/rest.php/variants/{{ GENE }}?show_variant_effect=1
Expand All @@ -40,8 +40,9 @@
* 3.0-27 (v2) /api/v#/ga4gh/table/variants/data:hg19:chr1:123456-234567 (GET/HEAD)
* 3.0-18 (v1) /api/v#/submissions (POST) (/v# is optional)
*
* Copyright : 2004-2020 Leiden University Medical Center; http://www.LUMC.nl/
* Copyright : 2004-2022 Leiden University Medical Center; http://www.LUMC.nl/
* Programmer : Ivo F.A.C. Fokkema <[email protected]>
* L. Werkman <[email protected]>
*
*
* This file is part of LOVD.
Expand Down Expand Up @@ -132,8 +133,14 @@
die('This gene does not have the VariantOnTranscript/DNA or the VariantOnGenome/DBID fields enabled, crucial for the API.');
}

// Store if we have hg38 annotation or not (GV shared had a custom column for that).
$bDNA38 = $_DATA['Genome']->colExists('VariantOnGenome/DNA/hg38');
// Store all active genome builds.
$aActiveGBs = $_DB->query('
SELECT id,
CONCAT("VariantOnGenome/DNA", if(column_suffix = "", "", "/"), column_suffix) as "DNA",
CONCAT("position_g_start", if(column_suffix = "", "", "_"), column_suffix) as "position_start",
CONCAT("position_g_end", if(column_suffix = "", "", "_"), column_suffix) as "position_end"
FROM ' . TABLE_GENOME_BUILDS
)->fetchAllGroupAssoc();

$bUnique = ($nID == 'unique');
if ($bUnique) {
Expand Down Expand Up @@ -239,7 +246,24 @@

} else {
// Normal API output; Atom feed with one entry per variant.
// First build query.

// Prepare the SQL that will look for all genomic data.
// We will go through all active builds and prepare a query
// that retrieves the information from each build individually.
$sPreparedGenomicQ = '';
foreach ($aActiveGBs as $sGBID => $aGBFields) {
$sPreparedGenomicQ .= '
vog.chromosome, vog.`' . $aGBFields['DNA'] . '`,
CONCAT("chr", vog.chromosome, ":",
IF (
vog.' . $aGBFields['position_start'] . ' = vog.' . $aGBFields['position_end'] . ',
vog.' . $aGBFields['position_start'] . ',
CONCAT(vog.' . $aGBFields['position_start'] . ', "_", vog.' . $aGBFields['position_end'] . ')
)
) AS position_genomic_' . $sGBID . ', ';
}

// Then build the query.
// Note that the MIN()s and MAX()es don't mean much if $bUnique is false, since we'll group by the vog.id anyway.
$sQ = 'SELECT MIN(vog.id) AS id,
GROUP_CONCAT(
Expand Down Expand Up @@ -282,17 +306,9 @@
ORDER BY t.id_ncbi
SEPARATOR ";"
) AS _position_mRNA,
' . (!$bDNA38? '' : 'vog.chromosome, GROUP_CONCAT(DISTINCT IFNULL(vog.`VariantOnGenome/DNA/hg38`, "") SEPARATOR ";") AS `DNA/hg38`, ') . '
CONCAT("chr", vog.chromosome, ":",
IF(
vog.position_g_start = vog.position_g_end,
vog.position_g_start,
CONCAT(vog.position_g_start, "_", vog.position_g_end)
)
) AS position_genomic,
' . $sPreparedGenomicQ . '
GROUP_CONCAT(DISTINCT LEFT(vog.effectid, 1) SEPARATOR ";") AS effect_reported,
GROUP_CONCAT(DISTINCT RIGHT(vog.effectid, 1) SEPARATOR ";") AS effect_concluded,
vog.`VariantOnGenome/DNA`,
GROUP_CONCAT(DISTINCT ' . ($nRefSeqID? '' : 't.id_ncbi, ":", ') . 'vot.`VariantOnTranscript/DNA`
ORDER BY t.id_ncbi SEPARATOR ";;") AS `__VariantOnTranscript/DNA`,
vog.`VariantOnGenome/DBID`,
Expand All @@ -309,7 +325,7 @@
LEFT OUTER JOIN ' . TABLE_INDIVIDUALS . ' AS i ON (s.individualid = i.id AND i.statusid >= ' . STATUS_MARKED . ')
LEFT OUTER JOIN ' . TABLE_USERS . ' AS uc ON (vog.created_by = uc.id)
LEFT OUTER JOIN ' . TABLE_USERS . ' AS uo ON (vog.owned_by = uo.id)
WHERE ' . ($nRefSeqID? 't.id = ' . $nRefSeqID : 't.geneid = ' . $_DB->quote($sSymbol)) . ' AND vog.statusid >= ' . STATUS_MARKED;
WHERE vog.chromosome = ' . $_DB->quote($sChromosome) . ' AND ' . ($nRefSeqID? 't.id = ' . $nRefSeqID : 't.geneid = ' . $_DB->quote($sSymbol)) . ' AND vog.statusid >= ' . STATUS_MARKED;
$bSearching = false;
if ($nID) {
$sFeedType = 'entry';
Expand All @@ -322,30 +338,62 @@
if (!empty($_GET['search_' . $sField])) {
$bSearching = true;
if ($sField == 'position') {
if ($sRefSeq && (preg_match('/^(g)\.([0-9]+)(_([0-9]+))?$/', $_GET['search_' . $sField], $aRegs) || preg_match('/^(c)\.([*-]?[0-9]+([+-][du]?[0-9]+)?)(_([*-]?[0-9]+([+-][du]?[0-9]+)?))?$/', $_GET['search_' . $sField], $aRegs))) {
// $aRegs numbering: 1 2 3 4 1 2 3 4 5 6
// Mapping is only possible if there is a Reference Sequence.
// The user wants to find variants on/within (a) certain position(s).
if ($sRefSeq // Mapping is only possible if there is a reference sequence.
&& (preg_match('/^(c)\.([*-]?[0-9]+([+-][du]?[0-9]+)?)(_([*-]?[0-9]+([+-][du]?[0-9]+)?))?$/', $_GET['search_' . $sField], $aRegs)
// $aRegs: 1 2 3 4 5 6 Fixme; This code does not support m. and n. DNA.
|| preg_match('/^(g)\.([0-9]+)(_([0-9]+))?$/', substr($_GET['search_position'], strpos($_GET['search_position'], ':')), $aRegs))
// $aRegs: 1 2 3 4
) {
if ($aRegs[1] == 'g') {
// The user is looking for a specific genomic position.
if (strpos($_GET['search_position'], ':') !== false) {
// If a ':' was found, the user specified a genome build.
$sGB = strstr($_GET['search_position'], ':', true);

if (!isset($aActiveGBs[$sGB])) {
// The genome build specified by the user is not active in the
// database. We will send an error.
header('HTTP/1.0 404 Not Found');
die('The given genome build was not found in the database.');
}

} else {
// The user did not specify a specific genome build.
if (count($aActiveGBs) == 1) {
// If there is only one build, we can simply use that one.
$sGB = key($aActiveGBs);
} else {
// There are multiple active builds, yet the user did not
// specify which one to use. We will send an error.
header('HTTP/1.0 400 Bad Request');
die('To search genomic positions, please identify which reference genome you want to use.');
}
}

if (empty($aRegs[3])) {
// No range. Absolute location.
$aRegs[4] = $aRegs[2];
}
// Very important in genomic positions: genes on antisense will have positions like g.5678_1234 in the database!!!
$nMin = min($aRegs[2], $aRegs[4]);
$nMax = max($aRegs[2], $aRegs[4]);
$nMin = (int) min($aRegs[2], $aRegs[4]);
$nMax = (int) max($aRegs[2], $aRegs[4]);

if (!empty($_GET['position_match'])) {
if ($_GET['position_match'] == 'exclusive') {
// Mutation should be completely in the range.
$sQ .= ' AND vog.position_g_start ' . ($bSense? '>= ' . $nMin : '<= ' . $nMax) . ' AND vog.position_g_end ' . ($bSense? '<= ' . $nMax : '>= ' . $nMin);
$sQ .= ' AND vog.' . $aActiveGBs[$sGB]['position_start'] . '>= ' . $nMin . ' AND vog.' . $aActiveGBs[$sGB]['position_end'] . ' <= ' . $nMax;
continue;
} elseif ($_GET['position_match'] == 'partial') {
$sQ .= ' AND (vog.position_g_start BETWEEN ' . $nMin . ' AND ' . $nMax . ' OR vog.position_g_end BETWEEN ' . $nMin . ' AND ' . $nMax . ' OR (vog.position_g_start ' . ($bSense? '<= ' . $nMin : '>= ' . $nMax) . ' AND vog.position_g_end ' . ($bSense? '>= ' . $nMax : '<= ' . $nMin) . '))';
$sQ .= ' AND (vog.' . $aActiveGBs[$sGB]['position_start'] . ' BETWEEN ' . $nMin . ' AND ' . $nMax . ' OR vog.' . $aActiveGBs[$sGB]['position_end'] . ' BETWEEN ' . $nMin . ' AND ' . $nMax . ' OR (vog.' . $aActiveGBs[$sGB]['position_start'] . ' <= ' . $nMin . ' AND vog.' . $aActiveGBs[$sGB]['position_end'] . ' >= ' . $nMax . '))';
continue;
}
}
// Exact match, directly requested through $_GET['position_match'] or argument not given/recognized.
$sQ .= ' AND position_' . $aRegs[1] . '_start = "' . ($bSense? $nMin : $nMax) . '" AND position_' . $aRegs[1] . '_end = "' . ($bSense? $nMax : $nMin) . '"';
$sQ .= ' AND ' . $aActiveGBs[$sGB]['position_start'] . ' = ' . $nMin . ' AND ' . $aActiveGBs[$sGB]['position_end'] . ' = ' . $nMax;

} else {
// The user is looking for a specific position on coding DNA.
$aStart = lovd_convertDNAPositionToDB($nPositionMRNAStart, $nPositionMRNAEnd, $nPositionCDSEnd, $aRegs[2]);
if (empty($aRegs[4])) {
$aEnd = $aStart;
Expand Down Expand Up @@ -374,7 +422,10 @@
} else {
$sQ .= ' GROUP BY vog.id';
}
$sQ .= ' ORDER BY vog.position_g_start, vog.position_g_end, `VariantOnGenome/DNA`';
$sBuild = (isset($sGB)? $sGB : key($aActiveGBs));
$sQ .= ' ORDER BY vog.' . $aActiveGBs[$sBuild]['position_start'] .
', vog.' . $aActiveGBs[$sBuild]['position_end'] .
', vog.`' . $aActiveGBs[$sBuild]['DNA'] . '`';
}


Expand Down Expand Up @@ -570,7 +621,7 @@
// Make all transformations.
$aData = array_map(function ($zData)
{
global $_CONF, $_SETT, $bDNA38, $bUnique, $nRefSeqID, $sChromosome, $sRefSeq, $sSymbol;
global $_SETT, $bUnique, $nRefSeqID, $sChromosome, $sRefSeq, $sSymbol, $aActiveGBs;

// Format fields for JSON payload.
// The Atom data will also use these transformations, but may have less fields and in a different order.
Expand Down Expand Up @@ -600,17 +651,20 @@
$zData['_position_mRNA'] = explode(';', $zData['_position_mRNA']);
}

// Adding the genomic variants and positions for each build individually.
$aGenomicVariants = array();
$aGenomicPositions = array();
foreach ($aActiveGBs as $sGBID => $aGBSuffix) {
$aGenomicVariants[$sGBID] = 'chr' . $sChromosome . ':' . $zData[$aGBSuffix['DNA']];
$aGenomicPositions[$sGBID] = $zData['position_genomic_' . $sGBID];
}

$aReturn = array(
'symbol' => $sSymbol,
'id' => $zData['id'],
'position_mRNA' => $zData['_position_mRNA'],
'position_genomic' => array(
$_CONF['refseq_build'] => $zData['position_genomic'],
),
'variant_genomic' => array(
$_CONF['refseq_build'] => 'chr' . $sChromosome . ':' .
$zData['VariantOnGenome/DNA'],
),
'position_genomic' => $aGenomicPositions,
'variant_genomic' => $aGenomicVariants,
loeswerkman marked this conversation as resolved.
Show resolved Hide resolved
'Variant/DNA' => explode(';;', $zData['__VariantOnTranscript/DNA']),
'Variant/DBID' => $zData['Variant/DBID'],
'Times_reported' => $zData['Times'],
Expand All @@ -620,19 +674,6 @@
'edited_date' => date('c', strtotime($zData['edited_date'])),
);

// GV shared and future LOVDs; if we have hg38 data, add that.
if (FORMAT == 'application/json' && $_CONF['refseq_build'] != 'hg38'
&& $bDNA38 && $zData['DNA/hg38']) {
// We asked for a list, so we might get different values.
// Just pick the first that's filled in.
$zData['DNA/hg38'] = strstr(trim($zData['DNA/hg38'], ';') . ';', ';', true);
$aPositions = lovd_getVariantInfo($zData['DNA/hg38']);
$aReturn['position_genomic']['hg38'] = 'chr' . $zData['chromosome'] .
':' . $aPositions['position_start'] .
($aPositions['position_start'] == $aPositions['position_end']? '' : '_' . $aPositions['position_end']);
$aReturn['variant_genomic']['hg38'] = 'chr' . $zData['chromosome'] .
':' . $zData['DNA/hg38'];
}

if ($bUnique && FORMAT == 'application/json') {
unset($aReturn['id']);
Expand Down Expand Up @@ -687,7 +728,7 @@

$sContent = '';
$zData['position_mRNA'] = $zData['position_mRNA'][0];
$zData['position_genomic'] = current($zData['position_genomic']); // JSON made this an array, so undo that here and take first value.
$zData['position_genomic'] = $zData['position_genomic'][(isset($sBuild)? $sBuild : key($this->aActiveGBs))]; // JSON made this an array, so undo that here and take first value.
$zData['Variant/DNA'] = htmlspecialchars($zData['Variant/DNA'][0]);
if (!empty($_GET['show_variant_effect'])) {
// Optionally, add the variant effect to the output.
Expand Down
Loading