6 <& /page/page_title.mas, title=>"Compare genotypes using BrAPI" &>
8 Server: <input id="server_address" size="40" value="" /><br />
10 malt.pw.usda.gov/t3/wheatplus
17 Genotype 1 name: <input id="genotype1" size="40" value="IITA-TMS-IBA000017" /><br />
18 Genotype 2 name: <input id="genotype2" size="40" value="95NA-00063" /><br />
20 <button id="submit">Submit</button>
28 jQuery('#submit').click( function() {
33 function compare_genotypes() {
35 var genotype1 = jQuery('#genotype1').val();
36 var genotype2 = jQuery('#genotype2').val();
37 var server = jQuery('#server_address').val();
39 alert('genotype1 '+genotype1+' genotype2 '+genotype2 +' server '+server);
45 url: server + '/brapi/0.1/germplasm/find',
46 data: { q : genotype1 },
49 success: function(response) {
50 alert("RESPONSE 1: "+response[0].germplasmId);
51 id1 = response[0].germplasmId;
53 error: function(response) {
54 alert("An error occurred.");
59 url: server + '/brapi/0.1/germplasm/find',
60 data: { q : genotype2 },
63 success: function(response) {
64 alert("RESPONSE 2: "+response[0].germplasmId);
65 id2 = response[0].germplasmId;
67 error: function(response) {
68 alert("An error occurred");
73 alert("Fetch genotype for "+ id1);
79 url: server + '/brapi/0.1/genotype/'+id1,
82 success: function(response) {
83 alert("RESPONSE for "+id1+": "+Object.keys(response.genotypes[0].genotype).length);
84 scores1 = response.genotypes[0].genotype;
86 error: function(response) {
87 alert("An error occurred fetching the genotype of "+id1);
92 url: server + '/brapi/0.1/genotype/'+id2,
95 success: function(response) {
96 alert("RESPONSE for "+id2+": "+Object.keys(response.genotypes[0].genotype).join(" / "));
97 scores2 = response.genotypes[0].genotype;
99 error: function(response) {
100 alert("An error occurred fetching the genotype of "+id1);
105 alert("KEYS: "+Object.keys(scores1).join(">>>"));
106 Object.keys(scores1).forEach( function(k) {
108 if (scores1[k] === scores2[k]) {
114 alert("Matches: "+matches + " Total: "+total+ " D :" + (matches / total));