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/variant creation form #588

Open
wants to merge 99 commits into
base: release/3.5
Choose a base branch
from
Open
Changes from 4 commits
Commits
Show all changes
99 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
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
a906b9c
Only reset values if the DB holds human GBs
loeswerkman Apr 8, 2022
e156a4e
Fix dates
loeswerkman Apr 8, 2022
a00ddfc
WIP: Only mapping GBs recognised by LOVD and VV
loeswerkman Apr 11, 2022
03c995a
Remove floating var_dump
loeswerkman Apr 12, 2022
03f5a4b
Remove refseq from not-accepted variants
loeswerkman Apr 12, 2022
3639e62
Update dates
loeswerkman Apr 12, 2022
b5d5c49
Use htmlspecialchars around all REQUEST variables
loeswerkman Apr 12, 2022
c89a307
Add documentation regarding REQUEST/POST/GET
loeswerkman Apr 12, 2022
eda072b
Make sure all variables in output are safe
loeswerkman Apr 13, 2022
8d6dfa0
Fix minor issue in refSeq ternary if
loeswerkman Apr 13, 2022
cd542ba
Update dates
loeswerkman Apr 13, 2022
6c9c5c2
Clarify error message that is thrown when VV fails
loeswerkman Apr 13, 2022
6a38123
Fix issues concerning URL en- & decoding
loeswerkman Jun 9, 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
81 changes: 39 additions & 42 deletions src/ajax/check_hgvs_dialogue.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* LEIDEN OPEN VARIATION DATABASE (LOVD)
*
* Created : 2022-02-26
* Modified : 2022-04-12
* Modified : 2022-04-13
* For LOVD : 3.0-27
*
* Copyright : 2004-2022 Leiden University Medical Center; http://www.LUMC.nl/
Expand Down Expand Up @@ -35,35 +35,31 @@
header('Content-type: text/javascript; charset=UTF-8');


// Retrieving the variant and the transcripts to map to.
// Retrieving the transcripts to map to.
// We are using REQUEST and not GET or POST, because the
// input of this script can be both GET and POST.
$sVariant = htmlspecialchars($_REQUEST['var']);
$aTranscripts = (empty($_REQUEST['transcripts'])? array() : explode('|', htmlspecialchars($_REQUEST['transcripts'])));
$aTranscripts = (empty($_REQUEST['transcripts'])? array() : explode('|', urldecode($_REQUEST['transcripts'])));

// Retrieving the name of the input field.
$sFieldName = htmlspecialchars($_REQUEST['fieldName']);
$sFieldName = urldecode($_REQUEST['fieldName']);
loeswerkman marked this conversation as resolved.
Show resolved Hide resolved



