Skip to content

Commit

Permalink
Merge pull request #41 from pnnl/develop
Browse files Browse the repository at this point in the history
Separate `finish` and `parse` functionality
  • Loading branch information
smcolby authored Dec 12, 2024
2 parents ba0fc28 + cc34dc8 commit d2f2cb9
Show file tree
Hide file tree
Showing 16 changed files with 593 additions and 1,628 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ jobs:
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-version: 4.9.2-4
miniforge-version: latest
use-mamba: true
environment-file: envs/linux.yml
use-only-tar-bz2: true
use-only-tar-bz2: false
auto-activate-base: false
activate-environment: isicle

Expand All @@ -65,10 +65,10 @@ jobs:
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-version: 4.9.2-4
miniforge-version: latest
use-mamba: true
environment-file: envs/osx.yml
use-only-tar-bz2: true
use-only-tar-bz2: false
auto-activate-base: false
activate-environment: isicle

Expand Down Expand Up @@ -97,11 +97,11 @@ jobs:
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-version: 4.9.2-4
miniforge-version: latest
use-mamba: true
python-version: 3.9
python-version: 3.12
channels: conda-forge,bioconda
use-only-tar-bz2: true
use-only-tar-bz2: false
auto-activate-base: true

- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ requirements:
- openbabel >=3.0.0
- openmpi
- pandas >=1.1.4
- python =3.9
- python >=3.9
- rdkit >=2023.09.1
- snakemake >=6.3.0
- statsmodels >=0.11.1
Expand Down
2 changes: 1 addition & 1 deletion envs/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
- openbabel >=3.0.0
- openmpi
- pandas >=1.1.4
- python =3.9
- python >=3.9
- rdkit >=2023.09.1
- snakemake >=6.3.0
- statsmodels >=0.11.1
Expand Down
2 changes: 1 addition & 1 deletion envs/osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
- openbabel >=3.0.0
- openmpi
- pandas >=1.1.4
- python =3.9
- python >=3.9
- rdkit >=2023.09.1
- snakemake >=6.3.0
- statsmodels >=0.11.1
Expand Down
2 changes: 1 addition & 1 deletion isicle/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from isicle import adducts, conformers, geometry, md, mobility, qm
from isicle import adducts, conformers, geometry, md, mobility, parse, qm
from isicle.io import load, save

__version__ = "2.0.0"
47 changes: 11 additions & 36 deletions isicle/adducts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
import pickle
import re

import rdkit.Chem.rdchem as rdc
from rdkit import Chem

import isicle
from isicle.conformers import ConformationalEnsemble
from isicle.interfaces import WrapperInterface
from isicle.md import md
from isicle.utils import safelist
Expand Down Expand Up @@ -296,13 +294,6 @@ def set_geometry(self, geom):
else:
raise ValueError('Could not find self.mol or self.geom')

def set_charge(self):
'''
'''

if self.geom.__dict__.get('charge') is None:
self.geom.__dict__.update(charge=self.geom.get_charge())

def _set_ions(self, ion_path=None, ion_list=None):
'''
'''
Expand Down Expand Up @@ -468,6 +459,7 @@ def _forcefield_selector(self, forcefield, mw):
raise ValueError(
'RDKit only supports UFF, MMFF, MMFF94, MMFF94s as forcefields.')

# TODO: update this
def _update_geometry_charge(self, geom):
'''
'''
Expand Down Expand Up @@ -873,9 +865,6 @@ def run(self, geom, ion_path=None, ion_list=None, **kwargs):
# Sets geom to self.geom
self.set_geometry(geom)

# Infers charge of geom.mol
self.set_charge()

# Load specified ions by type
# Validity check if negative ionization can be done
self.configure(ion_path=ion_path, ion_list=ion_list)
Expand Down Expand Up @@ -975,18 +964,6 @@ def set_geometry(self, geom):
else:
raise ValueError('Could not find self.xyz, self.mol, or self.geom')

def set_charge(self):
'''
'''

if self.geom.__dict__.get('charge') is None:
if self.geom.load.get('filetype') == '.xyz':
# self.geom.__dict__.update(charge=charge)
raise ValueError(
'Must first run geom.set_charge for an xyz structure')
else:
self.geom.__dict__.update(charge=self.geom.get_charge())

