Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions notebooks/validations.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "90cd0bf2",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
3 changes: 2 additions & 1 deletion src/excel2sbol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
from .helpers import *
from .library2 import *
from .library3 import *
from .lookup_compiler import *
from .lookup_compiler import *
from .validator import *
23 changes: 20 additions & 3 deletions src/excel2sbol/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@

# the homespace only works if the change is made to pysbol2 shown in https://github.com/SynBioDex/pySBOL2/pull/411/files

def _is_update_true(val):
if val is None:
return False
if isinstance(val, bool):
return val
if isinstance(val, (int, float)):
return val == 1
return str(val).strip().upper() in {"TRUE", "T", "YES", "Y", "1"}

def initialise_welcome(file_path_in):
init_info = pd.read_excel(file_path_in, sheet_name="Init",
skiprows=9, index_col=0,
Expand Down Expand Up @@ -130,9 +139,17 @@ def initialise(file_path_in):
lib_df = pd.read_excel(file_path_in, sheet_name=sheet_name,
header=0, skiprows=skipval,
engine='openpyxl').fillna("")

sheet_dict['library'] = lib_df.applymap(lambda x: x.strip() if isinstance(x, str) else x).to_dict('list')

lib_df = lib_df.applymap(lambda x: x.strip() if isinstance(x, str) else x)

# Only convert rows where Update is TRUE
if 'Update' in lib_df.columns:
before_count = len(lib_df)
lib_df = lib_df[lib_df['Update'].apply(_is_update_true)].copy()
after_count = len(lib_df)
print(f"INFO: Sheet '{sheet_name}': kept {after_count}/{before_count} rows where Update is TRUE.")

sheet_dict['library'] = lib_df.to_dict('list')
# need dicitonary with as keys every column name and as values a list of values (note ordered list and need place holder empty values)
compiled_sheets[sheet_name] = sheet_dict

Expand Down Expand Up @@ -354,7 +371,7 @@ def column_parse(to_convert, compiled_sheets, sht_convert_dict, dict_of_objs,
# checks that the cell isn't blank
col_convert_df = col_read_df.loc[(col_read_df['Sheet Name'] == sht) & (col_read_df['Column Name'] == col)]
if col_convert_df.empty:
raise ValueError(f"There is an issue with the column definitions sheet missing values. Sheet:'{sht}' with Column:'{col}' cannot be found. Please check for any spaces.")
continue

# split method
split_on = col_convert_df['Split On'].values[0]
Expand Down
Loading