-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstance.html
executable file
·322 lines (293 loc) · 11 KB
/
instance.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript" src="/site_media/jquery/js/jquery-1.6.1.min.js"></script>
<style type="text/css">
#formwrap {
line-height: 2em;
background: #eef;
margin: 10px;
padding: 10px;
height: 500px;
}
body {
font-family: "Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
}
.center { margin-left:auto; margin-right:auto; }
.message { font-style: italic; padding: 0px 8px; }
.help {cursor:help; border-bottom: 1px dotted #A9A9A9}
</style>
<script>
$(function() {
var allowDefaultTargetsOverride = false;
if( allowDefaultTargetsOverride ) {
$('.resettargets').show();
} else {
$('.resettargets').hide();
}
var reportUrl = '/rundb/api/v1/results/'+TB_result+'/?format=json&noplugin=True';
var experimentUrl;
var easUrl;
var referenceID = "Unknown";
$.ajaxSetup({async: false});
$.get( reportUrl, function(data) {
referenceID = data.reference;
experimentUrl = data.experiment;
easUrl = data.eas;
// set up any config.html plan settings
$.each( data.config, function(key,val) {
try { $("#"+key).val(val); $("#"+key).attr('checked',(val=='Yes')); }
catch(e) {}
});
});
$('#referenceid').html(referenceID);
// attempt to get Plan details for default selection values - should be in EAS!
var planLibType = "";
if( experimentUrl != undefined && experimentUrl != null && experimentUrl != "" ) {
var planUrl;
$.get( experimentUrl+"?format=json", function(data) { planUrl = data.plan; } );
if( planUrl != undefined && planUrl != null && planUrl != "" ) {
$.get( planUrl+"?format=json", function(data) { planLibType = data.runType; });
}
}
// get majority of current report settings from EAS
var def_nuc = (planLibType == 'AMPS_RNA' || planLibType == 'RNA') ? 'RNA' : 'DNA';
var planBedFile = "";
if( easUrl != undefined && easUrl != null && easUrl != "" ) {
$.get( easUrl+"?format=json", function(data) {
planBedFile = data.targetRegionBedFile;
});
}
// load the barcode IDs
var barcodeNames = [];
$.get( easUrl, function(data) {
$.each( data.barcodedSamples, function(sample,sdata) {
try { barcodeNames = barcodeNames.concat( sdata.barcodes ) }
catch(e) {}
});
});
function loadCSV(csvFile) {
$('#LoadingMessage').text('Validating Contig Name Mapping file content...');
$('#bc2faMap').val("");
var numRecords = 0;
var dataString = ";";
var errmsg = "";
var reader = new FileReader();
reader.onload = function(e) {
var lines = this.result.split(/\r?\n/);
for( var n = 0; n < lines.length; ++n ) {
var line = $.trim(lines[n]);
if( line.length == 0 ) continue;
var fields = line.split(',').slice(0,2);
if( fields.length < 2 || fields[0] == "" || fields[1] == "" ) {
errmsg = "Missing data fields at line "+(n+1)+".";
break;
}
if( n == 0 ) continue;
var barcode = fields[0];
if( barcodeNames.includes(barcode) ) {
dataString += fields[0]+"="+fields[1]+";";
numRecords += 1;
} else {
errmsg = "Unknown/unused barcode '"+barcode+"' at line "+(n+1)+".";
break;
}
}
$('#LoadingMessage').text('');
if( numRecords == 0 ) {
errmsg = "No barcode to FASTA header mappings were defined.";
}
if( errmsg === "" ) {
$('#bc2faMap').val(dataString);
launchRun();
} else {
alert("An error occurred while loading from "+csvfile.name+":\n"+errmsg+"\nRefer to the Description and Usage Notes for file format details.");
}
};
reader.onerror = function(e) {
$('#LoadingMessage').text('');
alert("An error occurred while loading from "+csvfile.name+":\nFile is missing or not text formatted.");
};
reader.readAsText(csvFile);
}
function populateVariantCallerList(selectorID) {
if( selectorID == '' ) return;
$('#'+selectorID).empty();
var nItems = 0;
var runtypeUrl = '/rundb/api/v1/results/'+TB_result+'/pluginresults/?format=json';
$.ajaxSetup({async:false});
$.get( runtypeUrl, function(data) {
$.each( data, function(intIndex,plugin) {
if( plugin['Name'] == "generateConsensus" ) {
pluginPath = plugin['Path']
var pluginID = plugin['Name']+"_out."+plugin['id'];
$('#'+selectorID).append("<option value='"+pluginPath+"'>"+pluginID+"</option>");
++nItems;
}
});
});
if( nItems ) {
orderSelectorList(selectorID);
} else {
$('#'+selectorID).append("<option value=''>None available</option>");
}
}
var refBedType = '/unmerged/detail/';
function targetNameFromURL(bedURL) {
var i = bedURL.lastIndexOf(refBedType);
if( i >= 0 ) {
bedURL = bedURL.substr(i+refBedType.length);
} else {
i = bedURL.lastIndexOf('/');
if( i >= 0 ) bedURL = bedURL.substr(i+1);
}
if( bedURL.substr(0,7) == 'example' ) return "";
i = bedURL.lastIndexOf('.bed');
if( i > 0 ) return bedURL.substr(0,i);
return bedURL;
}
// For each selector populated by this function a list of items and selected reference is recorded
// for performance by avoiding multiple API queries to poplate and sort these lists.
var selectRefs = {};
var selectLst = {};
// Returns true if the list was created or changed. Returns false if no change was necessary.
function populateTargetsList(refID,selectorID,firstItem) {
if( selectorID == '' || selectRefs[selectorID] == refID ) return false;
selectRefs[selectorID] = refID;
$('#'+selectorID).empty();
var lstID = selectorID+"@"+refID;
if( !selectLst[lstID] ) {
var refBedURL = '/rundb/api/v1/content/?format=json&limit=0&publisher__name=BED&path__startswith=/'+refID+refBedType;
$.get( refBedURL, function(data) {
$.each( data.objects, function(intIndex,result) {
var targfile = result.file;
var selName = targetNameFromURL(targfile);
if( selName != "" && !result.meta.hotspot ) {
$('#'+selectorID).append("<option value='"+targfile+"'>"+selName+"</option>");
}
});
});
orderSelectorList(selectorID,firstItem);
// ensure reference with no targets get 'none' selection
if( $('#'+selectorID+' option').size() == 0 ) {
$('#'+selectorID).append("<option value=''>None</option>");
}
selectLst[lstID] = $('#'+selectorID+' option');
} else {
$('#'+selectorID).append(selectLst[lstID]);
if( $('#'+selectorID+' option').size() > 0 )
$('#'+selectorID+' option')[0].selected = true;
}
return true;
}
function orderSelectorList(selectorID,firstItem) {
var lst = $('#'+selectorID+' option');
lst.sort(function(a,b) {
var at = parseInt(a.text.replace(/.*\./,""));
var bt = parseInt(b.text.replace(/.*\./,""));
if( at < bt ) return 1;
if( at > bt ) return -1;
return 0;
});
$('#'+selectorID).empty();
if( firstItem ) {
$('#'+selectorID).append("<option value=''>"+firstItem+"</option>");
}
$('#'+selectorID).append(lst);
if( $('#'+selectorID+' option').size() > 0 )
$('#'+selectorID+' option')[0].selected = true;
}
function invalidNumRange(strval,minval,maxval) {
var floatRegex = /^-?\d*(\.)?[0-9]*$/;
var val = parseFloat(strval);
return !floatRegex.test(strval) || strval == "." || val < minval || val > maxval;
}
populateTargetsList(referenceID,'targetregions','None');
var deadTarget = 0;
if( planBedFile !== "" ) {
if( $("#barcodetargets option[value='"+planBedFile+"']").length == 0 ) ++deadTarget;
$("#targetregions").val(planBedFile);
}
populateVariantCallerList('variant_caller_path')
$('#postbutton').click( function() {
// validate the simple options first
var defTargetsID = $('#targetregions option:selected').text();
$('#targetregions_id').val(defTargetsID);
var tvcp = $("#variant_caller_path").val()
if( !tvcp ) {
alert("This plugin cannot be run without a valid variantCaller plugin result run and selected.");
return false;
}
launchRun();
return false; // return state not important here
});
function launchRun() {
obj = $('#generateConsensus').serializeObject();
// insert barcode selection table if built by plugin.py
//obj.barcodetable = parent.TB_plugin_functions.get_plugin_barcodetable();
pluginAPIJSON = { "plugin" : [TB_plugin.fields.name], "pluginconfig" : obj };
pluginAPIJSON = JSON.stringify(pluginAPIJSON);
pluginURL = "/rundb/api/v1/results/" + TB_result + "/plugin/";
$.ajax({
type: "POST",
url: pluginURL,
async: false,
contentType: "application/json; charset=utf-8",
success: function(data)
{
$("#json_result").html('<div style="text-align: center;"><img src="/site_media/jquery/colorbox/images/loading.gif" alt="Running Plugin" style="float:center"></img><p>Running the Plugin... Check generateConsensus.html in the Plugin Summary</p></div>');
setTimeout("parent.$.fn.colorbox.close()",2000);
},
data: pluginAPIJSON,
dataType: "json"
});
}
$.fn.serializeObject = function() {
var o = {};
var a = this.serializeArray();
$.each(a,
function() {
if (o[this.name] != null) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
});
</script>
</head>
<body>
<form id="generateConsensus" name="generateConsensus">
<div style="text-align:center">
<h1>ClustalO Plugin</h1>
<h3>Multiple Sequence Alignment using ClustalO.</h3>
</div>
<table class="center" cellpadding="5px">
<tr>
<td><span class="help" title="Use which generateConsensus_out.xxx">generateConsensus Run:</span></td>
<td><select id="variant_caller_path" name="variant_caller_path"></select></td>
</tr>
</table>
</form>
<br/><br/>
<div align="center" id="json_result">
<input id="postbutton" type="submit" value="Submit">
<br/><br/>
<span id="LoadingMessage" class="message"></span>
</div>
<div align="left">
<h3>Description and Usage Notes</h3>
<p>
Clustal Omega is a new multiple sequence alignment program that uses seeded guide trees and HMM profile-profile techniques to generate alignments between three or more sequences.
See: https://www.ebi.ac.uk/Tools/msa/clustalo/ and http://www.clustal.org/omega/ for more details.
</p>
</div>
</body>
</html>