Skip to content

Commit

Permalink
first drafts of screenshot script
Browse files Browse the repository at this point in the history
  • Loading branch information
SeriousHorncat committed Aug 22, 2024
1 parent 7d9bf4c commit 6966dcd
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 1 deletion.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,9 @@ media/
**/.certificates/**
*.pem

etc/.rosalution-db-backups
etc/.rosalution-db-backups


*.env

**/rosalution-screenshot-annotations/**
3 changes: 3 additions & 0 deletions etc/database/screenshot-datasets-automate/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
selenium==4.23.1
requests==2.32.3
python-dotenv==1.0.1
55 changes: 55 additions & 0 deletions etc/database/screenshot-datasets-automate/screenshot-annotate.py
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions etc/database/screenshot-datasets-automate/setup-env.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6966dcd

Please sign in to comment.