def _set_ions(self, ion_path=None, ion_list=None):
cations, anions, complex = _parse_ions(
ion_path=ion_path, ion_list=ion_list)
Expand Down Expand Up @@ -1032,11 +1009,11 @@ def _check_valid(self):
self.adducts['complex'] = self._filter_supported_by_xtb(
self.adducts['complex'])

if self.geom.load['filetype'] != '.xyz':
self.adducts['anions'] = _filter_by_substructure_match(
self.geom.mol, self.adducts['anions'])
self.adducts['complex'] = _filter_by_substructure_match(
self.geom.mol, self.adducts['complex'])

self.adducts['anions'] = _filter_by_substructure_match(
self.geom.mol, self.adducts['anions'])
self.adducts['complex'] = _filter_by_substructure_match(
self.geom.mol, self.adducts['complex'])

def configure(self, ion_path=None, ion_list=None):
self._set_ions(ion_path=ion_path, ion_list=ion_list)
Expand All @@ -1054,14 +1031,15 @@ def _parse_ion_charge(self, ion):
charge = int(charge[0])
return charge

# TODO: update this
def _update_geometry_charge(self, geom, adduct, ion_charge, mode):
'''
'''

if mode == 'negative':
charge = geom.__dict__.get('charge') - ion_charge
charge = geom.get_charge() - ion_charge
elif mode == 'positive':
charge = geom.__dict__.get('charge') + ion_charge
charge = geom.get_charge() + ion_charge
adduct.__dict__.update(charge=charge)

def _positive_mode(self, geom, forcefield, ewin, cation, optlevel, dryrun, processes, solvation, ignore_topology):
Expand All @@ -1070,7 +1048,7 @@ def _positive_mode(self, geom, forcefield, ewin, cation, optlevel, dryrun, proce
'''

output = md(geom, program='xtb', task='protonate', forcefield=forcefield,
ewin=ewin, ion=cation, optlevel=optlevel, dryrun=dryrun, charge=geom.charge, processes=processes, solvation=solvation, ignore_topology=ignore_topology)
ewin=ewin, ion=cation, optlevel=optlevel, dryrun=dryrun, processes=processes, solvation=solvation, ignore_topology=ignore_topology)
ion_charge = self._parse_ion_charge(cation)
for adduct in output.geom:
self._update_geometry_charge(geom, adduct, ion_charge, 'positive')
Expand All @@ -1082,7 +1060,7 @@ def _negative_mode(self, geom, forcefield, ewin, anion, optlevel, dryrun, proces
'''

output = md(geom, program='xtb', task='deprotonate', forcefield=forcefield,
ewin=ewin, ion=anion, optlevel=optlevel, dryrun=dryrun, charge=geom.charge, processes=processes, solvation=solvation, ignore_topology=ignore_topology)
ewin=ewin, ion=anion, optlevel=optlevel, dryrun=dryrun, processes=processes, solvation=solvation, ignore_topology=ignore_topology)
ion_charge = self._parse_ion_charge(anion)
for adduct in output.geom:
self._update_geometry_charge(geom, adduct, ion_charge, 'negative')
Expand Down Expand Up @@ -1181,9 +1159,6 @@ def run(self, geom, ion_path=None, ion_list=None, **kwargs):

self.set_geometry(geom)

# Infers charge for non xyz files, infers default neutral for xyz files
self.set_charge()

# Load specified ions by type
# Validity check if negative ionization can be done
# Validity check if CREST supports the ions specified
Expand Down
5 changes: 2 additions & 3 deletions isicle/conformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import pandas as pd
from statsmodels.stats.weightstats import DescrStatsW

from isicle import io
from isicle.geometry import Geometry, XYZGeometry
from isicle.geometry import Geometry
from isicle.utils import TypedList, safelist


Expand Down Expand Up @@ -382,7 +381,7 @@ def __init__(self, *args):
'''

super().__init__((Geometry, XYZGeometry), *args)
super().__init__(Geometry, *args)

def _check_attributes(self, attr):
'''
Expand Down
Loading

0 comments on commit d2f2cb9

Please sign in to comment.