Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge MOFid 2024 #37

Merged
merged 79 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
5dd937c
ignore conventional virtualenv names
dweber2022 Jun 26, 2024
6818073
(temporary) force gcc-10 and g++-10 compiler versions
dweber2022 Jun 26, 2024
80374a1
(temporary) comment out install_requires for Python 2.x configs
dweber2022 Jun 26, 2024
f125081
Create main.yml
dweber2022 Jun 26, 2024
37789df
Update main.yml
dweber2022 Jun 26, 2024
7955d67
test workflow response to intentional test fail
dweber2022 Jun 26, 2024
a448b81
Update check_mof_composition.py
dweber2022 Jun 26, 2024
30067ea
remove intentional test fail
dweber2022 Jun 26, 2024
b96936a
upgrade Eigen from 3.3.7 to 3.3.9
dweber2022 Jul 1, 2024
8042677
upgrade Eigen from 3.3.9 to 3.4.0
dweber2022 Jul 1, 2024
901c59b
apply tabs to spaces filter for all Python files
dweber2022 Jul 1, 2024
cf5b336
apply tabs to spaces filter for all Python files
dweber2022 Jul 1, 2024
5330877
add workflow path filters
dweber2022 Jul 1, 2024
5f03203
upgrade Systre to 20.8.0
dweber2022 Jul 1, 2024
e5fa45e
add GTest framework to project, modify compile flags
dweber2022 Jul 8, 2024
107af26
add correct command substitution to Makefile
dweber2022 Jul 9, 2024
7e2b07d
implement invectortest
dweber2022 Jul 9, 2024
0b545f5
add unit tests to CI
dweber2022 Jul 9, 2024
8214996
parallelize exe target in Makefile
dweber2022 Jul 9, 2024
afb25ee
add mofidtest library
dweber2022 Jul 9, 2024
0490ecf
add OBDetails unit test
dweber2022 Jul 9, 2024
86c918c
find OpenBabel package and link mofidtest and openbabel libraries
dweber2022 Jul 9, 2024
4d24f47
add paths for find_package for OpenBabel
dweber2022 Jul 9, 2024
3905346
add OBDetails unit test
dweber2022 Jul 9, 2024
3f2df58
add OBDetails unit test
dweber2022 Jul 9, 2024
c44ac93
add OBDetails unit test
dweber2022 Jul 10, 2024
d695f06
add OBDetails unit test
dweber2022 Jul 10, 2024
93d0a8d
remove dead code
dweber2022 Jul 10, 2024
f4e65f3
add OBDetails unit test
dweber2022 Jul 10, 2024
28e7772
finish basic unit tests for OBDetails
dweber2022 Jul 10, 2024
b1cb36a
remove example.cpp
dweber2022 Jul 15, 2024
89a8825
update to match Makefile changes
dweber2022 Jul 22, 2024
d65b18f
add Makefile targets for unit/integration tests and debug/release builds
dweber2022 Jul 22, 2024
0594412
make test build optional
dweber2022 Jul 22, 2024
c935b9e
remove unused Travis CI file
dweber2022 Jul 22, 2024
35cd7f9
explicitly disable building tests for init target
dweber2022 Jul 23, 2024
2afa772
index on master: 35cd7f9 explicitly disable building tests for init t…
dweber2022 Jul 23, 2024
01efe53
WIP on master: 35cd7f9 explicitly disable building tests for init target
dweber2022 Jul 23, 2024
ed3fe49
explicitly make Output directory
dweber2022 Jul 23, 2024
b990eca
improve check_intermediate script
dweber2022 Jul 24, 2024
8f689b1
add more info to test output
dweber2022 Jul 24, 2024
c856440
add verbose flag to check_intermediate
dweber2022 Jul 24, 2024
2441341
add directory variables to Makefile and compile Python bindings
dweber2022 Jul 29, 2024
0ac9a79
update workflow
dweber2022 Jul 29, 2024
55599ad
fix ctest test-dir argument
dweber2022 Jul 29, 2024
2aaae80
update check_intermediate to use check_file.py and compare molecule a…
dweber2022 Jul 29, 2024
cf78746
fix workflow/Makefile ordering bug
dweber2022 Jul 29, 2024
3b5e98d
fix workflow syntax error
dweber2022 Jul 29, 2024
157254d
find path to site-packages
dweber2022 Jul 29, 2024
c2aa2c7
fix command to find Python site-packages directory
dweber2022 Jul 29, 2024
41fe831
update test targets in Makefile and improve test output
dweber2022 Jul 31, 2024
d177333
output test_intermediate mismatches to Mismatch directory; update wor…
dweber2022 Jul 31, 2024
6da55d7
switch from gcc 10.5 to gcc 11.3
dweber2022 Aug 5, 2024
c65fcc0
remove MD files (moved to docs) and update README
dweber2022 Aug 5, 2024
d0822b6
remove openbabel
dweber2022 Aug 5, 2024
8a21d6f
add openbabel as submodule
dweber2022 Aug 5, 2024
f7f04d6
migrate to openbabel 3.x
dweber2022 Aug 5, 2024
f20abdd
migrate to openbabel 3.x
dweber2022 Aug 5, 2024
f2ecb9e
migrate to openbabel 3.x
dweber2022 Aug 6, 2024
e241e8b
migrate to openbabel 3.x
dweber2022 Aug 6, 2024
4842be7
migrate to openbabel 3.x
dweber2022 Aug 6, 2024
2c9fd4e
resolve BABEL_LIBDIR missing (see http://www0.cs.ucl.ac.uk/staff/ucac…
dweber2022 Aug 6, 2024
dd59757
update checks for orig_mol.cif
dweber2022 Aug 6, 2024
acb492b
upgrade GTest to 1.15.2
dweber2022 Aug 7, 2024
ee45732
remove .gitmodules
dweber2022 Aug 7, 2024
4335ad9
remove openbabel
dweber2022 Aug 7, 2024
8406c5f
add openbabel
dweber2022 Aug 7, 2024
4b19074
refactor print into logging, added checks for atoms and bonds
dweber2022 Aug 13, 2024
645644d
update bond checks
dweber2022 Aug 13, 2024
f0b1eb1
add CIF comparison executable
dweber2022 Aug 14, 2024
e0ab899
update regex pattern for diff check
dweber2022 Aug 14, 2024
793d8ec
overhaul atom and bond comparisons
dweber2022 Aug 19, 2024
1b45c52
update README
dweber2022 Aug 21, 2024
6db91b0
remove extraneous config files
dweber2022 Aug 21, 2024
c180045
update README
dweber2022 Aug 21, 2024
6d92577
update Dockerfile and add dockerignore
dweber2022 Aug 26, 2024
e45deec
add commit ref to MOFid and MOFkey
dweber2022 Aug 27, 2024
3f6ad57
catch OSError if not a Git repo
dweber2022 Aug 27, 2024
79e2668
make check_run_mofid ignore commit ref
dweber2022 Aug 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# .dockerignore
bin/
openbabel/build
openbabel/installed
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ openbabel/data/* text eol=lf
openbabel/data/*.png binary
Makefile text eol=lf
*.sh text eol=lf

# Apply spabs filter
*.py filter=spabs
44 changes: 44 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: run_tests
on:
push:
paths:
- "**.py"
- "Makefile"
- "openbabel/**"
- "eigen/**"
- "src/**"
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install colordiff
run: |
sudo apt-get update
sudo apt-get install colordiff
- name: Build Project
run: |
mkdir Output
make test
- name: Run Unit Tests
run: make unittest
- name: Run Intermediate Tests
run : make intermediatetest
- name: Archive Mismatch Artifacts
uses: actions/upload-artifact@v4
with:
name: mismatch
path: Mismatch
if-no-files-found: ignore
retention-days: 1
- name: Run Integration Tests
run: |
python set_paths.py
pip install .
make pytest
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Mismatch/
.venv/
venv/
.env/
env/
*.pyc
Data/
!README.md
Expand Down
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

44 changes: 22 additions & 22 deletions Analysis/extract_carbon_mofs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
DEST_DIR = 'Summary/OrigCore/'

if not os.path.isdir(DEST_DIR):
print('Moving original CoRE MOF files to a new directory: ' + DEST_DIR)
os.mkdir(DEST_DIR)
core_files = glob.glob('Summary/core*')
for core_output in core_files:
shutil.move(core_output, DEST_DIR)
print('Moving original CoRE MOF files to a new directory: ' + DEST_DIR)
os.mkdir(DEST_DIR)
core_files = glob.glob('Summary/core*')
for core_output in core_files:
shutil.move(core_output, DEST_DIR)

def read_file(data_file):
with open(os.path.join('Summary/OrigCore/', data_file), 'r') as f:
data_contents = f.readlines()
# Let's keep the newlines so we don't have to rewrite them later:
#data_contents = [x.strip('\n') for x in data_contents]
return data_contents
with open(os.path.join('Summary/OrigCore/', data_file), 'r') as f:
data_contents = f.readlines()
# Let's keep the newlines so we don't have to rewrite them later:
#data_contents = [x.strip('\n') for x in data_contents]
return data_contents

mofids = read_file('core_mofid.smi')
#smis = read_file('core.smi')
Expand All @@ -37,18 +37,18 @@ def read_file(data_file):

# Map the input to output files line-by-line
for lineno in range(len(elements)):
cif_name = elements[lineno].split()[0]
assert cif_name.endswith('.cif') or cif_name.endswith('.CIF')
cif_name = cif_name[:-4]
# Check that our lines are properly aligned between all of the MOFid code output files
assert mofids[lineno].endswith(';' + cif_name + '\n')
assert mofkeys[lineno].startswith(cif_name + '.cif\t')

contains_carbon = re.search(r'[ \t]C ', elements[lineno])
if contains_carbon:
out_mofids.write(mofids[lineno])
out_mofkeys.write(mofkeys[lineno])
out_files.write(cif_name + '\n')
cif_name = elements[lineno].split()[0]
assert cif_name.endswith('.cif') or cif_name.endswith('.CIF')
cif_name = cif_name[:-4]
# Check that our lines are properly aligned between all of the MOFid code output files
assert mofids[lineno].endswith(';' + cif_name + '\n')
assert mofkeys[lineno].startswith(cif_name + '.cif\t')

contains_carbon = re.search(r'[ \t]C ', elements[lineno])
if contains_carbon:
out_mofids.write(mofids[lineno])
out_mofkeys.write(mofkeys[lineno])
out_files.write(cif_name + '\n')

out_mofids.close()
out_mofkeys.close()
Expand Down
30 changes: 9 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
FROM continuumio/miniconda3
# MOFid 2024
FROM python:3.11-bookworm

# set up conda and deps, per .travis.yml
RUN apt-get update -qq
RUN mkdir -p /usr/share/man/man1/ # required to prevent default-jre installation from crashing
RUN apt-get install -qq default-jre
RUN apt-get install -qq build-essential cmake
LABEL AUTHOR="[email protected]"
LABEL version="2024"

RUN conda config --set always_yes yes --set changeps1 no
RUN conda create -q -n py2 python=2.7

# copy source code from git
WORKDIR /mofid
COPY . /mofid

# compile openbabel, C++ analysis code, and Python package
RUN make init
RUN python set_paths.py
RUN pip install .
# Disabling conda environment for now and keeping with base Python
#RUN source activate py2
#RUN pip install .
#RUN conda deactivate

# then run the code, either interactively or via docker command line

RUN apt-get update -qq \
&& apt-get install -qq default-jre gcc-11 g++-11 cmake \
&& make init \
&& python set_paths.py \
&& pip install . \
62 changes: 50 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.PHONY: all backup test diff ob_changes.patch init eclipse web init-web github-web html one exe btc
.PHONY: all backup test unittest intermediatetest pytest diff ob_changes.patch init debug eclipse web init-web github-web html one exe btc

mofid-dir := $(shell pwd)
python-packages-dir := $(shell python -m site | grep -o "/.*/site-packages" | head --lines 1)

all:
@echo "Sample make file for experimentation. Still needs work. Only backup implemented"
Expand All @@ -17,11 +20,11 @@ bin/tsfm_smiles: src/tsfm_smiles.cpp openbabel/build/lib/cifformat.so
cd bin && make tsfm_smiles

exe:
cd bin && make
cd bin && make -j$$(nproc)

one:
cd bin && make; \
cd ..; \
cd $(mofid-dir); \
bin/sbu Resources/TestCIFs/P1-IRMOF-1.cif

btc:
Expand All @@ -40,23 +43,58 @@ ob_changes.patch:
git diff --no-prefix 7810ca7bb1beef14b2a62cf5bad3a8551b187824 -- openbabel/*.cpp openbabel/*.h ':!openbabel/data/*' ':!openbabel/test/*' > $@
# Lists my changes to the main OpenBabel code

test: bin/sbu
python tests/check_run_mofid.py
python tests/check_mof_composition.py
test:
cd openbabel; \
mkdir build installed; \
cd build; \
cmake -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_INSTALL_PREFIX=../installed -DBUILD_GUI=OFF -DENABLE_TESTS=OFF -DEIGEN3_INCLUDE_DIR=../eigen -DRUN_SWIG=ON -DPYTHON_BINDINGS=ON ..; \
make -j$$(nproc) || exit 2; \
make install; \
cd $(python-packages-dir); \
test -f openbabel.pth || echo $(mofid-dir)/openbabel/installed/lib/python*/site-packages > openbabel.pth; \
cd $(mofid-dir); \
mkdir bin; \
cd bin; \
cmake -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 -DOpenBabel3_DIR=../openbabel/build -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON ../src/; \
make -j$$(nproc); \

unittest:
ctest --output-on-failure --test-dir bin/test

intermediatetest:
tests/check_intermediate.sh

pytest:
python tests/check_run_mofid.py; \
python tests/check_mof_composition.py

init:
cd openbabel; \
mkdir build installed; \
cd build; \
cmake -DCMAKE_INSTALL_PREFIX=../installed -DBUILD_GUI=OFF -DEIGEN3_INCLUDE_DIR=../eigen ..; \
make -j2 || exit 2; \
cmake -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_INSTALL_PREFIX=../installed -DENABLE_TESTS=OFF -DBUILD_GUI=OFF -DEIGEN3_INCLUDE_DIR=../eigen ..; \
make -j$$(nproc) || exit 2; \
make install; \
cd $(mofid-dir); \
mkdir bin; \
cd bin; \
cmake -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 -DOpenBabel3_DIR=../openbabel/build -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release ../src/; \
make -j$$(nproc)
# Sets up all the cmake details, so that usage is as simple as
# `bin/sbu MOF.cif` and re-compilation is as easy as `make exe`

debug:
cd openbabel; \
mkdir build installed; \
cd build; \
cmake -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_INSTALL_PREFIX=../installed -DBUILD_GUI=OFF -DENABLE_TESTS=OFF -DEIGEN3_INCLUDE_DIR=../eigen ..; \
make -j$$(nproc) || exit 2; \
make install; \
cd ../../; \
cd $(mofid-dir); \
mkdir bin; \
cd bin; \
cmake -DOpenBabel2_DIR=../openbabel/build ../src/; \
make
cmake -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 -DOpenBabel3_DIR=../openbabel/build ../src/ -DCMAKE_BUILD_TYPE=Debug;\
make -j$$(nproc)
# Sets up all the cmake details, so that usage is as simple as
# `bin/sbu MOF.cif` and re-compilation is as easy as `make exe`

Expand Down Expand Up @@ -91,7 +129,7 @@ init-web:
cd ../..; \
mkdir embin; \
cd embin; \
emcmake cmake -DOpenBabel2_DIR=../openbabel/embuild -static ../src/ -DCMAKE_CXX_FLAGS="-O3 --preload-file ../openbabel/data@/ob_datadir/ --preload-file ../src/Web/web_data@/web_data/ --preload-file ../Resources/RCSRnets.arc@/RCSRnets.arc --pre-js ../src/pre_emscripten.js -s TOTAL_MEMORY=128MB -s WASM=1 -s EXTRA_EXPORTED_RUNTIME_METHODS=\"['ccall', 'cwrap', 'UTF8ToString']\""; \
emcmake cmake -DOpenBabel3_DIR=../openbabel/embuild -static ../src/ -DCMAKE_CXX_FLAGS="-O3 --preload-file ../openbabel/data@/ob_datadir/ --preload-file ../src/Web/web_data@/web_data/ --preload-file ../Resources/RCSRnets.arc@/RCSRnets.arc --pre-js ../src/pre_emscripten.js -s TOTAL_MEMORY=128MB -s WASM=1 -s EXTRA_EXPORTED_RUNTIME_METHODS=\"['ccall', 'cwrap', 'UTF8ToString']\""; \
mkdir kekule; \
cd kekule; \
unzip ../../Resources/kekule.release.0.7.5.170624.zip; \
Expand Down
84 changes: 42 additions & 42 deletions Python/convert_smi_to_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,59 +13,59 @@


def dict_to_delim(to_export, filename, delim='\t'):
with open(filename, 'w') as f:
for key in to_export:
if type(to_export[key]) is list:
for j in to_export[key]:
f.write(key + delim + str(j) + '\n')
else:
f.write(key + delim + str(to_export[key]) + '\n')
with open(filename, 'w') as f:
for key in to_export:
if type(to_export[key]) is list:
for j in to_export[key]:
f.write(key + delim + str(j) + '\n')
else:
f.write(key + delim + str(to_export[key]) + '\n')


class MOFExporter:
# Exports a .smi-formatted list of MOFid into separate tables for the various parts
def __init__(self):
self.tables = dict()
self.datatypes = list() # smiles, topology, catenation, etc.
# Exports a .smi-formatted list of MOFid into separate tables for the various parts
def __init__(self):
self.tables = dict()
self.datatypes = list() # smiles, topology, catenation, etc.

def parse(self, filename):
with open(filename, 'r') as f:
for line in f:
parsed = parse_mofid(line)
name = parsed['name']
del parsed['name']
parsed['smiles_part'] = parsed['smiles'].split('.')
parsed['base_topology'] = parsed['topology'].split(',')[0]
parsed['extra_topology'] = ','.join(parsed['topology'].split(',')[1:]) # '' if empty
self.tables[name] = copy.deepcopy(parsed)
self.datatypes = parsed.keys()
return self
def parse(self, filename):
with open(filename, 'r') as f:
for line in f:
parsed = parse_mofid(line)
name = parsed['name']
del parsed['name']
parsed['smiles_part'] = parsed['smiles'].split('.')
parsed['base_topology'] = parsed['topology'].split(',')[0]
parsed['extra_topology'] = ','.join(parsed['topology'].split(',')[1:]) # '' if empty
self.tables[name] = copy.deepcopy(parsed)
self.datatypes = parsed.keys()
return self

def _tidy_tables(self):
tidy_dict = dict()
for info in self.datatypes:
tidy_dict[info] = dict()
def _tidy_tables(self):
tidy_dict = dict()
for info in self.datatypes:
tidy_dict[info] = dict()

for mof in self.tables:
for info in self.datatypes:
tidy_dict[info][mof] = self.tables[mof][info]
for mof in self.tables:
for info in self.datatypes:
tidy_dict[info][mof] = self.tables[mof][info]

return tidy_dict
return tidy_dict

def write(self, folder='.'):
if not os.path.isdir(folder):
os.mkdir(folder)
def write(self, folder='.'):
if not os.path.isdir(folder):
os.mkdir(folder)

tidy_output = self._tidy_tables()
for key in tidy_output:
dict_to_delim(tidy_output[key], folder + '/' + key + '.tsv', delim='\t')
tidy_output = self._tidy_tables()
for key in tidy_output:
dict_to_delim(tidy_output[key], folder + '/' + key + '.tsv', delim='\t')



if __name__ == '__main__':
args = sys.argv[1:]
if len(args) != 1:
raise SyntaxError('Extract info from a list of MOFid strings. Only a single .smi filename expected.')
args = sys.argv[1:]
if len(args) != 1:
raise SyntaxError('Extract info from a list of MOFid strings. Only a single .smi filename expected.')

input_smi = args[0]
MOFExporter().parse(input_smi).write('TableOutput')
input_smi = args[0]
MOFExporter().parse(input_smi).write('TableOutput')
Loading