Skip to content

Commit

Permalink
rings still not merging
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronabrams committed Dec 24, 2023
1 parent bd0fbd1 commit 21b540b
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 12 deletions.
2 changes: 1 addition & 1 deletion HTPolyNet/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
HTPOLYNET_VERSION='1.0.7.1'
HTPOLYNET_VERSION='1.0.8'
10 changes: 9 additions & 1 deletion HTPolyNet/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions HTPolyNet/dataframetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down
16 changes: 10 additions & 6 deletions HTPolyNet/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}')
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion HTPolyNet/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion HTPolyNet/topocoord.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies = [
"pandas>=2",
"scipy>=1.10",
"parmed>=4",
"networkx>=3.2s",
"networkx>=3.2",
"gputil>=1.4"
]

Expand Down

0 comments on commit 21b540b

Please sign in to comment.