if (!$sVariant) {
if (!($_REQUEST['var'])) {
loeswerkman marked this conversation as resolved.
Show resolved Hide resolved
// If the variant is empty, we can simply close the script.
exit;
}



// Retrieving information on the reference sequence from the URL.
$sRefSeqInfo = htmlspecialchars($_REQUEST['refSeqInfo']);

// Retrieve the reference sequence from the info given through the URL.
if (strpos($sRefSeqInfo, '-') === false) {
if (strpos($_REQUEST['refSeqInfo'], '-') === false) {
loeswerkman marked this conversation as resolved.
Show resolved Hide resolved
// The '-' serves as a communication tool; it tells us that
// the given input was a GB + chromosome. When no '-' is
// found, we know that the input was the reference sequence
// of a transcript.
$sType = 'VOT';
$sReferenceSequence = $sRefSeqInfo;
$sReferenceSequence = urldecode($_REQUEST['refSeqInfo']);
loeswerkman marked this conversation as resolved.
Show resolved Hide resolved
global $_DB;
$bRefSeqIsSupportedByVV = (
'hg' == substr($_DB->query('SELECT id FROM ' . TABLE_GENOME_BUILDS . ' LIMIT 1')->fetchColumn(), 0, 2)
Expand All @@ -73,10 +69,10 @@
// We know we got information on a GB. This is given through
// JS in the format of <genome build ID>-<chromosome>.
$sType = 'VOG';
list($sGenomeBuildID, $sChromosome) = explode('-', $sRefSeqInfo);
list($sGenomeBuildID, $sChromosome) = explode('-', urldecode($_REQUEST['refSeqInfo']));
loeswerkman marked this conversation as resolved.
Show resolved Hide resolved
$sReferenceSequence = (
!isset($_SETT['human_builds'][$sGenomeBuildID])?
'' : $sReferenceSequence = $_SETT['human_builds'][$sGenomeBuildID]['ncbi_sequences'][$sChromosome]
'' : $_SETT['human_builds'][$sGenomeBuildID]['ncbi_sequences'][$sChromosome]
);

$bRefSeqIsSupportedByVV = (
Expand Down Expand Up @@ -128,15 +124,15 @@
// We will fill in this fixed variant, close the dialogue,
// and perform a new call to this script by activating
// the onChange.
var oInput = $(\'input[name="' . $sFieldName . '"]\');
oInput.val("' . addslashes(lovd_fixHGVS($sVariant)) . '");
var oInput = $(\'input[name="' . htmlspecialchars($sFieldName) . '"]\');
loeswerkman marked this conversation as resolved.
Show resolved Hide resolved
oInput.val("' . htmlspecialchars(lovd_fixHGVS($_REQUEST['var'])) . '");
loeswerkman marked this conversation as resolved.
Show resolved Hide resolved
$(this).dialog("close");
oInput.change();
}};
var oButtonNo = {"No, I will take a look myself":function () {
// The user does not accept the given fixed variant.
var oInput = $(\'input[name="' . $sFieldName . '"]\');
oInput.val("' . addslashes($sVariant) . '").attr("class", "err");
var oInput = $(\'input[name="' . htmlspecialchars($sFieldName) . '"]\');
oInput.val("' . htmlspecialchars($_REQUEST['var']) . '").attr("class", "err");
oInput.siblings("img:first").attr({src: "gfx/cross.png", title: "Please check the HGVS syntax of your variant description before sending it into the database."});
$(this).dialog("close");
}};
Expand All @@ -148,8 +144,8 @@
}};
var oButtonOKInvalid = {"OK":function () {
// The user agrees to change their invalid input manually.
var oInput = $(\'input[name="' . $sFieldName . '"]\');
oInput.val("' . substr(strstr(addslashes($sVariant), ':'), 1) . '").attr("class", "err");
var oInput = $(\'input[name="' . htmlspecialchars($sFieldName) . '"]\');
oInput.val("' . htmlspecialchars(substr(strstr($_REQUEST['var'], ':'), 1)) . '").attr("class", "err");
oInput.siblings("img:first").attr({src: "gfx/cross.png", title: "Your variant is not validated..."});
$(this).dialog("close");
}};
Expand All @@ -160,8 +156,8 @@
// Just to be sure, we remove the reference sequence here,
// because it might still be stuck to the variant
// description from the mapping process.
var oInput = $(\'input[name="' . $sFieldName . '"]\');
oInput.val("' . substr(strstr(addslashes($sVariant), ':'), 1) . '").attr("class", "warn");
var oInput = $(\'input[name="' . htmlspecialchars($sFieldName) . '"]\');
oInput.val("' . htmlspecialchars(substr(strstr($_REQUEST['var'], ':'), 1)) . '").attr("class", "warn");
oInput.siblings("img:first").attr({src: "gfx/check_orange.png", title: "Your variant could not be (in)validated..."});
$(this).dialog("close");
}};
Expand Down Expand Up @@ -209,7 +205,7 @@ function update_images_per_step($sStep, $sImage)


// Performing initial checks.
if (htmlspecialchars($_REQUEST['action']) == 'check') {
if ($_REQUEST['action'] == 'check') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a certain reason to not use ACTION?

// Opening the dialogue.
print('
// Setting up the dialogue.
Expand All @@ -228,7 +224,7 @@ function update_images_per_step($sStep, $sImage)


// Check whether this variant is supported by LOVD.
$aVariant = lovd_getVariantInfo($sVariant, false);
$aVariant = lovd_getVariantInfo($_REQUEST['var'], false);
$bIsSupportedByLOVD = !isset($aVariant['errors']['ENOTSUPPORTED']);

if (!$bIsSupportedByLOVD) {
Expand All @@ -247,15 +243,15 @@ function update_images_per_step($sStep, $sImage)


// Perform our HGVS check.
if (!lovd_isHGVS($sVariant)) {
if (!lovd_isHGVS($_REQUEST['var'])) {
// If the variant is not HGVS, we cannot send the variant to
// VariantValidator yet. We will try to see if our fixHGVS
// function knows what to do, but if not, we need to exit
// this script and wait for the user to return with a variant
// which we can interpret.

// Let the user know that the given variant did not pass our HGVS check.
$sResponse = '<br>Your variant (\"' . htmlspecialchars($sVariant) . '\") did not pass our HGVS check.<br><br>';
$sResponse = '<br>Your variant (\"' . htmlspecialchars($_REQUEST['var']) . '\") did not pass our HGVS check.<br><br>';
update_images_per_step('statusChecks', 'gfx/cross.png');


Expand All @@ -271,12 +267,12 @@ function update_images_per_step($sStep, $sImage)


// Show the fixed variant if fixHGVS was successful.
$sFixedVariant = lovd_fixHGVS($sVariant);
$sFixedVariant = lovd_fixHGVS($_REQUEST['var']);

if ($sFixedVariant !== $sVariant && lovd_isHGVS($sFixedVariant)) {
if ($sFixedVariant !== $_REQUEST['var'] && lovd_isHGVS($sFixedVariant)) {
// Good, we can propose a fix. If the user agrees with the fix,
// we can continue to the mapping.
update_dialogue($sResponse . 'Did you mean \"' . $sFixedVariant . '\"?<br>',
update_dialogue($sResponse . 'Did you mean \"' . htmlspecialchars($sFixedVariant) . '\"?<br>',
'oButtonYes, oButtonNo');

// Our 'Yes' button sets the steps in motion which change the user's
Expand Down Expand Up @@ -318,7 +314,7 @@ function update_images_per_step($sStep, $sImage)
// anyway, since this issue lies with us.
die('
$("#variantCheckDialogue").dialog("close");
var oInput = $(\'input[name="' . addslashes($sFieldName) . '"]\');
var oInput = $(\'input[name="' . htmlspecialchars(sFieldName) . '"]\');
oInput.attr("class", "warn");
oInput.siblings("img:first").attr({src: "gfx/check_orange.png", title: "We validated the syntax, but could not validate the positions."});
');
Expand All @@ -327,17 +323,17 @@ function update_images_per_step($sStep, $sImage)

// Check if the description itself holds a reference sequence.
// if (lovd_holdsRefSeq($sVariant)) { Fixme; Update line below with this line once the necessary code has been pulled in -> Committed in feat/checkHGVSTool on January 14th 2022; ID 7abf9d70dc3094f5f9cfa0dfc43039c49b4217ff.
if (preg_match('/.*:[a-z]\./', $sVariant)) {
if (preg_match('/.*:[a-z]\./', $_REQUEST['var'])) {
// The given variant description holds a reference sequence.
$sRefSeqInDescription = substr($sVariant, 0, strpos($sVariant, ':'));
$sRefSeqInDescription = substr($_REQUEST['var'], 0, strpos($_REQUEST['var'], ':'));

if ($sRefSeqInDescription == $sReferenceSequence) {
// Perfect, no issues found; the user redundantly gave
// the reference sequence in the variant description,
// but that is no problem at all, since the given refSeq
// matches our expectations. The reference sequence will
// be cut from the description after the mapping.
$sFullVariant = $sVariant;
$sFullVariant = $_REQUEST['var'];

} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this would have been in the VOT, I believe we would have thrown WTRANSCRIPTFOUND, WTRANSCRIPTVERSION, or WDIFFERENTREFSEQ. So I think this means that this code is only reachable for VOG entries. I think this means that VOTs and VOGs may be handled differently if they contain refseqs in the input. Could you confirm or refute this?

// The user gave a refSeq within the variant description
Expand All @@ -357,7 +353,7 @@ function update_images_per_step($sStep, $sImage)
// The variant in the input field does not hold a reference
// sequence. We will add it to make a full variant that we
// can then send to VariantValidator.
$sFullVariant = $sReferenceSequence . ':' . $sVariant;
$sFullVariant = $sReferenceSequence . ':' . $_REQUEST['var'];
}


Expand All @@ -369,10 +365,10 @@ function update_images_per_step($sStep, $sImage)
$.get("ajax/check_hgvs_dialogue.php?"
+ "action=map"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will be nicer to use the ACTION feature here.
(i.e., send (...)dialog.php?map&var=(...) after which the ACTION constant is populated with the value "map").

+ "&var=' . urlencode($sFullVariant) . '"
+ "&fieldName=' . $sFieldName . '"
+ "&fieldName=' . urlencode($sFieldName) . '"
+ "&type=' . $sType . '"
+ "&refSeqInfo=' . urlencode($sRefSeqInfo) . '"
+ "&transcripts=' . implode('|', $aTranscripts) . '"
+ "&refSeqInfo=' . urlencode($_REQUEST['refSeqInfo']) . '"
+ "&transcripts=' . urlencode(implode('|', $aTranscripts)) . '"
).fail(function(){alert("An error occurred while trying to map your variant, please try again later.");$("#variantCheckDialogue").dialog("close");})
');
}
Expand All @@ -382,7 +378,7 @@ function update_images_per_step($sStep, $sImage)


// Performing the mapping.
if (htmlspecialchars($_REQUEST['action']) == 'map') {
if ($_REQUEST['action'] == 'map') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I understand correctly that this "map" block is used also for the actual validation step? And mapping is optional? (it requires other DNA fields)

// Add the source of the variant that will be mapped.
print('
// Add source.
Expand All @@ -394,13 +390,13 @@ function update_images_per_step($sStep, $sImage)
$_VV = new LOVD_VV();
$aMappedVariant = (
$sType == 'VOG' ?
$_VV->verifyGenomic($sVariant, array(
$_VV->verifyGenomic($_REQUEST['var'], array(
'map_to_transcripts' => !empty($aTranscript), // Should we map the variant to transcripts?
'predict_protein' => !empty($aTranscript), // Should we get protein predictions?
'lift_over' => (1 < (int) $_DB->query('SELECT COUNT(*) FROM ' . TABLE_GENOME_BUILDS)->fetchColumn()), // Should we get other genomic mappings of this variant?
'select_transcripts' => $aTranscripts,
)) :
$_VV->verifyVariant($sVariant, array('select_transcripts' => $aTranscripts))
$_VV->verifyVariant($_REQUEST['var'], array('select_transcripts' => $aTranscripts))
);

// Check for issues on our end.
Expand All @@ -410,9 +406,10 @@ function update_images_per_step($sStep, $sImage)
// error, this is an issue that lies with us, not the user.
// We will have to allow these variants into the database.
update_images_per_step('statusMapping', 'gfx/cross.png');
update_dialogue(
'<br>This variant type is not supported by VariantValidator.' .
' Therefore, we can only check the syntax and not perform the mapping.',
update_dialogue('<br>' .
($aMappedVariant === false? 'An unknown issue occurred while calling VariantValidator.'
: 'This variant type is not supported by VariantValidator.') .
' Therefore, we could only check the syntax and not perform the mapping.',
'oButtonOKCouldBeValid'
);
exit;
Expand Down