diff --git a/HTPolyNet/__init__.py b/HTPolyNet/__init__.py index e3c984b..3399198 100644 --- a/HTPolyNet/__init__.py +++ b/HTPolyNet/__init__.py @@ -1 +1 @@ -HTPOLYNET_VERSION='1.0.7.1' +HTPOLYNET_VERSION='1.0.8' diff --git a/HTPolyNet/coordinates.py b/HTPolyNet/coordinates.py index 9c8b212..9c196cb 100644 --- a/HTPolyNet/coordinates.py +++ b/HTPolyNet/coordinates.py @@ -161,6 +161,7 @@ def read_gro(cls,filename,wrap_coords=True): # logger.debug(ln) if wrap_coords: inst.wrap_coords() + logger.debug(inst.A.dtypes) return inst @classmethod @@ -773,7 +774,14 @@ def get_R(self,idx): :rtype: numpy.ndarray(3,float) """ df=self.A - return np.array(get_row_attribute(df,['posX','posY','posZ'],{'globalIdx':idx})) + assert df['posX'].dtypes==float + assert df['posY'].dtypes==float + assert df['posZ'].dtypes==float + res=get_row_attribute(df,['posX','posY','posZ'],{'globalIdx':idx}) + # logger.debug(f'get_R result from get_row_attribute is {res} with type {type(res)} dtype {res.dtype}') + res=res.to_numpy(dtype=float) + # logger.debug(f'...and after to_numpy(), it is {res} type {type(res)} dtype {res.dtype}') + return res def get_atom_attribute(self,name,attributes): """get_atom_attribute return values of attributes listed in name from atoms specified by attribute:value pairs in attributes diff --git a/HTPolyNet/dataframetools.py b/HTPolyNet/dataframetools.py index 5f3168c..c3d8b6c 100644 --- a/HTPolyNet/dataframetools.py +++ b/HTPolyNet/dataframetools.py @@ -19,6 +19,9 @@ def get_row(df:pd.DataFrame,attributes:dict): sdf=df for k,v in attributes.items(): sdf=sdf[sdf[k]==v] + # res=pd.Series(sdf.iloc[0,:]) + # logger.debug(f'sdf dtypes {sdf.dtypes}') + # logger.debug(f'get_row returns series {res.to_string()} with dtypes {res.dtypes}') return pd.Series(sdf.iloc[0,:]) def get_row_attribute(df:pd.DataFrame,name,attributes): @@ -35,6 +38,8 @@ def get_row_attribute(df:pd.DataFrame,name,attributes): :rtype: scalar """ row=get_row(df,attributes) + # res=row[name] + # logger.debug(f'get_row_attribute of {name} returns {res} with type {type(res)}') return row[name] def get_row_as_string(df:pd.DataFrame,attributes): diff --git a/HTPolyNet/molecule.py b/HTPolyNet/molecule.py index 49f21a6..9e21b26 100644 --- a/HTPolyNet/molecule.py +++ b/HTPolyNet/molecule.py @@ -284,7 +284,7 @@ def initialize_molecule_rings(self): """ TC=self.TopoCoord TC.Topology.detect_rings() - + logger.debug(f'Detected {len(TC.Topology.rings)} unique rings.') # TC.idx_lists['cycle']=[] # cycle_dict=TC.Topology.detect_cycles() # logger.debug(f'Cycle dict: {cycle_dict}') @@ -362,7 +362,7 @@ def initialize_monomer_grx_attributes(self): TC.idx_lists['chain'].append(entry) TC.reset_grx_attributes_from_idx_list('chain') # set cycle, cycle_idx - self.initialize_molecule_cycles() + self.initialize_molecule_rings() def previously_parameterized(self): """previously_parameterized if a gro file exists in the project molecule/parameterized directory for this molecule, return True @@ -835,7 +835,7 @@ def make_bonds(self,bdf:pd.DataFrame,moldict,stage): else: template_source='internal' # signals that a template molecule should be identified to parameterize this bond TC.update_topology_and_coordinates(bdf,moldict,explicit_sacH=explicit_sacrificial_Hs,template_source=template_source) - self.initialize_molecule_cycles() + self.initialize_molecule_rings() def transrot(self,at_idx,at_resid,from_idx,from_resid,connected_resids=[]): """transrot given a composite molecule, translate and rotate the piece downstream of the yet-to-be created bond specified by (at_idx,at_resid) and (from_idx,from_resid) to minimize steric overlaps and identify the best two sacrificial hydrogens @@ -888,21 +888,25 @@ def transrot(self,at_idx,at_resid,from_idx,from_resid,connected_resids=[]): Ri=TC.get_R(at_idx) Rj=TC.get_R(from_idx) + logger.debug(f'Ri {at_idx} {Ri} {type(Ri)} {Ri.dtype}') + logger.debug(f'Rj {from_idx} {Rj} {type(Rj)} {Rj.dtype}') overall_maximum=(-1.e9,-1,-1) coord_trials={} for myH,myHnm in myHpartners.items(): # keys are globalIdx's, values are names coord_trials[myH]:dict[TopoCoord]={} Rh=TC.get_R(myH) + logger.debug(f' Rh {myH} {Rh} {Rh.dtype}') Rih=Ri-Rh Rih*=1.0/np.linalg.norm(Rih) for otH,otHnm in otHpartners.items(): - # logger.debug(f'{self.name}: Considering {myH} {otH}') + logger.debug(f'{self.name}: Considering {myH} {otH}') coord_trials[myH][otH]=deepcopy(BTC) - # logger.debug(f'\n{coord_trials[myH][otH].Coordinates.A.to_string()}') + logger.debug(f'\n{coord_trials[myH][otH].Coordinates.A.to_string()}') Rk=coord_trials[myH][otH].get_R(otH) - # logger.debug(f'{self.name}: otH {otH} Rk {Rk}') + logger.debug(f'{self.name}: otH {otH} Rk {Rk} {Rk.dtype}') Rkj=Rk-Rj Rkj*=1.0/np.linalg.norm(Rkj) + logger.debug(f'Rkj {Rkj} {Rkj.dtype} Rih {Rih} {Rih.dtype}') #Rhk=Rh-Rk #rhk=np.linalg.norm(Rhk) cp=np.cross(Rkj,Rih) diff --git a/HTPolyNet/runtime.py b/HTPolyNet/runtime.py index 4e26cd7..a2727c0 100644 --- a/HTPolyNet/runtime.py +++ b/HTPolyNet/runtime.py @@ -517,7 +517,7 @@ def _initialize_topology(self,inpfnm='init'): logger.info(f'Topology "{inpfnm}.top" in {pfs.cwd()}') TC.write_top(f'{inpfnm}.top') TC.write_tpx(f'{inpfnm}.tpx') - return f'{inpfnm}.top' + return f'{inpfnm}.top',f'{inpfnm}.tpx' def _initialize_coordinates(self,inpfnm='init'): """_initialize_coordinates builds initial top and gro files for initial liquid simulation diff --git a/HTPolyNet/topocoord.py b/HTPolyNet/topocoord.py index 9099451..95bf47b 100644 --- a/HTPolyNet/topocoord.py +++ b/HTPolyNet/topocoord.py @@ -599,7 +599,7 @@ def write_top(self,topfilename): def write_tpx(self,tpxfilename): self.Topology.write_tpx(tpxfilename) - self.files['tpx']=os.path.apbspath(tpxfilename) + self.files['tpx']=os.path.abspath(tpxfilename) def write_gro(self,grofilename,grotitle=''): """write_gro Write a Gromacs-format coordinate file; wrapper for Coordinates.write_gro() diff --git a/README.md b/README.md index ccf90d6..eb426b9 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ The programs ``antechamber``, ``parmchk2`` and ``tleap`` from AmberTools must be ## Release History * 1.0.8 - * uses `chordless_cycles` to find rings + * uses `chordless_cycles` to find rings; ringidx no long unique atom attribute; improved ring-pierce detection * 1.0.7.2 * moved Library package to resources subpackage of HTPolyNet.HTPolyNet * 1.0.6 diff --git a/pyproject.toml b/pyproject.toml index c5b7ca9..b9342c2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,7 @@ dependencies = [ "pandas>=2", "scipy>=1.10", "parmed>=4", - "networkx>=3.2s", + "networkx>=3.2", "gputil>=1.4" ]