Created
June 20, 2014 10:04
-
-
Save s4553711/063c444aeaa27064216b to your computer and use it in GitHub Desktop.
Some example about phantomjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var page = require('webpage').create(); | |
var system = require('system'); | |
var map_result = { | |
"Reference Sequence" : "mouse_mm10(UCSC)", | |
"Known SNP/Indel" : "dbSNP138", | |
"leftReadsInput" : "36730566", | |
"leftReadsMapped" : "35130795 (95.6% of input)", | |
"leftReadsOfThese" : "9607 ( 0.0%) have multiple alignments (11204 have >1)", | |
"rightReadsInput" : "36730566", | |
"rightReadsMapped" : "34139600 (92.9% of input)", | |
"rightReadsOfThese" : "9607 ( 0.0%) have multiple alignments (10956 have >1)", | |
"totalReadsMap" : "94.3% overall read mapping rate.", | |
"alignedPairs" : "33231563", | |
"alignedPairsOfThese" : "9607 ( 0.0%) have multiple alignments", | |
"alignedPairsOfTheseDiscordant" : "2664795 ( 8.0%) are discordant alignments", | |
"alignedPairsMap" : "83.2% concordant pair alignment rate.", | |
} | |
function match_result(result){ | |
for (var i = 0; i < result.length; i++) { | |
if (result[i] == "") continue; | |
//console.log("d> "+result[i]); | |
var ts = result[i].split(" : "); | |
if (ts[0] in map_result){ | |
if (ts[1] == map_result[ts[0]]){ | |
console.log("Log> Test on "+ts[0]+": \033[32mOK\033[m"); | |
} else { | |
console.log("Log> Test on "+ts[0]+": \033[31mFail\033[m"); | |
} | |
} | |
} | |
} | |
console.log(system.args[1]); | |
page.open('http://hipipe.ncgm.sinica.edu.tw/hipipe_new/result?taskId=cf8741c5-c85b-42e9-94ad-b036537f0b2b#mapsummary',function(){ | |
console.log('Log> Open Page .. Success'); | |
// | |
var spec = page.evaluate(function() { | |
var tar = $("#ref div"); | |
return Array.prototype.map.call(tar,function(e){ | |
return e.textContent.trim(); | |
}); | |
}); | |
match_result(spec); | |
// | |
var time_list = page.evaluate(function() { | |
var tar = $("#time div"); | |
return Array.prototype.map.call(tar,function(e){ | |
return e.textContent.trim(); | |
}); | |
}); | |
for (var i = 0; i < time_list.length; i++) { | |
console.log(">>"+time_list[i]); | |
} | |
// | |
var map_summary = page.evaluate(function() { | |
var tar = $("#mapsummary span"); | |
return Array.prototype.map.call(tar,function(e){ | |
if (e.id == "") | |
return "" | |
else | |
return e.id+" : "+e.textContent.trim(); | |
}); | |
}); | |
match_result(map_summary); | |
var links = page.evaluate(function() { | |
var l = $("#downloadFiles a"); | |
return Array.prototype.map.call(l,function(e){ | |
//return e.getAttribute('href') + " : "+e.text; | |
return { href: e.getAttribute('href'), text: e.text}; | |
}); | |
}); | |
for (var i = 0; i < links.length; i++) { | |
var uri_info = links[i].href.split("/"); | |
if (uri_info[uri_info.length-1] == links[i].text) { | |
console.log("Log> Test on link "+uri_info[uri_info.length-1]+": \033[32mOK\033[m"); | |
} else { | |
console.log("Log> Test on link "+uri_info[uri_info.length-1]+": \033[31mFail\033[m ("+uri_info[uri_info.length-1]+" vs "+links[i].text+")"); | |
} | |
} | |
phantom.exit(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment