<jupyter_start><jupyter_text>ISODISTORT Automationby <NAME> 2016-03-21 We begin by creating a set of parent structures to be used with ISODISTORT from our starting cifs<jupyter_code># Test case: assume we have parent structures already in a directory
# from pymatgen import * # Used to edit structure files
from os import listdir
from os.path import isfile, join, abspath


# Get list of paths to parent cif files for feeding into ISODISTORT
onlyparents = [f for f in listdir("./") if isfile(join("./", f)) and 'parent' in f]
parent_paths = []
for element in onlyparents:
    parent_paths.append(abspath(element))
parent_paths.sort()    
    
    
onlychildren = [f for f in listdir("./") if isfile(join("./", f)) and 'parent' not in f and 'cif' in f]
child_paths = []
for element in onlychildren:
    child_paths.append(abspath(element))
child_paths.sort()<jupyter_output><empty_output><jupyter_text>Next, we upload our parent structure to ISODISTORT and select "OK"<jupyter_code>### Use pyautogui to perform clicking and keyboard actions
import pyautogui, sys
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
import time

# First page where you upload parent
pyautogui.PAUSE = 0.4
browser = webdriver.Firefox() # Get local session of firefox
browser.get("http://stokes.byu.edu/iso/isodistort.php") # Load page
actions = ActionChains(browser)
select_parent_button = browser.find_element_by_name("toProcess")
select_parent_button.click()

# File dialog on first page
pyautogui.hotkey('ctrl', 'l')
pyautogui.typewrite(parent_paths[0])
pyautogui.press("enter")
elem = browser.find_element_by_class_name("btn.btn-primary")
time.sleep(0.2)
elem.click()
# Second page where you upload child cif
time.sleep(3)
select_child_button = browser.find_element_by_name("toProcess")
select_child_button.click()
time.sleep(0.5)
pyautogui.typewrite(child_paths[0])
pyautogui.press("enter")
time.sleep(0.5)
elems = browser.find_elements_by_class_name("btn-primary")
window_before = browser.window_handles[0]
elems[6].click()
time.sleep(3)
# Third page where you select bases
window_after=browser.window_handles[1]
browser.close()
browser.switch_to_window(window_after)
bases = browser.find_element_by_name("basisselect")
bases.click()
pyautogui.press("down")
pyautogui.press("enter")
ok_button = browser.find_element_by_class_name("btn-primary")
ok_button.click()
time.sleep(2)
# Final page. Time to get mode details
radio_buttons = browser.find_elements_by_name("origintype")
radio_buttons[6].click()
ok_button = browser.find_element_by_class_name("btn-primary")
ok_button.click()
time.sleep(3)
browser.switch_to.window(browser.window_handles[1])
html = browser.page_source
browser.quit()
# Scrape mode details
from bs4 import BeautifulSoup

soup = BeautifulSoup(html, "lxml")
# Move through html to find mode amplitudes
found_text = []
for i, x in enumerate(soup.find("b").nextSiblingGenerator()):
    if i == 20:
        found_text.append(x)
    elif 'b/' in x:
        i+=1
        break
    else:
        continue
found_text = found_text[0].split("\n")
for x in found_text:
    print(x)
# Strip out text before irrep label
for i, x in enumerate(found_text):
    if ']' in found_text[i]:
        found_text[i] = ''.join(x.split("]")[1:])
    found_text[i] = found_text[i].split(" ")
    found_text[i] = list(filter(None, found_text[i]))
    for j in range(len(found_text[i])):
        if '[' in found_text[i][j]:
            temp = found_text[i][j].split("[")
            found_text[i].insert(1, temp[1])
            found_text[i][j] = temp[0]
found_text = [x for x in found_text if x != []]
# Gather only 'all' mode amplitude in parent setting for each mode
mode_amps = {}
for x in found_text:
    if 'all' in x[1]:
        mode_amps[x[0]] = {'Ap': float(x[3])}
print(mode_amps)
import pandas as pd
df = pd.DataFrame.from_dict(mode_amps)
df<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1218236173393124, 'fraction_numerical': 0.009715994020926755, 'mean_word_length': 5.092564491654021, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '639976', 'license': 'MIT', 'n_tokens_mistral': 1387, 'n_tokens_neox': 1355, 'n_words': 355, 'path': 'ISODISTORT_automation/ISODISTORT Automation.ipynb', 'repo_name': 'MTD-group/Sym-Modes', 'size': '4023'}