diff --git a/.gitignore b/.gitignore index dc1d1762..9e3e34bb 100644 --- a/.gitignore +++ b/.gitignore @@ -70,4 +70,9 @@ media/ **/.certificates/** *.pem -etc/.rosalution-db-backups \ No newline at end of file +etc/.rosalution-db-backups + + +*.env + +**/rosalution-screenshot-annotations/** \ No newline at end of file diff --git a/etc/database/screenshot-datasets-automate/requirements.txt b/etc/database/screenshot-datasets-automate/requirements.txt new file mode 100644 index 00000000..a47f2e1a --- /dev/null +++ b/etc/database/screenshot-datasets-automate/requirements.txt @@ -0,0 +1,3 @@ +selenium==4.23.1 +requests==2.32.3 +python-dotenv==1.0.1 \ No newline at end of file diff --git a/etc/database/screenshot-datasets-automate/screenshot-annotate.py b/etc/database/screenshot-datasets-automate/screenshot-annotate.py new file mode 100644 index 00000000..42cc3524 --- /dev/null +++ b/etc/database/screenshot-datasets-automate/screenshot-annotate.py @@ -0,0 +1,55 @@ +from selenium import webdriver +from selenium.webdriver.chrome.options import Options +from selenium.webdriver.common.by import By +import time +import os +from datetime import datetime +from dotenv import dotenv_values + +import requests + +config = dotenv_values('.env') + + + +#@ https://local.rosalution.cgds/rosalution/api/analysis/CPAM0002/genomic_units + +# Get the current timestamp for the image name +today = datetime.now() +image_name = today.strftime("%Y-%m-%d %H:%M:%S") + +# Set the path where the screenshot will be saved +path = os.path.dirname(os.path.abspath(__file__)) + +# Configure Chrome WebDriver options +options = Options() +options.add_argument("--window-size=1920,1080") +options.add_argument("--start-maximized") +options.add_argument("--headless") +options.add_argument("--disable-gpu") + +# Initialize the Chrome WebDriver +driver = webdriver.Chrome(options=options) +driver.maximize_window() + + + + +driver.get("https://gtexportal.org/home/gene/CEP104") + +time.sleep(1) + +width = driver.execute_script("return Math.max( document.body.scrollWidth, document.body.offsetWidth, document.documentElement.clientWidth, document.documentElement.scrollWidth, document.documentElement.offsetWidth );") +height = driver.execute_script("return Math.max( document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight );") + +driver.set_window_size(width, height) + +full_page = driver.find_element(By.ID, "gene-expr-vplot") +full_page.screenshot(f"{image_name}.png") + +# Close the browser window +driver.quit() + + + +# Get genomic units from the analysis \ No newline at end of file diff --git a/etc/database/screenshot-datasets-automate/setup-env.sh b/etc/database/screenshot-datasets-automate/setup-env.sh new file mode 100755 index 00000000..3536956a --- /dev/null +++ b/etc/database/screenshot-datasets-automate/setup-env.sh @@ -0,0 +1,8 @@ +python3 -m venv rosalution-screenshot-annotations +source rosalution-screenshot-annotations/bin/activate + +# install requirements +pip3 install -r requirements.txt + +# deactivate venv and return to root directory +deactivate \ No newline at end of file