yes, i answer my question I asked 8 months ago.
I want to write a script of auto online search which links FISH probe design program of FISH-quant tools. So our biologists who only have Windows can perform probe design script by themselves.
main python tools used is selenium, a excellent web tool for python and java.
I also used katalon recorder, a firefox plugin record your action of web navigating and export codes, so you can copy paste directly in your script to reproduce same action.
of course, firefox inspector is needed to understand web pages.
Here's my script to upload fasta sequence from .fasta file and online search repeat region with croiss_match option. finally, to get results .masked file.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
import time, re, os
import traceback,logging
try:
file="your/fasta/file"
seqs=open(file,'r').read()
driver = webdriver.Firefox()
driver.get("http://www.repeatmasker.org/cgi-bin/WEBRepeatMasker")
driver.find_element_by_name("sequence").send_keys(seqs)
driver.find_element_by_xpath("(.//*[normalize-space(text()) and normalize-space(.)='Search Engine'])[1]/following::input[3]").click()
driver.find_element_by_name("submit").click()
still=True
i=1
while i < 9 or still==True:
print("waiting "+str(i*30)+" seconds...")
time.sleep(30*i)
try:
masked=driver.find_element_by_partial_link_text(".masked").click()
except NoSuchElementException:
if driver.find_element_by_tag_name('h2').text=='Request Queued':
try:
driver.find_element_by_partial_link_text('.html').click()
except Exception as e:
print(e)
if "No repetitive sequences" in driver.find_element_by_tag_name('pre').text:
still=False
exit("no repetitive sequences were detected")
else:
still =False
driver.refresh()
print("page refreshed")
i+=1
content=driver.find_element_by_tag_name('pre')
with open("seqs.masked",'w') as out:
out.write(content)
except Exception as e:
print(e)
finally:
driver.close()
selenium + katalon recorder, very strong combination!!!
That took courage :-)
sorry, l tried to use a metaphor from programmers community