Mercurial > repos > eduardo > annotateviz
comparison static/js/editgff.js @ 4:92921dfea0b5 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/annotateviz commit 230f5fe14cc469e56626201a5c377686976d81fc
| author | eduardo |
|---|---|
| date | Sat, 24 Jun 2017 14:55:25 -0400 |
| parents | |
| children | 9a09f7072ed5 |
comparison
equal
deleted
inserted
replaced
| 3:3302f18f9e16 | 4:92921dfea0b5 |
|---|---|
| 1 var jsonobj=[] | |
| 2 $.ajax({url: "gff.json", success: function(result){ | |
| 3 jsonobj = result; | |
| 4 }}); | |
| 5 | |
| 6 | |
| 7 function merge_prediction() { | |
| 8 var lpart = document.getElementById("lpart").value; | |
| 9 var rpart = document.getElementById("rpart").value; | |
| 10 edit_annot(lpart,rpart); | |
| 11 } | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 function edit_annot(lpart,rpart) { | |
| 17 for (var i = jsonobj.length -1; i >= 0 ; i--) { | |
| 18 if (jsonobj[i].attributes.hasOwnProperty("Parent")) { | |
| 19 if (jsonobj[i].attributes.Parent[0] === lpart){ | |
| 20 if (jsonobj[i].featuretype == "three_prime_UTR") { | |
| 21 jsonobj.splice(i,1); | |
| 22 console.log("removed lpart three_prime_UTR"); | |
| 23 } | |
| 24 else { | |
| 25 jsonobj[i].attributes.Parent[0] = '.'.join(lpart,1); | |
| 26 } | |
| 27 } | |
| 28 if (jsonobj[i].attributes.Parent[0] === rpart){ | |
| 29 if (jsonobj[i].featuretype == "five_prime_UTR") { | |
| 30 jsonobj.splice(i,1); | |
| 31 console.log("removed rpart five_prime_UTR"); | |
| 32 } | |
| 33 else { | |
| 34 jsonobj[i].attributes.Parent[0] = '.'.join(lpart,1); | |
| 35 } | |
| 36 } | |
| 37 } | |
| 38 | |
| 39 }; | |
| 40 } | |
| 41 | |
| 42 function export_gff() { | |
| 43 var text=""; | |
| 44 var line=""; | |
| 45 for (var i=0;i<jsonobj.length;i++){ | |
| 46 var attributes=""; | |
| 47 for (var attribute in jsonobj[i].attributes){ | |
| 48 attributes=attribute+'='+jsonobj[i].attributes[attribute][0]+';'; | |
| 49 } | |
| 50 line = jsonobj[i].seqid+'\t'+ | |
| 51 jsonobj[i].source+'\t'+ | |
| 52 jsonobj[i].featuretype+'\t'+ | |
| 53 jsonobj[i].start+'\t'+ | |
| 54 jsonobj[i].end+'\t'+ | |
| 55 jsonobj[i].score+'\t'+ | |
| 56 jsonobj[i].strand+'\t'+ | |
| 57 jsonobj[i].frame+'\t'+ | |
| 58 attributes; | |
| 59 text=text+line+'\''; | |
| 60 } | |
| 61 var gfffile = new Blob([text], {type: "text/plain;charset=utf-8"}); | |
| 62 var blob = new Blob([text], {type: "text/plain;charset=utf-8"}); | |
| 63 var link = document.createElement('a'); | |
| 64 link.setAttribute('href', window.URL.createObjectURL(blob)); | |
| 65 link.setAttribute('download', "gff_export"); | |
| 66 link.click(); | |
| 67 } | |
| 68 |
