Skip to content

Commit

Permalink
fix Multiallelic error message
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyao00 committed Mar 23, 2023
1 parent 5873431 commit 82adb99
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 16 deletions.
1 change: 1 addition & 0 deletions LDlink/LDcommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ def get_query_variant_c(snp_coord, pop_ids, request, genome_build, is_output,out
if "," in geno[3] or "," in geno[4]:
# print('handle error: snp + " is not a biallelic variant."')
queryVariantWarnings.append([snp_coord[0], "NA", "Variant is not a biallelic."])
output["error"]= snp_coord[0] + " variant is not a biallelic." + str(output["warning"] if "warning" in output else "")

index = []
for i in range(9, len(head)):
Expand Down
7 changes: 6 additions & 1 deletion LDlink/LDhap.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,12 @@ def calculate_hap(snplst, pop, request, web, genome_build):
alleles = a2+"="+str(round(f1, 3))+", " + \
a1+"="+str(round(f0, 3))
allele_lst.append(alleles)

else:
if len(snp_dict) > 1:
output["warning"] = str(output["warning"] if "warning" in output else "") + rs_input+ " variant is not a biallelic"
else:
output["error"] = str(output["error"] if "error" in output else "") + rs_input+ " variant is not a biallelic"
return(json.dumps(output, sort_keys=True, indent=2))
haps = {}
for i in range(len(index)):
h1 = "_".join(hap1[i])
Expand Down
File renamed without changes.
28 changes: 17 additions & 11 deletions LDlink/LDlink-5.5.1.js → LDlink/LDlink-5.5.2.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var ldlink_version = "Version 5.5.1";
var ldlink_version = "Version 5.5.2";


// var restService = {protocol:'http',hostname:document.location.hostname,fqn:"nci.nih.gov",port:9090,route : "LDlinkRestWeb"}
Expand Down Expand Up @@ -67,7 +67,7 @@ $(document).ready(function() {
});

// Load news text from news.html to news-container div
$.get("news-5.5.1.html", function (data) {
$.get("news-5.5.2.html", function (data) {
let tmpData = data.split("<p>")
let i = 0;
var newsHTMLList = [];
Expand Down Expand Up @@ -1469,12 +1469,13 @@ function ldproxy_rs_results_link(data, type, row) {
if(!data.includes("rs") || data.length <= 2) {
return ".";
}
var server = 'http://www.ncbi.nlm.nih.gov/projects/SNP/snp_ref.cgi';
var server = 'http://www.ncbi.nlm.nih.gov/snp/';
var rs_number = data.substring(2);
var params = {
rs : rs_number
};
var href = server + "?" + $.param(params);
//var href = server + "?" + $.param(params);
var href = server + data;
var target = 'rs_number_' + Math.floor(Math.random() * (99999 - 10000 + 1));
// var href = 'http://www.ncbi.nlm.nih.gov/projects/SNP/snp_ref.cgi?rs=128';
var link;
Expand Down Expand Up @@ -1856,7 +1857,7 @@ function populateHeaderValues(event, numFiles, label) {
}

function loadHelp() {
$('#help-tab').load('help-5.5.1.html');
$('#help-tab').load('help-5.5.2.html');
}

function calculate(e) {
Expand Down Expand Up @@ -2990,14 +2991,14 @@ function populateSNPlist(data) {
}

function anchorRSnumber(rs_number) {
var server = 'http://www.ncbi.nlm.nih.gov/projects/SNP/snp_ref.cgi';

//var server = 'http://www.ncbi.nlm.nih.gov/projects/SNP/snp_ref.cgi';
var server = 'http://www.ncbi.nlm.nih.gov/snp/';
var raw_rs_number = rs_number.substring(2);
var params = {
rs : raw_rs_number
};
var url = server + "?" + $.param(params);

//var url = server + "?" + $.param(params);
var url = server + rs_number;
return '<a href="'+url+'" target="rs_number_'+rs_number+'">'+rs_number+'</a>';
}

Expand Down Expand Up @@ -4757,7 +4758,8 @@ function addLDHapHyperLinks(request, ldhapTable) {
$.each(ldhapTable.rows, function(index, value) {
//console.log(index + ": " + value);
// Create RSnumber link (Cluster Report)
server = 'http://www.ncbi.nlm.nih.gov/projects/SNP/snp_ref.cgi';
//server = 'http://www.ncbi.nlm.nih.gov/projects/SNP/snp_ref.cgi';
var server = 'http://www.ncbi.nlm.nih.gov/snp/';
// snp1-rsum
rs_number = value.RS.substring(2);
params = {
Expand All @@ -4782,6 +4784,7 @@ function addLDHapHyperLinks(request, ldhapTable) {
'hgFind.matches' : rs_number
};
url = server + "?" + $.param(params);
//url = server + value.RS;
$('#Coord_hap_' + index + ' a:first-child').attr('href', url);
});

Expand All @@ -4797,9 +4800,12 @@ function addLDpairHyperLinks(data) {
//
// Cluster Report:
//
server = 'http://www.ncbi.nlm.nih.gov/projects/SNP/snp_ref.cgi';
//server = 'http://www.ncbi.nlm.nih.gov/projects/SNP/snp_ref.cgi';
var server = 'http://www.ncbi.nlm.nih.gov/snp/';
//url = server + rs_number;
// snp1-rsum
rs_number = data.snp1.rsnum.substring(2);
console.log(data)
params = {
rs : rs_number
};
Expand Down
10 changes: 10 additions & 0 deletions LDlink/LDmatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,16 @@ def calculate_matrix(snplst, pop, request, web, request_method, genome_build, r2
alleles = a1 + "/" + a2
allele_lst.append(alleles)

else:
if len(snp_dict) > 1:
output["warning"] = str(output["warning"] if "warning" in output else "") + rs_input+ " variant is not a biallelic"
else:
output["error"] = str(output["error"] if "error" in output else "") + rs_input+ " variant is not a biallelic"
json_output = json.dumps(output, sort_keys=True, indent=2)
print(json_output, file=out_json)
out_json.close()
return("", "")


# Calculate Pairwise LD Statistics
all_haps = hap1 + hap2
Expand Down
2 changes: 1 addition & 1 deletion LDlink/LDpop.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def calculate_pop(snp1, snp2, pop, r2_d, web, genome_build, request=None):

temp = [snp2, str(snp2_coord['chromosome']), snp2_coord[genome_build_vars[genome_build]['position']]]
(vcf2, head2, output2) = get_query_variant_c(temp, pop_split, str(request), genome_build, False,output)
if vcf1 == None or vcf2 == None:
if vcf1 == None or vcf2 == None or "error" in output:
#if web:
output = json.dumps(output, sort_keys=True, indent=2)
return output
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions LDlink/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/media/css/jquery.dataTables.min.css" integrity="sha256-4vA/Qvj3cRozXbsauVemzsbGBdKSD4GVsVaaMjYTuRk=" crossorigin="anonymous">
<link rel="stylesheet" href="/common/css/style.css">
<link rel="stylesheet" href="/common/css/social.css">
<link rel="stylesheet" href="LDlink-5.5.1.css">
<link rel="stylesheet" href="LDlink-5.5.2.css">
</head>

<!-- <body class="d-flex flex-column vh-100" role="document"> -->
Expand Down Expand Up @@ -2722,7 +2722,7 @@ <h3 class="modal-title apiaccess">Modal title</h3>
<pre class="apiaccess-examples">
curl -k -H "Content-Type: application/json" -X POST -d '{"snps": "rs3\nrs4", "pop": "CEU","r2_d": "d", "genome_build": "grch37"}' 'https://ldlink.nci.nih.gov/LDlinkRest/ldmatrix?token=faketoken123'
</pre>
<p><i>Note: POST requests can support up to 1,000 SNPs.</i></p>
<p><i>Note: POST requests can support up to 2,500 SNPs.</i></p>
</p>
<p><a class="help-anchor-link" href="#LDpair">LDpair</a><br>
<pre class="apiaccess-examples">
Expand Down Expand Up @@ -2890,7 +2890,7 @@ <h4 class="modal-title">Modal title</h4>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha256-Sk3nkD6mLTMOF0EOpNtsIry+s1CsaqQC1rVLTAy+0yc=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/output/knockout-latest.js" integrity="sha256-TwqMvYd1Dm109PGsukUkZ5vwLfsPCzY0YGG9eBMPBOE=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/knockout.mapping.js" integrity="sha256-TUlOKeuoLfKJnB2YhKMgopAf5JurOPSCdfqw0jBlkXw=" crossorigin="anonymous"></script>
<script type="text/javascript" src="LDlink-5.5.1.js"></script>
<script type="text/javascript" src="LDlink-5.5.2.js"></script>
<script type="text/javascript" src="/common/js/purify.js"></script>
<script type="text/javascript" src="/common/js/bootstrap-multiselect.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.browser.min.js" integrity="sha256-Rr2aTI0oGDN2yUVggLBqR2hq8L33245rgO7SdZXj3po=" crossorigin="anonymous"></script>
Expand Down
5 changes: 5 additions & 0 deletions LDlink/news-5.5.1.html → LDlink/news-5.5.2.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<p><b>LDlink 5.5.2 Release (3/25/2023)</b></p>
<ul>
<li>Fix the multiallelic error message for LDpair</li>
</ul>
<br>
<p><b>LDlink 5.5.1 Release (11/15/2022)</b></p>
<ul>
<li>Add a link to FORGEdb scoring scheme for LDassoc and LDproxy</li>
Expand Down

0 comments on commit 82adb99

Please sign in to comment.